From 9c4ef5136fed495e618610ba675a03de9efbe921 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Wed, 29 Jan 2014 15:13:59 +0100 Subject: Add new timerapplet in c To replace old timer-applet written in pygtk and not working in 1.6 See https://github.com/mate-desktop/mate-applets/issues/45 --- Makefile.am | 6 + configure.ac | 8 + po/POTFILES.in | 2 + timerapplet/Makefile.am | 45 +++ ...ate.applets.TimerApplet.mate-panel-applet.in.in | 10 + ...mate.panel.applet.TimerAppletFactory.service.in | 3 + .../org.mate.panel.applet.timer.gschema.xml.in.in | 20 + timerapplet/timerapplet.c | 447 +++++++++++++++++++++ 8 files changed, 541 insertions(+) create mode 100644 timerapplet/Makefile.am create mode 100644 timerapplet/org.mate.applets.TimerApplet.mate-panel-applet.in.in create mode 100644 timerapplet/org.mate.panel.applet.TimerAppletFactory.service.in create mode 100644 timerapplet/org.mate.panel.applet.timer.gschema.xml.in.in create mode 100644 timerapplet/timerapplet.c diff --git a/Makefile.am b/Makefile.am index 537372ce..6b2f46f8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,6 +35,10 @@ if BUILD_INVEST_APPLET invest_applet_SUBDIR = invest-applet endif +if BUILD_TIMERAPPLET +timerapplet_SUBDIR = timerapplet +endif + if BUILD_TIMER_APPLET timer_applet_SUBDIR = timer-applet endif @@ -59,6 +63,7 @@ SUBDIRS = \ $(accessx_status_SUBDIR) \ $(invest_applet_SUBDIR) \ $(cpufreq_SUBDIR) \ + $(timerapplet_SUBDIR) \ $(timer_applet_SUBDIR) DIST_SUBDIRS = \ @@ -73,6 +78,7 @@ DIST_SUBDIRS = \ man \ accessx-status \ stickynotes \ + timerapplet \ trashapplet \ cpufreq \ invest-applet \ diff --git a/configure.ac b/configure.ac index 1e5e882c..68011189 100644 --- a/configure.ac +++ b/configure.ac @@ -542,6 +542,12 @@ AM_CONDITIONAL(BUILD_CPUFREQ_APPLET, test x$build_cpufreq_applet = xyes) AM_CONDITIONAL(BUILD_CPUFREQ_SELECTOR, test x$enable_selector = xyes) AM_CONDITIONAL(CPUFREQ_SELECTOR_SUID, test x$suid = xyes) +dnl *************************************************************************** +dnl *** timerapplet specific checks *** +dnl *************************************************************************** + +AM_CONDITIONAL(BUILD_TIMERAPPLET, test "x$HAVE_LIBNOTIFY" = "xyes") + dnl *************************************************************************** dnl *** invest-applet specific checks *** dnl *************************************************************************** @@ -698,6 +704,7 @@ cpufreq/src/Makefile cpufreq/src/cpufreq-selector/Makefile cpufreq/pixmaps/Makefile cpufreq/help/Makefile +timerapplet/Makefile timer-applet/Makefile timer-applet/data/Makefile timer-applet/images/Makefile @@ -738,6 +745,7 @@ mate-applets-$VERSION configure summary: - modemlights $BUILD_MODEM_LIGHTS - multiload $build_gtop_applets - stickynotes $enable_stickynotes + - timerapplet $HAVE_LIBNOTIFY - trashapplet always - timer-applet $enable_timerapplet diff --git a/po/POTFILES.in b/po/POTFILES.in index 60211e55..3544bb59 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -78,6 +78,8 @@ stickynotes/org.mate.stickynotes.gschema.xml.in.in stickynotes/stickynotes_applet.c stickynotes/stickynotes_applet_callbacks.c stickynotes/stickynotes_callbacks.c +timerapplet/org.mate.panel.applet.timer.gschema.xml.in.in +timerapplet/timerapplet.c timer-applet/data/TimerApplet.server.in.in timer-applet/data/TimerApplet.xml timer-applet/data/timer-applet.glade diff --git a/timerapplet/Makefile.am b/timerapplet/Makefile.am new file mode 100644 index 00000000..e0af8402 --- /dev/null +++ b/timerapplet/Makefile.am @@ -0,0 +1,45 @@ +AM_CPPFLAGS = \ + $(MATE_APPLETS4_CFLAGS) \ + $(LIBNOTIFY_CFLAGS) \ + -I$(srcdir) \ + -DMATELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ + $(DISABLE_DEPRECATED_CFLAGS) + +APPLET_LOCATION = $(libexecdir)/timer-applet + +libexec_PROGRAMS = timer-applet +timer_applet_SOURCES = timerapplet.c +timer_applet_LDADD = $(MATE_APPLETS4_LIBS) $(LIBNOTIFY_LIBS) +timer_applet_CFLAGS = $(WARN_CFLAGS) + +appletsdir = $(datadir)/mate-panel/applets +applets_in_files = org.mate.applets.TimerApplet.mate-panel-applet.in +applets_DATA = $(applets_in_files:.mate-panel-applet.in=.mate-panel-applet) + +$(applets_in_files): $(applets_in_files).in Makefile + $(AM_V_GEN)sed \ + -e "s|\@LOCATION\@|$(APPLET_LOCATION)|" \ + $< > $@ +%.mate-panel-applet: %.mate-panel-applet.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache + +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)|" \ + $< > $@ + +@INTLTOOL_XML_NOMERGE_RULE@ +gsettings_SCHEMAS = org.mate.panel.applet.timer.gschema.xml +@GSETTINGS_RULES@ + +%.gschema.xml.in: %.gschema.xml.in.in Makefile + $(AM_V_GEN) $(SED) -e 's^\@GETTEXT_PACKAGE\@^$(GETTEXT_PACKAGE)^g' < $< > $@ + +EXTRA_DIST = \ + $(applets_in_files) \ + $(service_in_files) \ + $(gsettings_SCHEMAS).in.in + diff --git a/timerapplet/org.mate.applets.TimerApplet.mate-panel-applet.in.in b/timerapplet/org.mate.applets.TimerApplet.mate-panel-applet.in.in new file mode 100644 index 00000000..38a23a63 --- /dev/null +++ b/timerapplet/org.mate.applets.TimerApplet.mate-panel-applet.in.in @@ -0,0 +1,10 @@ +[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 +Icon=time diff --git a/timerapplet/org.mate.panel.applet.TimerAppletFactory.service.in b/timerapplet/org.mate.panel.applet.TimerAppletFactory.service.in new file mode 100644 index 00000000..b8cd68cc --- /dev/null +++ b/timerapplet/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/org.mate.panel.applet.timer.gschema.xml.in.in b/timerapplet/org.mate.panel.applet.timer.gschema.xml.in.in new file mode 100644 index 00000000..8e2b40b9 --- /dev/null +++ b/timerapplet/org.mate.panel.applet.timer.gschema.xml.in.in @@ -0,0 +1,20 @@ + + + + 'Timer' + <_summary>Name of timer + + + 10 + <_summary>Duration of timer in seconds + + + true + <_summary>Show notification popup when timer finish + + + false + <_summary>Show dialog window when timer finish + + + diff --git a/timerapplet/timerapplet.c b/timerapplet/timerapplet.c new file mode 100644 index 00000000..59b62ca4 --- /dev/null +++ b/timerapplet/timerapplet.c @@ -0,0 +1,447 @@ +/* timerapplet.c: + * + * Copyright (C) 2014 Stefano Karapetsas + * + * This file is part of MATE Applets. + * + * MATE Applets 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 3 of the License, or + * (at your option) any later version. + * + * MATE Applets 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 MATE Applets. If not, see . + * + * Authors: + * Stefano Karapetsas + */ + +#include + +#include +#include +#include +#include + +#include + +#include +#include + +/* Applet constants */ +#define APPLET_ICON "time" +#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" + +typedef struct +{ + MatePanelApplet *applet; + + GSettings *settings; + + GtkActionGroup *action_group; + GtkLabel *label; + GtkImage *image; + GtkImage *pause_image; + GtkHBox *hbox; + + 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_preferences_callback (GtkAction *action, TimerApplet *applet); + +static const GtkActionEntry applet_menu_actions [] = { + { "Start", GTK_STOCK_MEDIA_PLAY, N_("_Start timer"), NULL, NULL, G_CALLBACK (timer_start_callback) }, + { "Pause", GTK_STOCK_MEDIA_PAUSE, N_("P_ause timer"), NULL, NULL, G_CALLBACK (timer_pause_callback) }, + { "Stop", GTK_STOCK_MEDIA_STOP, N_("S_top timer"), NULL, NULL, G_CALLBACK (timer_stop_callback) }, + { "Preferences", GTK_STOCK_PROPERTIES, N_("_Preferences"), NULL, NULL, G_CALLBACK (timer_preferences_callback) }, + { "About", GTK_STOCK_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; + name = NULL; + tooltip = NULL; + + if (!applet->active) + { + gtk_label_set_text (applet->label, ""); + gtk_widget_set_tooltip_text (GTK_WIDGET (applet->label), ""); + gtk_widget_hide (GTK_WIDGET (applet->pause_image)); + } + else + { + if (applet->active && !applet->pause) + applet->elapsed += STEP; + + duration = g_settings_get_int (applet->settings, DURATION_KEY); + name = g_settings_get_string (applet->settings, NAME_KEY); + + remaining = duration - (applet->elapsed / 1000); + + if (remaining <= 0) + { + applet->active = FALSE; + gtk_label_set_text (applet->label, _("Finished")); + 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!"), "time"); + 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 (name); + 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, "Preferences"), !applet->active && !applet->pause); + + 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); +} + +/* Show the about dialog */ +static void +timer_about_callback (GtkAction *action, TimerApplet *applet) +{ + const char* authors[] = { "Stefano Karapetsas ", NULL }; + + gtk_show_about_dialog(NULL, + "version", VERSION, + "copyright", "Copyright © 2014 Stefano Karapetsas", + "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 = 0; + + duration += gtk_spin_button_get_value (applet->hours) * 60 * 60; + duration += gtk_spin_button_get_value (applet->minutes) * 60; + duration += gtk_spin_button_get_value (applet->seconds); + + g_settings_set_int (applet->settings, DURATION_KEY, duration); +} + +/* Show the preferences dialog */ +static void +timer_preferences_callback (GtkAction *action, TimerApplet *applet) +{ + GtkDialog *dialog; + GtkTable *table; + GtkWidget *widget; + gint duration, hours, minutes, seconds; + + 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_STOCK_CLOSE, + GTK_RESPONSE_CLOSE, + NULL)); + table = gtk_table_new (6, 2, FALSE); + gtk_table_set_row_spacings (table, 12); + gtk_table_set_col_spacings (table, 12); + + gtk_window_set_default_size (GTK_WINDOW (dialog), 350, 150); + + widget = gtk_label_new (_("Name:")); + gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5); + gtk_table_attach (table, widget, 1, 2, 0, 1, + GTK_FILL, GTK_FILL, + 0, 0); + + widget = gtk_entry_new (); + gtk_table_attach (table, widget, 2, 3, 0, 1, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, + 0, 0); + g_settings_bind (applet->settings, NAME_KEY, widget, "text", G_SETTINGS_BIND_DEFAULT); + + widget = gtk_label_new (_("Hours:")); + gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5); + gtk_table_attach (table, widget, 1, 2, 1, 2, + GTK_FILL, GTK_FILL, + 0, 0); + + widget = gtk_spin_button_new_with_range (0.0, 100.0, 1.0); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), hours); + gtk_table_attach (table, widget, 2, 3, 1, 2, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, + 0, 0); + 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_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5); + gtk_table_attach (table, widget, 1, 2, 2, 3, + GTK_FILL, GTK_FILL, + 0, 0); + + widget = gtk_spin_button_new_with_range (0.0, 59.0, 1.0); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), minutes); + gtk_table_attach (table, widget, 2, 3, 2, 3, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, + 0, 0); + 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_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5); + gtk_table_attach (table, widget, 1, 2, 3, 4, + GTK_FILL, GTK_FILL, + 0, 0); + + widget = gtk_spin_button_new_with_range (0.0, 59.0, 1.0); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), seconds); + gtk_table_attach (table, widget, 2, 3, 3, 4, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, + 0, 0); + 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_table_attach (table, widget, 2, 3, 4, 5, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, + 0, 0); + g_settings_bind (applet->settings, SHOW_NOTIFICATION_KEY, widget, "active", G_SETTINGS_BIND_DEFAULT); + + widget = gtk_check_button_new_with_label (_("Show dialog")); + gtk_table_attach (table, widget, 2, 3, 5, 6, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, + 0, 0); + g_settings_bind (applet->settings, SHOW_DIALOG_KEY, widget, "active", G_SETTINGS_BIND_DEFAULT); + + gtk_box_pack_start_defaults (GTK_BOX (dialog->vbox), GTK_WIDGET (table)); + + g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); + + gtk_widget_show_all (GTK_WIDGET (dialog)); +} + +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 (applet_widget, GTK_WIDGET (applet)); + + 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->hbox = GTK_HBOX (gtk_hbox_new (FALSE, 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 (GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_BUTTON)); + applet->label = GTK_LABEL (gtk_label_new ("")); + + /* we add the Gtk label into the applet */ + gtk_box_pack_start (GTK_BOX (applet->hbox), + GTK_WIDGET (applet->image), + TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (applet->hbox), + GTK_WIDGET (applet->pause_image), + TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (applet->hbox), + GTK_WIDGET (applet->label), + TRUE, TRUE, 3); + + gtk_container_add (GTK_CONTAINER (applet_widget), + GTK_WIDGET (applet->hbox)); + + 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); + + /* set up context menu */ + applet->action_group = gtk_action_group_new ("Timer Applet Actions"); + 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); + + 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 From 103274c655d5eed254b552ed5cf19265cd8f98f2 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Wed, 29 Jan 2014 15:23:00 +0100 Subject: Remove old timer-applet --- Makefile.am | 8 +- configure.ac | 18 - timer-applet/AUTHORS | 2 - timer-applet/Makefile.am | 1 - timer-applet/data/Makefile.am | 27 - timer-applet/data/TimerApplet.server.in.in | 22 - timer-applet/data/TimerApplet.xml | 19 - timer-applet/data/timer-applet.glade | 1302 -------------------- timer-applet/data/timer-applet.schemas.in | 87 -- timer-applet/images/Makefile.am | 5 - timer-applet/images/timer-applet.png | Bin 2820 -> 0 bytes timer-applet/images/timer-applet.svg | 725 ----------- timer-applet/src/Makefile.am | 6 - timer-applet/src/timer-applet | 136 -- timer-applet/src/timerapplet/Makefile.am | 27 - timer-applet/src/timerapplet/__init__.py | 1 - timer-applet/src/timerapplet/config.py | 39 - .../timerapplet/controllers/GlobalController.py | 91 -- .../src/timerapplet/controllers/Makefile.am | 8 - .../src/timerapplet/controllers/TimerApplet.py | 637 ---------- .../timerapplet/controllers/TimerManagerService.py | 42 - .../src/timerapplet/controllers/TimerService.py | 49 - .../src/timerapplet/controllers/__init__.py | 20 - .../src/timerapplet/core/AppletMateConfWrapper.py | 89 -- timer-applet/src/timerapplet/core/Makefile.am | 6 - timer-applet/src/timerapplet/core/PresetsStore.py | 160 --- timer-applet/src/timerapplet/core/Timer.py | 175 --- timer-applet/src/timerapplet/core/__init__.py | 19 - timer-applet/src/timerapplet/defs.py.in | 7 - timer-applet/src/timerapplet/logger.py | 23 - .../src/timerapplet/ui/AddEditPresetDialog.py | 75 -- .../src/timerapplet/ui/ContinueTimerDialog.py | 63 - timer-applet/src/timerapplet/ui/DurationChooser.py | 166 --- timer-applet/src/timerapplet/ui/Makefile.am | 15 - .../src/timerapplet/ui/ManagePresetsDialog.py | 86 -- timer-applet/src/timerapplet/ui/Notifier.py | 73 -- timer-applet/src/timerapplet/ui/PieMeter.py | 77 -- .../src/timerapplet/ui/PreferencesDialog.py | 192 --- timer-applet/src/timerapplet/ui/PulseButton.py | 69 -- .../src/timerapplet/ui/ScrollableButtonList.py | 65 - .../src/timerapplet/ui/StartNextTimerDialog.py | 66 - .../src/timerapplet/ui/StartTimerDialog.py | 267 ---- timer-applet/src/timerapplet/ui/StatusButton.py | 101 -- timer-applet/src/timerapplet/ui/__init__.py | 28 - timer-applet/src/timerapplet/utils.py | 79 -- 45 files changed, 1 insertion(+), 5172 deletions(-) delete mode 100644 timer-applet/AUTHORS delete mode 100644 timer-applet/Makefile.am delete mode 100644 timer-applet/data/Makefile.am delete mode 100644 timer-applet/data/TimerApplet.server.in.in delete mode 100644 timer-applet/data/TimerApplet.xml delete mode 100644 timer-applet/data/timer-applet.glade delete mode 100644 timer-applet/data/timer-applet.schemas.in delete mode 100644 timer-applet/images/Makefile.am delete mode 100644 timer-applet/images/timer-applet.png delete mode 100644 timer-applet/images/timer-applet.svg delete mode 100644 timer-applet/src/Makefile.am delete mode 100755 timer-applet/src/timer-applet delete mode 100644 timer-applet/src/timerapplet/Makefile.am delete mode 100644 timer-applet/src/timerapplet/__init__.py delete mode 100644 timer-applet/src/timerapplet/config.py delete mode 100644 timer-applet/src/timerapplet/controllers/GlobalController.py delete mode 100644 timer-applet/src/timerapplet/controllers/Makefile.am delete mode 100644 timer-applet/src/timerapplet/controllers/TimerApplet.py delete mode 100644 timer-applet/src/timerapplet/controllers/TimerManagerService.py delete mode 100644 timer-applet/src/timerapplet/controllers/TimerService.py delete mode 100644 timer-applet/src/timerapplet/controllers/__init__.py delete mode 100644 timer-applet/src/timerapplet/core/AppletMateConfWrapper.py delete mode 100644 timer-applet/src/timerapplet/core/Makefile.am delete mode 100644 timer-applet/src/timerapplet/core/PresetsStore.py delete mode 100644 timer-applet/src/timerapplet/core/Timer.py delete mode 100644 timer-applet/src/timerapplet/core/__init__.py delete mode 100644 timer-applet/src/timerapplet/defs.py.in delete mode 100644 timer-applet/src/timerapplet/logger.py delete mode 100644 timer-applet/src/timerapplet/ui/AddEditPresetDialog.py delete mode 100644 timer-applet/src/timerapplet/ui/ContinueTimerDialog.py delete mode 100644 timer-applet/src/timerapplet/ui/DurationChooser.py delete mode 100644 timer-applet/src/timerapplet/ui/Makefile.am delete mode 100644 timer-applet/src/timerapplet/ui/ManagePresetsDialog.py delete mode 100644 timer-applet/src/timerapplet/ui/Notifier.py delete mode 100644 timer-applet/src/timerapplet/ui/PieMeter.py delete mode 100644 timer-applet/src/timerapplet/ui/PreferencesDialog.py delete mode 100644 timer-applet/src/timerapplet/ui/PulseButton.py delete mode 100644 timer-applet/src/timerapplet/ui/ScrollableButtonList.py delete mode 100644 timer-applet/src/timerapplet/ui/StartNextTimerDialog.py delete mode 100644 timer-applet/src/timerapplet/ui/StartTimerDialog.py delete mode 100644 timer-applet/src/timerapplet/ui/StatusButton.py delete mode 100644 timer-applet/src/timerapplet/ui/__init__.py delete mode 100644 timer-applet/src/timerapplet/utils.py diff --git a/Makefile.am b/Makefile.am index 6b2f46f8..0e988730 100644 --- a/Makefile.am +++ b/Makefile.am @@ -39,10 +39,6 @@ if BUILD_TIMERAPPLET timerapplet_SUBDIR = timerapplet endif -if BUILD_TIMER_APPLET -timer_applet_SUBDIR = timer-applet -endif - always_built_SUBDIRS = \ charpick \ drivemount \ @@ -63,8 +59,7 @@ SUBDIRS = \ $(accessx_status_SUBDIR) \ $(invest_applet_SUBDIR) \ $(cpufreq_SUBDIR) \ - $(timerapplet_SUBDIR) \ - $(timer_applet_SUBDIR) + $(timerapplet_SUBDIR) DIST_SUBDIRS = \ po \ @@ -82,7 +77,6 @@ DIST_SUBDIRS = \ trashapplet \ cpufreq \ invest-applet \ - timer-applet \ command \ null_applet diff --git a/configure.ac b/configure.ac index 68011189..9bd24188 100644 --- a/configure.ac +++ b/configure.ac @@ -437,15 +437,6 @@ dnl *************************************************************************** enable_stickynotes="yes" AM_CONDITIONAL(BUILD_STICKYNOTES_APPLET, test "x$enable_stickynotes" = "xyes") -dnl *************************************************************************** -dnl *** Timer applet specific checks *** -dnl *************************************************************************** -AC_ARG_ENABLE([timer-applet], - AC_HELP_STRING([--enable-timer-applet], [Enable the timer applet.]), - enable_timerapplet=$enableval, - enable_timerapplet=no) -AM_CONDITIONAL(BUILD_TIMER_APPLET, test "x$enable_timerapplet" = "xyes") - dnl *************************************************************************** dnl *** keyboard accessibility status applet check *** dnl *************************************************************************** @@ -705,14 +696,6 @@ cpufreq/src/cpufreq-selector/Makefile cpufreq/pixmaps/Makefile cpufreq/help/Makefile timerapplet/Makefile -timer-applet/Makefile -timer-applet/data/Makefile -timer-applet/images/Makefile -timer-applet/src/Makefile -timer-applet/src/timerapplet/Makefile -timer-applet/src/timerapplet/controllers/Makefile -timer-applet/src/timerapplet/core/Makefile -timer-applet/src/timerapplet/ui/Makefile command/Makefile null_applet/Makefile ]) @@ -747,7 +730,6 @@ mate-applets-$VERSION configure summary: - stickynotes $enable_stickynotes - timerapplet $HAVE_LIBNOTIFY - trashapplet always - - timer-applet $enable_timerapplet Using DBUS: $HAVE_DBUS Using NetworkManager: $HAVE_NETWORKMANAGER diff --git a/timer-applet/AUTHORS b/timer-applet/AUTHORS deleted file mode 100644 index a12bc88c..00000000 --- a/timer-applet/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Jimmy Do -Stefano Karapetsas diff --git a/timer-applet/Makefile.am b/timer-applet/Makefile.am deleted file mode 100644 index 106cc3f9..00000000 --- a/timer-applet/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = data images src diff --git a/timer-applet/data/Makefile.am b/timer-applet/data/Makefile.am deleted file mode 100644 index 49f3b908..00000000 --- a/timer-applet/data/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -serverdir = $(libdir)/matecomponent/servers -server_in_files = TimerApplet.server.in -server_DATA = $(server_in_files:.server.in=.server) - -$(server_in_files): $(server_in_files:.server.in=.server.in.in) Makefile - sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@ - -schemasdir = $(MATECONF_SCHEMA_FILE_DIR) -schemas_in_files = timer-applet.schemas.in -schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) - -pkgdata_DATA = \ - TimerApplet.xml \ - timer-applet.glade - -EXTRA_DIST = \ - TimerApplet.server.in.in \ - $(pkgdata_DATA) \ - $(schemas_in_files) - -CLEANFILES = \ - $(server_DATA) \ - $(server_in_files) \ - $(schemas_DATA) - -@INTLTOOL_SERVER_RULE@ -@INTLTOOL_SCHEMAS_RULE@ diff --git a/timer-applet/data/TimerApplet.server.in.in b/timer-applet/data/TimerApplet.server.in.in deleted file mode 100644 index 5c7a826d..00000000 --- a/timer-applet/data/TimerApplet.server.in.in +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/timer-applet/data/TimerApplet.xml b/timer-applet/data/TimerApplet.xml deleted file mode 100644 index 67df361c..00000000 --- a/timer-applet/data/TimerApplet.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/timer-applet/data/timer-applet.glade b/timer-applet/data/timer-applet.glade deleted file mode 100644 index 2ac443e6..00000000 --- a/timer-applet/data/timer-applet.glade +++ /dev/null @@ -1,1302 +0,0 @@ - - - - - - Start Timer - dialog - False - - - True - - - True - 12 - - - True - 6 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - - - - False - False - 0 - - - - - True - 6 - - - True - 0 - _Name: - True - name_entry - - - False - False - 0 - - - - - True - True - True - - - 1 - - - - - False - False - 1 - - - - - True - True - - - True - - - True - 0 - none - - - True - 12 - - - True - - - True - 2 - - - True - - - 3 - - - - - Start automatically - True - False - True - False - True - - - 1 - 2 - 3 - - - - - 0 - - - - - - - - - True - <b>Define next timer</b> - True - - - label_item - - - - - 0 - - - - - True - 0 - none - - - True - 12 - - - True - 3 - - - 50 - True - True - 5 - Execute: - - - 0 - - - - - True - True - - - - 5 - 1 - - - - - - - - - True - <b>Run custom command</b> - True - - - label_item - - - - - 1 - - - - - True - True - True - - - 2 - - - - - - - True - Run executable after timer finished. - Advanced - - - label_item - - - - - 2 - - - - - True - end - - - S_ave as Preset - True - True - True - False - True - - - False - False - 0 - - - - - False - False - 3 - - - - - False - False - 0 - - - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - none - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 12 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 6 - - - True - - - - - - 0 - - - - - Mana_ge Presets - True - True - False - True - - - False - False - 1 - - - - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - <b>_Presets</b> - True - True - - - label_item - - - - - 2 - - - - - 1 - - - - - True - end - - - gtk-cancel - -6 - True - True - True - False - True - - - False - False - 0 - - - - - S_tart Timer - -5 - True - True - True - False - True - - - False - False - 1 - - - - - False - False - end - 0 - - - - - - - Manage Presets - dialog - False - - - True - - - True - 12 - 0 - none - - - True - 12 - - - True - 6 - - - True - True - never - automatic - in - - - True - True - False - - - - - 0 - - - - - True - 6 - - - _Delete - True - True - False - True - - - 0 - - - - - _Edit... - True - True - False - True - - - 1 - - - - - _Add... - True - True - False - True - - - 2 - - - - - False - False - 1 - - - - - - - - - True - <b>_Presets</b> - True - True - - - label_item - - - - - 1 - - - - - True - end - - - gtk-close - -7 - True - True - True - False - True - - - False - False - 0 - - - - - False - end - 0 - - - - - - - Timer Preferences - 189 - dialog - False - - - True - - - True - 12 - - - _Show remaining time while timer is running - True - True - False - True - True - - - False - False - 0 - - - - - True - - - _Play notification sound - True - True - False - True - True - - - False - False - 0 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 12 - - - True - - - Use d_efault sound - True - True - False - True - True - - - False - False - 0 - - - - - True - - - Use c_ustom sound - True - True - False - True - True - use_default_sound_radio - - - False - False - 0 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 12 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Choose A Sound File - - - - - False - False - 1 - - - - - False - False - 1 - - - - - - - 0 - - - - - False - False - 1 - - - - - False - False - 1 - - - - - _Show popup notification - True - True - False - _Show popup notification after timer has ended. - True - True - - - False - False - 2 - - - - - S_how pulsing panel icon - True - True - False - Show pulsing panel icon after timer has ended. - True - True - - - False - False - 3 - - - - - 1 - - - - - True - end - - - gtk-close - -7 - True - True - True - False - True - - - False - False - 0 - - - - - False - end - 0 - - - - - - - Add Preset - dialog - False - - - True - - - True - 12 - - - True - 0 - none - - - True - 12 - 12 - - - True - True - True - - - - - - - True - <b>_Name</b> - True - True - - - label_item - - - - - False - False - 0 - - - - - True - 0 - none - - - True - 12 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - - - - - - - - True - <b>_Duration</b> - True - True - - - label_item - - - - - 1 - - - - - True - 0 - none - - - True - 12 - 12 - - - True - True - - - - - - - True - Run custom command after timer has ended. - <b>Custom command</b> - True - - - label_item - - - - - 2 - - - - - True - 0 - none - - - True - 12 - 12 - - - True - - - True - True - - - 0 - - - - - Initiate automatically - True - True - False - True - - - 1 - - - - - - - - - True - <b>Interval timer</b> - True - - - label_item - - - - - 3 - - - - - 1 - - - - - True - end - - - gtk-cancel - -6 - True - True - True - False - True - - - False - False - 0 - - - - - gtk-save - -5 - True - True - True - False - True - - - False - False - 1 - - - - - False - end - 0 - - - - - - - center - normal - Copyright (c) 2010 by Kenny Meyer. -Copyright (c) 2007 by Jimmy Do - A timer applet for the perfect egg and beyond! - https://launchpad.net/timer-applet - Timer Applet - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geomraphical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. - Jimmy Do <jimmydo@users.sourceforge.net> - - - True - - - - - - True - - - False - end - 0 - - - - - - diff --git a/timer-applet/data/timer-applet.schemas.in b/timer-applet/data/timer-applet.schemas.in deleted file mode 100644 index eadc902a..00000000 --- a/timer-applet/data/timer-applet.schemas.in +++ /dev/null @@ -1,87 +0,0 @@ - - - - /schemas/apps/timer-applet/prefs/play_notification_sound - /apps/timer-applet/prefs/play_notification_sound - timer-applet - bool - false - - Play notification sound - Play a notification sound when the timer finishes a countdown - - - - - /schemas/apps/timer-applet/prefs/use_custom_notification_sound - /apps/timer-applet/prefs/use_custom_notification_sound - timer-applet - bool - false - - Use a custom notification sound - Use the custom notification sound specified in custom_notification_sound_path - - - - - /schemas/apps/timer-applet/prefs/custom_notification_sound_path - /apps/timer-applet/prefs/custom_notification_sound_path - timer-applet - string - - - Path to a custom notification sound - Path to a sound file that will be played when the timer finishes a countdown - - - - - /schemas/apps/timer-applet/prefs/show_pulsing_icon - /apps/timer-applet/prefs/show_pulsing_icon - timer-applet - bool - true - - Show Pulsing icon - Show pulsing tray icon when timer finished - - - - - /schemas/apps/timer-applet/prefs/show_popup_notification - /apps/timer-applet/prefs/show_popup_notification - timer-applet - bool - true - - Show Popup notification - Show Popup notification in the notification area - - - - - /schemas/apps/timer-applet/prefs/show_remaining_time - /apps/timer-applet/prefs/show_remaining_time - timer-applet - bool - true - - Show remaining time - Show the remaining time while the timer is running or paused - - - - - /schemas/apps/timer-applet/prefs/play_beep - /apps/timer-applet/prefs/play_beep - timer-applet - bool - false - - Play a beep sound - Play a beep sound on a computer's internal speaker when the timer finishes. This may not have an effect on all computers. - - - - diff --git a/timer-applet/images/Makefile.am b/timer-applet/images/Makefile.am deleted file mode 100644 index fd039a73..00000000 --- a/timer-applet/images/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -icondir = $(datadir)/pixmaps -icon_DATA = timer-applet.png - -EXTRA_DIST = $(icon_DATA) - diff --git a/timer-applet/images/timer-applet.png b/timer-applet/images/timer-applet.png deleted file mode 100644 index cb54c3c6..00000000 Binary files a/timer-applet/images/timer-applet.png and /dev/null differ diff --git a/timer-applet/images/timer-applet.svg b/timer-applet/images/timer-applet.svg deleted file mode 100644 index 8378578e..00000000 --- a/timer-applet/images/timer-applet.svg +++ /dev/null @@ -1,725 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - diff --git a/timer-applet/src/Makefile.am b/timer-applet/src/Makefile.am deleted file mode 100644 index d266f640..00000000 --- a/timer-applet/src/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -SUBDIRS = timerapplet - -libexec_SCRIPTS = timer-applet - -EXTRA_DIST = \ - timer-applet diff --git a/timer-applet/src/timer-applet b/timer-applet/src/timer-applet deleted file mode 100755 index cd550fbb..00000000 --- a/timer-applet/src/timer-applet +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2010 Kenny Meyer -# Copyright (C) 2008 Jimmy Do -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -from os import path -import gettext -import locale -import sys -import gtk -import mateapplet -from timerapplet import config -from timerapplet.controllers import GlobalController, TimerApplet, TimerService, TimerManagerService -from timerapplet.core import AppletMateConfWrapper, Timer - -from dbus.mainloop.glib import DBusGMainLoop -DBusGMainLoop(set_as_default=True) - -DBUS_BUS_NAME = 'net.launchpad.timerapplet.TimerApplet' -DBUS_OBJ_NAMESPACE = '/net/launchpad/timerapplet/TimerApplet' - -gettext.bindtextdomain(config.GETTEXT_PACKAGE, config.LOCALE_DIR) -gettext.bind_textdomain_codeset(config.GETTEXT_PACKAGE, 'UTF-8') -gettext.textdomain(config.GETTEXT_PACKAGE) -locale.bindtextdomain(config.GETTEXT_PACKAGE, config.LOCALE_DIR) -locale.bind_textdomain_codeset(config.GETTEXT_PACKAGE, 'UTF-8') -locale.textdomain(config.GETTEXT_PACKAGE) - -global_controller = GlobalController() -timer_manager_obj_path = path.join(DBUS_OBJ_NAMESPACE, 'TimerManager') -print 'Timer Manager D-Bus object path: %s' % timer_manager_obj_path - -timer_manager = None -try: - timer_manager = TimerManagerService(DBUS_BUS_NAME, timer_manager_obj_path) -except Exception, err: - print 'ERROR: Could not start TimerManagerService. D-Bus support will not be available. Error message: %s' % err - -def check_dependencies(): - # Check for optional dependencies - try: - import dbus # >= 0.80 - except ImportError, err: - print 'Missing optional dependency: %s' % err - - # Check for required dependencies - try: - import gobject # >= 2.12 - import gtk # >= 2.10, includes pango - import gtk.glade # >= 2.10 - import mateconf # >= 2.18 - import mate # >= 2.18, includes matecomponent.ui - import mateapplet # >= 2.18, included in python-mate2-desktop - import pynotify # >= 0.1.1 - except ImportError, err: - dialog = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, - buttons=gtk.BUTTONS_CLOSE, - message_format='%s\n\nPlease install required dependencies.' % err) - dialog.run() - dialog.destroy() - sys.exit(1) - -def get_timer_id(mateconf_wrapper): - path_components = mateconf_wrapper.get_base_path().split('/') - - # Use the second component from the end, which should usually be 'applet_*', - # where '*' is some integer assigned by the system. - # It could also be 'timer-applet' if we're running in standalone mode. - # D-Bus doesn't like hyphens in object paths, so we have to replace them - # with underscores. - return path_components[-2].replace('-', '_') - -def applet_factory(applet, iid): - check_dependencies() - - timer = Timer() - mateconf_wrapper = AppletMateConfWrapper(applet, - '/schemas/apps/timer-applet/prefs', - '/apps/timer-applet/prefs') - timer_id = get_timer_id(mateconf_wrapper) - print 'Timer ID: %s' % timer_id - - if timer_manager is not None: - timer_manager.register_timer_id(timer_id) - applet.connect('destroy', lambda sender: timer_manager.unregister_timer_id(timer_id)) - - TimerApplet(global_controller.get_presets_store(), - global_controller.get_manage_presets_dialog(), - applet, - timer, - mateconf_wrapper) - - timer_obj_path = path.join(DBUS_OBJ_NAMESPACE, 'Timers', timer_id) - print 'Timer D-Bus object path: %s' % timer_obj_path - - try: - TimerService(DBUS_BUS_NAME, timer_obj_path, timer) - except Exception, err: - print 'ERROR: Could not start TimerService. D-Bus support will not be available. Error message: %s' % err - - return True - -if __name__ == '__main__': - windowed_mode = (len(sys.argv) > 1 and sys.argv[1] == '-w') - - if windowed_mode: - win = gtk.Window() - win.set_title('Timer Applet') - applet = mateapplet.Applet() - applet_factory(applet, None) - applet.reparent(win) - - applet.connect('destroy', gtk.main_quit) - win.show() - - gtk.main() - else: - mateapplet.matecomponent_factory( - 'OAFIID:TimerApplet_Factory', - mateapplet.Applet.__gtype__, - config.PACKAGE, - config.VERSION, - applet_factory) diff --git a/timer-applet/src/timerapplet/Makefile.am b/timer-applet/src/timerapplet/Makefile.am deleted file mode 100644 index 08f474c0..00000000 --- a/timer-applet/src/timerapplet/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -SUBDIRS = controllers core ui - -defs.py: defs.py.in Makefile - sed -e "s|\@PACKAGE\@|$(PACKAGE)|" \ - -e "s|\@VERSION\@|$(VERSION)|" \ - -e "s|\@RESOURCESDIR\@|$(pkgdatadir)|" \ - -e "s|\@IMAGESDIR\@|$(datadir)/pixmaps|" \ - -e "s|\@LOCALEDIR\@|$(localedir)|" \ - -e "s|\@GETTEXT_PACKAGE\@|$(GETTEXT_PACKAGE)|" $< > $@ - -EXTRA_DIST = \ - defs.py.in - -CLEANFILES = \ - defs.py - -# Need this so that defs.py is actually created after cleaning. -BUILT_SOURCES = defs.py - -moduledir = $(pythondir)/timerapplet -module_PYTHON = \ - __init__.py \ - config.py \ - defs.py \ - utils.py \ - logger.py - diff --git a/timer-applet/src/timerapplet/__init__.py b/timer-applet/src/timerapplet/__init__.py deleted file mode 100644 index 8b137891..00000000 --- a/timer-applet/src/timerapplet/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/timer-applet/src/timerapplet/config.py b/timer-applet/src/timerapplet/config.py deleted file mode 100644 index 42376845..00000000 --- a/timer-applet/src/timerapplet/config.py +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (C) 2008 Jimmy Do -# -# 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 - -import os.path as path - -try: - from defs import * -except ImportError: - PACKAGE = 'timer-applet' - VERSION = '0' - GETTEXT_PACKAGE = '' - LOCALE_DIR = '' - RESOURCES_DIR = path.join(path.dirname(__file__), '../../data') - IMAGES_DIR = path.join(path.dirname(__file__), '../../images') - -print 'Using these definitions:' -print 'GETTEXT_PACKAGE: %s' % GETTEXT_PACKAGE -print 'LOCALE_DIR: %s' % LOCALE_DIR -print 'RESOURCES_DIR: %s' % RESOURCES_DIR -print 'IMAGES_DIR: %s' % IMAGES_DIR - -GLADE_PATH = path.join(RESOURCES_DIR, 'timer-applet.glade') -POPUP_MENU_FILE_PATH = path.join(RESOURCES_DIR, 'TimerApplet.xml') -ICON_PATH = path.join(IMAGES_DIR, 'timer-applet.png') -PRESETS_PATH = path.expanduser('~/.config/mate/timer-applet/presets.xml') -DEFAULT_SOUND_PATH = '/usr/share/sounds/gtk-events/clicked.wav' diff --git a/timer-applet/src/timerapplet/controllers/GlobalController.py b/timer-applet/src/timerapplet/controllers/GlobalController.py deleted file mode 100644 index fd3af2b1..00000000 --- a/timer-applet/src/timerapplet/controllers/GlobalController.py +++ /dev/null @@ -1,91 +0,0 @@ -# Copyright (C) 2008 Jimmy Do -# -# 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 - -from gettext import gettext as _ -import gtk -from timerapplet import core -from timerapplet import ui -from timerapplet import utils -from timerapplet import config - -class GlobalController(object): - def __init__(self): - self._presets_store = core.PresetsStore(config.PRESETS_PATH) - self._manage_presets_dialog = ui.ManagePresetsDialog(config.GLADE_PATH, - self._presets_store.get_model(), - lambda row_iter: utils.get_preset_display_text(self._presets_store, - row_iter)) - - self._manage_presets_dialog.connect('clicked-add', self._on_mgr_clicked_add) - self._manage_presets_dialog.connect('clicked-edit', self._on_mgr_clicked_edit) - self._manage_presets_dialog.connect('clicked-remove', self._on_mgr_clicked_remove) - - gtk.window_set_default_icon_from_file(config.ICON_PATH) - - def get_presets_store(self): - return self._presets_store - - def get_manage_presets_dialog(self): - return self._manage_presets_dialog - - def _on_mgr_clicked_add(self, sender, data=None): - add_dialog = ui.AddEditPresetDialog( - config.GLADE_PATH, - _('Add Preset'), - lambda name: utils.is_valid_preset_name(name, self._presets_store)) - - result = add_dialog.get_preset() - if result is not None: - (name, hours, minutes, seconds, command, next_timer, auto_start) = result - self._presets_store.add_preset(name, hours, minutes, seconds, - command, next_timer, auto_start) - - def _on_mgr_clicked_edit(self, sender, row_path, data=None): - row_iter = self._presets_store.get_model().get_iter(row_path) - (name, hours, minutes, seconds, command, next_timer, auto_start) = \ - self._presets_store.get_preset(row_iter) - - edit_dialog = ui.AddEditPresetDialog(config.GLADE_PATH, - _('Edit Preset'), - lambda name: utils.is_valid_preset_name(name, - self._presets_store, - (name,)), - name, - hours, - minutes, - seconds, - command, - next_timer, - auto_start - ) - - result = edit_dialog.get_preset() - if result is not None: - (name, hours, minutes, seconds, command, next_timer, auto_start) = result - self._presets_store.modify_preset(row_iter, name, hours, minutes, - seconds, command, next_timer, - auto_start) - - def _on_mgr_clicked_remove(self, sender, row_path, data=None): - row_iter = self._presets_store.get_model().get_iter(row_path) - self._presets_store.remove_preset(row_iter) - - # TODO - def _on_mgr_next_timer_is_being_edited(self, sender, row_path, data=None): - """Show a dropdown widget to help completing the next timer.""" - raise NotImplementedError("Not implemented, yet") - - diff --git a/timer-applet/src/timerapplet/controllers/Makefile.am b/timer-applet/src/timerapplet/controllers/Makefile.am deleted file mode 100644 index bb5018d6..00000000 --- a/timer-applet/src/timerapplet/controllers/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -moduledir = $(pythondir)/timerapplet/controllers -module_PYTHON = \ - __init__.py \ - GlobalController.py \ - TimerApplet.py \ - TimerManagerService.py \ - TimerService.py - diff --git a/timer-applet/src/timerapplet/controllers/TimerApplet.py b/timer-applet/src/timerapplet/controllers/TimerApplet.py deleted file mode 100644 index 2771038c..00000000 --- a/timer-applet/src/timerapplet/controllers/TimerApplet.py +++ /dev/null @@ -1,637 +0,0 @@ -# Copyright (C) 2008 Jimmy Do -# Copyright (C) 2010 Kenny Meyer -# -# 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 - -from gettext import gettext as _ -from gettext import ngettext -from datetime import datetime, timedelta -import mateapplet -import gst -import gtk -import gtk.glade as glade -import gtk.gdk as gdk -import subprocess -import shlex -import threading -from timerapplet import config -from timerapplet import core -from timerapplet import ui -from timerapplet import utils - -def on_widget_button_press_event(sender, event, data=None): - if event.button != 1: - sender.emit_stop_by_name('button-press-event') - return False - -def force_no_focus_padding(widget): - gtk.rc_parse_string('\n' - ' style "timer-applet-button-style"\n' - ' {\n' - ' GtkWidget::focus-line-width=0\n' - ' GtkWidget::focus-padding=0\n' - ' }\n' - '\n' - ' widget "*.timer-applet-button" style "timer-applet-button-style"\n' - '\n') - widget.set_name('timer-applet-button') - -class TimerApplet(object): - # MateConf key identifiers - ## You can find Timer Applet's schemas file in data/timer-applet.schemas.in - _SHOW_REMAINING_TIME_KEY = 'show_remaining_time' - _PLAY_SOUND_KEY = 'play_notification_sound' - _USE_CUSTOM_SOUND_KEY = 'use_custom_notification_sound' - _SHOW_POPUP_NOTIFICATION_KEY = 'show_popup_notification' - _SHOW_PULSING_ICON_KEY = 'show_pulsing_icon' - _CUSTOM_SOUND_PATH_KEY = 'custom_notification_sound_path' - - _PRESETS_PLACEHOLDER_NAME = 'Placeholder' - _PRESETS_PLACEHOLDER_PATH = '/popups/popup/Presets/' + _PRESETS_PLACEHOLDER_NAME - _PRESETS_PATH = '/popups/popup/Presets' - - def __init__(self, presets_store, manage_presets_dialog, applet, timer, mateconf_wrapper): - self._presets_store = presets_store - self._manage_presets_dialog = manage_presets_dialog - self._applet = applet - self._timer = timer - - self._gst_playbin = gst.element_factory_make('playbin', 'player') - def bus_event(bus, message): - t = message.type - if t == gst.MESSAGE_EOS: - self._gst_playbin.set_state(gst.STATE_NULL) - elif t == gst.MESSAGE_ERROR: - self._gst_playbin.set_state(gst.STATE_NULL) - err, debug = message.parse_error() - print 'Error playing sound: %s' % err, debug - return True - self._gst_playbin.get_bus().add_watch(bus_event) - - self._status_button = ui.StatusButton() - self._notifier = ui.Notifier('TimerApplet', gtk.STOCK_DIALOG_INFO, self._status_button) - self._start_next_timer_dialog = ui.StartNextTimerDialog( - config.GLADE_PATH, - "Start next timer", - "Would you like to start the next timer?") - self._start_timer_dialog = ui.StartTimerDialog(config.GLADE_PATH, - lambda name: utils.is_valid_preset_name(name, - self._presets_store), - self._presets_store.get_model(), - lambda row_iter: utils.get_preset_display_text(self._presets_store, - row_iter)) - self._continue_dialog = ui.ContinueTimerDialog(config.GLADE_PATH, - _('Continue timer countdown?'), - _('The timer is currently paused. Would you like to continue countdown?')) - self._preferences_dialog = ui.PreferencesDialog(config.GLADE_PATH) - self._mateconf = mateconf_wrapper - - self._about_dialog = glade.XML(config.GLADE_PATH, 'about_dialog').get_widget('about_dialog') - self._about_dialog.set_version(config.VERSION) - - self._applet.set_applet_flags(mateapplet.EXPAND_MINOR) - self._applet.setup_menu_from_file( - None, - config.POPUP_MENU_FILE_PATH, - None, - [('PauseTimer', lambda component, verb: self._timer.stop()), - ('ContinueTimer', lambda component, verb: self._timer.start()), - ('StopTimer', lambda component, verb: self._timer.reset()), - ('RestartTimer', lambda component, verb: self._restart_timer()), - ('StartNextTimer', lambda component, verb: self._start_next_timer()), - ('ManagePresets', lambda component, verb: self._manage_presets_dialog.show()), - ('Preferences', lambda component, - verb: self._preferences_dialog.show()), - ('About', lambda component, verb: self._about_dialog.show())] - ) - self._applet.add(self._status_button) - - # Remove padding around button contents. - force_no_focus_padding(self._status_button) - - # TODO: - # Fix bug in which button would not propogate middle-clicks - # and right-clicks to the applet. - self._status_button.connect('button-press-event', on_widget_button_press_event) - - self._status_button.set_relief(gtk.RELIEF_NONE) - self._status_button.set_icon(config.ICON_PATH); - - self._applet.set_tooltip_text(_("Timer Applet")) - - self._connect_signals() - self._update_status_button() - self._update_popup_menu() - self._update_preferences_dialog() - self._status_button.show() - self._applet.show() - - def _connect_signals(self): - self._applet.connect('change-orient', lambda applet, orientation: self._update_status_button()) - self._applet.connect('change-size', lambda applet, size: self._update_status_button()) - self._applet.connect('change-background', self._on_applet_change_background) - self._applet.connect('destroy', self._on_applet_destroy) - - self._presets_store.get_model().connect('row-deleted', - lambda model, - row_path: self._update_popup_menu()) - self._presets_store.get_model().connect('row-changed', - lambda model, - row_path, - row_iter: self._update_popup_menu()) - - self._timer.connect('time-changed', self._on_timer_time_changed) - self._timer.connect('state-changed', self._on_timer_state_changed) - self._status_button.connect('clicked', self._on_status_button_clicked) - self._start_timer_dialog.connect('clicked-start', - self._on_start_dialog_clicked_start) - self._start_timer_dialog.connect('clicked-manage-presets', - self._on_start_dialog_clicked_manage_presets) - self._start_timer_dialog.connect('clicked-save', - self._on_start_dialog_clicked_save) - self._start_timer_dialog.connect('clicked-preset', - self._on_start_dialog_clicked_preset) - self._start_timer_dialog.connect('double-clicked-preset', - self._on_start_dialog_double_clicked_preset) - - self._preferences_dialog.connect('show-remaining-time-changed', self._on_prefs_show_time_changed) - self._preferences_dialog.connect('play-sound-changed', self._on_prefs_play_sound_changed) - self._preferences_dialog.connect('use-custom-sound-changed', self._on_prefs_use_custom_sound_changed) - self._preferences_dialog.connect('show-popup-notification-changed', self._on_prefs_show_popup_notification_changed) - self._preferences_dialog.connect('show-pulsing-icon-changed', self._on_prefs_show_pulsing_icon_changed) - self._preferences_dialog.connect('custom-sound-path-changed', self._on_prefs_custom_sound_path_changed) - - self._about_dialog.connect('delete-event', gtk.Widget.hide_on_delete) - self._about_dialog.connect('response', lambda dialog, response_id: self._about_dialog.hide()) - - self._mateconf.add_notification(TimerApplet._SHOW_REMAINING_TIME_KEY, self._on_mateconf_changed) - self._mateconf.add_notification(TimerApplet._PLAY_SOUND_KEY, self._on_mateconf_changed) - self._mateconf.add_notification(TimerApplet._USE_CUSTOM_SOUND_KEY, self._on_mateconf_changed) - self._mateconf.add_notification(TimerApplet._SHOW_PULSING_ICON_KEY, self._on_mateconf_changed) - self._mateconf.add_notification(TimerApplet._SHOW_POPUP_NOTIFICATION_KEY, self._on_mateconf_changed) - self._mateconf.add_notification(TimerApplet._CUSTOM_SOUND_PATH_KEY, self._on_mateconf_changed) - - ## Private methods for updating UI ## - - def _update_status_button(self): - current_state = self._timer.get_state() - if current_state == core.Timer.STATE_IDLE: - print 'Idle' - # This label text should not be visible because the label - # is hidden when the timer is idle. - self._status_button.set_label('--:--:--') - self._status_button.set_tooltip(_('Click to start a new timer countdown.')) - elif current_state == core.Timer.STATE_RUNNING: - print 'Running' - elif current_state == core.Timer.STATE_PAUSED: - print 'Paused' - self._status_button.set_tooltip(_('Paused. Click to continue timer countdown.')) - elif current_state == core.Timer.STATE_FINISHED: - print 'Finished' - self._status_button.set_label(_('Finished')) - name_str = self._timer.get_name() - time_str = utils.get_display_text_from_datetime(self._timer.get_end_time()) - if len(name_str) > 0: - # "" finished at