[Xfce4-commits] <xfce4-appfinder:master> Add properties dialog with basic settings.

Nick Schermer noreply at xfce.org
Tue Sep 20 21:58:01 CEST 2011


Updating branch refs/heads/master
         to 5149c5c98de6c71943e51a1a131a9dcb573da662 (commit)
       from c68f8e7784306070b7d9a0ed7aa33b47b1ac8270 (commit)

commit 5149c5c98de6c71943e51a1a131a9dcb573da662
Author: Nick Schermer <nick at xfce.org>
Date:   Mon Aug 1 19:49:37 2011 +0200

    Add properties dialog with basic settings.

 src/Makefile.am                 |   22 ++
 src/appfinder-preferences.c     |  155 +++++++++++++
 src/appfinder-preferences.glade |  479 +++++++++++++++++++++++++++++++++++++++
 src/appfinder-preferences.h     |   42 ++++
 src/appfinder-window.c          |   37 +++-
 5 files changed, 732 insertions(+), 3 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 2c6551f..91065af 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,11 +8,17 @@ INCLUDES = \
 
 bin_PROGRAMS = xfce4-appfinder
 
+xfce4_appfinder_built_sources = \
+	appfinder-preferences-ui.h
+
 xfce4_appfinder_SOURCES = \
+	$(xfce4_appfinder_built_sources) \
 	appfinder-category-model.c \
 	appfinder-category-model.h \
 	appfinder-model.c \
 	appfinder-model.h \
+	appfinder-preferences.c \
+	appfinder-preferences.h \
 	appfinder-private.h \
 	appfinder-window.c \
 	appfinder-window.h \
@@ -42,3 +48,19 @@ xfce4_appfinder_LDADD = \
 xfce4_appfinder_LDFLAGS = \
 	-no-undefined \
 	$(PLATFORM_LDFLAGS)
+
+if MAINTAINER_MODE
+
+appfinder-preferences-ui.h: $(srcdir)/appfinder-preferences.glade Makefile
+	$(AM_V_GEN) exo-csource --static --strip-comments --strip-content --name=appfinder_preferences_ui $< >$@
+
+DISTCLEANFILES = \
+	$(xfce4_appfinder_built_sources)
+
+BUILT_SOURCES = \
+	$(xfce4_appfinder_built_sources)
+
+endif
+
+EXTRA_DIST = \
+	appfinder-preferences.glade
diff --git a/src/appfinder-preferences.c b/src/appfinder-preferences.c
new file mode 100644
index 0000000..026acfd
--- /dev/null
+++ b/src/appfinder-preferences.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2011 Nick Schermer <nick at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <libxfce4util/libxfce4util.h>
+#include <libxfce4ui/libxfce4ui.h>
+#include <xfconf/xfconf.h>
+
+#include <src/appfinder-preferences.h>
+#include <src/appfinder-preferences-ui.h>
+#include <src/appfinder-model.h>
+#include <src/appfinder-private.h>
+
+
+
+static void xfce_appfinder_preferences_response      (GtkWidget                *window,
+                                                      gint                      response_id,
+                                                      XfceAppfinderPreferences *preferences);
+static void xfce_appfinder_preferences_clear_history (XfceAppfinderPreferences *preferences);
+
+
+
+struct _XfceAppfinderPreferencesClass
+{
+  GtkBuilderClass __parent__;
+};
+
+struct _XfceAppfinderPreferences
+{
+  GtkBuilder __parent__;
+
+  GObject  *dialog;
+};
+
+
+
+G_DEFINE_TYPE (XfceAppfinderPreferences, xfce_appfinder_preferences, GTK_TYPE_BUILDER)
+
+
+
+static void
+xfce_appfinder_preferences_class_init (XfceAppfinderPreferencesClass *klass)
+{
+}
+
+
+
+static void
+xfce_appfinder_preferences_init (XfceAppfinderPreferences *preferences)
+{
+  XfconfChannel *channel;
+  GObject       *object;
+
+  /* load the builder data into the object */
+  gtk_builder_add_from_string (GTK_BUILDER (preferences), appfinder_preferences_ui,
+                               appfinder_preferences_ui_length, NULL);
+
+  preferences->dialog = gtk_builder_get_object (GTK_BUILDER (preferences), "dialog");
+  appfinder_return_if_fail (XFCE_IS_TITLED_DIALOG (preferences->dialog));
+  g_signal_connect (G_OBJECT (preferences->dialog), "response",
+      G_CALLBACK (xfce_appfinder_preferences_response), preferences);
+
+  channel = xfconf_channel_get ("xfce4-appfinder");
+
+  object = gtk_builder_get_object (GTK_BUILDER (preferences), "remember-category");
+  xfconf_g_property_bind (channel, "/RememberCategory", G_TYPE_BOOLEAN,
+                          G_OBJECT (object), "active");
+
+  object = gtk_builder_get_object (GTK_BUILDER (preferences), "always-center");
+  xfconf_g_property_bind (channel, "/AlwaysCenter", G_TYPE_BOOLEAN,
+                          G_OBJECT (object), "active");
+
+  object = gtk_builder_get_object (GTK_BUILDER (preferences), "button-clear");
+  g_signal_connect_swapped (G_OBJECT (object), "clicked",
+      G_CALLBACK (xfce_appfinder_preferences_clear_history), preferences);
+}
+
+
+
+static void
+xfce_appfinder_preferences_response (GtkWidget                *window,
+                                     gint                      response_id,
+                                     XfceAppfinderPreferences *preferences)
+{
+  appfinder_return_if_fail (GTK_IS_DIALOG (window));
+  appfinder_return_if_fail (XFCE_IS_APPFINDER_PREFERENCES (preferences));
+
+  gtk_widget_destroy (window);
+  g_object_unref (G_OBJECT (preferences));
+}
+
+
+
+static void
+xfce_appfinder_preferences_clear_history (XfceAppfinderPreferences *preferences)
+{
+  XfceAppfinderModel *model;
+  
+  appfinder_return_if_fail (XFCE_IS_APPFINDER_PREFERENCES (preferences));
+  
+  if (xfce_dialog_confirm (GTK_WINDOW (preferences->dialog), GTK_STOCK_CLEAR,
+                           _("Clear Command History"),
+                           _("This will permanently clear the custom command history."),
+                           _("Are you sure you want to clear the command history?")))
+    {
+      model = xfce_appfinder_model_get ();
+      xfce_appfinder_model_commands_clear (model);
+      g_object_unref (G_OBJECT (model));
+    }
+}
+
+
+
+void
+xfce_appfinder_preferences_show (GdkScreen *screen)
+{
+  static XfceAppfinderPreferences *preferences = NULL;
+
+  appfinder_return_if_fail (GDK_IS_SCREEN (screen));
+
+  if (preferences == NULL)
+    {
+      preferences = g_object_new (XFCE_TYPE_APPFINDER_PREFERENCES, NULL);
+      g_object_add_weak_pointer (G_OBJECT (preferences), (gpointer *) &preferences);
+      gtk_widget_show (GTK_WIDGET (preferences->dialog));
+    }
+  else
+    {
+      gtk_window_present (GTK_WINDOW (preferences->dialog));
+    }
+
+  gtk_window_set_screen (GTK_WINDOW (preferences->dialog), screen);
+}
diff --git a/src/appfinder-preferences.glade b/src/appfinder-preferences.glade
new file mode 100644
index 0000000..a4dad9c
--- /dev/null
+++ b/src/appfinder-preferences.glade
@@ -0,0 +1,479 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="2.20"/>
+  <!-- interface-requires libxfce4ui 4.5 -->
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkListStore" id="actions-store">
+    <columns>
+      <!-- column-name icon-name -->
+      <column type="gchararray"/>
+      <!-- column-name prefix -->
+      <column type="gchararray"/>
+      <!-- column-name command -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
+  <object class="XfceTitledDialog" id="dialog">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Application Finder</property>
+    <property name="default_width">385</property>
+    <property name="default_height">425</property>
+    <property name="icon_name">gtk-preferences</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="button-close">
+                <property name="label">gtk-close</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkNotebook" id="notebook1">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="border_width">6</property>
+            <child>
+              <object class="GtkVBox" id="vbox3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="border_width">6</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkFrame" id="frame1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment2">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="GtkVBox" id="vbox4">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="border_width">6</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkCheckButton" id="remember-category">
+                                <property name="label" translatable="yes">Remember last _selected category</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="always-center">
+                                <property name="label" translatable="yes">Always c_enter the window</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="tooltip_text" translatable="yes">Center the window on startup.</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label6">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Behaviour</property>
+                        <attributes>
+                          <attribute name="weight" value="bold"/>
+                        </attributes>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkFrame" id="frame2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment3">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="border_width">6</property>
+                        <property name="xalign">0</property>
+                        <property name="xscale">0</property>
+                        <property name="yscale">0</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="GtkButton" id="button-clear">
+                            <property name="label" translatable="yes">C_lear Custom Command History</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="image">image3</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label7">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">History</property>
+                        <attributes>
+                          <attribute name="weight" value="bold"/>
+                        </attributes>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">_General</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="vbox1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="border_width">6</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkHBox" id="hbox1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkScrolledWindow" id="scrolledwindow1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="hscrollbar_policy">automatic</property>
+                        <property name="vscrollbar_policy">automatic</property>
+                        <property name="shadow_type">etched-in</property>
+                        <child>
+                          <object class="GtkTreeView" id="actions-treeview">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="model">actions-store</property>
+                            <property name="headers_clickable">False</property>
+                            <property name="enable_search">False</property>
+                            <property name="search_column">0</property>
+                            <child>
+                              <object class="GtkTreeViewColumn" id="treeviewcolumn3">
+                                <property name="title" translatable="yes">Icon</property>
+                                <child>
+                                  <object class="GtkCellRendererPixbuf" id="cellrendererpixbuf1"/>
+                                  <attributes>
+                                    <attribute name="icon-name">0</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                                <property name="title" translatable="yes">Prefix</property>
+                                <child>
+                                  <object class="GtkCellRendererText" id="cellrenderertext1"/>
+                                  <attributes>
+                                    <attribute name="text">1</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+                                <property name="title" translatable="yes">Command</property>
+                                <child>
+                                  <object class="GtkCellRendererText" id="cellrenderertext2"/>
+                                  <attributes>
+                                    <attribute name="text">2</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkAlignment" id="alignment1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="yalign">0</property>
+                        <property name="xscale">0</property>
+                        <property name="yscale">0</property>
+                        <child>
+                          <object class="GtkVBox" id="vbox2">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkButton" id="button-add">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="tooltip_text" translatable="yes">Add a new custom action.</property>
+                                <property name="use_action_appearance">False</property>
+                                <child>
+                                  <object class="GtkImage" id="image1">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="stock">gtk-add</property>
+                                  </object>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkButton" id="button-remove">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="tooltip_text" translatable="yes">Remove the currently selected action.</property>
+                                <property name="use_action_appearance">False</property>
+                                <child>
+                                  <object class="GtkImage" id="image2">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="stock">gtk-delete</property>
+                                  </object>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkTable" id="table1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="n_rows">3</property>
+                    <property name="n_columns">2</property>
+                    <property name="column_spacing">12</property>
+                    <property name="row_spacing">6</property>
+                    <child>
+                      <object class="GtkEntry" id="action-prefix">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">•</property>
+                        <property name="invisible_char_set">True</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                        <property name="primary_icon_sensitive">True</property>
+                        <property name="secondary_icon_sensitive">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label3">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">P_refix:</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">action-prefix</property>
+                      </object>
+                      <packing>
+                        <property name="x_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label4">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Co_mmand:</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">action-cmd</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                        <property name="x_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label5">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">_Icon:</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">action-icon</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
+                        <property name="x_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="action-cmd">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">•</property>
+                        <property name="invisible_char_set">True</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                        <property name="primary_icon_sensitive">True</property>
+                        <property name="secondary_icon_sensitive">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="action-icon">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">•</property>
+                        <property name="invisible_char_set">True</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                        <property name="primary_icon_sensitive">True</property>
+                        <property name="secondary_icon_sensitive">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Custom _Actions</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="position">1</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="0">button-close</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkImage" id="image3">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="stock">gtk-clear</property>
+  </object>
+</interface>
diff --git a/src/appfinder-preferences.h b/src/appfinder-preferences.h
new file mode 100644
index 0000000..301e3de
--- /dev/null
+++ b/src/appfinder-preferences.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2011 Nick Schermer <nick at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __XFCE_APPFINDER_PREFERENCES_H__
+#define __XFCE_APPFINDER_PREFERENCES_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct _XfceAppfinderPreferencesClass XfceAppfinderPreferencesClass;
+typedef struct _XfceAppfinderPreferences      XfceAppfinderPreferences;
+
+#define XFCE_TYPE_APPFINDER_PREFERENCES            (xfce_appfinder_preferences_get_type ())
+#define XFCE_APPFINDER_PREFERENCES(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_APPFINDER_PREFERENCES, XfceAppfinderPreferences))
+#define XFCE_APPFINDER_PREFERENCES_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_APPFINDER_PREFERENCES, XfceAppfinderPreferencesClass))
+#define XFCE_IS_APPFINDER_PREFERENCES(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_APPFINDER_PREFERENCES))
+#define XFCE_IS_APPFINDER_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_APPFINDER_PREFERENCES))
+#define XFCE_APPFINDER_PREFERENCES_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_APPFINDER_PREFERENCES, XfceAppfinderPreferencesClass))
+
+GType xfce_appfinder_preferences_get_type (void) G_GNUC_CONST;
+
+void  xfce_appfinder_preferences_show     (GdkScreen *screen);
+
+G_END_DECLS
+
+#endif /* !__XFCE_APPFINDER_PREFERENCES_H__ */
diff --git a/src/appfinder-window.c b/src/appfinder-window.c
index 0040305..e78a3ac 100644
--- a/src/appfinder-window.c
+++ b/src/appfinder-window.c
@@ -32,6 +32,7 @@
 #include <src/appfinder-window.h>
 #include <src/appfinder-model.h>
 #include <src/appfinder-category-model.h>
+#include <src/appfinder-preferences.h>
 #include <src/appfinder-private.h>
 
 
@@ -70,6 +71,7 @@ static void       xfce_appfinder_window_drag_data_get                 (GtkWidget
 static void       xfce_appfinder_window_category_changed              (GtkTreeSelection            *selection,
                                                                        XfceAppfinderWindow         *window);
 static void       xfce_appfinder_window_category_set_categories       (XfceAppfinderWindow         *window);
+static void       xfce_appfinder_window_preferences                   (GtkWidget                   *button);
 static gboolean   xfce_appfinder_window_item_visible                  (GtkTreeModel                *model,
                                                                        GtkTreeIter                 *iter,
                                                                        gpointer                     data);
@@ -107,6 +109,7 @@ struct _XfceAppfinderWindow
 
   GtkWidget                  *bbox;
   GtkWidget                  *button_launch;
+  GtkWidget                  *button_preferences;
   GtkWidget                  *bin_collapsed;
   GtkWidget                  *bin_expanded;
 
@@ -178,6 +181,9 @@ xfce_appfinder_window_init (XfceAppfinderWindow *window)
   gtk_window_set_default_size (GTK_WINDOW (window), integer, -1);
   gtk_window_set_icon_name (GTK_WINDOW (window), GTK_STOCK_EXECUTE);
 
+  if (xfconf_channel_get_bool (window->channel, "/AlwaysCenter", FALSE))
+    gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
+
   vbox = gtk_vbox_new (FALSE, 6);
   gtk_container_add (GTK_CONTAINER (window), vbox);
   gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
@@ -314,9 +320,18 @@ xfce_appfinder_window_init (XfceAppfinderWindow *window)
   gtk_box_pack_start (GTK_BOX (vbox), window->bin_expanded, FALSE, TRUE, 0);
   gtk_widget_show (window->bin_expanded);
 
-  window->bbox = bbox = gtk_hbutton_box_new ();
+  window->bbox = hbox = gtk_hbox_new (FALSE, 6);
+  gtk_widget_show (hbox);
+
+  window->button_preferences = button = gtk_button_new_from_stock (GTK_STOCK_PREFERENCES);
+  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+  g_signal_connect (G_OBJECT (button), "clicked",
+      G_CALLBACK (xfce_appfinder_window_preferences), NULL);
+
+  bbox = gtk_hbutton_box_new ();
   gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END);
   gtk_button_box_set_spacing (GTK_BUTTON_BOX (bbox), 6);
+  gtk_box_pack_start (GTK_BOX (hbox), bbox, TRUE, TRUE, 0);
   gtk_widget_show (bbox);
 
   button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
@@ -651,7 +666,8 @@ xfce_appfinder_window_category_changed (GtkTreeSelection    *selection,
           gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (model));
 
           /* store last category */
-          xfconf_channel_set_string (window->channel, "/LastCategory", name);
+          if (xfconf_channel_get_bool (window->channel, "/RememberCategory", FALSE))
+            xfconf_channel_set_string (window->channel, "/LastCategory", name);
         }
 
       g_free (name);
@@ -675,7 +691,11 @@ xfce_appfinder_window_category_set_categories (XfceAppfinderWindow *window)
   if (categories != NULL)
     xfce_appfinder_category_model_set_categories (window->category_model, categories);
 
-  name = xfconf_channel_get_string (window->channel, "/LastCategory", NULL);
+  if (xfconf_channel_get_bool (window->channel, "/RememberCategory", FALSE))
+    name = xfconf_channel_get_string (window->channel, "/LastCategory", NULL);
+  else
+    name = NULL;
+
   path = xfce_appfinder_category_model_find_category (window->category_model, name);
   gtk_tree_view_set_cursor (GTK_TREE_VIEW (window->sidepane), path, NULL, FALSE);
   gtk_tree_path_free (path);
@@ -684,6 +704,16 @@ xfce_appfinder_window_category_set_categories (XfceAppfinderWindow *window)
 
 
 
+static void
+xfce_appfinder_window_preferences (GtkWidget *button)
+{
+  appfinder_return_if_fail (GTK_IS_WIDGET (button));
+
+  xfce_appfinder_preferences_show (gtk_widget_get_screen (button));
+}
+
+
+
 static gboolean
 xfce_appfinder_window_item_visible (GtkTreeModel *model,
                                     GtkTreeIter  *iter,
@@ -907,6 +937,7 @@ xfce_appfinder_window_set_expanded (XfceAppfinderWindow *window,
     gtk_container_add (GTK_CONTAINER (window->bin_collapsed), window->bbox);
   gtk_widget_set_visible (window->bin_expanded, expanded);
   gtk_widget_set_visible (window->bin_collapsed, !expanded);
+  gtk_widget_set_visible (window->button_preferences, expanded);
   g_object_unref (G_OBJECT (window->bbox));
 
   /* show/hide pane with treeviews */


More information about the Xfce4-commits mailing list