File: command.h

package info (click to toggle)
xfce4-whiskermenu-plugin 2.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,616 kB
  • sloc: cpp: 8,368; ansic: 25; makefile: 9
file content (112 lines) | stat: -rw-r--r-- 2,285 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * Copyright (C) 2013-2023 Graeme Gott <graeme@gottcode.org>
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef WHISKERMENU_COMMAND_H
#define WHISKERMENU_COMMAND_H

#include "settings.h"

#include <gtk/gtk.h>

namespace WhiskerMenu
{

class Command
{
public:
	explicit Command(const gchar* property, const gchar* show_property,
			const gchar* icon, const gchar* fallback_icon,
			const gchar* text,
			const gchar* command, bool shown,
			const gchar* error_text,
			const gchar* confirm_question = nullptr, const gchar* confirm_status = nullptr);
	~Command();

	Command(const Command&) = delete;
	Command(Command&&) = delete;
	Command& operator=(const Command&) = delete;
	Command& operator=(Command&&) = delete;

	GtkWidget* get_button();
	GtkWidget* get_menuitem();

	const gchar* get() const
	{
		return m_command;
	}

	bool get_shown() const
	{
		return m_shown;
	}

	const gchar* get_text() const
	{
		return m_mnemonic;
	}

	const gchar* get_tooltip() const
	{
		return m_text;
	}

	void set(const gchar* command);

	void set_shown(bool shown);

	void check();

	void activate();

	void load(XfceRc* rc, bool is_default);
	bool load(const gchar* property, const GValue* value);

private:
	bool confirm();
	static gboolean confirm_countdown(gpointer data);

private:
	GtkWidget* m_button;
	GtkWidget* m_menuitem;
	gchar* m_icon;
	gchar* m_mnemonic;
	gchar* m_text;
	String m_command;
	gchar* m_error_text;
	Boolean m_shown;

	enum class CommandStatus
	{
		Unchecked,
		Invalid,
		Valid
	}
	m_status;

	struct TimeoutDetails
	{
		GtkWidget* dialog;
		gchar* question;
		gchar* status;
		gint time_left;
	}
	m_timeout_details;
};

}

#endif // WHISKERMENU_COMMAND_H