Sophie

Sophie

distrib > Mandriva > 2007.1 > x86_64 > by-pkgid > 72682f97789893cb05925a6c35ec9c08 > files > 3

gnome-panel-2.18.0-5mdv2007.1.src.rpm

--- gnome-panel-2.14.1/gnome-panel/main.c.suspend	2006-03-24 22:46:29.000000000 +0100
+++ gnome-panel-2.14.1/gnome-panel/main.c	2006-04-13 11:10:37.000000000 +0200
@@ -47,6 +47,7 @@
 	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
+	bind_textdomain_codeset ("gtk+mdk", "UTF-8");
 
 	context = g_option_context_new ("");
 	g_option_context_set_ignore_unknown_options (context, TRUE);
--- gnome-panel-2.14.1/gnome-panel/panel-action-button.c.suspend	2006-04-13 11:10:37.000000000 +0200
+++ gnome-panel-2.14.1/gnome-panel/panel-action-button.c	2006-04-13 11:15:29.000000000 +0200
@@ -81,6 +81,7 @@
 	{ PANEL_ACTION_SHUTDOWN,       "shutdown"       },
 	/* compatibility with GNOME < 2.13.90 */
 	{ PANEL_ACTION_SCREENSHOT,     "screenshot"     },
+	{ PANEL_ACTION_SUSPEND,        "suspend"        },
 	{ 0,                           NULL             },
 };
 
@@ -267,6 +268,32 @@
 	}
 }
 
+/* Suspend to disk
+ */
+static void
+panel_action_suspend (GtkWidget *widget)
+{
+	GtkWidget *dialog;
+	gint result;
+
+	dialog = gtk_message_dialog_new (NULL,
+                                  0,
+                                  GTK_MESSAGE_WARNING,
+                                  GTK_BUTTONS_OK_CANCEL,
+                                  dgettext("gtk+mdk","Do you really want to suspend to disk?"));
+	result = gtk_dialog_run (GTK_DIALOG (dialog));
+        gtk_widget_destroy (dialog);
+
+  	switch (result) {
+	      	case GTK_RESPONSE_OK:
+			gdk_spawn_command_line_on_screen (gtk_widget_get_screen (widget), 
+					"pmsuspend", NULL);
+	        	break;
+	      	default:
+        	 	break;
+    	}
+}
+
 typedef struct {
 	PanelActionButtonType   type;
 	char                   *icon_name;
@@ -367,6 +394,15 @@
 		PANEL_ACTION_SCREENSHOT,
 		NULL, NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, NULL
+	},
+	{
+		PANEL_ACTION_SUSPEND,
+		"gnome-shutdown", 
+		N_("Suspend To Disk"),
+		N_("Suspend To Disk"), 
+		"gospanel-563", 
+		"ACTION:suspend:NEW",
+		panel_action_suspend, NULL, NULL, NULL
 	}
 };
 
@@ -415,6 +451,9 @@
 {
 	g_return_val_if_fail (type > PANEL_ACTION_NONE && type < PANEL_ACTION_LAST, NULL);
 
+	if (type == PANEL_ACTION_SUSPEND)
+		return dgettext("gtk+mdk",actions[type].text);
+
 	return _(actions[type].text);
 }
 
@@ -423,6 +462,9 @@
 {
 	g_return_val_if_fail (type > PANEL_ACTION_NONE && type < PANEL_ACTION_LAST, NULL);
 
+	if (type == PANEL_ACTION_SUSPEND)
+		return dgettext("gtk+mdk",actions[type].tooltip);
+
 	return _(actions[type].tooltip);
 }
 
--- gnome-panel-2.14.1/gnome-panel/panel-enums.h.suspend	2006-01-22 13:08:24.000000000 +0100
+++ gnome-panel-2.14.1/gnome-panel/panel-enums.h	2006-04-13 11:13:45.000000000 +0200
@@ -98,6 +98,7 @@
         PANEL_ACTION_SHUTDOWN,
 	/* compatibility with GNOME < 2.13.90 */
         PANEL_ACTION_SCREENSHOT,
+        PANEL_ACTION_SUSPEND,
         PANEL_ACTION_LAST
 } PanelActionButtonType;
 
--- gnome-panel-2.14.1/gnome-panel/panel-stock-icons.h.suspend	2005-01-29 21:39:01.000000000 +0100
+++ gnome-panel-2.14.1/gnome-panel/panel-stock-icons.h	2006-04-13 11:10:37.000000000 +0200
@@ -43,6 +43,7 @@
 #define PANEL_STOCK_EXECUTE             "panel-execute"
 #define PANEL_STOCK_CLEAR               "panel-clear"
 #define PANEL_STOCK_DONT_DELETE         "panel-dont-delete"
+#define PANEL_STOCK_SUSPEND		"panel-suspend"
 
 void        panel_init_stock_icons_and_items (void);
 GtkIconSize panel_menu_icon_get_size         (void);
--- gnome-panel-2.14.1/gnome-panel/panel-menu-items.c.suspend	2006-03-24 22:46:29.000000000 +0100
+++ gnome-panel-2.14.1/gnome-panel/panel-menu-items.c	2006-04-13 11:16:40.000000000 +0200
@@ -1087,6 +1087,24 @@
 			gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 		}
 	}
+ 
+	if (panel_is_program_in_path ("pmsuspend") && 
+			(g_file_test("/proc/acpi", G_FILE_TEST_EXISTS) || g_file_test("/proc/apm",G_FILE_TEST_EXISTS))) {
+		char *console = g_strconcat ("/var/run/console/", g_get_user_name (), NULL);
+		if ((getuid () == 0) || g_file_test (console, G_FILE_TEST_EXISTS)) {
+			item = panel_menu_items_create_action_item (PANEL_ACTION_SUSPEND);
+			if (item != NULL) {
+				if (!separator_inserted) {
+					add_menu_separator (menu);
+					separator_inserted = TRUE;
+				}
+
+				gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+			}
+		}
+		g_free (console);
+	}
+
 
 	/* Translators: translate "panel:showusername|1" to anything
 	 * but "1" if "Log Out %s" doesn't make any sense in your