Updating branch refs/heads/master
         to 12b9528fd10769fff10346a503922fa280d0c293 (commit)
       from c0c498678def0f32f24bb0a1653408c78f9495da (commit)

commit 12b9528fd10769fff10346a503922fa280d0c293
Author: Eric Koegel <eric.koe...@gmail.com>
Date:   Sun Mar 2 10:20:56 2014 +0300

    Right click edits launchers
    
    When performing a right click, or shift + left click, on an item
    in the applications sub-menu of the desktop menu it will now pop
    up the dialog to edit the launcher.

 src/xfce-desktop.c            |    3 ++-
 src/xfdesktop-app-menu-item.c |   53 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/src/xfce-desktop.c b/src/xfce-desktop.c
index 7ba3caa..85ea597 100644
--- a/src/xfce-desktop.c
+++ b/src/xfce-desktop.c
@@ -1219,7 +1219,8 @@ xfce_desktop_popup_menu(GtkWidget *w)
     }
     
     xfce_desktop_popup_root_menu(XFCE_DESKTOP(w), button, etime);
-    
+
+    gdk_event_free((GdkEvent*)evt);
     return TRUE;
 }
 
diff --git a/src/xfdesktop-app-menu-item.c b/src/xfdesktop-app-menu-item.c
index ca19499..f443ec9 100644
--- a/src/xfdesktop-app-menu-item.c
+++ b/src/xfdesktop-app-menu-item.c
@@ -331,16 +331,67 @@ xfdesktop_app_menu_item_command(XfdesktopAppMenuItem 
*app_menu_item)
     return g_string_free(newstr, FALSE);
 }
 
+static gboolean
+xfdesktop_app_menu_item_edit_launcher(XfdesktopAppMenuItem *app_menu_item)
+{
+    GFile *file;
+    gchar *uri, *cmd;
+    GError *error = NULL;
+    gboolean ret = FALSE;
+
+    file = garcon_menu_item_get_file(app_menu_item->item);
+
+    if(file) {
+        uri = g_file_get_uri(file);
+        cmd = g_strdup_printf("exo-desktop-item-edit \"%s\"", uri);
+
+        if(!xfce_spawn_command_line_on_screen(NULL, cmd, FALSE, FALSE, 
&error)) {
+            xfce_message_dialog(NULL, _("Launch Error"),
+                                GTK_STOCK_DIALOG_ERROR,
+                                _("Unable to launch \"exo-desktop-item-edit\", 
which is required to create and edit launchers and links on the desktop."),
+                                error->message, GTK_STOCK_CLOSE,
+                                GTK_RESPONSE_ACCEPT, NULL);
+            g_error_free(error);
+        } else {
+            ret = TRUE;
+        }
+
+        g_free(uri);
+        g_free(cmd);
+        g_object_unref(file);
+    }
+
+    return ret;
+}
+
 static void
 xfdesktop_app_menu_item_activate (XfdesktopAppMenuItem *app_menu_item)
 {
    gchar *command;
+   GdkEventButton *evt;
+   guint button;
    GError *error = NULL;
 
+   TRACE("entering");
+
    command = xfdesktop_app_menu_item_command(app_menu_item);
    if (command == NULL)
        return;
 
+   evt = (GdkEventButton *)gtk_get_current_event();
+
+   /* Right click edits the launchers */
+   if(evt && GDK_BUTTON_RELEASE == evt->type) {
+       button = evt->button;
+
+       if(button == 3 || (button == 1 && (evt->state & GDK_SHIFT_MASK))) {
+            if(xfdesktop_app_menu_item_edit_launcher(app_menu_item)) {
+                gdk_event_free((GdkEvent*)evt);
+                return;
+            }
+       }
+   }
+
    
if(!xfce_spawn_command_line_on_screen(gtk_widget_get_screen(GTK_WIDGET(app_menu_item)),
                                          command,
                                          
garcon_menu_item_requires_terminal(app_menu_item->item),
@@ -350,6 +401,8 @@ xfdesktop_app_menu_item_activate (XfdesktopAppMenuItem 
*app_menu_item)
                  command, error->message);
         g_error_free(error);
     }
+
+    gdk_event_free((GdkEvent*)evt);
 }
 
 GtkWidget *
_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
https://mail.xfce.org/mailman/listinfo/xfce4-commits

Reply via email to