Package list xapp / 134e967
xapp-gtk-window: Add progress features, refactor, add demo script for XAppGtkWindow. New functions allow progress values to be set on a GtkWindow or a descendant. XAppGtkWindow supports it directly, while the wrapper functions can be used on other window types. This requires window manager support for _NET_WM_XAPP_PROGRESS and _NET_WM_XAPP_PROGRESS_PULSE properties on windows. Michael Webster 4 years ago
3 changed file(s) with 478 addition(s) and 143 deletion(s). Raw diff Collapse all Expand all
44 #include <string.h>
55 #include <math.h>
66 #include <X11/Xlib.h>
7 #include <X11/Xatom.h>
78
89 #include <gdk/gdk.h>
910 #include <gdk/gdkx.h>
1011 #include "xapp-gtk-window.h"
1112
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
1217 struct _XAppGtkWindowPrivate
1318 {
14 gchar *icon_name;
15 gchar *icon_path;
16 gboolean need_set_at_realize;
19 gchar *icon_name;
20 gchar *icon_path;
21 guint progress;
22 gboolean progress_pulse;
1723 };
1824
1925 G_DEFINE_TYPE (XAppGtkWindow, xapp_gtk_window, GTK_TYPE_WINDOW);
2026
2127 static void
22 clear_strings (XAppGtkWindow *window)
23 {
24 XAppGtkWindowPrivate *priv = window->priv;
25
28 clear_icon_strings (XAppGtkWindowPrivate *priv)
29 {
2630 g_clear_pointer (&priv->icon_name, g_free);
2731 g_clear_pointer (&priv->icon_path, g_free);
2832 }
2933
3034 static void
31 set_window_hint (GtkWidget *widget,
32 const gchar *str)
35 set_window_hint_utf8 (GtkWidget *widget,
36 const gchar *atom_name,
37 const gchar *str)
3338 {
3439 GdkDisplay *display;
3540 GdkWindow *window;
4853 {
4954 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
5055 GDK_WINDOW_XID (window),
51 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_XAPP_ICON_NAME"),
56 gdk_x11_get_xatom_by_name_for_display (display, atom_name),
5257 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
5358 PropModeReplace, (guchar *) str, strlen (str));
5459 }
5661 {
5762 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
5863 GDK_WINDOW_XID (window),
59 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_XAPP_ICON_NAME"));
60 }
61 }
62
63 static void
64 update_window (XAppGtkWindow *window)
65 {
66 XAppGtkWindowPrivate *priv = window->priv;
67
64 gdk_x11_get_xatom_by_name_for_display (display, atom_name));
65 }
66 }
67
68 static void
69 set_window_hint_cardinal (GtkWidget *widget,
70 const gchar *atom_name,
71 gulong cardinal)
72 {
73 GdkDisplay *display;
74 GdkWindow *window;
75
76 window = gtk_widget_get_window (widget);
77
78 if (gdk_window_get_effective_toplevel (window) != window)
79 {
80 g_warning ("Window is not toplevel");
81 return;
82 }
83
84 display = gdk_window_get_display (window);
85
86 if (cardinal > 0)
87 {
88 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
89 GDK_WINDOW_XID (window),
90 gdk_x11_get_xatom_by_name_for_display (display, atom_name),
91 XA_CARDINAL, 32,
92 PropModeReplace,
93 (guchar *) &cardinal, 1);
94 }
95 else
96 {
97 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
98 GDK_WINDOW_XID (window),
99 gdk_x11_get_xatom_by_name_for_display (display, atom_name));
100 }
101 }
102
103 static void
104 update_window_icon (GtkWindow *window,
105 XAppGtkWindowPrivate *priv)
106 {
107 /* Icon name/path */
68108 if (priv->icon_name != NULL)
69109 {
70 set_window_hint (GTK_WIDGET (window), priv->icon_name);
110 set_window_hint_utf8 (GTK_WIDGET (window), ICON_NAME_HINT, priv->icon_name);
71111 }
72112 else if (priv->icon_path != NULL)
73113 {
74 set_window_hint (GTK_WIDGET (window), priv->icon_path);
114 set_window_hint_utf8 (GTK_WIDGET (window), ICON_NAME_HINT, priv->icon_path);
115 }
116 else
117 {
118 set_window_hint_utf8 (GTK_WIDGET (window), ICON_NAME_HINT, NULL);
119 }
120 }
121
122 static void
123 update_window_progress (GtkWindow *window,
124 XAppGtkWindowPrivate *priv)
125 {
126 /* Progress: 0 - 100 */
127 set_window_hint_cardinal (GTK_WIDGET (window), PROGRESS_HINT, (gulong) priv->progress);
128 set_window_hint_cardinal (GTK_WIDGET (window), PROGRESS_PULSE_HINT, (gulong) (priv->progress_pulse ? 1 : 0));
129 }
130
131 static void
132 set_icon_name_internal (GtkWindow *window,
133 XAppGtkWindowPrivate *priv,
134 const gchar *icon_name)
135 {
136 if (g_strcmp0 (icon_name, priv->icon_name) == 0)
137 {
138 gtk_window_set_icon_name (window, icon_name);
139 return;
140 }
141
142 /* Clear both strings when either is set - this ensures the
143 * correct value is set during update_window() */
144 clear_icon_strings (priv);
145
146 if (icon_name != NULL)
147 {
148 priv->icon_name = g_strdup (icon_name);
149 }
150
151 /* If the window is realized, set the icon name immediately.
152 * If it's not, it will be set by xapp_gtk_window_realize(). */
153 if (gtk_widget_get_realized (GTK_WIDGET (window)))
154 {
155 update_window_icon (window, priv);
156 }
157
158 /* Call the GtkWindow method for compatibility */
159 gtk_window_set_icon_name (GTK_WINDOW (window), icon_name);
160 }
161
162 static void
163 set_icon_from_file_internal (GtkWindow *window,
164 XAppGtkWindowPrivate *priv,
165 const gchar *file_name,
166 GError **error)
167 {
168 if (g_strcmp0 (file_name, priv->icon_path) == 0)
169 {
170 gtk_window_set_icon_from_file (window, file_name, error);
171 return;
172 }
173
174 /* Clear both strings when either is set - this ensures the correct
175 * value is set during update_window() */
176 clear_icon_strings (priv);
177
178 if (file_name != NULL)
179 {
180 priv->icon_path = g_strdup (file_name);
181 }
182
183 /* If the window is realized, set the icon path immediately.
184 * If it's not, it will be set by xapp_gtk_window_realize(). */
185 if (gtk_widget_get_realized (GTK_WIDGET (window)))
186 {
187 update_window_icon (window, priv);
188 }
189
190 gtk_window_set_icon_from_file (GTK_WINDOW (window), file_name, error);
191 }
192
193 static void
194 set_progress_internal (GtkWindow *window,
195 XAppGtkWindowPrivate *priv,
196 gint progress)
197 {
198 gboolean update;
199 guint clamped_progress;
200
201 update = FALSE;
202
203 if (priv->progress_pulse)
204 {
205 priv->progress_pulse = FALSE;
206 update = TRUE;
207 }
208
209 clamped_progress = CLAMP (progress, 0, 100);
210
211 if (clamped_progress != priv->progress)
212 {
213 priv->progress = clamped_progress;
214 update = TRUE;
215 }
216
217 /* If the window is realized, set the progress immediately.
218 * If it's not, it will be set by xapp_gtk_window_realize(). */
219 if (gtk_widget_get_realized (GTK_WIDGET (window)))
220 {
221 if (update)
222 {
223 update_window_progress (window, priv);
224 }
225 }
226 }
227
228 static void
229 set_progress_pulse_internal (GtkWindow *window,
230 XAppGtkWindowPrivate *priv,
231 gboolean pulse)
232 {
233 gboolean update;
234
235 update = FALSE;
236
237 if (priv->progress_pulse != pulse)
238 {
239 priv->progress_pulse = pulse;
240
241 update = TRUE;
242 }
243
244 /* If the window is realized, set the progress immediately.
245 * If it's not, it will be set by xapp_gtk_window_realize(). */
246 if (gtk_widget_get_realized (GTK_WIDGET (window)))
247 {
248 if (update)
249 {
250 update_window_progress (window, priv);
251 }
75252 }
76253 }
77254
83260
84261 GTK_WIDGET_CLASS (xapp_gtk_window_parent_class)->realize (widget);
85262
86 if (priv->need_set_at_realize)
87 {
88 update_window (window);
89 priv->need_set_at_realize = FALSE;
90 }
263 update_window_icon (GTK_WINDOW (window), priv);
264 update_window_progress (GTK_WINDOW (window), priv);
91265 }
92266
93267 static void
94268 xapp_gtk_window_unrealize (GtkWidget *widget)
95269 {
96270 XAppGtkWindow *window = XAPP_GTK_WINDOW (widget);
97 XAppGtkWindowPrivate *priv = window->priv;
98271
99272 GTK_WIDGET_CLASS (xapp_gtk_window_parent_class)->unrealize (widget);
100
101 if (priv->icon_name != NULL || priv->icon_path != NULL)
102 {
103 priv->need_set_at_realize = TRUE;
104 }
105273 }
106274
107275 static void
110278 XAppGtkWindow *window = XAPP_GTK_WINDOW (object);
111279 XAppGtkWindowPrivate *priv = window->priv;
112280
113 g_clear_pointer (&priv->icon_name, g_free);
114 g_clear_pointer (&priv->icon_path, g_free);
281 clear_icon_strings (priv);
115282
116283 G_OBJECT_CLASS (xapp_gtk_window_parent_class)->finalize (object);
117284 }
127294
128295 priv->icon_name = NULL;
129296 priv->icon_path = NULL;
130 priv->need_set_at_realize = FALSE;
131297 }
132298
133299 static void
151317
152318 /**
153319 * xapp_gtk_window_set_icon_name:
154 * @window: The #GtkWindow to set the icon name for
320 * @window: The #XAppGtkWindow to set the icon name for
155321 * @icon_name: (nullable): The icon name or path to set, or %NULL to unset.
156322 *
157323 * Sets the icon name hint for a window manager (like muffin) to make
166332 {
167333 g_return_if_fail (XAPP_IS_GTK_WINDOW (window));
168334
169 clear_strings (window);
170
171 if (icon_name != NULL)
172 {
173 window->priv->icon_name = g_strdup (icon_name);
174 }
175
176 /* If the window is realized, set the icon name immediately */
177 if (gtk_widget_get_realized (GTK_WIDGET (window)))
178 {
179 update_window (window);
180 }
181 /* Otherwise, remind ourselves to do it in our realize vfunc */
182 else
183 {
184 window->priv->need_set_at_realize = TRUE;
185 }
186
187 /* Call the GtkWindow method for compatibility */
188 gtk_window_set_icon_name (GTK_WINDOW (window), icon_name);
189 }
190
335 set_icon_name_internal (GTK_WINDOW (window), window->priv, icon_name);
336 }
191337
192338 /**
193339 * xapp_gtk_window_set_icon_from_file:
208354 {
209355 g_return_if_fail (XAPP_IS_GTK_WINDOW (window));
210356
211 clear_strings (window);
212
213 if (file_name != NULL)
214 {
215 window->priv->icon_path = g_strdup (file_name);
216 }
217
218 /* If the window is realized, set the icon path immediately */
219 if (gtk_widget_get_realized (GTK_WIDGET (window)))
220 {
221 update_window (window);
222 }
223 /* Otherwise, remind ourselves to do it later */
224 else
225 {
226 window->priv->need_set_at_realize = TRUE;
227 }
228
229 gtk_window_set_icon_from_file (GTK_WINDOW (window), file_name, error);
230 }
357 set_icon_from_file_internal (GTK_WINDOW (window), window->priv, file_name, error);
358 }
359
360 /**
361 * xapp_gtk_window_set_progress:
362 * @window: The #XAppGtkWindow to set the progress for
363 * @progress: The value to set for progress.
364 *
365 * Sets the progress hint for a window manager (like muffin) to make
366 * available when applications want to display the application's progress
367 * in some operation. The value sent to the WM will be clamped to
368 * between 0 and 100.
369 *
370 * Setting progress will also cancel the 'pulsing' flag on the window as
371 * well, if it has been set.
372 */
373 void
374 xapp_gtk_window_set_progress (XAppGtkWindow *window,
375 gint progress)
376 {
377 g_return_if_fail (XAPP_IS_GTK_WINDOW (window));
378
379 set_progress_internal (GTK_WINDOW (window), window->priv, progress);
380 }
381
382 /**
383 * xapp_gtk_window_set_progress_pulse:
384 * @window: The #XAppGtkWindow to set the progress for
385 * @pulse: Whether to have pulsing set or not.
386 *
387 * Sets the progress pulse hint hint for a window manager (like muffin)
388 * to make available when applications want to display indeterminate or
389 * ongoing progress in a task manager.
390 *
391 * Setting an explicit progress value will unset this flag.
392 */
393 void
394 xapp_gtk_window_set_progress_pulse (XAppGtkWindow *window,
395 gboolean pulse)
396 {
397 g_return_if_fail (XAPP_IS_GTK_WINDOW (window));
398 g_return_if_fail (XAPP_IS_GTK_WINDOW (window));
399
400 set_progress_pulse_internal (GTK_WINDOW (window), window->priv, pulse);
401 }
402
231403
232404 /* Wrappers (for GtkWindow subclasses like GtkDialog)
233405 * window must be a GtkWindow or descendant */
234
235406 static void
236407 on_gtk_window_realized (GtkWidget *widget,
237408 gpointer user_data)
238409 {
239 gchar *int_string;
240
241 g_return_if_fail (GTK_IS_WIDGET (widget));
242
243 int_string = (gchar *) user_data;
244
245 g_signal_handlers_disconnect_by_func (widget, on_gtk_window_realized, int_string);
246 g_object_weak_unref (G_OBJECT (widget), (GWeakNotify) g_free, int_string);
247
248 set_window_hint (widget, int_string);
249
250 g_free (int_string);
410 XAppGtkWindowPrivate *priv;
411
412 priv = (XAppGtkWindowPrivate *) user_data;
413
414 update_window_icon (GTK_WINDOW (widget), priv);
415 update_window_progress (GTK_WINDOW (widget), priv);
416 }
417
418 static void
419 destroy_xapp_struct (gpointer user_data)
420 {
421 XAppGtkWindowPrivate *priv = (XAppGtkWindowPrivate *) user_data;
422
423 g_clear_pointer (&priv->icon_name, g_free);
424 g_clear_pointer (&priv->icon_path, g_free);
425
426 g_slice_free (XAppGtkWindowPrivate, priv);
427 }
428
429 static XAppGtkWindowPrivate *
430 get_xapp_struct (GtkWindow *window)
431 {
432 XAppGtkWindowPrivate *priv;
433
434 priv = g_object_get_data (G_OBJECT (window),
435 "xapp-window-struct");
436
437 if (priv)
438 {
439 return priv;
440 }
441
442 priv = g_slice_new0 (XAppGtkWindowPrivate);
443
444 g_object_set_data_full (G_OBJECT (window),
445 "xapp-window-struct",
446 priv,
447 (GDestroyNotify) destroy_xapp_struct);
448
449 g_signal_connect_after (GTK_WIDGET (window),
450 "realize",
451 G_CALLBACK (on_gtk_window_realized),
452 priv);
453
454 return priv;
251455 }
252456
253457 /**
268472 xapp_set_window_icon_name (GtkWindow *window,
269473 const gchar *icon_name)
270474 {
475 XAppGtkWindowPrivate *priv;
476
271477 g_return_if_fail (GTK_IS_WINDOW (window));
272478
479 priv = get_xapp_struct (window);
480
273481 if (XAPP_IS_GTK_WINDOW (window))
274482 {
275483 g_warning("Window is an instance of XAppGtkWindow. Use the instance set_icon_name method instead.");
276484 }
277485
278 /* If the window is realized, set the icon name immediately */
279 if (gtk_widget_get_realized (GTK_WIDGET (window)))
280 {
281 set_window_hint (GTK_WIDGET (window), icon_name);
282 }
283 /* Otherwise, hang a callback on window's realize signal and do it then */
284 else
285 {
286 gchar *int_string;
287
288 int_string = g_strdup (icon_name);
289
290 g_signal_connect_after (GTK_WIDGET (window),
291 "realize",
292 G_CALLBACK (on_gtk_window_realized),
293 int_string);
294
295 /* Insurance, in case window gets destroyed without ever being realized */
296 g_object_weak_ref (G_OBJECT (window),
297 (GWeakNotify) g_free,
298 int_string);
299 }
300
301 /* Call the GtkWindow method for compatibility */
302 gtk_window_set_icon_name (GTK_WINDOW (window), icon_name);
486 set_icon_name_internal (window, priv, icon_name);
303487 }
304488
305489
320504 const gchar *file_name,
321505 GError **error)
322506 {
507 XAppGtkWindowPrivate *priv;
508
323509 g_return_if_fail (GTK_IS_WINDOW (window));
324510
511 priv = get_xapp_struct (window);
512
325513 if (XAPP_IS_GTK_WINDOW (window))
326514 {
327515 g_warning("Window is an instance of XAppGtkWindow. Use the instance set_icon_from_file method instead.");
328516 }
329517
330 /* If the window is realized, set the icon name immediately */
331 if (gtk_widget_get_realized (GTK_WIDGET (window)))
332 {
333 set_window_hint (GTK_WIDGET (window), file_name);
334 }
335 /* Otherwise, hang a callback on window's realize signal and do it then */
336 else
337 {
338 gchar *int_string;
339
340 int_string = g_strdup (file_name);
341
342 g_signal_connect_after (GTK_WIDGET (window),
343 "realize",
344 G_CALLBACK (on_gtk_window_realized),
345 int_string);
346
347 /* Insurance, in case window gets destroyed without ever being realized */
348 g_object_weak_ref (G_OBJECT (window),
349 (GWeakNotify) g_free,
350 int_string);
351 }
352
353 /* Call the GtkWindow method for compatibility */
354 gtk_window_set_icon_from_file (GTK_WINDOW (window), file_name, error);
355 }
518 set_icon_from_file_internal (window, priv, file_name, error);
519 }
520
521 /**
522 * xapp_set_window_progress:
523 * @window: The #GtkWindow to set the progress for
524 * @progress: The value to set for progress.
525 *
526 * Sets the progress hint for a window manager (like muffin) to make
527 * available when applications want to display the application's progress
528 * in some operation. The value sent to the WM will be clamped to
529 * between 0 and 100.
530 *
531 * Setting progress will also cancel the 'pulsing' flag on the window as
532 * well, if it has been set.
533 */
534 void
535 xapp_set_window_progress (GtkWindow *window,
536 gint progress)
537 {
538 XAppGtkWindowPrivate *priv;
539
540 g_return_if_fail (GTK_IS_WINDOW (window));
541
542 priv = get_xapp_struct (window);
543
544 if (XAPP_IS_GTK_WINDOW (window))
545 {
546 g_warning("Window is an instance of XAppGtkWindow. Use the instance set_progress method instead.");
547 }
548
549 set_progress_internal (window, priv, progress);
550 }
551
552 /**
553 * xapp_set_window_progress_pulse:
554 * @window: The #GtkWindow to set the progress for
555 * @pulse: Whether to have pulsing set or not.
556 *
557 * Sets the progress pulse hint hint for a window manager (like muffin)
558 * to make available when applications want to display indeterminate or
559 * ongoing progress in a task manager.
560 *
561 * Setting an explicit progress value will unset this flag.
562 */
563 void
564 xapp_set_window_progress_pulse (GtkWindow *window,
565 gboolean pulse)
566 {
567 XAppGtkWindowPrivate *priv;
568
569 g_return_if_fail (GTK_IS_WINDOW (window));
570
571 priv = get_xapp_struct (window);
572
573 if (XAPP_IS_GTK_WINDOW (window))
574 {
575 g_warning("Window is an instance of XAppGtkWindow. Use the instance set_progress_pulse method instead.");
576 }
577
578 set_progress_pulse_internal (GTK_WINDOW (window), priv, pulse);
579 }
4040 void xapp_gtk_window_set_icon_from_file (XAppGtkWindow *window,
4141 const gchar *file_name,
4242 GError **error);
43
43 void xapp_gtk_window_set_progress (XAppGtkWindow *window,
44 gint progress);
45 void xapp_gtk_window_set_progress_pulse (XAppGtkWindow *window,
46 gboolean pulse);
4447 /* Wrappers (for GtkWindow subclasses like GtkDialog)*/
4548
4649 void xapp_set_window_icon_name (GtkWindow *window,
4952 void xapp_set_window_icon_from_file (GtkWindow *window,
5053 const gchar *file_name,
5154 GError **error);
55 void xapp_set_window_progress (GtkWindow *window,
56 gint progress);
57 void xapp_set_window_progress_pulse (GtkWindow *window,
58 gboolean pulse);
5259
5360 G_END_DECLS
5461
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
9 import gi
10 gi.require_version('Gtk', '3.0')
11 gi.require_version('XApp', '1.0')
12
13 from gi.repository import GLib, Gtk, XApp, GObject
14
15 signal.signal(signal.SIGINT, signal.SIG_DFL)
16
17 class Main:
18 def __init__(self):
19 self.win = XApp.GtkWindow()
20
21 self.win.set_default_size(320, 200)
22
23 frame = Gtk.Frame()
24 frame.set_margin_start(2)
25 frame.set_margin_end(2)
26 frame.set_margin_top(2)
27 frame.set_margin_bottom(2)
28
29 self.win.add(frame)
30
31 box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
32 box.set_margin_start(2)
33 box.set_margin_end(2)
34 box.set_margin_top(2)
35 box.set_margin_bottom(2)
36
37 frame.add(box)
38
39 heading = Gtk.Label()
40 heading.set_markup("Use '<span font_family='mono' weight='bold'>xprop -spy</span>' to monitor changes")
41 box.pack_start(heading, True, True, 4)
42
43 hbox = Gtk.HBox()
44 self.icon_name_entry = Gtk.Entry()
45 self.icon_name_setter = Gtk.Button("Set icon name")
46 self.icon_name_setter.connect("clicked", self.on_icon_name_setter_clicked)
47 hbox.pack_start(self.icon_name_entry, True, True, 4)
48 hbox.pack_start(self.icon_name_setter, False, False, 4)
49 box.pack_start(hbox, True, True, 4)
50
51 hbox = Gtk.HBox()
52 self.icon_path_entry = Gtk.Entry()
53 self.icon_path_setter = Gtk.Button("Set icon path")
54 self.icon_path_setter.connect("clicked", self.on_icon_path_setter_clicked)
55 hbox.pack_start(self.icon_path_entry, True, True, 4)
56 hbox.pack_start(self.icon_path_setter, False, False, 4)
57 box.pack_start(hbox, True, True, 4)
58
59 hbox = Gtk.HBox()
60 self.progress_label = Gtk.Label("Progress:")
61 self.progress = Gtk.Scale()
62 self.progress.connect("value-changed", self.on_progress_value_changed)
63 self.progress.set_draw_value(True)
64 self.progress.set_digits(0)
65 self.progress.set_range(0, 100)
66
67 hbox.pack_start(self.progress_label, False, False, 4)
68 hbox.pack_start(self.progress, True, True, 4)
69 box.pack_start(hbox, True, True, 4)
70
71 hbox = Gtk.HBox()
72 self.pulse_label = Gtk.Label("Progress pulse:")
73 self.pulse_switch = Gtk.Switch()
74 self.pulse_switch.set_halign(Gtk.Align.CENTER)
75 self.pulse_switch.connect("notify::active", self.on_pulse_switch_changed)
76 hbox.pack_start(self.pulse_label, False, False, 4)
77 hbox.pack_start(self.pulse_switch, True, True, 4)
78 box.pack_start(hbox, True, True, 4)
79
80 frame.show_all()
81 self.win.connect("delete-event", lambda w, e: Gtk.main_quit())
82 self.win.present()
83
84 Gtk.main()
85
86 def on_icon_name_setter_clicked(self, button, data=None):
87 self.win.set_icon_name(self.icon_name_entry.get_text())
88
89 def on_icon_path_setter_clicked(self, button, data=None):
90 try:
91 self.win.set_icon_from_file(self.icon_path_entry.get_text())
92 except GLib.Error as e:
93 print(e.message)
94
95 def on_progress_value_changed(self, range, data=None):
96 self.win.set_progress(int(self.progress.get_value()))
97 self.pulse_switch.set_active(False)
98
99 def on_pulse_switch_changed(self, switch, pspec, data=None):
100 self.win.set_progress_pulse(self.pulse_switch.get_active())
101
102 if __name__ == "__main__":
103 main = Main()