[Xfce4-commits] <xfce4-notifyd:master> Add a preview button in the preferences dialog (Bug #5319).

Jérôme Guelfucci noreply at xfce.org
Mon Nov 22 21:38:02 CET 2010


Updating branch refs/heads/master
         to 65ec36e435150b8bb10d6b51fb618876d10714e8 (commit)
       from ed069a02a1a0513ea9de2cf902688195aad7dd75 (commit)

commit 65ec36e435150b8bb10d6b51fb618876d10714e8
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Mon Nov 22 21:36:41 2010 +0100

    Add a preview button in the preferences dialog (Bug #5319).

 xfce4-notifyd-config/main.c                     |   34 +++++++++++++++++++++--
 xfce4-notifyd-config/xfce4-notifyd-config.glade |   22 +++++++++++++--
 2 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/xfce4-notifyd-config/main.c b/xfce4-notifyd-config/main.c
index 753ff1b..5839295 100644
--- a/xfce4-notifyd-config/main.c
+++ b/xfce4-notifyd-config/main.c
@@ -199,7 +199,7 @@ xfce4_notifyd_config_setup_treeview(GtkWidget *treeview,
 
     gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), 0,
                                          GTK_SORT_ASCENDING);
-    
+
     sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
     if(gtk_list_store_iter_is_valid(ls, &current_theme_iter))
         gtk_tree_selection_select_iter(sel, &current_theme_iter);
@@ -207,6 +207,28 @@ xfce4_notifyd_config_setup_treeview(GtkWidget *treeview,
     g_object_unref(G_OBJECT(ls));
 }
 
+static void
+xfce_notifyd_config_dialog_response(GtkWidget *dialog, gint response, gpointer unused)
+{
+  if (response == 0)
+      g_signal_stop_emission_by_name (dialog, "response");
+}
+
+static void
+xfce_notifyd_config_preview_clicked(GtkButton *button,
+                                    GtkWidget *dialog)
+{
+    GError *error = NULL;
+
+    if(!g_spawn_command_line_async(_("notify-send \"Notification Preview\""
+                                     " \"This is how notifications will look like\""),
+                                   &error)) {
+        xfce_dialog_show_error(GTK_WINDOW(dialog),
+                               error, _("Notification preview failed"));
+        g_error_free(error);
+    }
+}
+
 static GtkWidget *
 xfce4_notifyd_config_setup_dialog(GtkBuilder *builder)
 {
@@ -220,11 +242,17 @@ xfce4_notifyd_config_setup_dialog(GtkBuilder *builder)
     gtk_builder_connect_signals(builder, NULL);
 
     dlg = GTK_WIDGET(gtk_builder_get_object(builder, "notifyd_settings_dlg"));
-    btn = GTK_WIDGET(gtk_builder_get_object(builder, "close_btn"));
+    g_signal_connect(G_OBJECT(dlg), "response",
+                     G_CALLBACK(xfce_notifyd_config_dialog_response), NULL);
 
+    btn = GTK_WIDGET(gtk_builder_get_object(builder, "close_btn"));
     g_signal_connect_swapped(G_OBJECT(btn), "clicked",
                              G_CALLBACK(gtk_dialog_response), dlg);
 
+    btn = GTK_WIDGET(gtk_builder_get_object(builder, "preview_button"));
+    g_signal_connect(G_OBJECT(btn), "clicked",
+                     G_CALLBACK(xfce_notifyd_config_preview_clicked), dlg);
+
     if(!xfconf_init(&error)) {
         xfce_message_dialog(NULL, _("Xfce Notify Daemon"),
                             GTK_STOCK_DIALOG_ERROR,
@@ -270,7 +298,7 @@ xfce4_notifyd_config_setup_dialog(GtkBuilder *builder)
                            G_OBJECT(combo), "active");
     if(gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == -1)
         gtk_combo_box_set_active(GTK_COMBO_BOX(combo), GTK_CORNER_TOP_RIGHT);
-    
+
     return dlg;
 }
 
diff --git a/xfce4-notifyd-config/xfce4-notifyd-config.glade b/xfce4-notifyd-config/xfce4-notifyd-config.glade
index 62db217..a96d22b 100644
--- a/xfce4-notifyd-config/xfce4-notifyd-config.glade
+++ b/xfce4-notifyd-config/xfce4-notifyd-config.glade
@@ -236,7 +236,21 @@
         <child internal-child="action_area">
           <object class="GtkHButtonBox" id="dialog-action_area1">
             <property name="visible">True</property>
-            <property name="layout_style">end</property>
+            <property name="layout_style">edge</property>
+            <child>
+              <object class="GtkButton" id="preview_button">
+                <property name="label" translatable="yes">_Preview</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
             <child>
               <object class="GtkButton" id="close_btn">
                 <property name="label">gtk-close</property>
@@ -248,7 +262,8 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">0</property>
+                <property name="pack_type">end</property>
+                <property name="position">1</property>
               </packing>
             </child>
           </object>
@@ -261,7 +276,8 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="0">close_btn</action-widget>
+      <action-widget response="0">preview_button</action-widget>
+      <action-widget response="1">close_btn</action-widget>
     </action-widgets>
   </object>
 </interface>



More information about the Xfce4-commits mailing list