[Xfce4-commits] <xfce4-panel:devel> * Use response callback in the panel's preferences dialog.
Nick Schermer
nick at xfce.org
Tue Aug 11 20:26:27 CEST 2009
Updating branch refs/heads/devel
to 4c95fb9005e0faac648c0993f9c92a9e5bf7c887 (commit)
from 507f358480020e1a3ad1ce22220839572f77f88f (commit)
commit 4c95fb9005e0faac648c0993f9c92a9e5bf7c887
Author: Nick Schermer <nick at xfce.org>
Date: Thu Dec 11 19:54:14 2008 +0100
* Use response callback in the panel's preferences dialog.
panel/panel-preferences-dialog.c | 43 +++++++++++++++++++--------------
panel/panel-preferences-dialog.glade | 6 ++--
2 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/panel/panel-preferences-dialog.c b/panel/panel-preferences-dialog.c
index b341a1b..d4bc045 100644
--- a/panel/panel-preferences-dialog.c
+++ b/panel/panel-preferences-dialog.c
@@ -44,7 +44,7 @@
static void panel_preferences_dialog_class_init (PanelPreferencesDialogClass *klass);
static void panel_preferences_dialog_init (PanelPreferencesDialog *dialog);
static void panel_preferences_dialog_finalize (GObject *object);
-static void panel_preferences_dialog_help (GtkWidget *button);
+static void panel_preferences_dialog_response (GtkWidget *window, gint response_id, PanelPreferencesDialog *dialog);
static void panel_preferences_dialog_bindings_unbind (PanelPreferencesDialog *dialog);
@@ -145,14 +145,7 @@ panel_preferences_dialog_init (PanelPreferencesDialog *dialog)
/* get the dialog */
window = gtk_builder_get_object (GTK_BUILDER (dialog), "dialog");
panel_application_take_dialog (dialog->application, GTK_WINDOW (window));
- g_object_weak_ref (G_OBJECT (window), (GWeakNotify) g_object_unref, dialog);
-
- /* close button */
- object = gtk_builder_get_object (GTK_BUILDER (dialog), "button-close");
- g_signal_connect_swapped (G_OBJECT (object), "clicked", G_CALLBACK (gtk_widget_destroy), window);
-
- /* help button */
- connect_signal ("button-help", "clicked", panel_preferences_dialog_help);
+ g_signal_connect (G_OBJECT (window), "response", G_CALLBACK (panel_preferences_dialog_response), dialog);
/* panel selector buttons and combobox */
connect_signal ("panel-add", "clicked", panel_preferences_dialog_panel_add);
@@ -233,20 +226,34 @@ panel_preferences_dialog_finalize (GObject *object)
static void
-panel_preferences_dialog_help (GtkWidget *button)
+panel_preferences_dialog_response (GtkWidget *window,
+ gint response_id,
+ PanelPreferencesDialog *dialog)
{
GError *error = NULL;
GdkScreen *screen;
+
+ panel_return_if_fail (GTK_IS_DIALOG (window));
+ panel_return_if_fail (PANEL_IS_PREFERENCES_DIALOG (dialog));
- /* get the dialog screen */
- screen = gtk_widget_get_screen (button);
+ if (G_UNLIKELY (response_id == 1))
+ {
+ /* get the dialog screen */
+ screen = gtk_widget_get_screen (window);
- /* open the help url */
- if (exo_url_show_on_screen (PREFERENCES_HELP_URL, NULL, screen, &error) == FALSE)
+ /* open the help url */
+ if (exo_url_show_on_screen (PREFERENCES_HELP_URL, NULL, screen, &error) == FALSE)
+ {
+ /* show error and cleanup */
+ g_warning ("Failed to open help: %s", error->message);
+ g_error_free (error);
+ }
+ }
+ else
{
- /* show error and cleanup */
- g_warning ("Failed to open help: %s", error->message);
- g_error_free (error);
+ /* destroy the builder and dialog */
+ gtk_widget_destroy (window);
+ g_object_unref (G_OBJECT (dialog));
}
}
diff --git a/panel/panel-preferences-dialog.glade b/panel/panel-preferences-dialog.glade
index 0d9a40c..faa658c 100644
--- a/panel/panel-preferences-dialog.glade
+++ b/panel/panel-preferences-dialog.glade
@@ -684,7 +684,7 @@
</child>
<action-widgets>
<action-widget response="0">button-close</action-widget>
- <action-widget response="0">button-help</action-widget>
+ <action-widget response="1">button-help</action-widget>
</action-widgets>
</object>
<object class="GtkAdjustment" id="size">
@@ -721,9 +721,9 @@
</object>
<object class="GtkSizeGroup" id="sizegroup1">
<widgets>
- <widget name="label10"/>
- <widget name="label9"/>
<widget name="label7"/>
+ <widget name="label9"/>
+ <widget name="label10"/>
</widgets>
</object>
</interface>
More information about the Xfce4-commits
mailing list