Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
DISCONTINUED:openSUSE:11.2
gnome-panel
gnome-panel-recently-used-apps.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gnome-panel-recently-used-apps.patch of Package gnome-panel
Index: gnome-panel-2.27.91/gnome-panel/panel-run-dialog.c =================================================================== --- gnome-panel-2.27.91.orig/gnome-panel/panel-run-dialog.c +++ gnome-panel-2.27.91/gnome-panel/panel-run-dialog.c @@ -65,6 +65,14 @@ #include "panel-xutils.h" #include "panel-icon-names.h" +#include <gtk/gtkversion.h> +#if GTK_CHECK_VERSION (2,10,0) +# define USE_GTK_RECENT_MANAGER +# include <gtk/gtkrecentmanager.h> +#else +# include "egg-recent-model.h" +#endif + typedef struct { GtkWidget *run_dialog; @@ -148,6 +156,8 @@ _panel_run_get_recent_programs_list (voi return GTK_TREE_MODEL (list); } +static void panel_run_dialog_update_recent_apps (PanelRunDialog *dialog, const gchar *cmd); + static void _panel_run_save_recent_programs_list (GtkComboBoxEntry *entry, char *lastcommand) @@ -480,6 +490,8 @@ panel_run_dialog_execute (PanelRunDialog /* only save working commands in history */ _panel_run_save_recent_programs_list (GTK_COMBO_BOX_ENTRY (dialog->combobox), command); + + panel_run_dialog_update_recent_apps (dialog, command); /* only close the dialog if we successfully showed or launched * something */ @@ -735,6 +747,160 @@ panel_run_dialog_find_command_idle (Pane return FALSE; } +static void +panel_run_dialog_update_recent_apps (PanelRunDialog *dialog, const gchar *cmd) +{ + GtkTreeIter iter; + GtkTreeModel *model = NULL; + GtkTreePath *path = NULL; + + gchar *found_ditem_path = NULL; + gchar *found_ditem_uri = NULL; + gchar *found_cmd = NULL; + + gchar *cmd_i; + gchar *ditem_path_i; + + gboolean fuzzy; + +#ifdef USE_GTK_RECENT_MANAGER + GtkRecentManager *recent_manager; + GtkRecentData recent_data; +#else + EggRecentModel *recent_model; + EggRecentItem *recent_item; +#endif + + GError *error = NULL; + + + if (! cmd) + return; + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->program_list)); + path = gtk_tree_path_new_first (); + + if (! path || ! gtk_tree_model_get_iter (model, & iter, path)) { + if (path) + gtk_tree_path_free (path); + + return; + } + + do { + cmd_i = NULL; + ditem_path_i = NULL; + + gtk_tree_model_get ( + model, & iter, + COLUMN_EXEC, & cmd_i, + COLUMN_PATH, & ditem_path_i, + -1 + ); + + if (cmd_i && ditem_path_i) { + fuzzy = FALSE; + + if (fuzzy_command_match (sure_string (cmd), cmd_i, & fuzzy)) { + g_free (found_ditem_path); + + found_ditem_path = g_strdup (ditem_path_i); + found_cmd = g_strdup (cmd_i); + + if (! fuzzy) { + /* + * if not fuzzy then we have a precise + * match and we can quit, else keep + * searching for a better match + */ + g_free (cmd_i); + g_free (ditem_path_i); + + break; + } + } + } + + g_free (cmd_i); + g_free (ditem_path_i); + + } while (gtk_tree_model_iter_next (model, & iter)); + + gtk_tree_path_free (path); + +#ifdef USE_GTK_RECENT_MANAGER + recent_manager = gtk_recent_manager_get_default (); + + if (! recent_manager) + goto exit; +#else + recent_model = egg_recent_model_new (EGG_RECENT_MODEL_SORT_NONE); + + if (! recent_model) + goto exit; +#endif + + if (found_ditem_path) { + found_ditem_uri = g_filename_to_uri (found_ditem_path, NULL, & error); + + if (! error) { +#ifdef USE_GTK_RECENT_MANAGER + recent_data.display_name = NULL; + recent_data.description = NULL; + recent_data.mime_type = g_strdup ("application/x-desktop"); + recent_data.is_private = TRUE; + + recent_data.app_name = g_strdup (g_get_application_name ()); + if (! recent_data.app_name) + recent_data.app_name = g_strdup ("gnome-panel run dialog"); + + recent_data.app_exec = g_strdup (g_strdup (found_cmd)); + if (! recent_data.app_exec) + recent_data.app_exec = g_strdup ("gnome-open %u"); + + recent_data.groups = g_new0 (gchar *, 2); + recent_data.groups [0] = g_strdup ("recently-used-apps"); + recent_data.groups [1] = NULL; + + gtk_recent_manager_add_full (recent_manager, found_ditem_uri, & recent_data); + + g_free (recent_data.mime_type); + g_free (recent_data.app_name); + g_free (recent_data.app_exec); + g_free (recent_data.groups [0]); + g_free (recent_data.groups); + +#else + + recent_item = egg_recent_item_new_from_uri (found_ditem_uri); + egg_recent_item_add_group (recent_item, "recently-used-apps"); + egg_recent_item_set_private (recent_item, TRUE); + + egg_recent_model_add_full (recent_model, recent_item); + + if (recent_item) + egg_recent_item_unref (recent_item); +#endif + } + else { + g_warning ("unable to create uri from [%s] to insert into recent file list.\n", + found_ditem_path); + + g_error_free (error); + } + } + +#ifndef USE_GTK_RECENT_MANAGER + g_object_unref (recent_model); +#endif + +exit: + + g_free (found_ditem_path); + g_free (found_ditem_uri); + g_free (found_cmd); +} + static gboolean panel_run_dialog_add_icon_idle (PanelRunDialog *dialog) {
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor