Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
DISCONTINUED:openSUSE:11.2
gnome-panel
gnome-panel-run-fixes.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gnome-panel-run-fixes.patch of Package gnome-panel
Index: gnome-panel/panel-run-dialog.c =================================================================== --- gnome-panel/panel-run-dialog.c.orig +++ gnome-panel/panel-run-dialog.c @@ -241,6 +241,105 @@ panel_run_dialog_set_icon (PanelRunDialo } } +static char * +fuzzy_command_merge (const char *ditem_cmd, + const char *user_cmd) +{ + char **tokens; + char *path, *basename, *new_cmd; + + if (!strcmp (ditem_cmd, user_cmd) || + !g_path_is_absolute (ditem_cmd) || + g_path_is_absolute (user_cmd)) + return g_strdup (user_cmd); + + /* find path from desktop item */ + tokens = g_strsplit (ditem_cmd, " ", -1); + if (!tokens || !tokens [0]) { + g_strfreev (tokens); + return g_strdup (user_cmd); + } + + path = g_path_get_dirname (tokens [0]); + g_strfreev (tokens); + + /* merge it with basename from user_cmd */ + tokens = g_strsplit (user_cmd, " ", -1); + if (!tokens || !tokens [0]) { + g_free (path); + g_strfreev (tokens); + return g_strdup (user_cmd); + } + basename = g_path_get_basename (tokens [0]); + g_free (tokens [0]); + tokens [0] = g_build_filename (path, basename, NULL); + + new_cmd = g_strjoinv (" ", tokens); + + g_free (path); + g_free (basename); + g_strfreev (tokens); + + return new_cmd; +} + +static gboolean +panel_run_dialog_launch_ditem (PanelRunDialog *dialog, + const char *desktop_path, + const char *command, + const char *escaped) +{ + GnomeDesktopItem *ditem; + int result; + char *merged_command; + GError *error = NULL; + + ditem = gnome_desktop_item_new_from_file (desktop_path, + GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS, + &error); + if (!ditem) { + char *primary; + + primary = g_strdup_printf (_("Cannot open desktop item '%s'"), + desktop_path); + panel_error_dialog (GTK_WINDOW (dialog->run_dialog), NULL, + "cannot_open_desktop_item", TRUE, + primary, + error ? error->message : g_strerror (ENOENT)); + g_free (primary); + g_error_free (error); + return FALSE; + } + + merged_command = fuzzy_command_merge ( + gnome_desktop_item_get_string (ditem, GNOME_DESKTOP_ITEM_EXEC), + command); + gnome_desktop_item_set_string (ditem, GNOME_DESKTOP_ITEM_EXEC, merged_command); + g_free (merged_command); + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->terminal_checkbox))) { + gnome_desktop_item_set_string (ditem, GNOME_DESKTOP_ITEM_TERMINAL, + "true"); + } + + result = panel_ditem_launch (ditem, NULL, + gtk_window_get_screen (GTK_WINDOW (dialog->run_dialog)), + &error); + if (result == -1) { + char *primary; + + primary = g_strdup_printf (_("Cannot launch command '%s'"), + escaped); + panel_error_dialog (GTK_WINDOW (dialog->run_dialog), NULL, + "cannot_spawn_command", TRUE, + primary, error->message); + g_free (primary); + g_error_free (error); + } + + return result != -1; +} + static gboolean command_is_executable (const char *command) { @@ -292,9 +391,6 @@ panel_run_dialog_launch_command (PanelRu char **argv; int argc; - if (!command_is_executable (command)) - return FALSE; - argc = 3; argv = g_new0 (char *, 4); argv [0] = gnome_util_user_shell (); @@ -423,18 +519,20 @@ panel_run_dialog_execute (PanelRunDialog escaped = g_markup_escape_text (url, -1); result = FALSE; - if (!g_ascii_strcasecmp (scheme, "http") || - !g_ascii_strcasecmp (scheme, "file")) - /* If this returns an http or file url, the url might refer to - * a command that is somewhere in the path or an executable - * file. So try executing it before displaying it. We execute - * the command in the user's shell so that it can do all the - * parameter expansion and other magic for us. */ + + + if (dialog->desktop_path) { + result = panel_run_dialog_launch_ditem (dialog, dialog->desktop_path, disk, + escaped); + } else if ((!g_ascii_strcasecmp (scheme, "http") || + !g_ascii_strcasecmp (scheme, "file")) && + command_is_executable (disk)) { result = panel_run_dialog_launch_command (dialog, disk, escaped); - if (!result) + } else { result = panel_run_dialog_show_url (dialog, url, escaped); - + } + if (result) { /* only save working commands in history */ gnome_entry_append_history (GNOME_ENTRY (dialog->gnome_entry), @@ -609,6 +707,7 @@ panel_run_dialog_find_command_idle (Pane const char *text; char *found_icon; char *found_name; + char *found_path; gboolean fuzzy; model = GTK_TREE_MODEL (dialog->program_list_store); @@ -616,6 +715,7 @@ panel_run_dialog_find_command_idle (Pane text = sure_string (gtk_entry_get_text (GTK_ENTRY (dialog->gtk_entry))); found_icon = NULL; found_name = NULL; + found_path = NULL; fuzzy = FALSE; if (!path || !gtk_tree_model_get_iter (model, &iter, path)) { @@ -633,12 +733,14 @@ panel_run_dialog_find_command_idle (Pane char *icon = NULL; char *name = NULL; char *comment = NULL; + char *desktop_path = NULL; gtk_tree_model_get (model, &iter, COLUMN_EXEC, &exec, COLUMN_ICON_FILE, &icon, COLUMN_NAME, &name, COLUMN_COMMENT, &comment, + COLUMN_PATH, &desktop_path, -1); if (!fuzzy && exec && icon && @@ -648,6 +750,7 @@ panel_run_dialog_find_command_idle (Pane found_icon = g_strdup (icon); found_name = g_strdup (name); + found_path = g_strdup (desktop_path); gtk_list_store_set (dialog->program_list_store, &iter, @@ -688,6 +791,8 @@ panel_run_dialog_find_command_idle (Pane g_free (dialog->item_name); dialog->item_name = found_name; + g_free (dialog->desktop_path); + dialog->desktop_path = found_path; dialog->find_command_idle_id = 0; return FALSE; Index: gnome-panel/panel-util.c =================================================================== --- gnome-panel/panel-util.c.orig +++ gnome-panel/panel-util.c @@ -37,7 +37,7 @@ #include "launcher.h" #include "panel-icon-names.h" -static int +int panel_ditem_launch (GnomeDesktopItem *item, GList *file_list, GdkScreen *screen, Index: gnome-panel/panel-util.h =================================================================== --- gnome-panel/panel-util.h.orig +++ gnome-panel/panel-util.h @@ -3,6 +3,7 @@ #include <gio/gio.h> #include <gtk/gtk.h> +#include <libgnome/gnome-desktop-item.h> G_BEGIN_DECLS @@ -21,6 +22,10 @@ void panel_launch_desktop_fil const char *fallback_exec, GdkScreen *screen, GError **error); +int panel_ditem_launch (GnomeDesktopItem *item, + GList *file_list, + GdkScreen *screen, + GError **error); char * panel_util_make_exec_uri_for_desktop (const char *exec);
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