[Xfce4-commits] <xfce4-appfinder:master> Fix default item loading.
Nick Schermer
noreply at xfce.org
Tue Sep 20 21:58:03 CEST 2011
Updating branch refs/heads/master
to dbce37f8979ae6230c13438da1c21a8e53cb6091 (commit)
from dd42543902d453068a1d5e7a4a0e42f1b75872d0 (commit)
commit dbce37f8979ae6230c13438da1c21a8e53cb6091
Author: Nick Schermer <nick at xfce.org>
Date: Mon Sep 19 21:25:36 2011 +0200
Fix default item loading.
src/appfinder-actions.c | 19 +++++++++++--------
src/appfinder-preferences.c | 5 +++++
src/appfinder-window.c | 37 +++++++++++++++++++++++--------------
3 files changed, 39 insertions(+), 22 deletions(-)
diff --git a/src/appfinder-actions.c b/src/appfinder-actions.c
index cfb5b46..01c1feb 100644
--- a/src/appfinder-actions.c
+++ b/src/appfinder-actions.c
@@ -145,9 +145,10 @@ xfce_appfinder_actions_load_defaults (XfceAppfinderActions *actions)
XfceAppfinderAction *action;
XfceAppfinderAction defaults[] =
{
- { XFCE_APPFINDER_ACTION_TYPE_PREFIX, 0,
- "#",
- "exo-open --launch TerminalEmulator man %s",
+ /* default actions, sorted */
+ { XFCE_APPFINDER_ACTION_TYPE_REGEX, 0,
+ "^(file|http|https):\\/\\/(.*)$",
+ "exo-open \\0",
NULL },
{ XFCE_APPFINDER_ACTION_TYPE_PREFIX, 0,
"!",
@@ -157,9 +158,9 @@ xfce_appfinder_actions_load_defaults (XfceAppfinderActions *actions)
"!w",
"exo-open --launch WebBrowser http://en.wikipedia.org/wiki/%s",
NULL },
- { XFCE_APPFINDER_ACTION_TYPE_REGEX, 0,
- "^(file|http|https):\\/\\/(.*)$",
- "exo-open \\0",
+ { XFCE_APPFINDER_ACTION_TYPE_PREFIX, 0,
+ "#",
+ "exo-open --launch TerminalEmulator man %s",
NULL }
};
@@ -274,7 +275,8 @@ xfce_appfinder_actions_save (XfceAppfinderActions *actions,
GPtrArray *array;
gchar prop[32];
- g_signal_handler_block (actions->channel, actions->property_watch_id);
+ if (actions->property_watch_id > 0)
+ g_signal_handler_block (actions->channel, actions->property_watch_id);
array = g_ptr_array_new ();
@@ -304,7 +306,8 @@ xfce_appfinder_actions_save (XfceAppfinderActions *actions,
xfconf_array_free (array);
- g_signal_handler_unblock (actions->channel, actions->property_watch_id);
+ if (actions->property_watch_id > 0)
+ g_signal_handler_unblock (actions->channel, actions->property_watch_id);
}
diff --git a/src/appfinder-preferences.c b/src/appfinder-preferences.c
index a277f0f..e48f424 100644
--- a/src/appfinder-preferences.c
+++ b/src/appfinder-preferences.c
@@ -131,6 +131,7 @@ xfce_appfinder_preferences_init (XfceAppfinderPreferences *preferences)
object = gtk_builder_get_object (GTK_BUILDER (preferences), "actions-treeview");
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (object));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
g_signal_connect (G_OBJECT (selection), "changed",
G_CALLBACK (xfce_appfinder_preferences_selection_changed), preferences);
@@ -375,6 +376,10 @@ xfce_appfinder_preferences_selection_changed (GtkTreeSelection *selectio
objects[i].prop_type, object,
objects[i].prop_name);
}
+ else if (GTK_IS_ENTRY (object))
+ {
+ gtk_entry_set_text (GTK_ENTRY (object), "");
+ }
}
object = gtk_builder_get_object (GTK_BUILDER (preferences), "button-remove");
diff --git a/src/appfinder-window.c b/src/appfinder-window.c
index 5f50b73..c2135a5 100644
--- a/src/appfinder-window.c
+++ b/src/appfinder-window.c
@@ -72,7 +72,8 @@ 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 void xfce_appfinder_window_preferences (GtkWidget *button,
+ XfceAppfinderWindow *window);
static gboolean xfce_appfinder_window_item_visible (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data);
@@ -96,6 +97,8 @@ struct _XfceAppfinderWindow
XfceAppfinderCategoryModel *category_model;
+ XfceAppfinderActions *actions;
+
GtkEntryCompletion *completion;
XfconfChannel *channel;
@@ -327,7 +330,7 @@ xfce_appfinder_window_init (XfceAppfinderWindow *window)
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);
+ G_CALLBACK (xfce_appfinder_window_preferences), window);
bbox = gtk_hbutton_box_new ();
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END);
@@ -376,6 +379,7 @@ xfce_appfinder_window_finalize (GObject *object)
g_object_unref (G_OBJECT (window->category_model));
g_object_unref (G_OBJECT (window->completion));
g_object_unref (G_OBJECT (window->icon_find));
+ g_object_unref (G_OBJECT (window->actions));
if (window->filter_category != NULL)
g_object_unref (G_OBJECT (window->filter_category));
@@ -706,10 +710,15 @@ xfce_appfinder_window_category_set_categories (XfceAppfinderWindow *window)
static void
-xfce_appfinder_window_preferences (GtkWidget *button)
+xfce_appfinder_window_preferences (GtkWidget *button,
+ XfceAppfinderWindow *window)
{
appfinder_return_if_fail (GTK_IS_WIDGET (button));
+ /* preload the actions, to make sure there are default values */
+ if (window->actions == NULL)
+ window->actions = xfce_appfinder_actions_get ();
+
xfce_appfinder_preferences_show (gtk_widget_get_screen (button));
}
@@ -789,20 +798,20 @@ xfce_appfinder_window_icon_theme_changed (XfceAppfinderWindow *window)
static gboolean
-xfce_appfinder_window_execute_command (const gchar *cmd,
- GdkScreen *screen,
- GError **error)
+xfce_appfinder_window_execute_command (const gchar *cmd,
+ GdkScreen *screen,
+ XfceAppfinderWindow *window,
+ GError **error)
{
- XfceAppfinderActions *actions;
- gboolean succeed = FALSE;
+ gboolean succeed = FALSE;
- actions = xfce_appfinder_actions_get ();
+ if (window->actions == NULL)
+ window->actions = xfce_appfinder_actions_get ();
- if (xfce_appfinder_actions_execute (actions, cmd, screen, error) == XFCE_APPFINDER_ACTIONS_SUCCEED)
+ if (xfce_appfinder_actions_execute (window->actions, cmd, screen, error)
+ == XFCE_APPFINDER_ACTIONS_SUCCEED)
succeed = TRUE;
- g_object_unref (G_OBJECT (actions));
-
return succeed;
}
@@ -836,7 +845,7 @@ xfce_appfinder_window_execute (XfceAppfinderWindow *window)
if (!result && regular_command)
{
gtk_tree_model_get (model, &iter, XFCE_APPFINDER_MODEL_COLUMN_COMMAND, &cmd, -1);
- result = xfce_appfinder_window_execute_command (cmd, screen, &error);
+ result = xfce_appfinder_window_execute_command (cmd, screen, window, &error);
g_free (cmd);
}
}
@@ -844,7 +853,7 @@ xfce_appfinder_window_execute (XfceAppfinderWindow *window)
else
{
text = gtk_entry_get_text (GTK_ENTRY (window->entry));
- if (xfce_appfinder_window_execute_command (text, screen, &error))
+ if (xfce_appfinder_window_execute_command (text, screen, window, &error))
result = xfce_appfinder_model_save_command (window->model, text, &error);
}
More information about the Xfce4-commits
mailing list