diff options
author | Ali Abdallah <ali.slackware@gmail.com> | 2009-04-10 21:31:33 +0000 |
---|---|---|
committer | Ali Abdallah <ali.slackware@gmail.com> | 2009-04-10 21:31:33 +0000 |
commit | aeaccf4e673546d532f41077563f9f4f679bad42 (patch) | |
tree | 3d2f4828baac8cee80e982032566aa6ff6d88332 /settings | |
parent | ed818a555711f483181fc2d52029d7fd6f0db674 (diff) | |
download | ixfce4-power-manager-aeaccf4e673546d532f41077563f9f4f679bad42.tar.gz |
Making the settings dialog pluggable+use the shutdown interface on the xfce4-session to shutdown0.8.0beta1
(Old svn revision: 7159)
Diffstat (limited to 'settings')
-rw-r--r-- | settings/xfce4-power-manager-settings.desktop.in | 19 | ||||
-rw-r--r-- | settings/xfpm-settings-main.c | 64 | ||||
-rw-r--r-- | settings/xfpm-settings.c | 58 | ||||
-rw-r--r-- | settings/xfpm-settings.glade | 2 | ||||
-rw-r--r-- | settings/xfpm-settings.h | 5 |
5 files changed, 89 insertions, 59 deletions
diff --git a/settings/xfce4-power-manager-settings.desktop.in b/settings/xfce4-power-manager-settings.desktop.in index 6c82c08c..2cf63c23 100644 --- a/settings/xfce4-power-manager-settings.desktop.in +++ b/settings/xfce4-power-manager-settings.desktop.in @@ -3,25 +3,6 @@ Version=1.0 Encoding=UTF-8 _Name=Xfce 4 Power Manager _GenericName=Power Manager -X-XfceSettingsName=Power -X-XfceSettingsName[ca]=Energia -X-XfceSettingsName[cs]=Napájení -X-XfceSettingsName[da]=Strøm -X-XfceSettingsName[de]=Energie -X-XfceSettingsName[el]=Ρεύμα -X-XfceSettingsName[es]=Energía -X-XfceSettingsName[et]=Vool -X-XfceSettingsName[eu]=Energia -X-XfceSettingsName[fi]=Virranhallinta -X-XfceSettingsName[id]=Daya -X-XfceSettingsName[ja]=電源 -X-XfceSettingsName[nb]=Strøm -X-XfceSettingsName[pt]=Energia -X-XfceSettingsName[pt_BR]=Energia -X-XfceSettingsName[sv]=Ström -X-XfceSettingsName[tr]=Güç -X-XfceSettingsName[uk]=Живлення -X-XfceSettingsName[zh_CN]=电源 _Comment=Settings for the Xfce 4 Power Manager Exec=xfce4-power-manager-settings Icon=gpm-ac-adapter diff --git a/settings/xfpm-settings-main.c b/settings/xfpm-settings-main.c index 5b4a0322..c427ecf9 100644 --- a/settings/xfpm-settings-main.c +++ b/settings/xfpm-settings-main.c @@ -46,43 +46,46 @@ #include "xfpm-settings.h" #include "xfpm-config.h" -//FIXME: Unref XfconfChannel -static void dialog_response_cb (GtkDialog *dialog, gint response, gpointer data) -{ - DBusGConnection *bus = (DBusGConnection *) data; - switch(response) - { - case GTK_RESPONSE_HELP: - xfpm_help(); - break; - default: - xfpm_dbus_release_name(dbus_g_connection_get_connection(bus), "org.xfce.PowerManager.Config"); - dbus_g_connection_unref(bus); - xfconf_shutdown(); - gtk_widget_destroy(GTK_WIDGET(dialog)); - gtk_main_quit(); - break; - } -} - int main(int argc, char **argv) { xfce_textdomain(GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); - //FIXME: Help argument - gtk_init(&argc, &argv); - GError *error = NULL; - DBusGConnection *bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + DBusGConnection *bus; gboolean system_laptop; gboolean user_privilege; gboolean can_suspend; gboolean can_hibernate; gboolean has_lcd_brightness; + + GdkNativeWindow socket_id = 0; XfconfChannel *channel; DBusGProxy *proxy; - GtkWidget *dialog; + + GOptionEntry option_entries[] = + { + { "socket-id", 's', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT, &socket_id, N_("Settings manager socket"), N_("SOCKET ID") }, + { NULL, }, + }; + + if( !gtk_init_with_args (&argc, &argv, "", option_entries, PACKAGE, &error)) + { + if( error) + { + g_printerr("%s: %s.\n", G_LOG_DOMAIN, error->message); + g_printerr(_("Type '%s --help' for usage."), G_LOG_DOMAIN); + g_printerr("\n"); + g_error_free(error); + } + else + { + g_error("Unable to open display."); + } + return EXIT_FAILURE; + } + + bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if ( error ) { @@ -140,16 +143,15 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - dialog = xfpm_settings_dialog_new (channel, system_laptop, user_privilege, - can_suspend, can_hibernate, has_lcd_brightness, - system_laptop); + xfpm_settings_dialog_new (channel, system_laptop, user_privilege, + can_suspend, can_hibernate, has_lcd_brightness, + system_laptop, socket_id); - g_signal_connect(dialog, "response", G_CALLBACK(dialog_response_cb), bus); - - gtk_widget_show(dialog); - gtk_main(); + xfpm_dbus_release_name(dbus_g_connection_get_connection(bus), "org.xfce.PowerManager.Config"); + dbus_g_connection_unref(bus); + return EXIT_SUCCESS; } else diff --git a/settings/xfpm-settings.c b/settings/xfpm-settings.c index 174d57d7..23908cf3 100644 --- a/settings/xfpm-settings.c +++ b/settings/xfpm-settings.c @@ -804,6 +804,8 @@ xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege, val = xfconf_channel_get_bool (channel, DPMS_ENABLED_CFG, TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dpms), val); + gtk_widget_set_tooltip_text (dpms, _("Disable Display Power Management Signaling (DPMS), "\ + "e.g don't attempt to switch off the display or put it in sleep mode.")); #endif /* * Power button @@ -1195,18 +1197,48 @@ xfpm_settings_tree_view (XfconfChannel *channel, gboolean system_laptop) g_signal_connect(view,"cursor-changed",G_CALLBACK(_cursor_changed_cb),NULL); } -GtkWidget * -xfpm_settings_dialog_new (XfconfChannel *channel, - gboolean system_laptop, gboolean user_privilege, - gboolean can_suspend, gboolean can_hibernate, - gboolean has_lcd_brightness, gboolean has_lid) +static void +settings_quit (GtkWidget *widget, XfconfChannel *channel) +{ + g_object_unref (channel); + xfconf_shutdown(); + gtk_widget_destroy (widget); + gtk_main_quit(); +} + +static void dialog_response_cb (GtkDialog *dialog, gint response, XfconfChannel *channel) +{ + switch(response) + { + case GTK_RESPONSE_HELP: + xfpm_help(); + break; + default: + settings_quit (GTK_WIDGET (dialog), channel); + break; + } +} + +static void +delete_event_cb (GtkWidget *plug, GdkEvent *ev, XfconfChannel *channel) +{ + settings_quit (plug, channel); +} + +void +xfpm_settings_dialog_new (XfconfChannel *channel, gboolean system_laptop, + gboolean user_privilege, gboolean can_suspend, + gboolean can_hibernate, gboolean has_lcd_brightness, + gboolean has_lid, GdkNativeWindow id) { TRACE("system_laptop=%s user_privilege=%s can_suspend=%s can_hibernate=%s has_lcd_brightness=%s has_lid=%s", xfpm_bool_to_string (system_laptop), xfpm_bool_to_string (user_privilege), xfpm_bool_to_string (can_suspend), xfpm_bool_to_string (can_hibernate), xfpm_bool_to_string (has_lcd_brightness), xfpm_bool_to_string (has_lid) ); + GtkWidget *plug; GtkWidget *dialog; + GtkWidget *allbox; xml = glade_xml_new_from_buffer (xfpm_settings_glade, xfpm_settings_glade_length, @@ -1224,5 +1256,19 @@ xfpm_settings_dialog_new (XfconfChannel *channel, xfpm_settings_general (channel, user_privilege, can_suspend, can_hibernate); xfpm_settings_advanced (channel, system_laptop, user_privilege); - return dialog; + if ( id != 0 ) + { + allbox = glade_xml_get_widget (xml, "allbox"); + plug = gtk_plug_new (id); + gtk_widget_show (plug); + gtk_widget_reparent (allbox, plug); + g_signal_connect (plug, "delete-event", + G_CALLBACK (delete_event_cb), channel); + gdk_notify_startup_complete (); + } + else + { + g_signal_connect (dialog, "response", G_CALLBACK (dialog_response_cb), channel); + gtk_widget_show (dialog); + } } diff --git a/settings/xfpm-settings.glade b/settings/xfpm-settings.glade index 7b6b4036..2f2235a1 100644 --- a/settings/xfpm-settings.glade +++ b/settings/xfpm-settings.glade @@ -17,7 +17,7 @@ <property name="visible">True</property> <property name="spacing">2</property> <child> - <widget class="GtkVBox" id="vbox"> + <widget class="GtkVBox" id="allbox"> <property name="visible">True</property> <child> <widget class="GtkHBox" id="hbox"> diff --git a/settings/xfpm-settings.h b/settings/xfpm-settings.h index e360f678..0877dffa 100644 --- a/settings/xfpm-settings.h +++ b/settings/xfpm-settings.h @@ -22,13 +22,14 @@ #define __XFPM_SETTINGS_H -GtkWidget * xfpm_settings_dialog_new (XfconfChannel *channel, +void xfpm_settings_dialog_new (XfconfChannel *channel, gboolean system_laptop, gboolean user_privilege, gboolean can_suspend, gboolean can_hibernate, gboolean has_lcd_brightness, - gboolean has_lid); + gboolean has_lid, + GdkNativeWindow id); |