Updated version 1.0.4 from 'upstream/1.0.4'
with Debian dir c85d45176d8698048bdf0dd04163b2ca481d1fd6
Fabio Fantoni
6 years ago
0 | 0 | SUBDIRS = libxapp po schemas files docs |
1 | if ENABLE_PYTHON | |
2 | SUBDIRS += pygobject | |
3 | endif | |
1 | 4 | |
2 | 5 | ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} |
3 | 6 |
0 | 0 | |
1 | AC_INIT(xapp, 1.0.3) | |
1 | AC_INIT(xapp, 1.0.4) | |
2 | 2 | AC_CONFIG_SRCDIR(libxapp) |
3 | 3 | m4_ifdef([AX_IS_RELEASE], [AX_IS_RELEASE([always])]) |
4 | 4 | |
96 | 96 | |
97 | 97 | GOBJECT_INTROSPECTION_CHECK([0.9.7]) |
98 | 98 | |
99 | CFLAGS="$CFLAGS -Wno-declaration-after-statement" | |
100 | ||
101 | # Python support | |
102 | ||
103 | PYGOBJECT_REQUIRED=2.90 | |
104 | ||
105 | PKG_CHECK_EXISTS([pygobject-3.0 >= $PYGOBJECT_REQUIRED], | |
106 | [have_python=yes], [have_python=no]) | |
107 | ||
108 | AS_IF([test "x$have_python" = "xyes"], | |
109 | [AM_PATH_PYTHON | |
110 | AC_SUBST([pyoverridesdir], [`$PYTHON -c "import gi;print (gi._overridesdir)" 2>/dev/null`])]) | |
111 | ||
112 | AM_CONDITIONAL([ENABLE_PYTHON], [test "x$have_python" = "xyes"]) | |
113 | ||
99 | 114 | AC_CONFIG_FILES([ |
100 | 115 | Makefile |
101 | 116 | docs/Makefile |
102 | 117 | docs/reference/Makefile |
118 | pygobject/Makefile | |
103 | 119 | libxapp/Makefile |
104 | 120 | libxapp/xapp.pc |
105 | 121 | libxapp/xapp-uninstalled.pc |
7 | 7 | ]> |
8 | 8 | <book id="index"> |
9 | 9 | <bookinfo> |
10 | <title>Xapp Reference Manual</title> | |
10 | <title>XApp Reference Manual</title> | |
11 | 11 | <releaseinfo> |
12 | 12 | for &package_string;. |
13 | 13 | </releaseinfo> |
15 | 15 | |
16 | 16 | <chapter> |
17 | 17 | <title>API reference</title> |
18 | <xi:include href="xml/xapp-kbd-layout-controller.xml"/> | |
18 | <xi:include href="xml/xapp-kbd-layout-controller.xml"/> | |
19 | 19 | <xi:include href="xml/xapp-monitor-blanker.xml"/> |
20 | <xi:include href="xml/xapp-gtk-window.xml"/> | |
20 | 21 | |
21 | 22 | </chapter> |
22 | 23 | <chapter id="object-tree"> |
0 | /* xapp.vapi generated by vapigen, do not modify. */ | |
1 | ||
2 | [CCode (cprefix = "XApp", gir_namespace = "XApp", gir_version = "1.0", lower_case_cprefix = "xapp__")] | |
3 | namespace XApp { | |
4 | [CCode (cheader_filename = "libxapp/xapp-gtk-window.h", type_id = "xapp_gtk_window_get_type ()")] | |
5 | public class GtkWindow : Gtk.Window, Atk.Implementor, Gtk.Buildable { | |
6 | [CCode (cname = "xapp_gtk_window_new", has_construct_function = false, type = "GtkWidget*")] | |
7 | public GtkWindow (Gtk.WindowType type); | |
8 | [CCode (cname = "xapp_gtk_window_set_icon_from_file")] | |
9 | public void set_icon_from_file (string? file_name) throws GLib.Error; | |
10 | [CCode (cname = "xapp_gtk_window_set_icon_name")] | |
11 | public void set_icon_name (string? icon_name); | |
12 | [CCode (cname = "xapp_gtk_window_set_progress")] | |
13 | public void set_progress (int progress); | |
14 | [CCode (cname = "xapp_gtk_window_set_progress_pulse")] | |
15 | public void set_progress_pulse (bool pulse); | |
16 | } | |
17 | [CCode (cheader_filename = "libxapp/xapp-kbd-layout-controller.h", type_id = "xapp_kbd_layout_controller_get_type ()")] | |
18 | public class KbdLayoutController : GLib.Object { | |
19 | [CCode (cname = "xapp_kbd_layout_controller_new", has_construct_function = false)] | |
20 | public KbdLayoutController (); | |
21 | [CCode (array_length = false, array_null_terminated = true, cname = "xapp_kbd_layout_controller_get_all_names")] | |
22 | public unowned string[] get_all_names (); | |
23 | [CCode (cname = "xapp_kbd_layout_controller_get_current_flag_id")] | |
24 | public int get_current_flag_id (); | |
25 | [CCode (cname = "xapp_kbd_layout_controller_get_current_group")] | |
26 | public uint get_current_group (); | |
27 | [CCode (cname = "xapp_kbd_layout_controller_get_current_icon_name")] | |
28 | public string get_current_icon_name (); | |
29 | [CCode (cname = "xapp_kbd_layout_controller_get_current_name")] | |
30 | public string get_current_name (); | |
31 | [CCode (cname = "xapp_kbd_layout_controller_get_current_short_group_label")] | |
32 | public string get_current_short_group_label (); | |
33 | [CCode (cname = "xapp_kbd_layout_controller_get_current_variant_label")] | |
34 | public string get_current_variant_label (); | |
35 | [CCode (cname = "xapp_kbd_layout_controller_get_enabled")] | |
36 | public bool get_enabled (); | |
37 | [CCode (cname = "xapp_kbd_layout_controller_get_flag_id_for_group")] | |
38 | public int get_flag_id_for_group (uint group); | |
39 | [CCode (cname = "xapp_kbd_layout_controller_get_icon_name_for_group")] | |
40 | public string get_icon_name_for_group (uint group); | |
41 | [CCode (cname = "xapp_kbd_layout_controller_get_short_group_label_for_group")] | |
42 | public string get_short_group_label_for_group (uint group); | |
43 | [CCode (cname = "xapp_kbd_layout_controller_get_variant_label_for_group")] | |
44 | public string get_variant_label_for_group (uint group); | |
45 | [CCode (cname = "xapp_kbd_layout_controller_next_group")] | |
46 | public void next_group (); | |
47 | [CCode (cname = "xapp_kbd_layout_controller_previous_group")] | |
48 | public void previous_group (); | |
49 | [CCode (cname = "xapp_kbd_layout_controller_render_cairo_subscript")] | |
50 | public static void render_cairo_subscript (Cairo.Context cr, double x, double y, double width, double height, int subscript); | |
51 | [CCode (cname = "xapp_kbd_layout_controller_set_current_group")] | |
52 | public void set_current_group (uint group); | |
53 | [NoAccessorMethod] | |
54 | public bool enabled { get; } | |
55 | public signal void config_changed (); | |
56 | public signal void layout_changed (uint object); | |
57 | } | |
58 | [CCode (cheader_filename = "libxapp/xapp-monitor-blanker.h", type_id = "xapp_monitor_blanker_get_type ()")] | |
59 | public class MonitorBlanker : GLib.Object { | |
60 | [CCode (cname = "xapp_monitor_blanker_new", has_construct_function = false)] | |
61 | public MonitorBlanker (); | |
62 | [CCode (cname = "xapp_monitor_blanker_are_monitors_blanked")] | |
63 | public bool are_monitors_blanked (); | |
64 | [CCode (cname = "xapp_monitor_blanker_blank_other_monitors")] | |
65 | public void blank_other_monitors (Gtk.Window window); | |
66 | [CCode (cname = "xapp_monitor_blanker_unblank_monitors")] | |
67 | public void unblank_monitors (); | |
68 | } | |
69 | [CCode (cheader_filename = "libxapp/xapp-gtk-window.h")] | |
70 | [SimpleType] | |
71 | public struct GtkWindow_autoptr { | |
72 | } | |
73 | [CCode (cheader_filename = "libxapp/xapp-gtk-window.h", cname = "xapp_set_window_icon_from_file")] | |
74 | public static void set_window_icon_from_file (Gtk.Window window, string? file_name) throws GLib.Error; | |
75 | [CCode (cheader_filename = "libxapp/xapp-gtk-window.h", cname = "xapp_set_window_icon_name")] | |
76 | public static void set_window_icon_name (Gtk.Window window, string? icon_name); | |
77 | [CCode (cheader_filename = "libxapp/xapp-gtk-window.h", cname = "xapp_set_window_progress")] | |
78 | public static void set_window_progress (Gtk.Window window, int progress); | |
79 | [CCode (cheader_filename = "libxapp/xapp-gtk-window.h", cname = "xapp_set_window_progress_pulse")] | |
80 | public static void set_window_progress_pulse (Gtk.Window window, bool pulse); | |
81 | [CCode (cheader_filename = "libxapp/xapp-gtk-window.h", cname = "xapp_set_xid_icon_from_file")] | |
82 | public static void set_xid_icon_from_file (ulong xid, string? file_name); | |
83 | [CCode (cheader_filename = "libxapp/xapp-gtk-window.h", cname = "xapp_set_xid_icon_name")] | |
84 | public static void set_xid_icon_name (ulong xid, string? icon_name); | |
85 | [CCode (cheader_filename = "libxapp/xapp-gtk-window.h", cname = "xapp_set_xid_progress")] | |
86 | public static void set_xid_progress (ulong xid, int progress); | |
87 | [CCode (cheader_filename = "libxapp/xapp-gtk-window.h", cname = "xapp_set_xid_progress_pulse")] | |
88 | public static void set_xid_progress_pulse (ulong xid, bool pulse); | |
89 | } |
15 | 15 | |
16 | 16 | introspection_sources = \ |
17 | 17 | xapp-monitor-blanker.c \ |
18 | xapp-kbd-layout-controller.c | |
18 | xapp-kbd-layout-controller.c \ | |
19 | xapp-gtk-window.c \ | |
20 | xapp-glade-catalog.c | |
19 | 21 | |
20 | 22 | libxapp_la_SOURCES = \ |
21 | 23 | $(introspection_sources) |
34 | 36 | pkgconfigdir = $(libdir)/pkgconfig |
35 | 37 | pkgconfig_DATA = xapp.pc |
36 | 38 | |
39 | catalogdir = $(prefix)/share/glade/catalogs/ | |
40 | catalog_DATA = xapp-glade-catalog.xml | |
41 | ||
37 | 42 | libxappdir = $(includedir)/xapp/libxapp |
38 | 43 | libxapp_HEADERS = \ |
39 | 44 | xapp-monitor-blanker.h \ |
40 | xapp-kbd-layout-controller.h | |
45 | xapp-kbd-layout-controller.h \ | |
46 | xapp-gtk-window.h | |
41 | 47 | |
42 | 48 | -include $(INTROSPECTION_MAKEFILE) |
43 | 49 | INTROSPECTION_GIRS = |
0 | #include "config.h" | |
1 | #include <glib-object.h> | |
2 | ||
3 | #include "xapp-gtk-window.h" | |
4 | ||
5 | void | |
6 | xapp_glade_catalog_init (const gchar *catalog_name); | |
7 | ||
8 | void | |
9 | xapp_glade_catalog_init (const gchar *catalog_name) | |
10 | { | |
11 | g_type_ensure (XAPP_TYPE_GTK_WINDOW); | |
12 | } |
0 | <?xml version="1.0" encoding="UTF-8"?> | |
1 | <glade-catalog name="xapp" library="xapp" depends="gtk+"> | |
2 | <init-function>xapp_glade_catalog_init</init-function> | |
3 | <glade-widget-classes> | |
4 | <glade-widget-class name="XAppGtkWindow" generic-name="xappgtkwindow" | |
5 | title="XAppGtkWindow" parent="GtkWindow" /> | |
6 | </glade-widget-classes> | |
7 | ||
8 | <glade-widget-group name="xapp-widgets" title="XApp Widgets"> | |
9 | <glade-widget-class-ref name="XAppGtkWindow" /> | |
10 | </glade-widget-group> | |
11 | </glade-catalog> |
0 | ||
1 | #include <config.h> | |
2 | ||
3 | #include <stdlib.h> | |
4 | #include <string.h> | |
5 | #include <math.h> | |
6 | #include <X11/Xlib.h> | |
7 | #include <X11/Xatom.h> | |
8 | ||
9 | #include <gdk/gdk.h> | |
10 | #include <gdk/gdkx.h> | |
11 | #include "xapp-gtk-window.h" | |
12 | ||
13 | #define ICON_NAME_HINT "_NET_WM_XAPP_ICON_NAME" | |
14 | #define PROGRESS_HINT "_NET_WM_XAPP_PROGRESS" | |
15 | #define PROGRESS_PULSE_HINT "_NET_WM_XAPP_PROGRESS_PULSE" | |
16 | ||
17 | /** | |
18 | * SECTION:xapp-gtk-window | |
19 | * @Short_description: A subclass of %GtkWindow that allows additional | |
20 | communication with the window manager. | |
21 | * @Title: XAppGtkWindow | |
22 | * | |
23 | * This widget is a simple subclass of GtkWindow that provides the following | |
24 | * additional capabilities: | |
25 | * | |
26 | * - Ability to set an icon name or icon file path for the window manager to | |
27 | * make use of, rather than relying on a desktop file or fixed-size window- | |
28 | * backed icon that Gtk normally generates. The window manager must support | |
29 | * the NET_WM_XAPP_ICON_NAME hint. | |
30 | * | |
31 | * - Ability to send progress info to the window manager, in the form of an integer, | |
32 | * 0-100, which can then be used to display this progress in some manner in a task | |
33 | * manager or window list. The window manager must support the NET_WM_XAPP_PROGRESS | |
34 | * hint. | |
35 | * | |
36 | * - Ability to signal a 'pulsing' progress state, of potentially indeterminate value, | |
37 | * in the form of a boolean, which can be passed on to a window list. The window | |
38 | * manager must support the NET_WM_XAPP_PROGRESS_PULSE hint | |
39 | * | |
40 | * Wrappers: | |
41 | * | |
42 | * Also provided are corresponding wrapper functions for normal GtkWindows. | |
43 | * They are not class methods - they are called with the target widget as their first | |
44 | * argument. | |
45 | * | |
46 | * For example: | |
47 | * | |
48 | * win = Gtk.Window() | |
49 | * XApp.set_window_icon_name(win, "foobar") | |
50 | * | |
51 | * These functions mirror those of the #XAppGtkWindow class, but allow the properties | |
52 | * to work with normal GtkWindows and descendants of GtkWindow. | |
53 | */ | |
54 | ||
55 | typedef struct | |
56 | { | |
57 | gchar *icon_name; | |
58 | gchar *icon_path; | |
59 | guint progress; | |
60 | gboolean progress_pulse; | |
61 | } XAppGtkWindowPrivate; | |
62 | ||
63 | struct _XAppGtkWindow | |
64 | { | |
65 | GtkWindow parent_object; | |
66 | ||
67 | XAppGtkWindowPrivate *priv; | |
68 | }; | |
69 | ||
70 | G_DEFINE_TYPE_WITH_PRIVATE (XAppGtkWindow, xapp_gtk_window, GTK_TYPE_WINDOW) | |
71 | ||
72 | static void | |
73 | clear_icon_strings (XAppGtkWindowPrivate *priv) | |
74 | { | |
75 | g_clear_pointer (&priv->icon_name, g_free); | |
76 | g_clear_pointer (&priv->icon_path, g_free); | |
77 | } | |
78 | ||
79 | static void | |
80 | set_window_hint_utf8 (Window xid, | |
81 | const gchar *atom_name, | |
82 | const gchar *str) | |
83 | { | |
84 | GdkDisplay *display; | |
85 | ||
86 | display = gdk_display_get_default (); | |
87 | ||
88 | if (str != NULL) | |
89 | { | |
90 | XChangeProperty (GDK_DISPLAY_XDISPLAY (display), | |
91 | xid, | |
92 | gdk_x11_get_xatom_by_name_for_display (display, atom_name), | |
93 | gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8, | |
94 | PropModeReplace, (guchar *) str, strlen (str)); | |
95 | } | |
96 | else | |
97 | { | |
98 | XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), | |
99 | xid, | |
100 | gdk_x11_get_xatom_by_name_for_display (display, atom_name)); | |
101 | } | |
102 | } | |
103 | ||
104 | static void | |
105 | set_window_hint_cardinal (Window xid, | |
106 | const gchar *atom_name, | |
107 | gulong cardinal) | |
108 | { | |
109 | GdkDisplay *display; | |
110 | ||
111 | display = gdk_display_get_default (); | |
112 | ||
113 | gdk_error_trap_push (); | |
114 | ||
115 | if (cardinal > 0) | |
116 | { | |
117 | XChangeProperty (GDK_DISPLAY_XDISPLAY (display), | |
118 | xid, | |
119 | gdk_x11_get_xatom_by_name_for_display (display, atom_name), | |
120 | XA_CARDINAL, 32, | |
121 | PropModeReplace, | |
122 | (guchar *) &cardinal, 1); | |
123 | } | |
124 | else | |
125 | { | |
126 | XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), | |
127 | xid, | |
128 | gdk_x11_get_xatom_by_name_for_display (display, atom_name)); | |
129 | } | |
130 | ||
131 | gdk_error_trap_pop (); | |
132 | } | |
133 | ||
134 | static Window | |
135 | get_window_xid (GtkWindow *window) | |
136 | { | |
137 | GdkWindow *gdk_window; | |
138 | ||
139 | gdk_window = gtk_widget_get_window (GTK_WIDGET (window)); | |
140 | ||
141 | if (gdk_window_get_effective_toplevel (gdk_window) != gdk_window) | |
142 | { | |
143 | g_warning ("Window is not toplevel"); | |
144 | return 0; | |
145 | } | |
146 | ||
147 | return GDK_WINDOW_XID (gdk_window); | |
148 | } | |
149 | ||
150 | static void | |
151 | update_window_icon (GtkWindow *window, | |
152 | XAppGtkWindowPrivate *priv) | |
153 | { | |
154 | /* Icon name/path */ | |
155 | if (priv->icon_name != NULL) | |
156 | { | |
157 | set_window_hint_utf8 (get_window_xid (window), | |
158 | ICON_NAME_HINT, | |
159 | priv->icon_name); | |
160 | } | |
161 | else if (priv->icon_path != NULL) | |
162 | { | |
163 | set_window_hint_utf8 (get_window_xid (window), | |
164 | ICON_NAME_HINT, | |
165 | priv->icon_path); | |
166 | } | |
167 | else | |
168 | { | |
169 | set_window_hint_utf8 (get_window_xid (window), | |
170 | ICON_NAME_HINT, | |
171 | NULL); | |
172 | } | |
173 | } | |
174 | ||
175 | static void | |
176 | update_window_progress (GtkWindow *window, | |
177 | XAppGtkWindowPrivate *priv) | |
178 | { | |
179 | /* Progress: 0 - 100 */ | |
180 | set_window_hint_cardinal (get_window_xid (window), | |
181 | PROGRESS_HINT, | |
182 | (gulong) priv->progress); | |
183 | ||
184 | set_window_hint_cardinal (get_window_xid (window), | |
185 | PROGRESS_PULSE_HINT, | |
186 | (gulong) (priv->progress_pulse ? 1 : 0)); | |
187 | } | |
188 | ||
189 | static void | |
190 | set_icon_name_internal (GtkWindow *window, | |
191 | XAppGtkWindowPrivate *priv, | |
192 | const gchar *icon_name) | |
193 | { | |
194 | if (g_strcmp0 (icon_name, priv->icon_name) == 0) | |
195 | { | |
196 | gtk_window_set_icon_name (window, icon_name); | |
197 | return; | |
198 | } | |
199 | ||
200 | /* Clear both strings when either is set - this ensures the | |
201 | * correct value is set during update_window() */ | |
202 | clear_icon_strings (priv); | |
203 | ||
204 | if (icon_name != NULL) | |
205 | { | |
206 | priv->icon_name = g_strdup (icon_name); | |
207 | } | |
208 | ||
209 | /* If the window is realized, set the icon name immediately. | |
210 | * If it's not, it will be set by xapp_gtk_window_realize(). */ | |
211 | if (gtk_widget_get_realized (GTK_WIDGET (window))) | |
212 | { | |
213 | update_window_icon (window, priv); | |
214 | } | |
215 | ||
216 | /* Call the GtkWindow method for compatibility */ | |
217 | gtk_window_set_icon_name (GTK_WINDOW (window), icon_name); | |
218 | } | |
219 | ||
220 | static void | |
221 | set_icon_from_file_internal (GtkWindow *window, | |
222 | XAppGtkWindowPrivate *priv, | |
223 | const gchar *file_name, | |
224 | GError **error) | |
225 | { | |
226 | if (g_strcmp0 (file_name, priv->icon_path) == 0) | |
227 | { | |
228 | gtk_window_set_icon_from_file (window, file_name, error); | |
229 | return; | |
230 | } | |
231 | ||
232 | /* Clear both strings when either is set - this ensures the correct | |
233 | * value is set during update_window() */ | |
234 | clear_icon_strings (priv); | |
235 | ||
236 | if (file_name != NULL) | |
237 | { | |
238 | priv->icon_path = g_strdup (file_name); | |
239 | } | |
240 | ||
241 | /* If the window is realized, set the icon path immediately. | |
242 | * If it's not, it will be set by xapp_gtk_window_realize(). */ | |
243 | if (gtk_widget_get_realized (GTK_WIDGET (window))) | |
244 | { | |
245 | update_window_icon (window, priv); | |
246 | } | |
247 | ||
248 | gtk_window_set_icon_from_file (GTK_WINDOW (window), file_name, error); | |
249 | } | |
250 | ||
251 | static void | |
252 | set_progress_internal (GtkWindow *window, | |
253 | XAppGtkWindowPrivate *priv, | |
254 | gint progress) | |
255 | { | |
256 | gboolean update; | |
257 | guint clamped_progress; | |
258 | ||
259 | update = FALSE; | |
260 | ||
261 | if (priv->progress_pulse) | |
262 | { | |
263 | priv->progress_pulse = FALSE; | |
264 | update = TRUE; | |
265 | } | |
266 | ||
267 | clamped_progress = CLAMP (progress, 0, 100); | |
268 | ||
269 | if (clamped_progress != priv->progress) | |
270 | { | |
271 | priv->progress = clamped_progress; | |
272 | update = TRUE; | |
273 | } | |
274 | ||
275 | /* If the window is realized, set the progress immediately. | |
276 | * If it's not, it will be set by xapp_gtk_window_realize(). */ | |
277 | if (gtk_widget_get_realized (GTK_WIDGET (window))) | |
278 | { | |
279 | if (update) | |
280 | { | |
281 | update_window_progress (window, priv); | |
282 | } | |
283 | } | |
284 | } | |
285 | ||
286 | static void | |
287 | set_progress_pulse_internal (GtkWindow *window, | |
288 | XAppGtkWindowPrivate *priv, | |
289 | gboolean pulse) | |
290 | { | |
291 | gboolean update; | |
292 | ||
293 | update = FALSE; | |
294 | ||
295 | if (priv->progress_pulse != pulse) | |
296 | { | |
297 | priv->progress_pulse = pulse; | |
298 | ||
299 | update = TRUE; | |
300 | } | |
301 | ||
302 | /* If the window is realized, set the progress immediately. | |
303 | * If it's not, it will be set by xapp_gtk_window_realize(). */ | |
304 | if (gtk_widget_get_realized (GTK_WIDGET (window))) | |
305 | { | |
306 | if (update) | |
307 | { | |
308 | update_window_progress (window, priv); | |
309 | } | |
310 | } | |
311 | } | |
312 | ||
313 | static void | |
314 | xapp_gtk_window_realize (GtkWidget *widget) | |
315 | { | |
316 | XAppGtkWindow *window = XAPP_GTK_WINDOW (widget); | |
317 | XAppGtkWindowPrivate *priv = window->priv; | |
318 | ||
319 | GTK_WIDGET_CLASS (xapp_gtk_window_parent_class)->realize (widget); | |
320 | ||
321 | update_window_icon (GTK_WINDOW (window), priv); | |
322 | update_window_progress (GTK_WINDOW (window), priv); | |
323 | } | |
324 | ||
325 | static void | |
326 | xapp_gtk_window_unrealize (GtkWidget *widget) | |
327 | { | |
328 | GTK_WIDGET_CLASS (xapp_gtk_window_parent_class)->unrealize (widget); | |
329 | } | |
330 | ||
331 | static void | |
332 | xapp_gtk_window_finalize (GObject *object) | |
333 | { | |
334 | XAppGtkWindow *window = XAPP_GTK_WINDOW (object); | |
335 | XAppGtkWindowPrivate *priv = window->priv; | |
336 | ||
337 | clear_icon_strings (priv); | |
338 | ||
339 | G_OBJECT_CLASS (xapp_gtk_window_parent_class)->finalize (object); | |
340 | } | |
341 | ||
342 | static void | |
343 | xapp_gtk_window_init (XAppGtkWindow *window) | |
344 | { | |
345 | XAppGtkWindowPrivate *priv; | |
346 | ||
347 | window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, XAPP_TYPE_GTK_WINDOW, XAppGtkWindowPrivate); | |
348 | ||
349 | priv = window->priv; | |
350 | ||
351 | priv->icon_name = NULL; | |
352 | priv->icon_path = NULL; | |
353 | } | |
354 | ||
355 | static void | |
356 | xapp_gtk_window_class_init (XAppGtkWindowClass *klass) | |
357 | { | |
358 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass); | |
359 | GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass); | |
360 | ||
361 | gobject_class->finalize = xapp_gtk_window_finalize; | |
362 | wclass->realize = xapp_gtk_window_realize; | |
363 | wclass->unrealize = xapp_gtk_window_unrealize; | |
364 | } | |
365 | ||
366 | /** | |
367 | * xapp_gtk_window_new: | |
368 | * @type: The #GtkWindowType to use | |
369 | * | |
370 | * Creates a new #XAppGtkWindow of type @type. See gtk_window_new() | |
371 | * for more details. | |
372 | * | |
373 | * Returns: A new #XAppGtkWindow (transfer: full) | |
374 | */ | |
375 | GtkWidget * | |
376 | xapp_gtk_window_new (GtkWindowType type) | |
377 | { | |
378 | return g_object_new (XAPP_TYPE_GTK_WINDOW, "type", type, NULL); | |
379 | } | |
380 | ||
381 | /** | |
382 | * xapp_gtk_window_set_icon_name: | |
383 | * @window: The #XAppGtkWindow to set the icon name for | |
384 | * @icon_name: (nullable): The icon name or path to set, or %NULL to unset. | |
385 | * | |
386 | * Sets the icon name hint for a window manager (like muffin) to make | |
387 | * available when applications want to change their icons during runtime | |
388 | * without having to resort to the internal low-res pixbufs that GdkWindow | |
389 | * sets on the client side. This also chains up and calls GtkWindow.set_icon_name | |
390 | * for convenience and compatibility. Set to %NULL to unset. | |
391 | */ | |
392 | void | |
393 | xapp_gtk_window_set_icon_name (XAppGtkWindow *window, | |
394 | const gchar *icon_name) | |
395 | { | |
396 | g_return_if_fail (XAPP_IS_GTK_WINDOW (window)); | |
397 | ||
398 | set_icon_name_internal (GTK_WINDOW (window), window->priv, icon_name); | |
399 | } | |
400 | ||
401 | /** | |
402 | * xapp_gtk_window_set_icon_from_file: | |
403 | * @window: The #XAppGtkWindow to set the icon name for | |
404 | * @file_name: (nullable): The icon path to set, or %NULL to unset. | |
405 | * @error: (nullable): An error to set if something goes wrong. | |
406 | * | |
407 | * Sets the icon name hint for a window manager (like muffin) to make | |
408 | * available when applications want to change their icons during runtime | |
409 | * without having to resort to the internal low-res pixbufs that GdkWindow | |
410 | * sets on the client side. This also chains up and calls GtkWindow.set_icon_from_file | |
411 | * for convenience and compatibility. Set to %NULL to unset. | |
412 | */ | |
413 | void | |
414 | xapp_gtk_window_set_icon_from_file (XAppGtkWindow *window, | |
415 | const gchar *file_name, | |
416 | GError **error) | |
417 | { | |
418 | g_return_if_fail (XAPP_IS_GTK_WINDOW (window)); | |
419 | ||
420 | set_icon_from_file_internal (GTK_WINDOW (window), window->priv, file_name, error); | |
421 | } | |
422 | ||
423 | /** | |
424 | * xapp_gtk_window_set_progress: | |
425 | * @window: The #XAppGtkWindow to set the progress for | |
426 | * @progress: The value to set for progress. | |
427 | * | |
428 | * Sets the progress hint for a window manager (like muffin) to make | |
429 | * available when applications want to display the application's progress | |
430 | * in some operation. The value sent to the WM will be clamped to | |
431 | * between 0 and 100. | |
432 | * | |
433 | * Note: If a window will stick around after progress is complete, you will | |
434 | * probaby need to set progress to 0 to remove any progress effects on taskbars | |
435 | * and window lists. | |
436 | * | |
437 | * Setting progress will also cancel the 'pulsing' flag on the window as | |
438 | * well, if it has been set. | |
439 | */ | |
440 | void | |
441 | xapp_gtk_window_set_progress (XAppGtkWindow *window, | |
442 | gint progress) | |
443 | { | |
444 | g_return_if_fail (XAPP_IS_GTK_WINDOW (window)); | |
445 | ||
446 | set_progress_internal (GTK_WINDOW (window), window->priv, progress); | |
447 | } | |
448 | ||
449 | /** | |
450 | * xapp_gtk_window_set_progress_pulse: | |
451 | * @window: The #XAppGtkWindow to set the progress for | |
452 | * @pulse: Whether to have pulsing set or not. | |
453 | * | |
454 | * Sets the progress pulse hint hint for a window manager (like muffin) | |
455 | * to make available when applications want to display indeterminate or | |
456 | * ongoing progress in a task manager. | |
457 | * | |
458 | * Note: If a window will stick around after progress is complete, you will | |
459 | * probaby need to set progress to 0 to remove any progress effects on taskbars | |
460 | * and window lists. This will also remove the pulse state, if it is set. | |
461 | * | |
462 | * Setting an explicit progress value will unset this flag. | |
463 | */ | |
464 | void | |
465 | xapp_gtk_window_set_progress_pulse (XAppGtkWindow *window, | |
466 | gboolean pulse) | |
467 | { | |
468 | g_return_if_fail (XAPP_IS_GTK_WINDOW (window)); | |
469 | g_return_if_fail (XAPP_IS_GTK_WINDOW (window)); | |
470 | ||
471 | set_progress_pulse_internal (GTK_WINDOW (window), window->priv, pulse); | |
472 | } | |
473 | ||
474 | ||
475 | /* Wrappers (for GtkWindow subclasses like GtkDialog) | |
476 | * window must be a GtkWindow or descendant */ | |
477 | static void | |
478 | on_gtk_window_realized (GtkWidget *widget, | |
479 | gpointer user_data) | |
480 | { | |
481 | XAppGtkWindowPrivate *priv; | |
482 | ||
483 | priv = (XAppGtkWindowPrivate *) user_data; | |
484 | ||
485 | update_window_icon (GTK_WINDOW (widget), priv); | |
486 | update_window_progress (GTK_WINDOW (widget), priv); | |
487 | } | |
488 | ||
489 | static void | |
490 | destroy_xapp_struct (gpointer user_data) | |
491 | { | |
492 | XAppGtkWindowPrivate *priv = (XAppGtkWindowPrivate *) user_data; | |
493 | ||
494 | g_clear_pointer (&priv->icon_name, g_free); | |
495 | g_clear_pointer (&priv->icon_path, g_free); | |
496 | ||
497 | g_slice_free (XAppGtkWindowPrivate, priv); | |
498 | } | |
499 | ||
500 | static XAppGtkWindowPrivate * | |
501 | get_xapp_struct (GtkWindow *window) | |
502 | { | |
503 | XAppGtkWindowPrivate *priv; | |
504 | ||
505 | priv = g_object_get_data (G_OBJECT (window), | |
506 | "xapp-window-struct"); | |
507 | ||
508 | if (priv) | |
509 | { | |
510 | return priv; | |
511 | } | |
512 | ||
513 | priv = g_slice_new0 (XAppGtkWindowPrivate); | |
514 | ||
515 | g_object_set_data_full (G_OBJECT (window), | |
516 | "xapp-window-struct", | |
517 | priv, | |
518 | (GDestroyNotify) destroy_xapp_struct); | |
519 | ||
520 | g_signal_connect_after (GTK_WIDGET (window), | |
521 | "realize", | |
522 | G_CALLBACK (on_gtk_window_realized), | |
523 | priv); | |
524 | ||
525 | return priv; | |
526 | } | |
527 | ||
528 | /** | |
529 | * xapp_set_window_icon_name: | |
530 | * @window: The #GtkWindow to set the icon name for | |
531 | * @icon_name: (nullable): The icon name to set, or %NULL to unset. | |
532 | * | |
533 | * Sets the icon name hint for a window manager (like muffin) to make | |
534 | * available when applications want to change their icons during runtime | |
535 | * without having to resort to the internal low-res pixbufs that GdkWindow | |
536 | * sets on the client side. This is a function, not a method, for taking | |
537 | * advantage of this feature with descendants of GtkWindows, such as | |
538 | * GtkDialogs. Sets gtk_window_set_icon_name as well, to avoid needing | |
539 | * to have two calls each time. Set to %NULL to unset. | |
540 | */ | |
541 | void | |
542 | xapp_set_window_icon_name (GtkWindow *window, | |
543 | const gchar *icon_name) | |
544 | { | |
545 | XAppGtkWindowPrivate *priv; | |
546 | ||
547 | g_return_if_fail (GTK_IS_WINDOW (window)); | |
548 | ||
549 | priv = get_xapp_struct (window); | |
550 | ||
551 | if (XAPP_IS_GTK_WINDOW (window)) | |
552 | { | |
553 | g_warning("Window is an instance of XAppGtkWindow. Use the instance set_icon_name method instead."); | |
554 | } | |
555 | ||
556 | set_icon_name_internal (window, priv, icon_name); | |
557 | } | |
558 | ||
559 | ||
560 | /** | |
561 | * xapp_set_window_icon_from_file: | |
562 | * @window: The #GtkWindow to set the icon name for | |
563 | * @file_name: (nullable): The icon path to set, or %NULL to unset. | |
564 | * @error: (nullable): An error to set if something goes wrong. | |
565 | * | |
566 | * Sets the icon name hint for a window manager (like muffin) to make | |
567 | * available when applications want to change their icons during runtime | |
568 | * without having to resort to the internal low-res pixbufs that GdkWindow | |
569 | * sets on the client side. This also chains up and calls GtkWindow.set_icon_from_file | |
570 | * for convenience and compatibility. Set to %NULL to unset. | |
571 | */ | |
572 | void | |
573 | xapp_set_window_icon_from_file (GtkWindow *window, | |
574 | const gchar *file_name, | |
575 | GError **error) | |
576 | { | |
577 | XAppGtkWindowPrivate *priv; | |
578 | ||
579 | g_return_if_fail (GTK_IS_WINDOW (window)); | |
580 | ||
581 | priv = get_xapp_struct (window); | |
582 | ||
583 | if (XAPP_IS_GTK_WINDOW (window)) | |
584 | { | |
585 | g_warning("Window is an instance of XAppGtkWindow. Use the instance set_icon_from_file method instead."); | |
586 | } | |
587 | ||
588 | set_icon_from_file_internal (window, priv, file_name, error); | |
589 | } | |
590 | ||
591 | /** | |
592 | * xapp_set_window_progress: | |
593 | * @window: The #GtkWindow to set the progress for | |
594 | * @progress: The value to set for progress. | |
595 | * | |
596 | * Sets the progress hint for a window manager (like muffin) to make | |
597 | * available when applications want to display the application's progress | |
598 | * in some operation. The value sent to the WM will be clamped to | |
599 | * between 0 and 100. | |
600 | * | |
601 | * Note: If a window will stick around after progress is complete, you will | |
602 | * probaby need to set progress to 0 to remove any progress effects on taskbars | |
603 | * and window lists. | |
604 | * | |
605 | * Setting progress will also cancel the 'pulsing' flag on the window as | |
606 | * well, if it has been set. | |
607 | */ | |
608 | void | |
609 | xapp_set_window_progress (GtkWindow *window, | |
610 | gint progress) | |
611 | { | |
612 | XAppGtkWindowPrivate *priv; | |
613 | ||
614 | g_return_if_fail (GTK_IS_WINDOW (window)); | |
615 | ||
616 | priv = get_xapp_struct (window); | |
617 | ||
618 | if (XAPP_IS_GTK_WINDOW (window)) | |
619 | { | |
620 | g_warning("Window is an instance of XAppGtkWindow. Use the instance set_progress method instead."); | |
621 | } | |
622 | ||
623 | set_progress_internal (window, priv, progress); | |
624 | } | |
625 | ||
626 | /** | |
627 | * xapp_set_window_progress_pulse: | |
628 | * @window: The #GtkWindow to set the progress for | |
629 | * @pulse: Whether to have pulsing set or not. | |
630 | * | |
631 | * Sets the progress pulse hint hint for a window manager (like muffin) | |
632 | * to make available when applications want to display indeterminate or | |
633 | * ongoing progress in a task manager. | |
634 | * | |
635 | * Note: If a window will stick around after progress is complete, you will | |
636 | * probaby need to set progress to 0 to remove any progress effects on taskbars | |
637 | * and window lists. This will also remove the pulse state, if it is set. | |
638 | * | |
639 | * Setting an explicit progress value will unset this flag. | |
640 | */ | |
641 | void | |
642 | xapp_set_window_progress_pulse (GtkWindow *window, | |
643 | gboolean pulse) | |
644 | { | |
645 | XAppGtkWindowPrivate *priv; | |
646 | ||
647 | g_return_if_fail (GTK_IS_WINDOW (window)); | |
648 | ||
649 | priv = get_xapp_struct (window); | |
650 | ||
651 | if (XAPP_IS_GTK_WINDOW (window)) | |
652 | { | |
653 | g_warning("Window is an instance of XAppGtkWindow. Use the instance set_progress_pulse method instead."); | |
654 | } | |
655 | ||
656 | set_progress_pulse_internal (GTK_WINDOW (window), priv, pulse); | |
657 | } | |
658 | ||
659 | /** | |
660 | * xapp_set_xid_icon_name: | |
661 | * @xid: The Window to set the icon name for | |
662 | * @icon_name: (nullable): The icon name to set, or %NULL to unset. | |
663 | * | |
664 | * Sets the icon name hint for a window manager (like muffin) to make | |
665 | * available when applications want to change their icons during runtime | |
666 | * without having to resort to the internal low-res pixbufs that GdkWindow | |
667 | * sets on the client side. This is a function, not a method, for applying | |
668 | * the icon name property for a given (possibly foreign) window, by passing | |
669 | * the window's XID. Set to %NULL to unset. | |
670 | */ | |
671 | void | |
672 | xapp_set_xid_icon_name (gulong xid, | |
673 | const gchar *icon_name) | |
674 | { | |
675 | g_return_if_fail (xid > 0); | |
676 | ||
677 | set_window_hint_utf8 (xid, ICON_NAME_HINT, icon_name); | |
678 | } | |
679 | ||
680 | /** | |
681 | * xapp_set_xid_icon_from_file: | |
682 | * @xid: The Window to set the icon name for | |
683 | * @file_name: (nullable): The icon path to set, or %NULL to unset. | |
684 | * | |
685 | * Sets the icon name hint for a window manager (like muffin) to make | |
686 | * available when applications want to change their icons during runtime | |
687 | * without having to resort to the internal low-res pixbufs that GdkWindow | |
688 | * sets on the client side. This is a function, not a method, for applying | |
689 | * the icon name property for a given (possibly foreign) window, by passing | |
690 | * the window's XID. Set to %NULL to unset. | |
691 | */ | |
692 | void | |
693 | xapp_set_xid_icon_from_file (gulong xid, | |
694 | const gchar *file_name) | |
695 | { | |
696 | ||
697 | g_return_if_fail (xid > 0); | |
698 | ||
699 | set_window_hint_utf8 (xid, ICON_NAME_HINT, file_name); | |
700 | } | |
701 | ||
702 | /** | |
703 | * xapp_set_xid_progress: | |
704 | * @xid: The Window to set the progress for | |
705 | * @progress: The value to set for progress. | |
706 | * | |
707 | * Sets the progress hint for a window manager (like muffin) to make | |
708 | * available when applications want to display the application's progress | |
709 | * in some operation. The value sent to the WM will be clamped to | |
710 | * between 0 and 100. | |
711 | * | |
712 | * Setting progress will also cancel the 'pulsing' flag on the window as | |
713 | * well, if it has been set. | |
714 | * | |
715 | * Note: If a window will stick around after progress is complete, you will | |
716 | * probaby need to set progress to 0 to remove any progress effects on taskbars | |
717 | * and window lists. | |
718 | * | |
719 | * This is a function, not a method, for applying the progress property for | |
720 | * a given (possibly foreign) window, by passing the window's XID. | |
721 | */ | |
722 | void | |
723 | xapp_set_xid_progress (gulong xid, | |
724 | gint progress) | |
725 | { | |
726 | g_return_if_fail (xid > 0); | |
727 | ||
728 | set_window_hint_cardinal (xid, PROGRESS_HINT, (gulong) (CLAMP (progress, 0, 100))); | |
729 | set_window_hint_cardinal (xid, PROGRESS_PULSE_HINT, (gulong) 0); | |
730 | } | |
731 | ||
732 | /** | |
733 | * xapp_set_xid_progress_pulse: | |
734 | * @xid: The Window to set the progress for | |
735 | * @pulse: Whether to have pulsing set or not. | |
736 | * | |
737 | * Sets the progress pulse hint hint for a window manager (like muffin) | |
738 | * to make available when applications want to display indeterminate or | |
739 | * ongoing progress in a task manager. | |
740 | * | |
741 | * Note: If a window will stick around after progress is complete, you will | |
742 | * probaby need to set progress to 0 to remove any progress effects on taskbars | |
743 | * and window lists. | |
744 | * | |
745 | * Setting an explicit progress value will unset this flag. | |
746 | */ | |
747 | void | |
748 | xapp_set_xid_progress_pulse (gulong xid, | |
749 | gboolean pulse) | |
750 | { | |
751 | g_return_if_fail (xid > 0); | |
752 | ||
753 | set_window_hint_cardinal (xid, PROGRESS_PULSE_HINT, (gulong) (pulse ? 1 : 0)); | |
754 | } |
0 | #ifndef __XAPP_GTK_WINDOW_H__ | |
1 | #define __XAPP_GTK_WINDOW_H__ | |
2 | ||
3 | #include <stdio.h> | |
4 | ||
5 | #include <glib-object.h> | |
6 | #include <gtk/gtk.h> | |
7 | ||
8 | G_BEGIN_DECLS | |
9 | ||
10 | #define XAPP_TYPE_GTK_WINDOW (xapp_gtk_window_get_type ()) | |
11 | ||
12 | G_DECLARE_FINAL_TYPE (XAppGtkWindow, xapp_gtk_window, XAPP, GTK_WINDOW, GtkWindow) | |
13 | ||
14 | /* Class */ | |
15 | GtkWidget *xapp_gtk_window_new (GtkWindowType type); | |
16 | ||
17 | void xapp_gtk_window_set_icon_name (XAppGtkWindow *window, | |
18 | const gchar *icon_name); | |
19 | ||
20 | void xapp_gtk_window_set_icon_from_file (XAppGtkWindow *window, | |
21 | const gchar *file_name, | |
22 | GError **error); | |
23 | void xapp_gtk_window_set_progress (XAppGtkWindow *window, | |
24 | gint progress); | |
25 | void xapp_gtk_window_set_progress_pulse (XAppGtkWindow *window, | |
26 | gboolean pulse); | |
27 | /* Wrappers (for GtkWindow subclasses like GtkDialog)*/ | |
28 | ||
29 | void xapp_set_window_icon_name (GtkWindow *window, | |
30 | const gchar *icon_name); | |
31 | ||
32 | void xapp_set_window_icon_from_file (GtkWindow *window, | |
33 | const gchar *file_name, | |
34 | GError **error); | |
35 | void xapp_set_window_progress (GtkWindow *window, | |
36 | gint progress); | |
37 | void xapp_set_window_progress_pulse (GtkWindow *window, | |
38 | gboolean pulse); | |
39 | /* Low level for X11 Window xid's */ | |
40 | void xapp_set_xid_icon_name (gulong xid, | |
41 | const gchar *icon_name); | |
42 | void xapp_set_xid_icon_from_file (gulong xid, | |
43 | const gchar *file_name); | |
44 | void xapp_set_xid_progress (gulong xid, | |
45 | gint progress); | |
46 | void xapp_set_xid_progress_pulse (gulong xid, | |
47 | gboolean pulse); | |
48 | ||
49 | G_END_DECLS | |
50 | ||
51 | #endif /* __XAPP_GTK_WINDOW_H__ */ |
12 | 12 | #include <libgnomekbd/gkbd-configuration.h> |
13 | 13 | |
14 | 14 | #include "xapp-kbd-layout-controller.h" |
15 | ||
16 | /** | |
17 | * SECTION:xapp-kbd-layout-controller | |
18 | * @Short_description: Keyboard layout selection UI element provider. | |
19 | * @Title: XAppKbdLayoutController | |
20 | * | |
21 | * A GObject wrapper for Gkbd that provides additional UI element | |
22 | * support for keyboard layout flags and abbreviations, as well as | |
23 | * Wfacilities to distinguish regional and hardware-based variants | |
24 | * which might otherwise appear identical in a layout list. | |
25 | */ | |
15 | 26 | |
16 | 27 | enum |
17 | 28 | { |
60 | 71 | { |
61 | 72 | GkbdConfiguration *config; |
62 | 73 | |
63 | gint num_groups; | |
74 | guint num_groups; | |
64 | 75 | |
65 | 76 | GPtrArray *group_data; |
66 | 77 | |
129 | 140 | |
130 | 141 | /* Populate the GroupData pointer array */ |
131 | 142 | |
132 | gint i, j, group_dupe_id, variant_dupe_id; | |
143 | gint group_dupe_id, variant_dupe_id; | |
144 | guint i, j; | |
145 | ||
133 | 146 | GPtrArray *list = g_ptr_array_new_with_free_func ((GDestroyNotify) group_data_free); |
134 | 147 | |
135 | 148 | for (i = 0; i < priv->num_groups; i++) |
385 | 398 | 0, G_TYPE_NONE); |
386 | 399 | } |
387 | 400 | |
401 | /** | |
402 | * xapp_kbd_layout_controller_new | |
403 | * | |
404 | * Creates a new XAppKbdLayoutController instance. | |
405 | * | |
406 | * Returns: (transfer full): a new #XAppKbdLayoutController instance | |
407 | */ | |
388 | 408 | XAppKbdLayoutController * |
389 | 409 | xapp_kbd_layout_controller_new (void) |
390 | 410 | { |
391 | 411 | return g_object_new (XAPP_TYPE_KBD_LAYOUT_CONTROLLER, NULL); |
392 | 412 | } |
393 | 413 | |
414 | /** | |
415 | * xapp_kbd_layout_controller_get_enabled: | |
416 | * @controller: the #XAppKbdLayoutController | |
417 | * | |
418 | * Returns whether or not the layout controller is enabled | |
419 | */ | |
394 | 420 | gboolean |
395 | 421 | xapp_kbd_layout_controller_get_enabled (XAppKbdLayoutController *controller) |
396 | 422 | { |
397 | 423 | return controller->priv->enabled; |
398 | 424 | } |
399 | 425 | |
426 | /** | |
427 | * xapp_kbd_layout_controller_get_current_group: | |
428 | * @controller: the #XAppKbdLayoutController | |
429 | * | |
430 | * Selects the previous group in the group list. | |
431 | */ | |
400 | 432 | guint |
401 | 433 | xapp_kbd_layout_controller_get_current_group (XAppKbdLayoutController *controller) |
402 | 434 | { |
405 | 437 | return gkbd_configuration_get_current_group (controller->priv->config); |
406 | 438 | } |
407 | 439 | |
440 | /** | |
441 | * xapp_kbd_layout_controller_set_current_group | |
442 | * @controller: the #XAppKbdLayoutController | |
443 | * @group: the group number to make active | |
444 | * | |
445 | * Selects the given group number as active. | |
446 | */ | |
408 | 447 | void |
409 | 448 | xapp_kbd_layout_controller_set_current_group (XAppKbdLayoutController *controller, |
410 | 449 | guint group) |
420 | 459 | } |
421 | 460 | } |
422 | 461 | |
462 | /** | |
463 | * xapp_kbd_layout_controller_next_group | |
464 | * @controller: the #XAppKbdLayoutController | |
465 | * | |
466 | * Selects the next group in the group list. | |
467 | */ | |
423 | 468 | void |
424 | 469 | xapp_kbd_layout_controller_next_group (XAppKbdLayoutController *controller) |
425 | 470 | { |
428 | 473 | gkbd_configuration_lock_next_group (controller->priv->config); |
429 | 474 | } |
430 | 475 | |
476 | /** | |
477 | * xapp_kbd_layout_controller_previous_group | |
478 | * @controller: the #XAppKbdLayoutController | |
479 | * | |
480 | * Selects the previous group in the group list. | |
481 | */ | |
431 | 482 | void |
432 | 483 | xapp_kbd_layout_controller_previous_group (XAppKbdLayoutController *controller) |
433 | 484 | { |
451 | 502 | |
452 | 503 | /** |
453 | 504 | * xapp_kbd_layout_controller_get_current_name: |
505 | * @controller: the #XAppKbdLayoutController | |
454 | 506 | * |
455 | 507 | * Returns the full name of the current keyboard layout. |
456 | 508 | * |
467 | 519 | |
468 | 520 | /** |
469 | 521 | * xapp_kbd_layout_controller_get_all_names: |
522 | * @controller: the #XAppKbdLayoutController | |
470 | 523 | * |
471 | 524 | * Returns an array of all full layout names |
472 | 525 | * |
482 | 535 | |
483 | 536 | /** |
484 | 537 | * xapp_kbd_layout_controller_get_current_icon_name: |
538 | * @controller: the #XAppKbdLayoutController | |
485 | 539 | * |
486 | 540 | * Returns the icon file name (no path or extension) to use for the current layout |
487 | 541 | * |
501 | 555 | |
502 | 556 | /** |
503 | 557 | * xapp_kbd_layout_controller_get_icon_name_for_group: |
558 | * @controller: the #XAppKbdLayoutController | |
559 | * @group: a group number | |
504 | 560 | * |
505 | 561 | * Returns the icon file name (no path or extension) to use for the specified layout. |
506 | 562 | * |
520 | 576 | |
521 | 577 | /** |
522 | 578 | * xapp_kbd_layout_controller_get_current_flag_id: |
579 | * @controller: the #XAppKbdLayoutController | |
523 | 580 | * |
524 | 581 | * Returns the duplicate id for the current layout |
525 | 582 | * |
540 | 597 | |
541 | 598 | /** |
542 | 599 | * xapp_kbd_layout_controller_flag_id_for_group: |
600 | * @controller: the #XAppKbdLayoutController | |
601 | * @group: a group number | |
543 | 602 | * |
544 | 603 | * Returns the duplicate id for the specified layout |
545 | 604 | * |
559 | 618 | |
560 | 619 | /** |
561 | 620 | * xapp_kbd_layout_controller_get_current_short_group_label: |
621 | * @controller: the #XAppKbdLayoutController | |
562 | 622 | * |
563 | 623 | * Returns the short group label (and subscript, if any) of the current layout |
564 | 624 | * |
578 | 638 | |
579 | 639 | /** |
580 | 640 | * xapp_kbd_layout_controller_get_short_group_label_for_group: |
641 | * @controller: the #XAppKbdLayoutController | |
642 | * @group: a group number | |
581 | 643 | * |
582 | 644 | * Returns the short group label and subscript of the specified layout. |
583 | 645 | * |
598 | 660 | |
599 | 661 | /** |
600 | 662 | * xapp_kbd_layout_controller_get_current_variant_label: |
663 | * @controller: the #XAppKbdLayoutController | |
601 | 664 | * |
602 | 665 | * Returns the variant label (and subscript, if any) of the current layout |
603 | 666 | * |
617 | 680 | |
618 | 681 | /** |
619 | 682 | * xapp_kbd_layout_controller_get_variant_label_for_group: |
683 | * @controller: the #XAppKbdLayoutController | |
684 | * @group: a group number | |
620 | 685 | * |
621 | 686 | * Returns the variant label and subscript of the specified layout. |
622 | 687 | * |
635 | 700 | return g_strdup (GROUP_DATA (priv->group_data, group)->variant_label); |
636 | 701 | } |
637 | 702 | |
703 | /** | |
704 | * xapp_kbd_layout_controller_render_cairo_subscript: | |
705 | * @cr: a #cairo_t | |
706 | * @x: the x position of the drawing area | |
707 | * @y: the y position of the drawing area | |
708 | * @width: the width of the drawing area | |
709 | * @height: the height of the drawing area | |
710 | * @subscript: the number to render | |
711 | * | |
712 | * Renders a subscript number in the given work area. This should | |
713 | * be called from within a "draw" or "paint" widget/actor function, | |
714 | * where a valid cairo_t is provided to draw with. | |
715 | */ | |
638 | 716 | void |
639 | 717 | xapp_kbd_layout_controller_render_cairo_subscript (cairo_t *cr, |
640 | 718 | gdouble x, |
0 | 0 | dnl -*- mode: autoconf -*- |
1 | 1 | |
2 | # serial 1 | |
2 | # serial 2 | |
3 | 3 | |
4 | 4 | dnl Usage: |
5 | 5 | dnl GTK_DOC_CHECK([minimum-gtk-doc-version]) |
9 | 9 | AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first |
10 | 10 | AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first |
11 | 11 | |
12 | ifelse([$1],[],[gtk_doc_requires="gtk-doc"],[gtk_doc_requires="gtk-doc >= $1"]) | |
13 | AC_MSG_CHECKING([for gtk-doc]) | |
14 | PKG_CHECK_EXISTS([$gtk_doc_requires],[have_gtk_doc=yes],[have_gtk_doc=no]) | |
15 | AC_MSG_RESULT($have_gtk_doc) | |
16 | ||
17 | if test "$have_gtk_doc" = "no"; then | |
18 | AC_MSG_WARN([ | |
19 | You will not be able to create source packages with 'make dist' | |
20 | because $gtk_doc_requires is not found.]) | |
21 | fi | |
22 | ||
12 | 23 | dnl check for tools we added during development |
13 | AC_PATH_PROG([GTKDOC_CHECK],[gtkdoc-check]) | |
24 | dnl Use AC_CHECK_PROG to avoid the check target using an absolute path that | |
25 | dnl may not be writable by the user. Currently, automake requires that the | |
26 | dnl test name must end in '.test'. | |
27 | dnl https://bugzilla.gnome.org/show_bug.cgi?id=701638 | |
28 | AC_CHECK_PROG([GTKDOC_CHECK],[gtkdoc-check],[gtkdoc-check.test]) | |
29 | AC_PATH_PROG([GTKDOC_CHECK_PATH],[gtkdoc-check]) | |
14 | 30 | AC_PATH_PROGS([GTKDOC_REBASE],[gtkdoc-rebase],[true]) |
15 | 31 | AC_PATH_PROG([GTKDOC_MKPDF],[gtkdoc-mkpdf]) |
16 | 32 | |
27 | 43 | [use gtk-doc to build documentation [[default=no]]]),, |
28 | 44 | [enable_gtk_doc=no]) |
29 | 45 | |
30 | if test x$enable_gtk_doc = xyes; then | |
31 | ifelse([$1],[], | |
32 | [PKG_CHECK_EXISTS([gtk-doc],, | |
33 | AC_MSG_ERROR([gtk-doc not installed and --enable-gtk-doc requested]))], | |
34 | [PKG_CHECK_EXISTS([gtk-doc >= $1],, | |
35 | AC_MSG_ERROR([You need to have gtk-doc >= $1 installed to build $PACKAGE_NAME]))]) | |
36 | dnl don't check for glib if we build glib | |
37 | if test "x$PACKAGE_NAME" != "xglib"; then | |
38 | dnl don't fail if someone does not have glib | |
39 | PKG_CHECK_MODULES(GTKDOC_DEPS, glib-2.0 >= 2.10.0 gobject-2.0 >= 2.10.0,,) | |
40 | fi | |
46 | AC_MSG_CHECKING([whether to build gtk-doc documentation]) | |
47 | AC_MSG_RESULT($enable_gtk_doc) | |
48 | ||
49 | if test "x$enable_gtk_doc" = "xyes" && test "$have_gtk_doc" = "no"; then | |
50 | AC_MSG_ERROR([ | |
51 | You must have $gtk_doc_requires installed to build documentation for | |
52 | $PACKAGE_NAME. Please install gtk-doc or disable building the | |
53 | documentation by adding '--disable-gtk-doc' to '[$]0'.]) | |
41 | 54 | fi |
42 | 55 | |
43 | AC_MSG_CHECKING([whether to build gtk-doc documentation]) | |
44 | AC_MSG_RESULT($enable_gtk_doc) | |
56 | dnl don't check for glib if we build glib | |
57 | if test "x$PACKAGE_NAME" != "xglib"; then | |
58 | dnl don't fail if someone does not have glib | |
59 | PKG_CHECK_MODULES(GTKDOC_DEPS, glib-2.0 >= 2.10.0 gobject-2.0 >= 2.10.0,,[:]) | |
60 | fi | |
45 | 61 | |
46 | 62 | dnl enable/disable output formats |
47 | 63 | AC_ARG_ENABLE([gtk-doc-html], |
57 | 73 | enable_gtk_doc_pdf=no |
58 | 74 | fi |
59 | 75 | |
76 | if test -z "$AM_DEFAULT_VERBOSITY"; then | |
77 | AM_DEFAULT_VERBOSITY=1 | |
78 | fi | |
79 | AC_SUBST([AM_DEFAULT_VERBOSITY]) | |
60 | 80 | |
81 | AM_CONDITIONAL([HAVE_GTK_DOC], [test x$have_gtk_doc = xyes]) | |
61 | 82 | AM_CONDITIONAL([ENABLE_GTK_DOC], [test x$enable_gtk_doc = xyes]) |
62 | 83 | AM_CONDITIONAL([GTK_DOC_BUILD_HTML], [test x$enable_gtk_doc_html = xyes]) |
63 | 84 | AM_CONDITIONAL([GTK_DOC_BUILD_PDF], [test x$enable_gtk_doc_pdf = xyes]) |
153 | 153 | |
154 | 154 | # Substitute ALL_LINGUAS so we can use it in po/Makefile |
155 | 155 | AC_SUBST(ALL_LINGUAS) |
156 | ||
157 | # Set DATADIRNAME correctly if it is not set yet | |
158 | # (copied from glib-gettext.m4) | |
159 | if test -z "$DATADIRNAME"; then | |
160 | AC_LINK_IFELSE( | |
161 | [AC_LANG_PROGRAM([[]], | |
162 | [[extern int _nl_msg_cat_cntr; | |
163 | return _nl_msg_cat_cntr]])], | |
164 | [DATADIRNAME=share], | |
165 | [case $host in | |
166 | *-*-solaris*) | |
167 | dnl On Solaris, if bind_textdomain_codeset is in libc, | |
168 | dnl GNU format message catalog is always supported, | |
169 | dnl since both are added to the libc all together. | |
170 | dnl Hence, we'd like to go with DATADIRNAME=share | |
171 | dnl in this case. | |
172 | AC_CHECK_FUNC(bind_textdomain_codeset, | |
173 | [DATADIRNAME=share], [DATADIRNAME=lib]) | |
174 | ;; | |
175 | *) | |
176 | [DATADIRNAME=lib] | |
177 | ;; | |
178 | esac]) | |
179 | fi | |
180 | AC_SUBST(DATADIRNAME) | |
181 | 156 | |
182 | 157 | IT_PO_SUBDIR([po]) |
183 | 158 |
32 | 32 | datadir = @datadir@ |
33 | 33 | datarootdir = @datarootdir@ |
34 | 34 | libdir = @libdir@ |
35 | DATADIRNAME = @DATADIRNAME@ | |
36 | itlocaledir = $(prefix)/$(DATADIRNAME)/locale | |
35 | localedir = @localedir@ | |
37 | 36 | subdir = po |
38 | 37 | install_sh = @install_sh@ |
39 | 38 | # Automake >= 1.8 provides @mkdir_p@. |
79 | 78 | |
80 | 79 | .po.pox: |
81 | 80 | $(MAKE) $(GETTEXT_PACKAGE).pot |
82 | $(MSGMERGE) $< $(GETTEXT_PACKAGE).pot -o $*.pox | |
81 | $(MSGMERGE) $* $(GETTEXT_PACKAGE).pot -o $*.pox | |
83 | 82 | |
84 | 83 | .po.mo: |
85 | 84 | $(INTLTOOL_V_MSGFMT)$(MSGFMT) -o $@ $< |
107 | 106 | install-data-yes: all |
108 | 107 | linguas="$(USE_LINGUAS)"; \ |
109 | 108 | for lang in $$linguas; do \ |
110 | dir=$(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES; \ | |
109 | dir=$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES; \ | |
111 | 110 | $(mkdir_p) $$dir; \ |
112 | 111 | if test -r $$lang.gmo; then \ |
113 | 112 | $(INSTALL_DATA) $$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \ |
141 | 140 | uninstall: |
142 | 141 | linguas="$(USE_LINGUAS)"; \ |
143 | 142 | for lang in $$linguas; do \ |
144 | rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \ | |
145 | rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \ | |
143 | rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \ | |
144 | rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \ | |
146 | 145 | done |
147 | 146 | |
148 | 147 | check: all $(GETTEXT_PACKAGE).pot |
0 | from gi.overrides import override | |
1 | from gi.importer import modules | |
2 | ||
3 | """ | |
4 | The only purpose of this file is to ensure the XApp widget GType is registered | |
5 | at the time of import. Otherwise any user of XApp.GtkWindow would have to create | |
6 | a dummy widget prior to using a GtkBuilder to parse a ui file containing an | |
7 | XAppGtkWindow. | |
8 | ||
9 | The gi import machinery sweeps usr/lib/python*/dist-packages/gi/overrides for file | |
10 | matching the module name at the time of execution. | |
11 | ||
12 | This file needs to be in both python2 and python3 overrides locations. | |
13 | ||
14 | """ | |
15 | ||
16 | XApp = modules['XApp']._introspection_module | |
17 | ||
18 | __all__ = [] | |
19 | ||
20 | class GtkWindow(XApp.GtkWindow): | |
21 | pass | |
22 | ||
23 | GtkWindow = override(GtkWindow) | |
24 | __all__.append('GtkWindow') |
0 | #! /usr/bin/python3 | |
1 | ||
2 | """ | |
3 | A demo/test script for the XAppAppGtkWindow class | |
4 | """ | |
5 | import sys, os | |
6 | import signal | |
7 | import gettext | |
8 | import time | |
9 | ||
10 | import gi | |
11 | gi.require_version('Gtk', '3.0') | |
12 | gi.require_version('XApp', '1.0') | |
13 | ||
14 | from gi.repository import GLib, Gtk, XApp, GObject | |
15 | ||
16 | signal.signal(signal.SIGINT, signal.SIG_DFL) | |
17 | ||
18 | class Main: | |
19 | def __init__(self): | |
20 | self.win = XApp.GtkWindow() | |
21 | ||
22 | self._animate_progress = 0 | |
23 | ||
24 | self.win.set_default_size(320, 200) | |
25 | ||
26 | frame = Gtk.Frame() | |
27 | frame.set_margin_start(2) | |
28 | frame.set_margin_end(2) | |
29 | frame.set_margin_top(2) | |
30 | frame.set_margin_bottom(2) | |
31 | ||
32 | self.win.add(frame) | |
33 | ||
34 | box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) | |
35 | box.set_margin_start(2) | |
36 | box.set_margin_end(2) | |
37 | box.set_margin_top(2) | |
38 | box.set_margin_bottom(2) | |
39 | ||
40 | frame.add(box) | |
41 | ||
42 | heading = Gtk.Label() | |
43 | heading.set_markup("Use '<span font_family='mono' weight='bold'>xprop -spy</span>' to monitor changes") | |
44 | box.pack_start(heading, True, True, 4) | |
45 | ||
46 | hbox = Gtk.HBox() | |
47 | self.icon_name_entry = Gtk.Entry() | |
48 | self.icon_name_setter = Gtk.Button("Set icon name") | |
49 | self.icon_name_setter.connect("clicked", self.on_icon_name_setter_clicked) | |
50 | hbox.pack_start(self.icon_name_entry, True, True, 4) | |
51 | hbox.pack_start(self.icon_name_setter, False, False, 4) | |
52 | box.pack_start(hbox, True, True, 4) | |
53 | ||
54 | hbox = Gtk.HBox() | |
55 | self.icon_path_entry = Gtk.Entry() | |
56 | self.icon_path_setter = Gtk.Button("Set icon path") | |
57 | self.icon_path_setter.connect("clicked", self.on_icon_path_setter_clicked) | |
58 | hbox.pack_start(self.icon_path_entry, True, True, 4) | |
59 | hbox.pack_start(self.icon_path_setter, False, False, 4) | |
60 | box.pack_start(hbox, True, True, 4) | |
61 | ||
62 | hbox = Gtk.HBox() | |
63 | self.progress_label = Gtk.Label("Progress:") | |
64 | self.progress = Gtk.Scale() | |
65 | self.progress.connect("value-changed", self.on_progress_value_changed) | |
66 | self.progress.set_draw_value(True) | |
67 | self.progress.set_digits(0) | |
68 | self.progress.set_range(0, 100) | |
69 | ||
70 | hbox.pack_start(self.progress_label, False, False, 4) | |
71 | hbox.pack_start(self.progress, True, True, 4) | |
72 | box.pack_start(hbox, True, True, 4) | |
73 | ||
74 | hbox = Gtk.HBox() | |
75 | self.pulse_label = Gtk.Label("Progress pulse:") | |
76 | self.pulse_switch = Gtk.Switch() | |
77 | self.pulse_switch.set_halign(Gtk.Align.CENTER) | |
78 | self.pulse_switch.connect("notify::active", self.on_pulse_switch_changed) | |
79 | hbox.pack_start(self.pulse_label, False, False, 4) | |
80 | hbox.pack_start(self.pulse_switch, True, True, 4) | |
81 | box.pack_start(hbox, True, True, 4) | |
82 | ||
83 | hbox = Gtk.HBox() | |
84 | self.animate_button = Gtk.Button("Simulate progress over time") | |
85 | self.animate_button.connect("clicked", self.on_animate_progress_clicked) | |
86 | hbox.pack_start(self.animate_button, True, True, 4) | |
87 | ||
88 | box.pack_start(hbox, True, True, 4) | |
89 | ||
90 | frame.show_all() | |
91 | self.win.connect("delete-event", lambda w, e: Gtk.main_quit()) | |
92 | self.win.present() | |
93 | ||
94 | Gtk.main() | |
95 | ||
96 | def on_animate_progress_clicked(self, button, data=None): | |
97 | self.progress.set_sensitive(False) | |
98 | self.pulse_switch.set_sensitive(False) | |
99 | ||
100 | self._animate_progress = 0 | |
101 | self.win.set_progress(0) | |
102 | ||
103 | GObject.timeout_add(500, self.on_progress_tick) | |
104 | ||
105 | def on_progress_tick(self): | |
106 | self.win.set_progress(self._animate_progress) | |
107 | ||
108 | if self._animate_progress == 100: | |
109 | self.on_animate_complete() | |
110 | return False | |
111 | else: | |
112 | self._animate_progress += 1 | |
113 | return True | |
114 | ||
115 | def on_animate_complete(self): | |
116 | self.progress.set_sensitive(True) | |
117 | self.pulse_switch.set_sensitive(True) | |
118 | self.progress.set_value(100) | |
119 | ||
120 | def on_icon_name_setter_clicked(self, button, data=None): | |
121 | self.win.set_icon_name(self.icon_name_entry.get_text()) | |
122 | ||
123 | def on_icon_path_setter_clicked(self, button, data=None): | |
124 | try: | |
125 | self.win.set_icon_from_file(self.icon_path_entry.get_text()) | |
126 | except GLib.Error as e: | |
127 | print(e.message) | |
128 | ||
129 | def on_progress_value_changed(self, range, data=None): | |
130 | self.win.set_progress(int(self.progress.get_value())) | |
131 | self.pulse_switch.set_active(False) | |
132 | ||
133 | def on_pulse_switch_changed(self, switch, pspec, data=None): | |
134 | self.win.set_progress_pulse(self.pulse_switch.get_active()) | |
135 | ||
136 | if __name__ == "__main__": | |
137 | main = Main() |
0 | GtkWindow cheader_filename="libxapp/xapp-gtk-window.h" | |
1 | MonitorBlanker cheader_filename="libxapp/xapp-monitor-blanker.h" | |
2 | KbdLayoutController cheader_filename="libxapp/xapp-kbd-layout-controller.h" | |
3 | XApp cheader_filename="libxapp/xapp-gtk-window.h"⏎ |