[Goodies-commits] r7098 - in xfce4-power-manager/trunk: . libxfpm po src
Ali Abdallah
aliov at xfce.org
Thu Apr 2 15:36:32 CEST 2009
Author: aliov
Date: 2009-04-02 13:36:32 +0000 (Thu, 02 Apr 2009)
New Revision: 7098
Modified:
xfce4-power-manager/trunk/ChangeLog
xfce4-power-manager/trunk/TODO
xfce4-power-manager/trunk/libxfpm/xfpm-common.c
xfce4-power-manager/trunk/libxfpm/xfpm-common.h
xfce4-power-manager/trunk/libxfpm/xfpm-string.h
xfce4-power-manager/trunk/po/xfce4-power-manager.pot
xfce4-power-manager/trunk/src/xfpm-dbus-monitor.c
xfce4-power-manager/trunk/src/xfpm-dbus-monitor.h
xfce4-power-manager/trunk/src/xfpm-tray-icon.c
Log:
Added exit option in the context menu+some optimization to function calls in libxfpm common
Modified: xfce4-power-manager/trunk/ChangeLog
===================================================================
--- xfce4-power-manager/trunk/ChangeLog 2009-04-02 12:14:25 UTC (rev 7097)
+++ xfce4-power-manager/trunk/ChangeLog 2009-04-02 13:36:32 UTC (rev 7098)
@@ -1,4 +1,7 @@
+2009-04-02 15:36 Ali aliov at xfce.org
+ * : Added exit option in the context menu+some optimization to function calls in libxfpm common
+
2009-04-02 14:14 Ali aliov at xfce.org
* : Added on battery DBus signal+Fix brightness settings on battery power
Modified: xfce4-power-manager/trunk/TODO
===================================================================
--- xfce4-power-manager/trunk/TODO 2009-04-02 12:14:25 UTC (rev 7097)
+++ xfce4-power-manager/trunk/TODO 2009-04-02 13:36:32 UTC (rev 7098)
@@ -9,8 +9,6 @@
* : Support Suspend Hybrid! ( DeviceKit power will not support this ).
-* : Probably an exit option in the context menu?
-
* : Use the session logout when we do shutdown, probably use the shutdown session interface anyway.
* : Translations need to be updated.
Modified: xfce4-power-manager/trunk/libxfpm/xfpm-common.c
===================================================================
--- xfce4-power-manager/trunk/libxfpm/xfpm-common.c 2009-04-02 12:14:25 UTC (rev 7097)
+++ xfce4-power-manager/trunk/libxfpm/xfpm-common.c 2009-04-02 13:36:32 UTC (rev 7098)
@@ -19,7 +19,6 @@
*/
#include <glib.h>
-#include <glib/gi18n.h>
#include <libxfce4util/libxfce4util.h>
@@ -27,18 +26,18 @@
#include "xfpm-string.h"
static void
-xfpm_link_browser(GtkAboutDialog *about,const gchar *link,gpointer data)
+xfpm_link_browser (GtkAboutDialog *about, const gchar *link, gpointer data)
{
- gchar *cmd = g_strdup_printf("%s %s","xfbrowser4",link);
+ gchar *cmd = g_strdup_printf ("%s %s","xfbrowser4", link);
g_spawn_command_line_async (cmd, NULL);
- g_free(cmd);
+ g_free (cmd);
}
static void
-xfpm_link_mailto(GtkAboutDialog *about,const gchar *link,gpointer data)
+xfpm_link_mailto (GtkAboutDialog *about, const gchar *link, gpointer data)
{
- gchar *cmd = g_strdup_printf("%s %s","xdg-email",link);
+ gchar *cmd = g_strdup_printf( "%s %s", "xdg-email", link);
g_spawn_command_line_async (cmd, NULL);
@@ -47,20 +46,20 @@
GdkPixbuf *
-xfpm_load_icon(const char *icon_name,gint size)
+xfpm_load_icon (const char *icon_name, gint size)
{
GdkPixbuf *icon;
GError *error = NULL;
- icon = gtk_icon_theme_load_icon(gtk_icon_theme_get_default (),
- icon_name,
- size,
- GTK_ICON_LOOKUP_FORCE_SVG,
- &error);
+ icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ icon_name,
+ size,
+ GTK_ICON_LOOKUP_FORCE_SVG,
+ &error);
if ( error )
{
- g_warning("Error occured while loading icon %s: %s\n", icon_name, error->message);
- g_error_free(error);
+ g_warning ("Error occured while loading icon %s: %s\n", icon_name, error->message);
+ g_error_free (error);
}
return icon;
}
@@ -68,7 +67,7 @@
/*
* Map of int to strings shutdown values
*/
-const gchar *xfpm_int_to_shutdown_string (gint val)
+const gchar *xfpm_int_to_shutdown_string (gint val)
{
if ( val == 0 )
return "Nothing";
@@ -82,7 +81,7 @@
return "Invalid";
}
-gint xfpm_shutdown_string_to_int (const gchar *string)
+gint xfpm_shutdown_string_to_int (const gchar *string)
{
if ( xfpm_strequal("Nothing", string) )
return 0;
@@ -94,12 +93,10 @@
return 3;
return -1; /* error here */
-
-
}
void
-xfpm_lock_screen(void)
+xfpm_lock_screen (void)
{
gboolean ret = g_spawn_command_line_async ("xflock4", NULL);
@@ -126,17 +123,23 @@
}
void
-xfpm_preferences(void)
+xfpm_preferences (void)
{
g_spawn_command_line_async ("xfce4-power-manager-settings", NULL);
}
void
-xfpm_help(void)
+xfpm_help (void)
{
g_spawn_command_line_async ("xfhelp4 xfce4-power-manager.html", NULL);
}
+void
+xfpm_quit (void)
+{
+ g_spawn_command_line_async ("xfce4-power-manager -q", NULL);
+}
+
void
xfpm_about (GtkWidget *widget, gpointer data)
{
Modified: xfce4-power-manager/trunk/libxfpm/xfpm-common.h
===================================================================
--- xfce4-power-manager/trunk/libxfpm/xfpm-common.h 2009-04-02 12:14:25 UTC (rev 7097)
+++ xfce4-power-manager/trunk/libxfpm/xfpm-common.h 2009-04-02 13:36:32 UTC (rev 7098)
@@ -25,19 +25,26 @@
#include <config.h>
#endif
+#include <glib.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
GdkPixbuf* xfpm_load_icon (const gchar *icon_name,
- gint size);
+ gint size) G_GNUC_MALLOC;
-const gchar *xfpm_int_to_shutdown_string (gint val);
-gint xfpm_shutdown_string_to_int (const gchar *string);
+const gchar *xfpm_int_to_shutdown_string (gint val) G_GNUC_PURE;
+gint xfpm_shutdown_string_to_int (const gchar *string) G_GNUC_PURE;
+
void xfpm_lock_screen (void);
+
void xfpm_preferences (void);
+
void xfpm_help (void);
+
+void xfpm_quit (void);
+
void xfpm_about (GtkWidget *widget,
gpointer data);
Modified: xfce4-power-manager/trunk/libxfpm/xfpm-string.h
===================================================================
--- xfce4-power-manager/trunk/libxfpm/xfpm-string.h 2009-04-02 12:14:25 UTC (rev 7097)
+++ xfce4-power-manager/trunk/libxfpm/xfpm-string.h 2009-04-02 13:36:32 UTC (rev 7098)
@@ -24,14 +24,12 @@
#include <glib.h>
#include <string.h>
-gint xfpm_strcmp (const gchar *str1,
- const gchar *str2);
-
gboolean xfpm_strequal (const gchar *str1,
const gchar *str2);
-const gchar *xfpm_bool_to_string (gboolean value);
-gboolean xfpm_string_to_bool (const gchar *string);
+const gchar *xfpm_bool_to_string (gboolean value) G_GNUC_PURE;
+gboolean xfpm_string_to_bool (const gchar *string) G_GNUC_PURE;
+
#endif /* XFPM_STRING_H */
Modified: xfce4-power-manager/trunk/po/xfce4-power-manager.pot
===================================================================
--- xfce4-power-manager/trunk/po/xfce4-power-manager.pot 2009-04-02 12:14:25 UTC (rev 7097)
+++ xfce4-power-manager/trunk/po/xfce4-power-manager.pot 2009-04-02 13:36:32 UTC (rev 7098)
@@ -8,7 +8,7 @@
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-03-30 14:57+0200\n"
+"POT-Creation-Date: 2009-04-02 15:35+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <LL at li.org>\n"
@@ -108,7 +108,7 @@
#: ../settings/xfpm-settings.glade.h:22 ../settings/xfpm-settings.c:539
#: ../settings/xfpm-settings.c:653 ../settings/xfpm-settings.c:769
#: ../settings/xfpm-settings.c:817 ../src/xfpm-tray-icon.c:194
-#: ../src/xfpm-tray-icon.c:239
+#: ../src/xfpm-tray-icon.c:253
msgid "Suspend"
msgstr ""
@@ -138,7 +138,7 @@
#: ../settings/xfpm-settings.glade.h:29 ../settings/xfpm-settings-main.c:113
#: ../src/xfpm-main.c:125 ../src/xfpm-main.c:187 ../src/xfpm-main.c:217
-#: ../src/xfpm-tray-icon.c:290 ../src/xfce4-power-manager.desktop.in.h:2
+#: ../src/xfpm-tray-icon.c:304 ../src/xfce4-power-manager.desktop.in.h:2
msgid "Xfce Power Manager"
msgstr ""
@@ -174,7 +174,7 @@
#: ../settings/xfpm-settings.c:457 ../settings/xfpm-settings.c:545
#: ../settings/xfpm-settings.c:659 ../settings/xfpm-settings.c:775
#: ../settings/xfpm-settings.c:823 ../src/xfpm-tray-icon.c:167
-#: ../src/xfpm-tray-icon.c:224
+#: ../src/xfpm-tray-icon.c:238
msgid "Hibernate"
msgstr ""
@@ -257,8 +257,8 @@
msgid "Your battery is discharging"
msgstr ""
-#: ../src/xfpm-battery.c:112 ../src/xfpm-battery.c:369
-#: ../src/xfpm-battery.c:381
+#: ../src/xfpm-battery.c:112 ../src/xfpm-battery.c:372
+#: ../src/xfpm-battery.c:384
msgid "System is running on battery power"
msgstr ""
@@ -272,7 +272,7 @@
#: ../src/xfpm-battery.c:213 ../src/xfpm-supply.c:277 ../src/xfpm-supply.c:300
#: ../src/xfpm-tray-icon.c:115 ../src/xfpm-tray-icon.c:139
-#: ../src/xfpm-manager.c:215
+#: ../src/xfpm-manager.c:195
msgid "Xfce power manager"
msgstr ""
@@ -324,43 +324,43 @@
msgid "is almost empty"
msgstr ""
-#: ../src/xfpm-battery.c:300
+#: ../src/xfpm-battery.c:303
msgid "is not present"
msgstr ""
-#: ../src/xfpm-battery.c:331
+#: ../src/xfpm-battery.c:334
msgid "Battery not present"
msgstr ""
-#: ../src/xfpm-battery.c:353
+#: ../src/xfpm-battery.c:356
msgid "Estimated time left"
msgstr ""
-#: ../src/xfpm-battery.c:357
+#: ../src/xfpm-battery.c:360
msgid "Estimated time to be fully charged"
msgstr ""
-#: ../src/xfpm-battery.c:360
+#: ../src/xfpm-battery.c:363
msgid "hours"
msgstr ""
-#: ../src/xfpm-battery.c:360
+#: ../src/xfpm-battery.c:363
msgid "hour"
msgstr ""
-#: ../src/xfpm-battery.c:361
+#: ../src/xfpm-battery.c:364
msgid "minutes"
msgstr ""
-#: ../src/xfpm-battery.c:361
+#: ../src/xfpm-battery.c:364
msgid "minute"
msgstr ""
-#: ../src/xfpm-battery.c:365 ../src/xfpm-battery.c:377
+#: ../src/xfpm-battery.c:368 ../src/xfpm-battery.c:380
msgid "Battery"
msgstr ""
-#: ../src/xfpm-battery.c:368 ../src/xfpm-battery.c:380
+#: ../src/xfpm-battery.c:371 ../src/xfpm-battery.c:383
msgid "System is running on AC power"
msgstr ""
@@ -494,27 +494,40 @@
"to suspend the system?"
msgstr ""
-#: ../src/xfpm-engine.c:511 ../src/xfpm-engine.c:540
+#: ../src/xfpm-tray-icon.c:211
+msgid "Exit Xfce power manager"
+msgstr ""
+
+#: ../src/xfpm-tray-icon.c:213
+msgid "Quit"
+msgstr ""
+
+#: ../src/xfpm-engine.c:529 ../src/xfpm-engine.c:558
#, c-format
msgid "Permission denied"
msgstr ""
-#: ../src/xfpm-engine.c:518
+#: ../src/xfpm-engine.c:536
#, c-format
msgid "Hibernate not supported"
msgstr ""
-#: ../src/xfpm-engine.c:547
+#: ../src/xfpm-engine.c:565
#, c-format
msgid "Suspend not supported"
msgstr ""
-#: ../src/xfpm-manager.c:215
+#: ../src/xfpm-manager.c:195
msgid "HAL daemon is not running"
msgstr ""
-#: ../src/xfpm-inhibit.c:247
+#: ../src/xfpm-inhibit.c:333
#, c-format
+msgid "Invalid arguments"
+msgstr ""
+
+#: ../src/xfpm-inhibit.c:359
+#, c-format
msgid "Invalid cookie"
msgstr ""
@@ -584,69 +597,68 @@
msgid "mAh"
msgstr ""
-#: ../libxfpm/xfpm-common.c:168
+#: ../libxfpm/xfpm-common.c:171
msgid "translator-credits"
msgstr ""
-#: ../panel-plugins/brightness/brightness-plugin.c:462
-#: ../panel-plugins/brightness/brightness-plugin.c:519
+#: ../panel-plugins/brightness/brightness-plugin.c:460
+#: ../panel-plugins/brightness/brightness-plugin.c:517
msgid "Control your LCD brightness level"
msgstr ""
-#: ../panel-plugins/brightness/brightness-plugin.c:466
-#: ../panel-plugins/brightness/brightness-plugin.c:523
+#: ../panel-plugins/brightness/brightness-plugin.c:464
+#: ../panel-plugins/brightness/brightness-plugin.c:521
msgid "No device found"
msgstr ""
-#: ../panel-plugins/brightness/brightness-plugin.c:537
+#: ../panel-plugins/brightness/brightness-plugin.c:535
#: ../panel-plugins/brightness/xfce4-brightness-plugin.desktop.in.in.h:1
msgid "Brightness plugin"
msgstr ""
-#: ../panel-plugins/inhibit/inhibit-plugin.c:205
-#: ../panel-plugins/inhibit/inhibit-plugin.c:429
-#: ../panel-plugins/inhibit/inhibit-plugin.c:437
+#: ../panel-plugins/inhibit/inhibit-plugin.c:221
+#: ../panel-plugins/inhibit/inhibit-plugin.c:445
msgid "No power manager instance running"
msgstr ""
-#: ../panel-plugins/inhibit/inhibit-plugin.c:208
+#: ../panel-plugins/inhibit/inhibit-plugin.c:224
msgid "Automatic sleep inhibited"
msgstr ""
-#: ../panel-plugins/inhibit/inhibit-plugin.c:214
+#: ../panel-plugins/inhibit/inhibit-plugin.c:230
msgid "Another application is disabling the automatic sleep"
msgstr ""
-#: ../panel-plugins/inhibit/inhibit-plugin.c:216
+#: ../panel-plugins/inhibit/inhibit-plugin.c:232
msgid "Automatic sleep enabled"
msgstr ""
-#: ../panel-plugins/inhibit/inhibit-plugin.c:288
+#: ../panel-plugins/inhibit/inhibit-plugin.c:304
msgid "Power manager automatic sleep is disabled"
msgstr ""
-#: ../panel-plugins/inhibit/inhibit-plugin.c:289
+#: ../panel-plugins/inhibit/inhibit-plugin.c:305
msgid "Power manager automatic sleep is enabled"
msgstr ""
-#: ../panel-plugins/inhibit/inhibit-plugin.c:292
-#: ../panel-plugins/inhibit/inhibit-plugin.c:328
-#: ../panel-plugins/inhibit/inhibit-plugin.c:515
-#: ../panel-plugins/inhibit/inhibit-plugin.c:617
+#: ../panel-plugins/inhibit/inhibit-plugin.c:308
+#: ../panel-plugins/inhibit/inhibit-plugin.c:344
+#: ../panel-plugins/inhibit/inhibit-plugin.c:523
+#: ../panel-plugins/inhibit/inhibit-plugin.c:625
#: ../panel-plugins/inhibit/xfce4-inhibit-plugin.desktop.in.in.h:1
msgid "Inhibit plugin"
msgstr ""
-#: ../panel-plugins/inhibit/inhibit-plugin.c:302
-#: ../panel-plugins/inhibit/inhibit-plugin.c:338
-#: ../panel-plugins/inhibit/inhibit-plugin.c:525
+#: ../panel-plugins/inhibit/inhibit-plugin.c:318
+#: ../panel-plugins/inhibit/inhibit-plugin.c:354
+#: ../panel-plugins/inhibit/inhibit-plugin.c:533
msgid "Don't show again"
msgstr ""
-#: ../panel-plugins/inhibit/inhibit-plugin.c:329
+#: ../panel-plugins/inhibit/inhibit-plugin.c:345
msgid "Power manager disconnected"
msgstr ""
-#: ../panel-plugins/inhibit/inhibit-plugin.c:516
+#: ../panel-plugins/inhibit/inhibit-plugin.c:524
msgid "Power manager is connected"
msgstr ""
Modified: xfce4-power-manager/trunk/src/xfpm-dbus-monitor.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-dbus-monitor.c 2009-04-02 12:14:25 UTC (rev 7097)
+++ xfce4-power-manager/trunk/src/xfpm-dbus-monitor.c 2009-04-02 13:36:32 UTC (rev 7098)
@@ -175,12 +175,26 @@
return XFPM_DBUS_MONITOR (xfpm_dbus_monitor_object);
}
-void xfpm_dbus_monitor_add_match (XfpmDBusMonitor *monitor, const gchar *unique_name)
+gboolean xfpm_dbus_monitor_add_match (XfpmDBusMonitor *monitor, const gchar *unique_name)
{
- g_return_if_fail (XFPM_IS_DBUS_MONITOR (monitor) );
- g_return_if_fail (unique_name != NULL);
+ int i = 0;
+ gchar *name;
+ g_return_val_if_fail (XFPM_IS_DBUS_MONITOR (monitor), FALSE);
+ g_return_val_if_fail (unique_name != NULL, FALSE);
+
+ for ( i = 0; i<monitor->priv->array->len; i++)
+ {
+ name = g_ptr_array_index (monitor->priv->array, i);
+ if ( g_strcmp0 (name, unique_name) == 0 )
+ {
+ return FALSE;
+ }
+ }
+
g_ptr_array_add (monitor->priv->array, g_strdup (unique_name));
+
+ return TRUE;
}
gboolean xfpm_dbus_monitor_remove_match (XfpmDBusMonitor *monitor, const gchar *unique_name)
Modified: xfce4-power-manager/trunk/src/xfpm-dbus-monitor.h
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-dbus-monitor.h 2009-04-02 12:14:25 UTC (rev 7097)
+++ xfce4-power-manager/trunk/src/xfpm-dbus-monitor.h 2009-04-02 13:36:32 UTC (rev 7098)
@@ -49,7 +49,7 @@
GType xfpm_dbus_monitor_get_type (void) G_GNUC_CONST;
XfpmDBusMonitor *xfpm_dbus_monitor_new (void);
-void xfpm_dbus_monitor_add_match (XfpmDBusMonitor *monitor,
+gboolean xfpm_dbus_monitor_add_match (XfpmDBusMonitor *monitor,
const gchar *unique_name);
gboolean xfpm_dbus_monitor_remove_match (XfpmDBusMonitor *monitor,
Modified: xfce4-power-manager/trunk/src/xfpm-tray-icon.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-tray-icon.c 2009-04-02 12:14:25 UTC (rev 7097)
+++ xfce4-power-manager/trunk/src/xfpm-tray-icon.c 2009-04-02 13:36:32 UTC (rev 7098)
@@ -204,6 +204,20 @@
}
static void
+xfpm_tray_icon_exit_activated_cb (GtkWidget *w, gpointer data)
+{
+ gboolean ret;
+
+ ret = xfce_confirm (_("Exit Xfce power manager"),
+ GTK_STOCK_YES,
+ _("Quit"));
+ if ( ret )
+ {
+ xfpm_quit ();
+ }
+}
+
+static void
xfpm_tray_icon_popup_menu_cb (GtkStatusIcon *icon, guint button,
guint activate_time, XfpmTrayIcon *tray)
{
@@ -298,6 +312,16 @@
gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
+ mi = gtk_separator_menu_item_new ();
+ gtk_widget_show (mi);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
+ mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
+ gtk_widget_set_sensitive (mi, TRUE);
+ gtk_widget_show (mi);
+ g_signal_connect (mi, "activate", G_CALLBACK (xfpm_tray_icon_exit_activated_cb), NULL);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
// Popup the menu
gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
gtk_status_icon_position_menu,
More information about the Goodies-commits
mailing list