From f61476bf3632cd9af624a1832476cadc89b64411 Mon Sep 17 00:00:00 2001 From: rbuj Date: Sat, 29 Aug 2020 11:28:43 +0200 Subject: timerapplet: Use common subdirs - src, data --- configure.ac | 4 +- po/POTFILES.in | 8 +- timerapplet/Makefile.am | 72 +--- timerapplet/data/Makefile.am | 45 +++ ...ets.TimerApplet.mate-panel-applet.desktop.in.in | 11 + ...mate.panel.applet.TimerAppletFactory.service.in | 3 + .../org.mate.panel.applet.timer.gschema.xml.in | 20 + timerapplet/data/timerapplet-preferences.ui | 235 +++++++++++ .../data/timerapplet-resources.gresource.xml | 6 + ...ets.TimerApplet.mate-panel-applet.desktop.in.in | 11 - ...mate.panel.applet.TimerAppletFactory.service.in | 3 - .../org.mate.panel.applet.timer.gschema.xml.in | 20 - timerapplet/src/Makefile.am | 35 ++ timerapplet/src/timerapplet.c | 444 +++++++++++++++++++++ timerapplet/timerapplet-preferences.ui | 235 ----------- timerapplet/timerapplet-resources.gresource.xml | 6 - timerapplet/timerapplet.c | 444 --------------------- 17 files changed, 807 insertions(+), 795 deletions(-) create mode 100644 timerapplet/data/Makefile.am create mode 100644 timerapplet/data/org.mate.applets.TimerApplet.mate-panel-applet.desktop.in.in create mode 100644 timerapplet/data/org.mate.panel.applet.TimerAppletFactory.service.in create mode 100644 timerapplet/data/org.mate.panel.applet.timer.gschema.xml.in create mode 100644 timerapplet/data/timerapplet-preferences.ui create mode 100644 timerapplet/data/timerapplet-resources.gresource.xml delete mode 100644 timerapplet/org.mate.applets.TimerApplet.mate-panel-applet.desktop.in.in delete mode 100644 timerapplet/org.mate.panel.applet.TimerAppletFactory.service.in delete mode 100644 timerapplet/org.mate.panel.applet.timer.gschema.xml.in create mode 100644 timerapplet/src/Makefile.am create mode 100644 timerapplet/src/timerapplet.c delete mode 100644 timerapplet/timerapplet-preferences.ui delete mode 100644 timerapplet/timerapplet-resources.gresource.xml delete mode 100644 timerapplet/timerapplet.c diff --git a/configure.ac b/configure.ac index 04965bf7..ba388a3f 100644 --- a/configure.ac +++ b/configure.ac @@ -602,7 +602,9 @@ cpufreq/src/cpufreq-selector/Makefile cpufreq/pixmaps/Makefile cpufreq/help/Makefile timerapplet/Makefile -timerapplet/org.mate.panel.applet.timer.gschema.xml +timerapplet/data/Makefile +timerapplet/data/org.mate.panel.applet.timer.gschema.xml +timerapplet/src/Makefile command/Makefile command/data/Makefile command/data/org.mate.panel.applet.command.gschema.xml diff --git a/po/POTFILES.in b/po/POTFILES.in index 26050786..191e1898 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -68,10 +68,10 @@ stickynotes/org.mate.stickynotes.gschema.xml.in stickynotes/stickynotes_applet.c stickynotes/stickynotes_applet_callbacks.c 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 +timerapplet/data/org.mate.applets.TimerApplet.mate-panel-applet.desktop.in.in +timerapplet/data/org.mate.panel.applet.timer.gschema.xml.in +timerapplet/data/timerapplet-preferences.ui +timerapplet/src/timerapplet.c 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 520c9553..5d55ad08 100644 --- a/timerapplet/Makefile.am +++ b/timerapplet/Makefile.am @@ -1,73 +1,3 @@ -NULL = - -AM_CPPFLAGS = \ - $(MATE_APPLETS4_CFLAGS) \ - $(LIBNOTIFY_CFLAGS) \ - -I$(srcdir) \ - $(DISABLE_DEPRECATED_CFLAGS) - -APPLET_LOCATION = $(libexecdir)/timer-applet - -libexec_PROGRAMS = timer-applet - -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) - -$(applets_in_files): $(applets_in_files).in Makefile - $(AM_V_GEN)sed \ - -e "s|\@LOCATION\@|$(APPLET_LOCATION)|" \ - $< > $@ -$(applets_DATA): $(applets_in_files) Makefile - $(AM_V_GEN) $(MSGFMT) --desktop --keyword=Name --keyword=Description --template $< -d $(top_srcdir)/po -o $@ - -servicedir = $(datadir)/dbus-1/services -service_in_files = org.mate.panel.applet.TimerAppletFactory.service.in -service_DATA = $(service_in_files:.service.in=.service) - -org.mate.panel.applet.TimerAppletFactory.service: $(service_in_files) - $(AM_V_GEN)sed \ - -e "s|\@LOCATION\@|$(APPLET_LOCATION)|" \ - $< > $@ - -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) \ - timerapplet-preferences.ui \ - timerapplet-resources.gresource.xml \ - $(NULL) - -CLEANFILES = \ - $(BUILT_SOURCES) \ - $(applets_DATA) \ - $(applets_in_files) \ - $(service_DATA) \ - $(gsettings_SCHEMAS) \ - *.gschema.valid \ - $(NULL) +SUBDIRS = data src -include $(top_srcdir)/git.mk diff --git a/timerapplet/data/Makefile.am b/timerapplet/data/Makefile.am new file mode 100644 index 00000000..2c034da3 --- /dev/null +++ b/timerapplet/data/Makefile.am @@ -0,0 +1,45 @@ +NULL = + +APPLET_LOCATION = $(libexecdir)/timer-applet + +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) + +$(applets_in_files): $(applets_in_files).in Makefile + $(AM_V_GEN)sed \ + -e "s|\@LOCATION\@|$(APPLET_LOCATION)|" \ + $< > $@ +$(applets_DATA): $(applets_in_files) Makefile + $(AM_V_GEN) $(MSGFMT) --desktop --keyword=Name --keyword=Description --template $< -d $(top_srcdir)/po -o $@ + +servicedir = $(datadir)/dbus-1/services +service_in_files = org.mate.panel.applet.TimerAppletFactory.service.in +service_DATA = $(service_in_files:.service.in=.service) + +org.mate.panel.applet.TimerAppletFactory.service: $(service_in_files) + $(AM_V_GEN)sed \ + -e "s|\@LOCATION\@|$(APPLET_LOCATION)|" \ + $< > $@ + +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) \ + timerapplet-preferences.ui \ + timerapplet-resources.gresource.xml \ + $(NULL) + +CLEANFILES = \ + $(applets_DATA) \ + $(applets_in_files) \ + $(service_DATA) \ + $(gsettings_SCHEMAS) \ + *.gschema.valid \ + $(NULL) + +-include $(top_srcdir)/git.mk diff --git a/timerapplet/data/org.mate.applets.TimerApplet.mate-panel-applet.desktop.in.in b/timerapplet/data/org.mate.applets.TimerApplet.mate-panel-applet.desktop.in.in new file mode 100644 index 00000000..a111eb28 --- /dev/null +++ b/timerapplet/data/org.mate.applets.TimerApplet.mate-panel-applet.desktop.in.in @@ -0,0 +1,11 @@ +[Applet Factory] +Id=TimerAppletFactory +Location=@LOCATION@ +Name=Timer Factory +Description=Timer Factory + +[TimerApplet] +Name=Timer +Description=Start a timer and receive a notification when it is finished +# Translators: Do NOT translate or transliterate this text (this is an icon file name)! +Icon=mate-panel-clock diff --git a/timerapplet/data/org.mate.panel.applet.TimerAppletFactory.service.in b/timerapplet/data/org.mate.panel.applet.TimerAppletFactory.service.in new file mode 100644 index 00000000..b8cd68cc --- /dev/null +++ b/timerapplet/data/org.mate.panel.applet.TimerAppletFactory.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.mate.panel.applet.TimerAppletFactory +Exec=@LOCATION@ diff --git a/timerapplet/data/org.mate.panel.applet.timer.gschema.xml.in b/timerapplet/data/org.mate.panel.applet.timer.gschema.xml.in new file mode 100644 index 00000000..1201c8a6 --- /dev/null +++ b/timerapplet/data/org.mate.panel.applet.timer.gschema.xml.in @@ -0,0 +1,20 @@ + + + + 'Timer' + Name of timer + + + 10 + Duration of timer in seconds + + + true + Show notification popup when timer finish + + + false + Show dialog window when timer finish + + + diff --git a/timerapplet/data/timerapplet-preferences.ui b/timerapplet/data/timerapplet-preferences.ui new file mode 100644 index 00000000..04e13e7d --- /dev/null +++ b/timerapplet/data/timerapplet-preferences.ui @@ -0,0 +1,235 @@ + + + + + + 23 + 1 + 10 + + + True + False + window-close + + + 59 + 1 + 10 + + + 59 + 1 + 10 + + + False + 12 + Timer Applet Preferences + dialog + + + False + vertical + 2 + + + False + end + + + _Close + True + True + True + image1 + True + True + + + True + True + 0 + + + + + False + False + 0 + + + + + True + False + vertical + 6 + + + True + False + 6 + 12 + + + True + False + start + _Name: + True + name_entry + + + 0 + 0 + + + + + True + False + start + _Hours: + True + hours_spinbutton + + + 0 + 1 + + + + + True + False + start + _Minutes: + True + minutes_spinbutton + + + 0 + 2 + + + + + True + False + start + _Seconds: + True + seconds_spinbutton + + + 0 + 3 + + + + + True + True + True + + + 1 + 0 + + + + + True + True + True + hours_adjustment + + + + 1 + 1 + + + + + True + True + True + minutes_adjustment + + + + 1 + 2 + + + + + True + True + True + seconds_adjustment + + + + 1 + 3 + + + + + False + True + 0 + + + + + Show notification _popup + True + True + False + start + True + True + + + False + True + 1 + + + + + Show _dialog + True + True + False + start + True + True + + + False + True + 2 + + + + + False + True + 1 + + + + + + button1 + + + + + + diff --git a/timerapplet/data/timerapplet-resources.gresource.xml b/timerapplet/data/timerapplet-resources.gresource.xml new file mode 100644 index 00000000..71b7915a --- /dev/null +++ b/timerapplet/data/timerapplet-resources.gresource.xml @@ -0,0 +1,6 @@ + + + + timerapplet-preferences.ui + + diff --git a/timerapplet/org.mate.applets.TimerApplet.mate-panel-applet.desktop.in.in b/timerapplet/org.mate.applets.TimerApplet.mate-panel-applet.desktop.in.in deleted file mode 100644 index a111eb28..00000000 --- a/timerapplet/org.mate.applets.TimerApplet.mate-panel-applet.desktop.in.in +++ /dev/null @@ -1,11 +0,0 @@ -[Applet Factory] -Id=TimerAppletFactory -Location=@LOCATION@ -Name=Timer Factory -Description=Timer Factory - -[TimerApplet] -Name=Timer -Description=Start a timer and receive a notification when it is finished -# Translators: Do NOT translate or transliterate this text (this is an icon file name)! -Icon=mate-panel-clock diff --git a/timerapplet/org.mate.panel.applet.TimerAppletFactory.service.in b/timerapplet/org.mate.panel.applet.TimerAppletFactory.service.in deleted file mode 100644 index b8cd68cc..00000000 --- a/timerapplet/org.mate.panel.applet.TimerAppletFactory.service.in +++ /dev/null @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=org.mate.panel.applet.TimerAppletFactory -Exec=@LOCATION@ diff --git a/timerapplet/org.mate.panel.applet.timer.gschema.xml.in b/timerapplet/org.mate.panel.applet.timer.gschema.xml.in deleted file mode 100644 index 1201c8a6..00000000 --- a/timerapplet/org.mate.panel.applet.timer.gschema.xml.in +++ /dev/null @@ -1,20 +0,0 @@ - - - - 'Timer' - Name of timer - - - 10 - Duration of timer in seconds - - - true - Show notification popup when timer finish - - - false - Show dialog window when timer finish - - - diff --git a/timerapplet/src/Makefile.am b/timerapplet/src/Makefile.am new file mode 100644 index 00000000..6eb47ec9 --- /dev/null +++ b/timerapplet/src/Makefile.am @@ -0,0 +1,35 @@ +NULL = + +AM_CPPFLAGS = \ + $(MATE_APPLETS4_CFLAGS) \ + $(LIBNOTIFY_CFLAGS) \ + -I$(srcdir) \ + $(DISABLE_DEPRECATED_CFLAGS) \ + $(NULL) + +libexec_PROGRAMS = timer-applet + +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: $(srcdir)/../data/timerapplet-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/../data --generate-dependencies $(srcdir)/../data/timerapplet-resources.gresource.xml) + $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/../data --generate --c-name timerapplet $< + +timerapplet-resources.h: $(srcdir)/../data/timerapplet-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/../data --generate-dependencies $(srcdir)/../data/timerapplet-resources.gresource.xml) + $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/../data --generate --c-name timerapplet $< + +CLEANFILES = \ + $(BUILT_SOURCES) \ + $(NULL) + +-include $(top_srcdir)/git.mk diff --git a/timerapplet/src/timerapplet.c b/timerapplet/src/timerapplet.c new file mode 100644 index 00000000..0948be43 --- /dev/null +++ b/timerapplet/src/timerapplet.c @@ -0,0 +1,444 @@ +/* timerapplet.c: + * + * Copyright (C) 2014 Stefano Karapetsas + * + * This file is part of MATE Applets. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: + * Stefano Karapetsas + */ + +#include + +#include +#include +#include +#include + +#include + +#include +#include + +/* Applet constants */ +#define APPLET_ICON "mate-panel-clock" +#define STEP 100 + +/* GSettings constants */ +#define TIMER_SCHEMA "org.mate.panel.applet.timer" +#define NAME_KEY "name" +#define DURATION_KEY "duration" +#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; + + GSettings *settings; + + GtkActionGroup *action_group; + GtkLabel *label; + GtkImage *image; + GtkImage *pause_image; + GtkBox *box; + + GtkSpinButton *hours; + GtkSpinButton *minutes; + GtkSpinButton *seconds; + + gboolean active; + gboolean pause; + gint elapsed; + + guint timeout_id; +} TimerApplet; + +static void timer_start_callback (GtkAction *action, TimerApplet *applet); +static void timer_pause_callback (GtkAction *action, TimerApplet *applet); +static void timer_stop_callback (GtkAction *action, TimerApplet *applet); +static void timer_about_callback (GtkAction *action, TimerApplet *applet); +static void timer_reset_callback (GtkAction *action, TimerApplet *applet); +static void timer_preferences_callback (GtkAction *action, TimerApplet *applet); + +static const GtkActionEntry applet_menu_actions [] = { + { "Start", "media-playback-start", N_("_Start timer"), NULL, NULL, G_CALLBACK (timer_start_callback) }, + { "Pause", "media-playback-pause", N_("P_ause timer"), NULL, NULL, G_CALLBACK (timer_pause_callback) }, + { "Stop", "media-playback-stop", N_("S_top timer"), NULL, NULL, G_CALLBACK (timer_stop_callback) }, + { "Reset", "edit-undo", N_("R_eset"), NULL, NULL, G_CALLBACK (timer_reset_callback) }, + { "Preferences", "document-properties", N_("_Preferences"), NULL, NULL, G_CALLBACK (timer_preferences_callback) }, + { "About", "help-about", N_("_About"), NULL, NULL, G_CALLBACK (timer_about_callback) } +}; + +static char *ui = "" + "" + "" + "" + "" + ""; + +static void +timer_applet_destroy (MatePanelApplet *applet_widget, TimerApplet *applet) +{ + g_assert (applet); + + if (applet->timeout_id != 0) + { + g_source_remove(applet->timeout_id); + applet->timeout_id = 0; + } + + g_object_unref (applet->settings); + + notify_uninit (); +} + +/* timer management */ +static gboolean +timer_callback (TimerApplet *applet) +{ + gboolean retval = TRUE; + gchar *label; + gchar *name; + gchar *tooltip; + gint hours, minutes, seconds, duration, remaining; + + label = NULL; + tooltip = NULL; + + name = g_settings_get_string (applet->settings, NAME_KEY); + + if (!applet->active) + { + applet->pause = FALSE; + applet->elapsed = 0; + + gtk_label_set_text (applet->label, name); + gtk_widget_set_tooltip_text (GTK_WIDGET (applet->label), ""); + gtk_widget_hide (GTK_WIDGET (applet->pause_image)); + } + else + { + if (!applet->pause) + applet->elapsed += STEP; + + duration = g_settings_get_int (applet->settings, DURATION_KEY); + + remaining = duration - (applet->elapsed / 1000); + + if (remaining <= 0) + { + applet->active = FALSE; + applet->timeout_id = 0; + + label = g_strdup_printf ("Finished %s", name); + gtk_label_set_text (applet->label, label); + gtk_widget_set_tooltip_text (GTK_WIDGET (applet->label), name); + gtk_widget_hide (GTK_WIDGET (applet->pause_image)); + + if (g_settings_get_boolean (applet->settings, SHOW_NOTIFICATION_KEY)) + { + NotifyNotification *n; + n = notify_notification_new (name, _("Timer finished!"), APPLET_ICON); + notify_notification_set_timeout (n, 30000); + notify_notification_show (n, NULL); + g_object_unref (G_OBJECT (n)); + } + + if (g_settings_get_boolean (applet->settings, SHOW_DIALOG_KEY)) + { + GtkWidget *dialog = gtk_message_dialog_new_with_markup (NULL, + GTK_DIALOG_MODAL, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + "%s\n\n%s", name, _("Timer finished!")); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } + + /* stop further calls */ + retval = FALSE; + } + else + { + hours = remaining / 60 / 60; + minutes = remaining / 60 % 60; + seconds = remaining % 60; + + if (hours > 0) + label = g_strdup_printf ("%02d:%02d:%02d", hours, minutes, seconds); + else + label = g_strdup_printf ("%02d:%02d", minutes, seconds); + + hours = duration / 60 / 60; + minutes = duration / 60 % 60; + seconds = duration % 60; + + if (hours > 0) + tooltip = g_strdup_printf ("%s (%02d:%02d:%02d)", name, hours, minutes, seconds); + else + tooltip = g_strdup_printf ("%s (%02d:%02d)", name, minutes, seconds); + + gtk_label_set_text (applet->label, label); + gtk_widget_set_tooltip_text (GTK_WIDGET (applet->label), tooltip); + gtk_widget_set_visible (GTK_WIDGET (applet->pause_image), applet->pause); + } + + g_free (label); + g_free (tooltip); + } + + /* update actions sensitiveness */ + gtk_action_set_sensitive (gtk_action_group_get_action (applet->action_group, "Start"), !applet->active || applet->pause); + gtk_action_set_sensitive (gtk_action_group_get_action (applet->action_group, "Pause"), applet->active && !applet->pause); + gtk_action_set_sensitive (gtk_action_group_get_action (applet->action_group, "Stop"), applet->active); + gtk_action_set_sensitive (gtk_action_group_get_action (applet->action_group, "Reset"), !applet->active && !applet->pause && applet->elapsed); + gtk_action_set_sensitive (gtk_action_group_get_action (applet->action_group, "Preferences"), !applet->active && !applet->pause); + + g_free (name); + + return retval; +} + +/* start action */ +static void +timer_start_callback (GtkAction *action, TimerApplet *applet) +{ + applet->active = TRUE; + if (applet->pause) + applet->pause = FALSE; + else + applet->elapsed = 0; + applet->timeout_id = g_timeout_add (STEP, (GSourceFunc) timer_callback, applet); +} + +/* pause action */ +static void +timer_pause_callback (GtkAction *action, TimerApplet *applet) +{ + applet->pause = TRUE; + if (applet->timeout_id != 0) + { + g_source_remove(applet->timeout_id); + applet->timeout_id = 0; + } + timer_callback (applet); +} + +/* stop action */ +static void +timer_stop_callback (GtkAction *action, TimerApplet *applet) +{ + applet->active = FALSE; + if (applet->timeout_id != 0) + { + g_source_remove(applet->timeout_id); + applet->timeout_id = 0; + } + timer_callback (applet); +} + +/* reset action */ +static void +timer_reset_callback (GtkAction *action, TimerApplet *applet) +{ + applet->active = FALSE; + applet->pause = FALSE; + applet->elapsed = 0; + timer_callback (applet); +} + +/* Show the about dialog */ +static void +timer_about_callback (GtkAction *action, TimerApplet *applet) +{ + const char* authors[] = { "Stefano Karapetsas ", NULL }; + + gtk_show_about_dialog(NULL, + "title", _("About Timer Applet"), + "version", VERSION, + "copyright", _("Copyright \xc2\xa9 2014 Stefano Karapetsas\n" + "Copyright \xc2\xa9 2015-2020 MATE developers"), + "authors", authors, + "comments", _("Start a timer and receive a notification when it is finished"), + "translator-credits", _("translator-credits"), + "logo-icon-name", APPLET_ICON, + NULL); +} + +/* calculate duration and save in GSettings */ +static void +timer_spin_button_value_changed (GtkSpinButton *spinbutton, TimerApplet *applet) +{ + gint duration; + + duration = gtk_spin_button_get_value_as_int (applet->seconds); + duration += gtk_spin_button_get_value_as_int (applet->minutes) * 60; + duration += gtk_spin_button_get_value_as_int (applet->hours) * 3600; + + g_settings_set_int (applet->settings, DURATION_KEY, duration); +} + +/* Show the preferences dialog */ +static void +timer_preferences_callback (GtkAction *action, TimerApplet *applet) +{ + GtkBuilder *builder; + GtkDialog *dialog; + 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; + + 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)); +} + +static gboolean +timer_applet_click (TimerApplet *applet) +{ + if (!applet->active && !applet->pause && applet->elapsed) + timer_reset_callback (NULL, applet); + else if (applet->active && !applet->pause) + timer_pause_callback (NULL, applet); + else if (!applet->active || applet->pause) + timer_start_callback (NULL, applet); + return FALSE; +} + +static void +timer_settings_changed (GSettings *settings, gchar *key, TimerApplet *applet) +{ + timer_callback (applet); +} + +static gboolean +timer_applet_fill (MatePanelApplet* applet_widget) +{ + TimerApplet *applet; + + g_set_application_name (_("Timer Applet")); + gtk_window_set_default_icon_name (APPLET_ICON); + + if (!notify_is_initted ()) + notify_init ("timer-applet"); + + mate_panel_applet_set_flags (applet_widget, MATE_PANEL_APPLET_EXPAND_MINOR); + mate_panel_applet_set_background_widget (MATE_PANEL_APPLET (applet_widget), GTK_WIDGET (applet_widget)); + + applet = g_malloc0(sizeof(TimerApplet)); + applet->applet = applet_widget; + applet->settings = mate_panel_applet_settings_new (applet_widget,TIMER_SCHEMA); + applet->timeout_id = 0; + applet->active = FALSE; + applet->pause = FALSE; + + applet->box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); + applet->image = GTK_IMAGE (gtk_image_new_from_icon_name (APPLET_ICON, GTK_ICON_SIZE_BUTTON)); + applet->pause_image = GTK_IMAGE (gtk_image_new_from_icon_name ("media-playback-pause", GTK_ICON_SIZE_BUTTON)); + applet->label = GTK_LABEL (gtk_label_new ("")); + + /* we add the Gtk label into the applet */ + gtk_box_pack_start (applet->box, + GTK_WIDGET (applet->image), + TRUE, TRUE, 0); + gtk_box_pack_start (applet->box, + GTK_WIDGET (applet->pause_image), + TRUE, TRUE, 0); + gtk_box_pack_start (applet->box, + GTK_WIDGET (applet->label), + TRUE, TRUE, 3); + + gtk_container_add (GTK_CONTAINER (applet_widget), + GTK_WIDGET (applet->box)); + + gtk_widget_show_all (GTK_WIDGET (applet->applet)); + gtk_widget_hide (GTK_WIDGET (applet->pause_image)); + + g_signal_connect(G_OBJECT (applet->applet), "destroy", + G_CALLBACK (timer_applet_destroy), + applet); + + g_signal_connect_swapped(GTK_WIDGET (applet->applet), "button-release-event", + G_CALLBACK (timer_applet_click), applet); + + /* set up context menu */ + applet->action_group = gtk_action_group_new ("Timer Applet Actions"); + gtk_action_group_set_translation_domain (applet->action_group, GETTEXT_PACKAGE); + gtk_action_group_add_actions (applet->action_group, applet_menu_actions, + G_N_ELEMENTS (applet_menu_actions), applet); + mate_panel_applet_setup_menu (applet->applet, ui, applet->action_group); + + /* execute callback to set actions sensitiveness */ + timer_callback (applet); + + /* GSettings callback */ + g_signal_connect (G_OBJECT (applet->settings), "changed", + G_CALLBACK (timer_settings_changed), applet); + + return TRUE; +} + +/* this function, called by mate-panel, will create the applet */ +static gboolean +timer_factory (MatePanelApplet* applet, const char* iid, gpointer data) +{ + gboolean retval = FALSE; + + if (!g_strcmp0 (iid, "TimerApplet")) + retval = timer_applet_fill (applet); + + return retval; +} + +/* needed by mate-panel applet library */ +MATE_PANEL_APPLET_OUT_PROCESS_FACTORY("TimerAppletFactory", + PANEL_TYPE_APPLET, + "Timer applet", + timer_factory, + NULL) diff --git a/timerapplet/timerapplet-preferences.ui b/timerapplet/timerapplet-preferences.ui deleted file mode 100644 index 04e13e7d..00000000 --- a/timerapplet/timerapplet-preferences.ui +++ /dev/null @@ -1,235 +0,0 @@ - - - - - - 23 - 1 - 10 - - - True - False - window-close - - - 59 - 1 - 10 - - - 59 - 1 - 10 - - - False - 12 - Timer Applet Preferences - dialog - - - False - vertical - 2 - - - False - end - - - _Close - True - True - True - image1 - True - True - - - True - True - 0 - - - - - False - False - 0 - - - - - True - False - vertical - 6 - - - True - False - 6 - 12 - - - True - False - start - _Name: - True - name_entry - - - 0 - 0 - - - - - True - False - start - _Hours: - True - hours_spinbutton - - - 0 - 1 - - - - - True - False - start - _Minutes: - True - minutes_spinbutton - - - 0 - 2 - - - - - True - False - start - _Seconds: - True - seconds_spinbutton - - - 0 - 3 - - - - - True - True - True - - - 1 - 0 - - - - - True - True - True - hours_adjustment - - - - 1 - 1 - - - - - True - True - True - minutes_adjustment - - - - 1 - 2 - - - - - True - True - True - seconds_adjustment - - - - 1 - 3 - - - - - False - True - 0 - - - - - Show notification _popup - True - True - False - start - True - True - - - False - True - 1 - - - - - Show _dialog - True - True - False - start - True - True - - - False - True - 2 - - - - - False - True - 1 - - - - - - button1 - - - - - - diff --git a/timerapplet/timerapplet-resources.gresource.xml b/timerapplet/timerapplet-resources.gresource.xml deleted file mode 100644 index 71b7915a..00000000 --- a/timerapplet/timerapplet-resources.gresource.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - timerapplet-preferences.ui - - diff --git a/timerapplet/timerapplet.c b/timerapplet/timerapplet.c deleted file mode 100644 index 0948be43..00000000 --- a/timerapplet/timerapplet.c +++ /dev/null @@ -1,444 +0,0 @@ -/* timerapplet.c: - * - * Copyright (C) 2014 Stefano Karapetsas - * - * This file is part of MATE Applets. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: - * Stefano Karapetsas - */ - -#include - -#include -#include -#include -#include - -#include - -#include -#include - -/* Applet constants */ -#define APPLET_ICON "mate-panel-clock" -#define STEP 100 - -/* GSettings constants */ -#define TIMER_SCHEMA "org.mate.panel.applet.timer" -#define NAME_KEY "name" -#define DURATION_KEY "duration" -#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; - - GSettings *settings; - - GtkActionGroup *action_group; - GtkLabel *label; - GtkImage *image; - GtkImage *pause_image; - GtkBox *box; - - GtkSpinButton *hours; - GtkSpinButton *minutes; - GtkSpinButton *seconds; - - gboolean active; - gboolean pause; - gint elapsed; - - guint timeout_id; -} TimerApplet; - -static void timer_start_callback (GtkAction *action, TimerApplet *applet); -static void timer_pause_callback (GtkAction *action, TimerApplet *applet); -static void timer_stop_callback (GtkAction *action, TimerApplet *applet); -static void timer_about_callback (GtkAction *action, TimerApplet *applet); -static void timer_reset_callback (GtkAction *action, TimerApplet *applet); -static void timer_preferences_callback (GtkAction *action, TimerApplet *applet); - -static const GtkActionEntry applet_menu_actions [] = { - { "Start", "media-playback-start", N_("_Start timer"), NULL, NULL, G_CALLBACK (timer_start_callback) }, - { "Pause", "media-playback-pause", N_("P_ause timer"), NULL, NULL, G_CALLBACK (timer_pause_callback) }, - { "Stop", "media-playback-stop", N_("S_top timer"), NULL, NULL, G_CALLBACK (timer_stop_callback) }, - { "Reset", "edit-undo", N_("R_eset"), NULL, NULL, G_CALLBACK (timer_reset_callback) }, - { "Preferences", "document-properties", N_("_Preferences"), NULL, NULL, G_CALLBACK (timer_preferences_callback) }, - { "About", "help-about", N_("_About"), NULL, NULL, G_CALLBACK (timer_about_callback) } -}; - -static char *ui = "" - "" - "" - "" - "" - ""; - -static void -timer_applet_destroy (MatePanelApplet *applet_widget, TimerApplet *applet) -{ - g_assert (applet); - - if (applet->timeout_id != 0) - { - g_source_remove(applet->timeout_id); - applet->timeout_id = 0; - } - - g_object_unref (applet->settings); - - notify_uninit (); -} - -/* timer management */ -static gboolean -timer_callback (TimerApplet *applet) -{ - gboolean retval = TRUE; - gchar *label; - gchar *name; - gchar *tooltip; - gint hours, minutes, seconds, duration, remaining; - - label = NULL; - tooltip = NULL; - - name = g_settings_get_string (applet->settings, NAME_KEY); - - if (!applet->active) - { - applet->pause = FALSE; - applet->elapsed = 0; - - gtk_label_set_text (applet->label, name); - gtk_widget_set_tooltip_text (GTK_WIDGET (applet->label), ""); - gtk_widget_hide (GTK_WIDGET (applet->pause_image)); - } - else - { - if (!applet->pause) - applet->elapsed += STEP; - - duration = g_settings_get_int (applet->settings, DURATION_KEY); - - remaining = duration - (applet->elapsed / 1000); - - if (remaining <= 0) - { - applet->active = FALSE; - applet->timeout_id = 0; - - label = g_strdup_printf ("Finished %s", name); - gtk_label_set_text (applet->label, label); - gtk_widget_set_tooltip_text (GTK_WIDGET (applet->label), name); - gtk_widget_hide (GTK_WIDGET (applet->pause_image)); - - if (g_settings_get_boolean (applet->settings, SHOW_NOTIFICATION_KEY)) - { - NotifyNotification *n; - n = notify_notification_new (name, _("Timer finished!"), APPLET_ICON); - notify_notification_set_timeout (n, 30000); - notify_notification_show (n, NULL); - g_object_unref (G_OBJECT (n)); - } - - if (g_settings_get_boolean (applet->settings, SHOW_DIALOG_KEY)) - { - GtkWidget *dialog = gtk_message_dialog_new_with_markup (NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - "%s\n\n%s", name, _("Timer finished!")); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - - /* stop further calls */ - retval = FALSE; - } - else - { - hours = remaining / 60 / 60; - minutes = remaining / 60 % 60; - seconds = remaining % 60; - - if (hours > 0) - label = g_strdup_printf ("%02d:%02d:%02d", hours, minutes, seconds); - else - label = g_strdup_printf ("%02d:%02d", minutes, seconds); - - hours = duration / 60 / 60; - minutes = duration / 60 % 60; - seconds = duration % 60; - - if (hours > 0) - tooltip = g_strdup_printf ("%s (%02d:%02d:%02d)", name, hours, minutes, seconds); - else - tooltip = g_strdup_printf ("%s (%02d:%02d)", name, minutes, seconds); - - gtk_label_set_text (applet->label, label); - gtk_widget_set_tooltip_text (GTK_WIDGET (applet->label), tooltip); - gtk_widget_set_visible (GTK_WIDGET (applet->pause_image), applet->pause); - } - - g_free (label); - g_free (tooltip); - } - - /* update actions sensitiveness */ - gtk_action_set_sensitive (gtk_action_group_get_action (applet->action_group, "Start"), !applet->active || applet->pause); - gtk_action_set_sensitive (gtk_action_group_get_action (applet->action_group, "Pause"), applet->active && !applet->pause); - gtk_action_set_sensitive (gtk_action_group_get_action (applet->action_group, "Stop"), applet->active); - gtk_action_set_sensitive (gtk_action_group_get_action (applet->action_group, "Reset"), !applet->active && !applet->pause && applet->elapsed); - gtk_action_set_sensitive (gtk_action_group_get_action (applet->action_group, "Preferences"), !applet->active && !applet->pause); - - g_free (name); - - return retval; -} - -/* start action */ -static void -timer_start_callback (GtkAction *action, TimerApplet *applet) -{ - applet->active = TRUE; - if (applet->pause) - applet->pause = FALSE; - else - applet->elapsed = 0; - applet->timeout_id = g_timeout_add (STEP, (GSourceFunc) timer_callback, applet); -} - -/* pause action */ -static void -timer_pause_callback (GtkAction *action, TimerApplet *applet) -{ - applet->pause = TRUE; - if (applet->timeout_id != 0) - { - g_source_remove(applet->timeout_id); - applet->timeout_id = 0; - } - timer_callback (applet); -} - -/* stop action */ -static void -timer_stop_callback (GtkAction *action, TimerApplet *applet) -{ - applet->active = FALSE; - if (applet->timeout_id != 0) - { - g_source_remove(applet->timeout_id); - applet->timeout_id = 0; - } - timer_callback (applet); -} - -/* reset action */ -static void -timer_reset_callback (GtkAction *action, TimerApplet *applet) -{ - applet->active = FALSE; - applet->pause = FALSE; - applet->elapsed = 0; - timer_callback (applet); -} - -/* Show the about dialog */ -static void -timer_about_callback (GtkAction *action, TimerApplet *applet) -{ - const char* authors[] = { "Stefano Karapetsas ", NULL }; - - gtk_show_about_dialog(NULL, - "title", _("About Timer Applet"), - "version", VERSION, - "copyright", _("Copyright \xc2\xa9 2014 Stefano Karapetsas\n" - "Copyright \xc2\xa9 2015-2020 MATE developers"), - "authors", authors, - "comments", _("Start a timer and receive a notification when it is finished"), - "translator-credits", _("translator-credits"), - "logo-icon-name", APPLET_ICON, - NULL); -} - -/* calculate duration and save in GSettings */ -static void -timer_spin_button_value_changed (GtkSpinButton *spinbutton, TimerApplet *applet) -{ - gint duration; - - duration = gtk_spin_button_get_value_as_int (applet->seconds); - duration += gtk_spin_button_get_value_as_int (applet->minutes) * 60; - duration += gtk_spin_button_get_value_as_int (applet->hours) * 3600; - - g_settings_set_int (applet->settings, DURATION_KEY, duration); -} - -/* Show the preferences dialog */ -static void -timer_preferences_callback (GtkAction *action, TimerApplet *applet) -{ - GtkBuilder *builder; - GtkDialog *dialog; - 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; - - 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)); -} - -static gboolean -timer_applet_click (TimerApplet *applet) -{ - if (!applet->active && !applet->pause && applet->elapsed) - timer_reset_callback (NULL, applet); - else if (applet->active && !applet->pause) - timer_pause_callback (NULL, applet); - else if (!applet->active || applet->pause) - timer_start_callback (NULL, applet); - return FALSE; -} - -static void -timer_settings_changed (GSettings *settings, gchar *key, TimerApplet *applet) -{ - timer_callback (applet); -} - -static gboolean -timer_applet_fill (MatePanelApplet* applet_widget) -{ - TimerApplet *applet; - - g_set_application_name (_("Timer Applet")); - gtk_window_set_default_icon_name (APPLET_ICON); - - if (!notify_is_initted ()) - notify_init ("timer-applet"); - - mate_panel_applet_set_flags (applet_widget, MATE_PANEL_APPLET_EXPAND_MINOR); - mate_panel_applet_set_background_widget (MATE_PANEL_APPLET (applet_widget), GTK_WIDGET (applet_widget)); - - applet = g_malloc0(sizeof(TimerApplet)); - applet->applet = applet_widget; - applet->settings = mate_panel_applet_settings_new (applet_widget,TIMER_SCHEMA); - applet->timeout_id = 0; - applet->active = FALSE; - applet->pause = FALSE; - - applet->box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); - applet->image = GTK_IMAGE (gtk_image_new_from_icon_name (APPLET_ICON, GTK_ICON_SIZE_BUTTON)); - applet->pause_image = GTK_IMAGE (gtk_image_new_from_icon_name ("media-playback-pause", GTK_ICON_SIZE_BUTTON)); - applet->label = GTK_LABEL (gtk_label_new ("")); - - /* we add the Gtk label into the applet */ - gtk_box_pack_start (applet->box, - GTK_WIDGET (applet->image), - TRUE, TRUE, 0); - gtk_box_pack_start (applet->box, - GTK_WIDGET (applet->pause_image), - TRUE, TRUE, 0); - gtk_box_pack_start (applet->box, - GTK_WIDGET (applet->label), - TRUE, TRUE, 3); - - gtk_container_add (GTK_CONTAINER (applet_widget), - GTK_WIDGET (applet->box)); - - gtk_widget_show_all (GTK_WIDGET (applet->applet)); - gtk_widget_hide (GTK_WIDGET (applet->pause_image)); - - g_signal_connect(G_OBJECT (applet->applet), "destroy", - G_CALLBACK (timer_applet_destroy), - applet); - - g_signal_connect_swapped(GTK_WIDGET (applet->applet), "button-release-event", - G_CALLBACK (timer_applet_click), applet); - - /* set up context menu */ - applet->action_group = gtk_action_group_new ("Timer Applet Actions"); - gtk_action_group_set_translation_domain (applet->action_group, GETTEXT_PACKAGE); - gtk_action_group_add_actions (applet->action_group, applet_menu_actions, - G_N_ELEMENTS (applet_menu_actions), applet); - mate_panel_applet_setup_menu (applet->applet, ui, applet->action_group); - - /* execute callback to set actions sensitiveness */ - timer_callback (applet); - - /* GSettings callback */ - g_signal_connect (G_OBJECT (applet->settings), "changed", - G_CALLBACK (timer_settings_changed), applet); - - return TRUE; -} - -/* this function, called by mate-panel, will create the applet */ -static gboolean -timer_factory (MatePanelApplet* applet, const char* iid, gpointer data) -{ - gboolean retval = FALSE; - - if (!g_strcmp0 (iid, "TimerApplet")) - retval = timer_applet_fill (applet); - - return retval; -} - -/* needed by mate-panel applet library */ -MATE_PANEL_APPLET_OUT_PROCESS_FACTORY("TimerAppletFactory", - PANEL_TYPE_APPLET, - "Timer applet", - timer_factory, - NULL) -- cgit v1.2.1