Improve popup menu of plugins.
[lxde/lxpanel.git] / src / plugins / launchbar.c
index 2464790..c24ed89 100644 (file)
@@ -67,6 +67,7 @@ static const GtkTargetEntry target_table[] = {
 static const char desktop_ent[] = "Desktop Entry";
 
 typedef struct btn_t {
+    Plugin* plugin;
     GtkWidget* widget;
     gchar *desktop_id;
     gchar *image;
@@ -101,27 +102,50 @@ on_button_event(GtkWidget *widget, GdkEventButton *event, btn_t *b )
 {
     GtkWidget *image;
 
-    if( event->button == 1 )   /* left button */
+    if( event->button == 1 )    /* left button */
     {
-               image = gtk_bin_get_child(GTK_BIN(widget));
-               g_assert(b != NULL);
-               if (event->type == GDK_BUTTON_RELEASE) {
-                       if ((event->x >=0 && event->x < widget->allocation.width)
-                                 && (event->y >=0 && event->y < widget->allocation.height)) {
-
-                               g_spawn_command_line_async(b->action, NULL);
-                       }
-                       gtk_misc_set_padding (GTK_MISC(image), 0, 0);
-
-                       //system(b->action);
-               } else if (event->type == GDK_BUTTON_PRESS) {
-
-                       gtk_misc_set_padding (GTK_MISC(image), 0, 3);
-                       //ERR("here\n");
-               }
-       return TRUE;
-       }
-       return FALSE;
+        image = gtk_bin_get_child(GTK_BIN(widget));
+        g_assert(b != NULL);
+        if (event->type == GDK_BUTTON_RELEASE) {
+            if ((event->x >=0 && event->x < widget->allocation.width)
+                  && (event->y >=0 && event->y < widget->allocation.height)) {
+
+                g_spawn_command_line_async(b->action, NULL);
+            }
+            gtk_misc_set_padding (GTK_MISC(image), 0, 0);
+
+            //system(b->action);
+        } else if (event->type == GDK_BUTTON_PRESS) {
+
+            gtk_misc_set_padding (GTK_MISC(image), 0, 3);
+            //ERR("here\n");
+        }
+        return TRUE;
+    }
+    else if(event->button == 3) /* right click */
+    {
+        GtkMenu* popup = lxpanel_get_panel_menu( b->plugin->panel, b->plugin, TRUE );
+        GtkWidget* item;
+        char* title;
+
+#if 0
+        item = gtk_image_menu_item_new_with_label( _("Add Button") );
+        gtk_menu_shell_append( popup, item );
+        item = gtk_image_menu_item_new_with_label( _("Button Properties") );
+        gtk_menu_shell_append( popup, item );
+        /*
+        title = g_strdup_printf( _("Remove \"%s\""), b-> );
+        item = gtk_image_menu_item_new_with_label( _("Remove ") );
+        */
+        item = gtk_image_menu_item_new_with_label( _("Remove Button") );
+        gtk_menu_shell_append( popup, item );
+#endif
+        gtk_widget_show_all( (GtkWidget*)popup );
+
+        gtk_menu_popup( popup, NULL, NULL, NULL, NULL, event->button, event->time );
+        return TRUE;
+    }
+    return FALSE;
 }
 
 static void
@@ -201,6 +225,7 @@ read_button(Plugin *p, char** fp)
     ENTER;
 
     btn = g_slice_new0( btn_t );
+    btn->plugin = p;
 
     s.len = 256;
     fname= NULL;