diff options
-rw-r--r-- | mate-panel/applet.c | 50 | ||||
-rw-r--r-- | mate-panel/applet.h | 4 | ||||
-rw-r--r-- | mate-panel/launcher.c | 300 | ||||
-rw-r--r-- | mate-panel/launcher.h | 9 | ||||
-rw-r--r-- | mate-panel/libpanel-util/panel-launch.c | 37 | ||||
-rw-r--r-- | mate-panel/libpanel-util/panel-launch.h | 10 | ||||
-rw-r--r-- | mate-panel/libpanel-util/panel-show.c | 20 | ||||
-rw-r--r-- | mate-panel/mate-desktop-item-edit.c | 9 | ||||
-rw-r--r-- | mate-panel/panel-ditem-editor.c | 11 | ||||
-rw-r--r-- | mate-panel/panel-ditem-editor.h | 2 | ||||
-rw-r--r-- | mate-panel/panel-util.c | 10 | ||||
-rw-r--r-- | mate-panel/panel-util.h | 2 | ||||
-rw-r--r-- | mate-panel/xstuff.c | 3 |
13 files changed, 255 insertions, 212 deletions
diff --git a/mate-panel/applet.c b/mate-panel/applet.c index 4d40180d..9ed853fd 100644 --- a/mate-panel/applet.c +++ b/mate-panel/applet.c @@ -242,9 +242,14 @@ applet_callback_callback (GtkWidget *widget, switch (menu->info->type) { case PANEL_OBJECT_LAUNCHER: if (!strcmp (menu->name, "launch")) - launcher_launch (menu->info->data, widget); + launcher_launch (menu->info->data, NULL); else if (!strcmp (menu->name, "properties")) launcher_properties (menu->info->data); + else if (g_str_has_prefix (menu->name, "launch-action_")) { + const gchar *action; + action = menu->name + (sizeof("launch-action_") - 1); + launcher_launch (menu->info->data, action); + } break; case PANEL_OBJECT_DRAWER: if (strcmp (menu->name, "add") == 0) { @@ -329,7 +334,7 @@ mate_panel_applet_get_callback (GList *user_menu, void mate_panel_applet_add_callback (AppletInfo *info, const char *callback_name, - const char *stock_item, + const char *icon_name, const char *menuitem_text, CallbackEnabledFunc is_enabled_func) { @@ -341,7 +346,7 @@ mate_panel_applet_add_callback (AppletInfo *info, menu = g_new0 (AppletUserMenu, 1); menu->name = g_strdup (callback_name); - menu->stock_item = g_strdup (stock_item); + menu->gicon = panel_gicon_from_icon_name (icon_name); menu->text = g_strdup (menuitem_text); menu->is_enabled_func = is_enabled_func; menu->sensitive = TRUE; @@ -354,6 +359,24 @@ mate_panel_applet_add_callback (AppletInfo *info, mate_panel_applet_recreate_menu (info); } +void +mate_panel_applet_clear_user_menu (AppletInfo *info) +{ + GList *l; + + for (l = info->user_menu; l != NULL; l = l->next) { + AppletUserMenu *umenu = l->data; + + g_free (umenu->name); + g_clear_object (&(umenu->gicon)); + g_free (umenu->text); + g_free (umenu); + } + + g_list_free (info->user_menu); + info->user_menu = NULL; +} + static void setup_an_item (AppletUserMenu *menu, GtkWidget *submenu, @@ -362,8 +385,8 @@ setup_an_item (AppletUserMenu *menu, GtkWidget *image = NULL; menu->menuitem = gtk_image_menu_item_new_with_mnemonic (menu->text); - if (menu->stock_item && menu->stock_item [0]) { - image = gtk_image_new_from_stock (menu->stock_item, + if (menu->gicon) { + image = gtk_image_new_from_gicon (menu->gicon, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu->menuitem), image); @@ -439,7 +462,7 @@ add_to_submenus (AppletInfo *info, if (s_menu == NULL) { s_menu = g_new0 (AppletUserMenu,1); s_menu->name = g_strdup (t); - s_menu->stock_item = NULL; + s_menu->gicon = NULL; s_menu->text = g_strdup (_("???")); s_menu->sensitive = TRUE; s_menu->info = info; @@ -766,8 +789,6 @@ static void mate_panel_applet_destroy (GtkWidget *widget, AppletInfo *info) { - GList *l; - g_return_if_fail (info != NULL); info->widget = NULL; @@ -812,18 +833,7 @@ mate_panel_applet_destroy (GtkWidget *widget, info->data_destroy (info->data); info->data = NULL; - for (l = info->user_menu; l != NULL; l = l->next) { - AppletUserMenu *umenu = l->data; - - g_free (umenu->name); - g_free (umenu->stock_item); - g_free (umenu->text); - - g_free (umenu); - } - - g_list_free (info->user_menu); - info->user_menu = NULL; + mate_panel_applet_clear_user_menu (info); g_free (info->id); info->id = NULL; diff --git a/mate-panel/applet.h b/mate-panel/applet.h index 2ee60659..50205c8f 100644 --- a/mate-panel/applet.h +++ b/mate-panel/applet.h @@ -36,7 +36,7 @@ typedef gboolean (* CallbackEnabledFunc) (void); typedef struct { char *name; - char *stock_item; + GIcon *gicon; char *text; CallbackEnabledFunc is_enabled_func; @@ -84,6 +84,8 @@ void mate_panel_applet_add_callback (AppletInfo *info, const gchar *menuitem_text, CallbackEnabledFunc is_enabled_func); +void mate_panel_applet_clear_user_menu (AppletInfo *info); + AppletUserMenu *mate_panel_applet_get_callback (GList *user_menu, const gchar *name); diff --git a/mate-panel/launcher.c b/mate-panel/launcher.c index 4928fa34..7bbd1cef 100644 --- a/mate-panel/launcher.c +++ b/mate-panel/launcher.c @@ -44,6 +44,9 @@ #include "panel-icon-names.h" #include "panel-schemas.h" +static gboolean +launcher_properties_enabled (void); + static GdkScreen * launcher_get_screen (Launcher *launcher) { @@ -102,10 +105,10 @@ launch_url (Launcher *launcher) GdkScreen *screen; g_return_if_fail (launcher != NULL); - g_return_if_fail (launcher->key_file != NULL); + g_return_if_fail (launcher->app_info != NULL); /* FIXME panel_ditem_launch() should be enough for this! */ - url = panel_key_file_get_string (launcher->key_file, "URL"); + url = g_desktop_app_info_get_string (launcher->app_info, G_KEY_FILE_DESKTOP_KEY_URL); screen = launcher_get_screen (launcher); @@ -128,27 +131,26 @@ launch_url (Launcher *launcher) void launcher_launch (Launcher *launcher, - GtkWidget *widget) + const gchar *action) { char *type; g_return_if_fail (launcher != NULL); - g_return_if_fail (launcher->key_file != NULL); + g_return_if_fail (launcher->app_info != NULL); + + if (action == NULL) { + type = g_desktop_app_info_get_string (launcher->app_info, G_KEY_FILE_DESKTOP_KEY_TYPE); + } else { + type = NULL; + } - if (panel_global_config_get_enable_animations ()) - xstuff_zoom_animate (widget, - button_widget_get_pixbuf (BUTTON_WIDGET (widget)), - button_widget_get_orientation (BUTTON_WIDGET (widget)), - NULL); - - type = panel_key_file_get_string (launcher->key_file, "Type"); if (type && !strcmp (type, "Link")) launch_url (launcher); else { GError *error = NULL; - panel_launch_key_file (launcher->key_file, NULL, - launcher_get_screen (launcher), &error); + panel_app_info_launch (launcher->app_info, NULL, + launcher_get_screen (launcher), action, &error); if (error) { GtkWidget *error_dialog; @@ -164,24 +166,6 @@ launcher_launch (Launcher *launcher, } } g_free (type); - - if (panel_global_config_get_drawer_auto_close ()) { - PanelToplevel *toplevel; - PanelToplevel *parent; - - toplevel = PANEL_WIDGET (gtk_widget_get_parent (launcher->button))->toplevel; - - if (panel_toplevel_get_is_attached (toplevel)) { - parent = panel_toplevel_get_attach_toplevel (toplevel); - - while (panel_toplevel_get_is_attached (parent)) { - toplevel = parent; - parent = panel_toplevel_get_attach_toplevel (toplevel); - } - - panel_toplevel_hide (toplevel, FALSE, -1); - } - } } static void @@ -199,11 +183,15 @@ drag_data_received_cb (GtkWidget *widget, int i; GList *file_list; - if (panel_global_config_get_enable_animations ()) + if (panel_global_config_get_enable_animations ()) { + GdkPixbuf *pixbuf; + pixbuf = button_widget_get_pixbuf (BUTTON_WIDGET (widget)); xstuff_zoom_animate (widget, - button_widget_get_pixbuf (BUTTON_WIDGET (widget)), + pixbuf, button_widget_get_orientation (BUTTON_WIDGET (widget)), NULL); + g_object_unref (pixbuf); + } file_list = NULL; uris = g_uri_list_extract_uris ((const char *) gtk_selection_data_get_data (selection_data)); @@ -211,8 +199,8 @@ drag_data_received_cb (GtkWidget *widget, file_list = g_list_prepend (file_list, uris[i]); file_list = g_list_reverse (file_list); - panel_launch_key_file (launcher->key_file, file_list, - launcher_get_screen (launcher), &error); + panel_app_info_launch (launcher->app_info, file_list, + launcher_get_screen (launcher), NULL, &error); g_list_free (file_list); g_strfreev (uris); @@ -257,13 +245,7 @@ free_launcher (gpointer data) { Launcher *launcher = data; - if (launcher->key_file) - g_key_file_free (launcher->key_file); - launcher->key_file = NULL; - - if (launcher->location != NULL) - g_free (launcher->location); - launcher->location = NULL; + g_clear_object(&launcher->app_info); g_free (launcher); } @@ -271,15 +253,18 @@ free_launcher (gpointer data) void panel_launcher_delete (Launcher *launcher) { - if (!launcher->location) + const gchar *location; + + location = g_desktop_app_info_get_filename (launcher->app_info); + if (!location) return; /* do not remove the file if it's not in the user's launchers path */ - if (panel_launcher_is_in_personal_path (launcher->location)) { + if (panel_launcher_is_in_personal_path (location)) { GError *error; GFile *file; - file = panel_launcher_get_gfile (launcher->location); + file = panel_launcher_get_gfile (location); error = NULL; if (!g_file_delete (file, NULL, &error)) { @@ -378,7 +363,7 @@ enum { }; -static void +static void drag_data_get_cb (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data, @@ -386,11 +371,12 @@ drag_data_get_cb (GtkWidget *widget, guint time, Launcher *launcher) { - char *location; - + const char *location; + g_return_if_fail (launcher != NULL); + g_return_if_fail (launcher->app_info != NULL); - location = launcher->location; + location = g_desktop_app_info_get_filename (launcher->app_info); if (info == TARGET_URI_LIST) { char *uri[2]; @@ -409,23 +395,53 @@ drag_data_get_cb (GtkWidget *widget, } +static void +clicked_cb (Launcher *launcher, + GtkWidget *widget) +{ + if (panel_global_config_get_enable_animations ()) { + GdkPixbuf *pixbuf; + pixbuf = button_widget_get_pixbuf (BUTTON_WIDGET (widget)); + xstuff_zoom_animate (widget, + pixbuf, + button_widget_get_orientation (BUTTON_WIDGET (widget)), + NULL); + g_object_unref (pixbuf); + } + + launcher_launch (launcher, NULL); + + if (panel_global_config_get_drawer_auto_close ()) { + PanelToplevel *toplevel; + PanelToplevel *parent; + + toplevel = PANEL_WIDGET (gtk_widget_get_parent (launcher->button))->toplevel; + + if (panel_toplevel_get_is_attached (toplevel)) { + parent = panel_toplevel_get_attach_toplevel (toplevel); + + while (panel_toplevel_get_is_attached (parent)) { + toplevel = parent; + parent = panel_toplevel_get_attach_toplevel (toplevel); + } + + panel_toplevel_hide (toplevel, FALSE, -1); + } + } +} + static Launcher * create_launcher (const char *location) { - GKeyFile *key_file; - gboolean loaded = FALSE; + GDesktopAppInfo *app_info; Launcher *launcher; - GError *error = NULL; - char *new_location; if (!location) { g_printerr (_("No URI provided for panel launcher desktop file\n")); return NULL; } - new_location = NULL; - key_file = g_key_file_new (); - + app_info = NULL; if (!strchr (location, G_DIR_SEPARATOR)) { /* try to first load a file in our config directory, and if it * doesn't exist there, try to find it in the xdg data dirs */ @@ -436,49 +452,26 @@ create_launcher (const char *location) if (!g_file_test (path, G_FILE_TEST_EXISTS)) { g_free (path); path = panel_g_lookup_in_applications_dirs (location); - /* it's important to keep the full path if the desktop - * file comes from a data dir: when the user will edit - * it, we'll want to save it in PANEL_LAUNCHERS_PATH - * with a random name (and not evolution.desktop, eg) - * and having only a basename as location will make - * this impossible */ - if (path) - new_location = g_strdup (path); } if (path) { - loaded = g_key_file_load_from_file (key_file, path, - G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS, - &error); + app_info = g_desktop_app_info_new_from_filename (path); g_free (path); } } else - loaded = panel_key_file_load_from_uri (key_file, location, - G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS, - &error); - - if (!loaded) { - g_printerr (_("Unable to open desktop file %s for panel launcher%s%s\n"), - location, - error ? ": " : "", - error ? error->message : ""); - if (error) - g_error_free (error); + app_info = g_desktop_app_info_new_from_filename (location); - g_key_file_free (key_file); - g_free (new_location); + if (!app_info) { + g_printerr (_("Unable to open desktop file %s for panel launcher\n"), + location); return NULL; /*button is null*/ } - if (!new_location) - new_location = g_strdup (location); - launcher = g_new0 (Launcher, 1); launcher->info = NULL; launcher->button = NULL; - launcher->location = new_location; - launcher->key_file = key_file; + launcher->app_info = app_info; launcher->prop_dialog = NULL; launcher->destroy_handler = 0; @@ -507,7 +500,7 @@ create_launcher (const char *location) g_signal_connect (launcher->button, "drag_leave", G_CALLBACK (drag_leave_cb), launcher); g_signal_connect_swapped (launcher->button, "clicked", - G_CALLBACK (launcher_launch), launcher); + G_CALLBACK (clicked_cb), launcher); launcher->destroy_handler = g_signal_connect (launcher->button, "destroy", @@ -525,13 +518,46 @@ setup_button (Launcher *launcher) char *str; char *icon; char *unescaped_str; - +#if GLIB_CHECK_VERSION (2, 38, 0) + const gchar * const *actions; + const gchar * const *ptr; +#endif + g_return_if_fail (launcher != NULL); - name = panel_key_file_get_locale_string (launcher->key_file, "Name"); - comment = panel_key_file_get_locale_string (launcher->key_file, - "Comment"); + mate_panel_applet_clear_user_menu (launcher->info); + + mate_panel_applet_add_callback (launcher->info, + "launch", + "system-run", + _("_Launch"), + NULL); + +#if GLIB_CHECK_VERSION (2, 38, 0) + actions = g_desktop_app_info_list_actions (launcher->app_info); + ptr = actions; + for(; *ptr != NULL; ptr++) { + const gchar *action = *ptr; + gchar *callback = g_strdup_printf("launch-action_%s", action); + gchar *action_name = g_desktop_app_info_get_action_name (launcher->app_info, action); + mate_panel_applet_add_callback (launcher->info, + callback, + NULL, + action_name, + NULL); + g_free (callback); + g_free (action_name); + } +#endif + mate_panel_applet_add_callback (launcher->info, + "properties", + "document-properties", + _("_Properties"), + launcher_properties_enabled); + + name = g_desktop_app_info_get_string (launcher->app_info, G_KEY_FILE_DESKTOP_KEY_NAME); + comment = g_desktop_app_info_get_string (launcher->app_info, G_KEY_FILE_DESKTOP_KEY_COMMENT); /* Setup tooltip */ if (!PANEL_GLIB_STR_EMPTY (name) && !PANEL_GLIB_STR_EMPTY (comment)) str = g_strdup_printf ("%s\n%s", name, comment); @@ -561,15 +587,19 @@ setup_button (Launcher *launcher) g_free (str); /* Setup icon */ - icon = panel_key_file_get_locale_string (launcher->key_file, "Icon"); + icon = g_desktop_app_info_get_string (launcher->app_info, G_KEY_FILE_DESKTOP_KEY_ICON); if (icon && icon[0] == '\0') { g_free (icon); icon = NULL; } - if (!icon) + if (!icon) { + gchar *exec; + exec = g_desktop_app_info_get_string (launcher->app_info, G_KEY_FILE_DESKTOP_KEY_EXEC); icon = guess_icon_from_exec (button_widget_get_icon_theme (BUTTON_WIDGET (launcher->button)), - launcher->key_file); + exec); + g_free (exec); + } if (!icon) icon = g_strdup (PANEL_ICON_LAUNCHER); @@ -583,6 +613,7 @@ panel_launcher_find_writable_uri (const char *launcher_location, { char *path; char *uri; + char *filename; if (!launcher_location) return panel_make_unique_desktop_uri (NULL, source); @@ -594,7 +625,8 @@ panel_launcher_find_writable_uri (const char *launcher_location, return uri; } - if (panel_launcher_get_filename (launcher_location) != NULL) { + filename = panel_launcher_get_filename (launcher_location); + if (filename != NULL) { /* we have a file in the user directory. We either have a path * or an URI */ if (g_path_is_absolute (launcher_location)) @@ -604,6 +636,8 @@ panel_launcher_find_writable_uri (const char *launcher_location, return g_strdup (launcher_location); } + g_free (filename); + return panel_make_unique_desktop_uri (NULL, source); } @@ -622,16 +656,18 @@ launcher_command_changed (PanelDItemEditor *dialog, { char *exec; char *old_exec; + GKeyFile *key_file; GKeyFile *revert_key_file; + key_file = panel_ditem_editor_get_key_file (dialog); revert_key_file = panel_ditem_editor_get_revert_key_file (dialog); if (revert_key_file) { - exec = panel_key_file_get_string (launcher->key_file, "Exec"); + exec = panel_key_file_get_string (key_file, "Exec"); old_exec = panel_key_file_get_string (revert_key_file, "Exec"); if (!old_exec || !exec || strcmp (old_exec, exec)) - panel_key_file_remove_key (launcher->key_file, + panel_key_file_remove_key (key_file, "StartupNotify"); g_free (exec); @@ -662,9 +698,11 @@ launcher_save_uri (PanelDItemEditor *dialog, launcher = (Launcher *) data; - if (launcher) - new_uri = panel_launcher_find_writable_uri (launcher->location, + if (launcher) { + const gchar *location = g_desktop_app_info_get_filename (launcher->app_info); + new_uri = panel_launcher_find_writable_uri (location, exec_or_uri); + } else new_uri = panel_launcher_find_writable_uri (NULL, exec_or_uri); @@ -685,18 +723,21 @@ launcher_saved (GtkWidget *dialog, Launcher *launcher) { const char *uri; + gchar *location; + char *filename; + uri = panel_ditem_editor_get_uri (PANEL_DITEM_EDITOR (dialog)); - if (panel_launcher_get_filename (uri) != NULL) - uri = panel_launcher_get_filename (uri); + filename = panel_launcher_get_filename(uri); - if (uri && launcher->location && strcmp (uri, launcher->location)) { + g_settings_set_string (launcher->info->settings, PANEL_OBJECT_LAUNCHER_LOCATION_KEY, filename); - g_settings_set_string (launcher->info->settings, PANEL_OBJECT_LAUNCHER_LOCATION_KEY, uri); + g_free (filename); - if (launcher->location) - g_free (launcher->location); - launcher->location = g_strdup (uri); - } + g_object_unref (launcher->app_info); + + location = g_filename_from_uri (uri, NULL, NULL); + launcher->app_info = g_desktop_app_info_new_from_filename (location); + g_free (location); } static void @@ -713,6 +754,8 @@ launcher_error_reported (GtkWidget *dialog, void launcher_properties (Launcher *launcher) { + gchar *uri; + if (launcher->prop_dialog != NULL) { gtk_window_set_screen (GTK_WINDOW (launcher->prop_dialog), gtk_widget_get_screen (launcher->button)); @@ -720,10 +763,15 @@ launcher_properties (Launcher *launcher) return; } + g_return_if_fail (launcher->app_info != NULL); + + const gchar *location = g_desktop_app_info_get_filename (launcher->app_info); + + uri = g_filename_to_uri (location, NULL, NULL); launcher->prop_dialog = panel_ditem_editor_new (NULL, - launcher->key_file, - launcher->location, + uri, _("Launcher Properties")); + g_free (uri); panel_widget_register_open_dialog (PANEL_WIDGET (gtk_widget_get_parent (launcher->info->widget)), @@ -786,18 +834,6 @@ load_launcher_applet (const char *location, return NULL; } - mate_panel_applet_add_callback (launcher->info, - "launch", - GTK_STOCK_EXECUTE, - _("_Launch"), - NULL); - - mate_panel_applet_add_callback (launcher->info, - "properties", - GTK_STOCK_PROPERTIES, - _("_Properties"), - launcher_properties_enabled); - panel_widget_set_applet_expandable (panel, GTK_WIDGET (launcher->button), FALSE, TRUE); panel_widget_set_applet_size_constrained (panel, GTK_WIDGET (launcher->button), TRUE); @@ -862,14 +898,16 @@ launcher_new_saved (GtkWidget *dialog, PanelWidget *panel; int pos; const char *uri; + char *filename; pos = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), "pos")); panel = g_object_get_data (G_OBJECT (dialog), "panel"); uri = panel_ditem_editor_get_uri (PANEL_DITEM_EDITOR (dialog)); - if (panel_launcher_get_filename (uri) != NULL) - uri = panel_launcher_get_filename (uri); - panel_launcher_create (panel->toplevel, pos, uri); + filename = panel_launcher_get_filename (uri); + panel_launcher_create (panel->toplevel, pos, filename); + + g_free (filename); } void @@ -884,7 +922,7 @@ ask_about_launcher (const char *file, if (panel_lockdown_get_disable_command_line ()) return; - dialog = panel_ditem_editor_new (NULL, NULL, NULL, + dialog = panel_ditem_editor_new (NULL, NULL, _("Create Launcher")); panel_widget_register_open_dialog (panel, dialog); @@ -971,7 +1009,7 @@ panel_launcher_create_with_id (const char *toplevel_id, char *path; char *id; char *no_uri; - const char *new_location; + char *new_location; g_return_if_fail (location != NULL); @@ -982,7 +1020,7 @@ panel_launcher_create_with_id (const char *toplevel_id, path = g_strdup_printf ("%s%s/", PANEL_OBJECT_PATH, id); settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); - g_free (path); + g_free (path); no_uri = NULL; /* if we have an URI, it might contain escaped characters (? : etc) @@ -994,13 +1032,14 @@ panel_launcher_create_with_id (const char *toplevel_id, new_location = panel_launcher_get_filename (no_uri); if (new_location == NULL) - new_location = no_uri; + new_location = g_strdup (no_uri); g_settings_set_string (settings, PANEL_OBJECT_LAUNCHER_LOCATION_KEY, new_location); panel_profile_add_to_list (PANEL_GSETTINGS_OBJECTS, id); g_free (no_uri); + g_free (new_location); g_free (id); g_object_unref (settings); } @@ -1062,11 +1101,12 @@ find_launcher (const char *path) launcher = info->data; - if (launcher->key_file == NULL) + if (launcher->app_info == NULL) continue; - if (launcher->location != NULL && - strcmp (launcher->location, path) == 0) + const gchar *location = g_desktop_app_info_get_filename (launcher->app_info); + if (location != NULL && + strcmp (location, path) == 0) return launcher; } diff --git a/mate-panel/launcher.h b/mate-panel/launcher.h index 28cfd117..784fe876 100644 --- a/mate-panel/launcher.h +++ b/mate-panel/launcher.h @@ -14,6 +14,8 @@ #include "applet.h" #include "panel-widget.h" +#include <gio/gdesktopappinfo.h> + #ifdef __cplusplus extern "C" { #endif @@ -22,8 +24,7 @@ typedef struct { AppletInfo *info; GtkWidget *button; - char *location; - GKeyFile *key_file; + GDesktopAppInfo *app_info; GtkWidget *prop_dialog; GSList *error_dialogs; @@ -48,8 +49,8 @@ void panel_launcher_create_from_info (PanelToplevel *toplevel, const char *comment, const char *icon); -void launcher_launch (Launcher *launcher, - GtkWidget *widget); +void launcher_launch (Launcher *launcher, + const gchar *action); void launcher_properties (Launcher *launcher); diff --git a/mate-panel/libpanel-util/panel-launch.c b/mate-panel/libpanel-util/panel-launch.c index 59ca900a..0f4d7033 100644 --- a/mate-panel/libpanel-util/panel-launch.c +++ b/mate-panel/libpanel-util/panel-launch.c @@ -95,9 +95,10 @@ gather_pid_callback (GDesktopAppInfo *gapp, } gboolean -panel_app_info_launch_uris (GAppInfo *appinfo, +panel_app_info_launch_uris (GDesktopAppInfo *appinfo, GList *uris, GdkScreen *screen, + const gchar *action, guint32 timestamp, GError **error) { @@ -115,23 +116,28 @@ panel_app_info_launch_uris (GAppInfo *appinfo, gdk_app_launch_context_set_timestamp (context, timestamp); local_error = NULL; - retval = g_desktop_app_info_launch_uris_as_manager ((GDesktopAppInfo*)appinfo, uris, - (GAppLaunchContext *) context, + if (action == NULL) { + retval = g_desktop_app_info_launch_uris_as_manager (appinfo, uris, + G_APP_LAUNCH_CONTEXT (context), G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, gather_pid_callback, appinfo, &local_error); + } else { + g_desktop_app_info_launch_action (appinfo, action, G_APP_LAUNCH_CONTEXT (context)); + retval = TRUE; + } g_object_unref (context); if ((local_error == NULL) && (retval == TRUE)) return TRUE; - return _panel_launch_handle_error (g_app_info_get_name ((GAppInfo*) appinfo), + return _panel_launch_handle_error (g_app_info_get_name (G_APP_INFO(appinfo)), screen, local_error, error); } gboolean -panel_app_info_launch_uri (GAppInfo *appinfo, +panel_app_info_launch_uri (GDesktopAppInfo *appinfo, const gchar *uri, GdkScreen *screen, guint32 timestamp, @@ -149,7 +155,7 @@ panel_app_info_launch_uri (GAppInfo *appinfo, uris = g_list_prepend (uris, (gpointer) uri); retval = panel_app_info_launch_uris (appinfo, uris, - screen, timestamp, error); + screen, NULL, timestamp, error); g_list_free (uris); @@ -157,30 +163,23 @@ panel_app_info_launch_uri (GAppInfo *appinfo, } gboolean -panel_launch_key_file (GKeyFile *keyfile, +panel_app_info_launch (GDesktopAppInfo *appinfo, GList *uri_list, GdkScreen *screen, + const gchar *action, GError **error) { - GDesktopAppInfo *appinfo; gboolean retval; - g_return_val_if_fail (keyfile != NULL, FALSE); + g_return_val_if_fail (appinfo != NULL, FALSE); g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - appinfo = g_desktop_app_info_new_from_keyfile (keyfile); - - if (appinfo == NULL) - return FALSE; - - retval = panel_app_info_launch_uris (G_APP_INFO (appinfo), - uri_list, screen, + retval = panel_app_info_launch_uris (appinfo, + uri_list, screen, action, gtk_get_current_event_time (), error); - g_object_unref (appinfo); - return retval; } @@ -213,7 +212,7 @@ panel_launch_desktop_file (const char *desktop_file, if (appinfo == NULL) return FALSE; - retval = panel_app_info_launch_uris (G_APP_INFO (appinfo), NULL, screen, + retval = panel_app_info_launch_uris (appinfo, NULL, screen, NULL, gtk_get_current_event_time (), error); diff --git a/mate-panel/libpanel-util/panel-launch.h b/mate-panel/libpanel-util/panel-launch.h index 1e4033b1..b98b8ca4 100644 --- a/mate-panel/libpanel-util/panel-launch.h +++ b/mate-panel/libpanel-util/panel-launch.h @@ -25,28 +25,30 @@ #ifndef PANEL_LAUNCH_H #define PANEL_LAUNCH_H -#include <gio/gio.h> +#include <gio/gdesktopappinfo.h> #include <gdk/gdk.h> #ifdef __cplusplus extern "C" { #endif -gboolean panel_app_info_launch_uris (GAppInfo *appinfo, +gboolean panel_app_info_launch_uris (GDesktopAppInfo *appinfo, GList *uris, GdkScreen *screen, + const gchar *action, guint32 timestamp, GError **error); -gboolean panel_app_info_launch_uri (GAppInfo *appinfo, +gboolean panel_app_info_launch_uri (GDesktopAppInfo *appinfo, const gchar *uri, GdkScreen *screen, guint32 timestamp, GError **error); -gboolean panel_launch_key_file (GKeyFile *keyfile, +gboolean panel_app_info_launch (GDesktopAppInfo *appinfo, GList *uri_list, GdkScreen *screen, + const gchar *action, GError **error); gboolean panel_launch_desktop_file (const char *desktop_file, diff --git a/mate-panel/libpanel-util/panel-show.c b/mate-panel/libpanel-util/panel-show.c index 6c80a142..2eeee2ec 100644 --- a/mate-panel/libpanel-util/panel-show.c +++ b/mate-panel/libpanel-util/panel-show.c @@ -159,7 +159,7 @@ static gboolean panel_show_caja_search_uri(GdkScreen* screen, const gchar* uri, return FALSE; } - ret = panel_app_info_launch_uri((GAppInfo*) appinfo, uri, screen, timestamp, error); + ret = panel_app_info_launch_uri(appinfo, uri, screen, timestamp, error); g_object_unref(appinfo); return ret; @@ -191,8 +191,11 @@ panel_show_uri_force_mime_type (GdkScreen *screen, GError **error) { GFile *file; - GAppInfo *app; + GAppInfo *appinfo; gboolean ret; + GdkDisplay *display; + GdkAppLaunchContext *context; + GList *uris; g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE); g_return_val_if_fail (uri != NULL, FALSE); @@ -200,18 +203,23 @@ panel_show_uri_force_mime_type (GdkScreen *screen, g_return_val_if_fail (error == NULL || *error == NULL, FALSE); file = g_file_new_for_uri (uri); - app = g_app_info_get_default_for_type (mime_type, + appinfo = g_app_info_get_default_for_type (mime_type, !g_file_is_native (file)); g_object_unref (file); - if (app == NULL) { + if (appinfo == NULL) { /* no application for the mime type, so let's fallback on * automatic detection */ return panel_show_uri (screen, uri, timestamp, error); } - ret = panel_app_info_launch_uri (app, uri, screen, timestamp, error); - g_object_unref (app); + uris = g_list_append (NULL, (gpointer)uri); + display = gdk_screen_get_display (screen); + context = gdk_display_get_app_launch_context (display); + ret = g_app_info_launch_uris (appinfo, uris, G_APP_LAUNCH_CONTEXT(context), error); + g_object_unref (context); + g_list_free (uris); + g_object_unref (appinfo); return ret; } diff --git a/mate-panel/mate-desktop-item-edit.c b/mate-panel/mate-desktop-item-edit.c index 4860cf84..d5d768f4 100644 --- a/mate-panel/mate-desktop-item-edit.c +++ b/mate-panel/mate-desktop-item-edit.c @@ -140,7 +140,7 @@ main (int argc, char * argv[]) if (type == G_FILE_TYPE_DIRECTORY && create_new) { - dlg = panel_ditem_editor_new (NULL, NULL, NULL, + dlg = panel_ditem_editor_new (NULL, NULL, _("Create Launcher")); g_object_set_data_full (G_OBJECT (dlg), "dir", g_strdup (path), @@ -164,14 +164,13 @@ main (int argc, char * argv[]) ".directory") && !create_new) { dlg = panel_ditem_editor_new_directory (NULL, - NULL, uri, _("Directory Properties")); } else if (type == G_FILE_TYPE_REGULAR && g_str_has_suffix (desktops [i], ".desktop") && !create_new) { - dlg = panel_ditem_editor_new (NULL, NULL, uri, + dlg = panel_ditem_editor_new (NULL, uri, _("Launcher Properties")); } else if (type == G_FILE_TYPE_REGULAR && create_new) { @@ -188,13 +187,13 @@ main (int argc, char * argv[]) } else if (g_str_has_suffix (desktops [i], ".directory")) { /* a non-existant file. Well we can still edit that * sort of. We will just create it new */ - dlg = panel_ditem_editor_new_directory (NULL, NULL, uri, + dlg = panel_ditem_editor_new_directory (NULL, uri, _("Directory Properties")); } else if (g_str_has_suffix (desktops [i], ".desktop")) { /* a non-existant file. Well we can still edit that * sort of. We will just create it new */ - dlg = panel_ditem_editor_new (NULL, NULL, uri, + dlg = panel_ditem_editor_new (NULL, uri, _("Create Launcher")); } else { diff --git a/mate-panel/panel-ditem-editor.c b/mate-panel/panel-ditem-editor.c index 737925fd..bff453de 100644 --- a/mate-panel/panel-ditem-editor.c +++ b/mate-panel/panel-ditem-editor.c @@ -869,8 +869,7 @@ panel_ditem_editor_command_changed (PanelDItemEditor *dialog) exec_or_uri); icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (dialog))); - icon = guess_icon_from_exec (icon_theme, - dialog->priv->key_file); + icon = guess_icon_from_exec (icon_theme, exec_or_uri); if (icon) { char *current; @@ -1635,7 +1634,6 @@ panel_ditem_editor_load_uri (PanelDItemEditor *dialog, static GtkWidget * panel_ditem_editor_new_full (GtkWindow *parent, - GKeyFile *key_file, const char *uri, const char *title, gboolean type_directory) @@ -1644,7 +1642,6 @@ panel_ditem_editor_new_full (GtkWindow *parent, dialog = g_object_new (PANEL_TYPE_DITEM_EDITOR, "title", title, - "keyfile", key_file, "uri", uri, "type-directory", type_directory, NULL); @@ -1657,21 +1654,19 @@ panel_ditem_editor_new_full (GtkWindow *parent, GtkWidget * panel_ditem_editor_new (GtkWindow *parent, - GKeyFile *key_file, const char *uri, const char *title) { - return panel_ditem_editor_new_full (parent, key_file, uri, + return panel_ditem_editor_new_full (parent, uri, title, FALSE); } GtkWidget * panel_ditem_editor_new_directory (GtkWindow *parent, - GKeyFile *key_file, const char *uri, const char *title) { - return panel_ditem_editor_new_full (parent, key_file, uri, + return panel_ditem_editor_new_full (parent, uri, title, TRUE); } diff --git a/mate-panel/panel-ditem-editor.h b/mate-panel/panel-ditem-editor.h index 4b0a13c1..f08ec14b 100644 --- a/mate-panel/panel-ditem-editor.h +++ b/mate-panel/panel-ditem-editor.h @@ -85,12 +85,10 @@ typedef char * (*PanelDitemSaveUri) (PanelDItemEditor *dialog, gpointer data); GType panel_ditem_editor_get_type (void); GtkWidget *panel_ditem_editor_new (GtkWindow *parent, - GKeyFile *key_file, const char *uri, const char *title); GtkWidget *panel_ditem_editor_new_directory (GtkWindow *parent, - GKeyFile *key_file, const char *uri, const char *title); diff --git a/mate-panel/panel-util.c b/mate-panel/panel-util.c index 46ff444c..a958a761 100644 --- a/mate-panel/panel-util.c +++ b/mate-panel/panel-util.c @@ -760,20 +760,12 @@ panel_util_cairo_rgbdata_to_pixbuf (unsigned char *data, char * guess_icon_from_exec (GtkIconTheme *icon_theme, - GKeyFile *key_file) + const gchar *exec) { - char *exec; char *icon_name; char *path; - exec = panel_key_file_get_string (key_file, "Exec"); - if (!exec || !exec [0]) { - g_free (exec); - return NULL; - } - icon_name = g_path_get_basename (exec); - g_free (exec); path = panel_find_icon (icon_theme, icon_name, 48); if (!path) { diff --git a/mate-panel/panel-util.h b/mate-panel/panel-util.h index d30c9810..21352970 100644 --- a/mate-panel/panel-util.h +++ b/mate-panel/panel-util.h @@ -55,7 +55,7 @@ GdkPixbuf *panel_util_cairo_rgbdata_to_pixbuf (unsigned char *data, int height); char *guess_icon_from_exec (GtkIconTheme *icon_theme, - GKeyFile *key_file); + const gchar *exec); const char *panel_util_get_vfs_method_display_name (const char *method); char *panel_util_get_label_for_uri (const char *text_uri); diff --git a/mate-panel/xstuff.c b/mate-panel/xstuff.c index 885bd65d..f9156c31 100644 --- a/mate-panel/xstuff.c +++ b/mate-panel/xstuff.c @@ -367,9 +367,6 @@ xstuff_zoom_animate (GtkWidget *widget, dest.x, dest.y, dest.width, dest.height, MINIATURIZE_ANIMATION_STEPS_Z); } - - if (pixbuf) - g_object_unref (pixbuf); } static int |