summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-05-27 15:11:48 +0200
committerraveit65 <[email protected]>2020-06-25 09:43:50 +0200
commitaee2a8abdb50314e3e32f7bc7385172b0729a1a1 (patch)
tree18e9390aff0bc08464711db1e37305c544f02faf
parent1fe528777a3eca5ce3baaa08a8b4a2eb9e8d6003 (diff)
downloadmate-applets-aee2a8abdb50314e3e32f7bc7385172b0729a1a1.tar.bz2
mate-applets-aee2a8abdb50314e3e32f7bc7385172b0729a1a1.tar.xz
timerapplet: Add timerapplet-preferences.ui
-rw-r--r--po/POTFILES.in1
-rw-r--r--timerapplet/Makefile.am42
-rw-r--r--timerapplet/timerapplet-preferences.ui235
-rw-r--r--timerapplet/timerapplet-resources.gresource.xml6
-rw-r--r--timerapplet/timerapplet.c98
5 files changed, 307 insertions, 75 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0195c0f3..a5fe9f59 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -67,6 +67,7 @@ stickynotes/stickynotes_callbacks.c
timerapplet/org.mate.applets.TimerApplet.mate-panel-applet.desktop.in.in
timerapplet/org.mate.panel.applet.timer.gschema.xml.in
timerapplet/timerapplet.c
+timerapplet/timerapplet-preferences.ui
trashapplet/org.mate.applets.TrashApplet.mate-panel-applet.desktop.in.in
trashapplet/src/trashapplet.c
trashapplet/src/trash-empty.c
diff --git a/timerapplet/Makefile.am b/timerapplet/Makefile.am
index 7a69c74a..520c9553 100644
--- a/timerapplet/Makefile.am
+++ b/timerapplet/Makefile.am
@@ -1,3 +1,5 @@
+NULL =
+
AM_CPPFLAGS = \
$(MATE_APPLETS4_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
@@ -7,10 +9,26 @@ AM_CPPFLAGS = \
APPLET_LOCATION = $(libexecdir)/timer-applet
libexec_PROGRAMS = timer-applet
-timer_applet_SOURCES = timerapplet.c
-timer_applet_LDADD = $(MATE_APPLETS4_LIBS) $(LIBNOTIFY_LIBS)
+
+BUILT_SOURCES = timerapplet-resources.c timerapplet-resources.h
+nodist_timer_applet_SOURCES = $(BUILT_SOURCES)
+timer_applet_SOURCES = \
+ timerapplet.c \
+ $(NULL)
+
+timer_applet_LDADD = \
+ $(MATE_APPLETS4_LIBS) \
+ $(LIBNOTIFY_LIBS) \
+ $(NULL)
+
timer_applet_CFLAGS = $(WARN_CFLAGS)
+timerapplet-resources.c: timerapplet-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/timerapplet-resources.gresource.xml)
+ $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name timerapplet $<
+
+timerapplet-resources.h: timerapplet-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/timerapplet-resources.gresource.xml)
+ $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name timerapplet $<
+
appletsdir = $(datadir)/mate-panel/applets
applets_in_files = org.mate.applets.TimerApplet.mate-panel-applet.desktop.in
applets_DATA = $(applets_in_files:.mate-panel-applet.desktop.in=.mate-panel-applet)
@@ -35,11 +53,21 @@ timer_gschema_in_files = org.mate.panel.applet.timer.gschema.xml.in
gsettings_SCHEMAS = $(timer_gschema_in_files:.xml.in=.xml)
@GSETTINGS_RULES@
-EXTRA_DIST = \
- $(applets_in_files).in \
- $(service_in_files) \
- $(timer_gschema_in_files)
+EXTRA_DIST = \
+ $(applets_in_files).in \
+ $(service_in_files) \
+ $(timer_gschema_in_files) \
+ timerapplet-preferences.ui \
+ timerapplet-resources.gresource.xml \
+ $(NULL)
-CLEANFILES = $(applets_DATA) $(applets_in_files) $(service_DATA) $(gsettings_SCHEMAS) *.gschema.valid
+CLEANFILES = \
+ $(BUILT_SOURCES) \
+ $(applets_DATA) \
+ $(applets_in_files) \
+ $(service_DATA) \
+ $(gsettings_SCHEMAS) \
+ *.gschema.valid \
+ $(NULL)
-include $(top_srcdir)/git.mk
diff --git a/timerapplet/timerapplet-preferences.ui b/timerapplet/timerapplet-preferences.ui
new file mode 100644
index 00000000..04e13e7d
--- /dev/null
+++ b/timerapplet/timerapplet-preferences.ui
@@ -0,0 +1,235 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.36.0 -->
+<interface>
+ <requires lib="gtk+" version="3.22"/>
+ <object class="GtkAdjustment" id="hours_adjustment">
+ <property name="upper">23</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">window-close</property>
+ </object>
+ <object class="GtkAdjustment" id="minutes_adjustment">
+ <property name="upper">59</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="seconds_adjustment">
+ <property name="upper">59</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkDialog" id="preferences_dialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">12</property>
+ <property name="title" translatable="yes">Timer Applet Preferences</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button1">
+ <property name="label" translatable="yes">_Close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">image1</property>
+ <property name="use_underline">True</property>
+ <property name="always_show_image">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">_Name:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">name_entry</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">_Hours:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">hours_spinbutton</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">_Minutes:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">minutes_spinbutton</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">_Seconds:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">seconds_spinbutton</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="name_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="hours_spinbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="adjustment">hours_adjustment</property>
+ <signal name="value-changed" handler="on_hours_spinbutton_value_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="minutes_spinbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="adjustment">minutes_adjustment</property>
+ <signal name="value-changed" handler="on_minutes_spinbutton_value_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="seconds_spinbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="adjustment">seconds_adjustment</property>
+ <signal name="value-changed" handler="on_seconds_spinbutton_value_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="show_notification_popup_check">
+ <property name="label" translatable="yes">Show notification _popup</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="show_dialog_check">
+ <property name="label" translatable="yes">Show _dialog</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-6">button1</action-widget>
+ </action-widgets>
+ <child type="titlebar">
+ <placeholder/>
+ </child>
+ </object>
+</interface>
diff --git a/timerapplet/timerapplet-resources.gresource.xml b/timerapplet/timerapplet-resources.gresource.xml
new file mode 100644
index 00000000..71b7915a
--- /dev/null
+++ b/timerapplet/timerapplet-resources.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/mate/mate-applets/timerapplet">
+ <file compressed="true">timerapplet-preferences.ui</file>
+ </gresource>
+</gresources>
diff --git a/timerapplet/timerapplet.c b/timerapplet/timerapplet.c
index 3dd2abf5..bf862e33 100644
--- a/timerapplet/timerapplet.c
+++ b/timerapplet/timerapplet.c
@@ -45,6 +45,10 @@
#define SHOW_NOTIFICATION_KEY "show-notification"
#define SHOW_DIALOG_KEY "show-dialog"
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (builder, (x))))
+#define GET_DIALOG(x) (GTK_DIALOG (gtk_builder_get_object (builder, (x))))
+#define GET_SPIN_BUTTON(x) (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, (x))))
+
typedef struct
{
MatePanelApplet *applet;
@@ -286,7 +290,7 @@ timer_spin_button_value_changed (GtkSpinButton *spinbutton, TimerApplet *applet)
{
gint duration = 0;
- duration += gtk_spin_button_get_value (applet->hours) * 60 * 60;
+ duration += gtk_spin_button_get_value (applet->hours) * 3600;
duration += gtk_spin_button_get_value (applet->minutes) * 60;
duration += gtk_spin_button_get_value (applet->seconds);
@@ -297,83 +301,41 @@ timer_spin_button_value_changed (GtkSpinButton *spinbutton, TimerApplet *applet)
static void
timer_preferences_callback (GtkAction *action, TimerApplet *applet)
{
+ GtkBuilder *builder;
GtkDialog *dialog;
- GtkGrid *grid;
- GtkWidget *widget;
gint duration, hours, minutes, seconds;
+ builder = gtk_builder_new_from_resource ("/org/mate/mate-applets/timerapplet/timerapplet-preferences.ui");
+
+ dialog = GET_DIALOG ("preferences_dialog");
+ applet->hours = GET_SPIN_BUTTON ("hours_spinbutton");
+ applet->minutes = GET_SPIN_BUTTON ("minutes_spinbutton");
+ applet->seconds = GET_SPIN_BUTTON ("seconds_spinbutton");
+
duration = g_settings_get_int (applet->settings, DURATION_KEY);
hours = duration / 60 / 60;
minutes = duration / 60 % 60;
seconds = duration % 60;
- dialog = GTK_DIALOG (gtk_dialog_new_with_buttons(_("Timer Applet Preferences"),
- NULL,
- GTK_DIALOG_MODAL,
- "gtk-close",
- GTK_RESPONSE_CLOSE,
- NULL));
- grid = GTK_GRID (gtk_grid_new ());
- gtk_grid_set_row_spacing (grid, 12);
- gtk_grid_set_column_spacing (grid, 12);
-
- gtk_window_set_default_size (GTK_WINDOW (dialog), 350, 150);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 10);
-
- widget = gtk_label_new (_("Name:"));
- gtk_label_set_xalign (GTK_LABEL (widget), 1.0);
- gtk_label_set_yalign (GTK_LABEL (widget), 0.5);
- gtk_grid_attach (grid, widget, 1, 0, 1, 1);
-
- widget = gtk_entry_new ();
- gtk_grid_attach (grid, widget, 2, 0, 1, 1);
- g_settings_bind (applet->settings, NAME_KEY, widget, "text", G_SETTINGS_BIND_DEFAULT);
-
- widget = gtk_label_new (_("Hours:"));
- gtk_label_set_xalign (GTK_LABEL (widget), 1.0);
- gtk_label_set_yalign (GTK_LABEL (widget), 0.5);
- gtk_grid_attach (grid, widget, 1, 1, 1, 1);
-
- widget = gtk_spin_button_new_with_range (0.0, 100.0, 1.0);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), hours);
- gtk_grid_attach (grid, widget, 2, 1, 1, 1);
- applet->hours = GTK_SPIN_BUTTON (widget);
- g_signal_connect (widget, "value-changed", G_CALLBACK (timer_spin_button_value_changed), applet);
-
- widget = gtk_label_new (_("Minutes:"));
- gtk_label_set_xalign (GTK_LABEL (widget), 1.0);
- gtk_label_set_yalign (GTK_LABEL (widget), 0.5);
- gtk_grid_attach (grid, widget, 1, 2, 1, 1);
-
- widget = gtk_spin_button_new_with_range (0.0, 59.0, 1.0);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), minutes);
- gtk_grid_attach (grid, widget, 2, 2, 1, 1);;
- applet->minutes = GTK_SPIN_BUTTON (widget);
- g_signal_connect (widget, "value-changed", G_CALLBACK (timer_spin_button_value_changed), applet);
-
- widget = gtk_label_new (_("Seconds:"));
- gtk_label_set_xalign (GTK_LABEL (widget), 1.0);
- gtk_label_set_yalign (GTK_LABEL (widget), 0.5);
- gtk_grid_attach (grid, widget, 1, 3, 1, 1);
-
- widget = gtk_spin_button_new_with_range (0.0, 59.0, 1.0);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), seconds);
- gtk_grid_attach (grid, widget, 2, 3, 1, 1);
- applet->seconds = GTK_SPIN_BUTTON (widget);
- g_signal_connect (widget, "value-changed", G_CALLBACK (timer_spin_button_value_changed), applet);
-
- widget = gtk_check_button_new_with_label (_("Show notification popup"));
- gtk_grid_attach (grid, widget, 2, 4, 1, 1);
- g_settings_bind (applet->settings, SHOW_NOTIFICATION_KEY, widget, "active", G_SETTINGS_BIND_DEFAULT);
-
- widget = gtk_check_button_new_with_label (_("Show dialog"));
- gtk_grid_attach (grid, widget, 2, 5, 1, 1);
- g_settings_bind (applet->settings, SHOW_DIALOG_KEY, widget, "active", G_SETTINGS_BIND_DEFAULT);
-
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (dialog)), GTK_WIDGET (grid), TRUE, TRUE, 0);
-
+ gtk_spin_button_set_value (applet->hours, hours);
+ gtk_spin_button_set_value (applet->minutes, minutes);
+ gtk_spin_button_set_value (applet->seconds, seconds);
+
+ g_settings_bind (applet->settings, NAME_KEY, GET_WIDGET ("name_entry"), "text", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (applet->settings, SHOW_NOTIFICATION_KEY, GET_WIDGET ("show_notification_popup_check"), "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (applet->settings, SHOW_DIALOG_KEY, GET_WIDGET ("show_dialog_check"), "active", G_SETTINGS_BIND_DEFAULT);
+
+ /* signals */
+ gtk_builder_add_callback_symbols (builder,
+ "on_hours_spinbutton_value_changed", G_CALLBACK (timer_spin_button_value_changed),
+ "on_minutes_spinbutton_value_changed", G_CALLBACK (timer_spin_button_value_changed),
+ "on_seconds_spinbutton_value_changed", G_CALLBACK (timer_spin_button_value_changed),
+ NULL);
+ gtk_builder_connect_signals (builder, applet);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
+ g_object_unref (builder);
+
gtk_widget_show_all (GTK_WIDGET (dialog));
}