changeset 3600:aba660a4a15d trunk

Pop up playback menu if right clicked over playback-control widgets
author Tomasz Mon <desowin@gmail.com>
date Sun, 23 Sep 2007 15:36:35 +0200
parents 24ae9b303a9d
children 98ba3170b2de
files src/audacious/ui_main.c src/audacious/ui_skinned_button.c src/audacious/ui_skinned_horizontal_slider.c
diffstat 3 files changed, 46 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/ui_main.c	Sat Sep 22 22:50:57 2007 +0300
+++ b/src/audacious/ui_main.c	Sun Sep 23 15:36:35 2007 +0200
@@ -371,17 +371,6 @@
                             1, GDK_CURRENT_TIME);
 }
 
-static void
-mainwin_about_cb(void)
-{
-    gint x, y;
-    gdk_window_get_pointer(NULL, &x, &y, NULL);
-    ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu),
-                            x + 6 * (1 + cfg.doublesize),
-                            y + MAINWIN_SHADED_HEIGHT * (1 + cfg.doublesize),
-                            1, GDK_CURRENT_TIME);
-}
-
 void
 mainwin_minimize_cb(void)
 {
@@ -860,6 +849,16 @@
 }
 
 static gboolean
+mainwin_widget_contained(GdkEventButton *event, int x, int y, int w, int h)
+{
+    if ((event->x > x && event->y > y) &&
+        (event->x < x+w && event->y < y+h))
+    return TRUE;
+
+    return FALSE;
+}
+
+static gboolean
 mainwin_mouse_button_press(GtkWidget * widget,
                            GdkEventButton * event,
                            gpointer callback_data)
@@ -887,7 +886,21 @@
     }
 
     if (event->button == 3) {
-        if ( (event->y > 70) && (event->x < 128) )
+        /* Pop up playback menu if right clicked over playback-control widgets,
+         * otherwise popup general menu
+         */
+        if (mainwin_widget_contained(event, bmp_active_skin->properties.mainwin_position_x,
+                                     bmp_active_skin->properties.mainwin_position_y, 248, 10) ||
+            mainwin_widget_contained(event, bmp_active_skin->properties.mainwin_previous_x,
+                                     bmp_active_skin->properties.mainwin_previous_y, 23, 18) ||
+            mainwin_widget_contained(event, bmp_active_skin->properties.mainwin_play_x,
+                                     bmp_active_skin->properties.mainwin_play_y, 23, 18) ||
+            mainwin_widget_contained(event, bmp_active_skin->properties.mainwin_pause_x,
+                                     bmp_active_skin->properties.mainwin_pause_y, 23, 18) ||
+            mainwin_widget_contained(event, bmp_active_skin->properties.mainwin_stop_x,
+                                     bmp_active_skin->properties.mainwin_stop_y, 23, 18) ||
+            mainwin_widget_contained(event, bmp_active_skin->properties.mainwin_next_x,
+                                     bmp_active_skin->properties.mainwin_next_y, 23, 18))
         {
 
             ui_manager_popup_menu_show(GTK_MENU(mainwin_playback_menu),
@@ -2477,7 +2490,6 @@
     mainwin_about = ui_skinned_button_new();
     ui_skinned_small_button_setup(mainwin_about, SKINNED_WINDOW(mainwin)->fixed, 247, 83, 20, 25);
     g_signal_connect(mainwin_about, "clicked", show_about_window, NULL);
-    g_signal_connect(mainwin_about, "right-clicked", mainwin_about_cb, NULL );
 
     mainwin_vis = ui_vis_new(SKINNED_WINDOW(mainwin)->fixed, 24, 43, 76);
     g_signal_connect(mainwin_vis, "button-press-event", G_CALLBACK(mainwin_vis_cb), NULL);
--- a/src/audacious/ui_skinned_button.c	Sat Sep 22 22:50:57 2007 +0300
+++ b/src/audacious/ui_skinned_button.c	Sun Sep 23 15:36:35 2007 +0200
@@ -28,7 +28,6 @@
     PRESSED,
     RELEASED,
     CLICKED,
-    RIGHT_CLICKED,
     DOUBLED,
     REDRAW,
     LAST_SIGNAL
@@ -128,7 +127,6 @@
     klass->pressed = button_pressed;
     klass->released = button_released;
     klass->clicked = NULL;
-    klass->right_clicked = NULL;
     klass->doubled = ui_skinned_button_toggle_doublesize;
     klass->redraw = ui_skinned_button_redraw;
 
@@ -147,11 +145,6 @@
                       G_STRUCT_OFFSET (UiSkinnedButtonClass, clicked), NULL, NULL,
                       gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
 
-    button_signals[RIGHT_CLICKED] = 
-        g_signal_new ("right-clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
-                      G_STRUCT_OFFSET (UiSkinnedButtonClass, right_clicked), NULL, NULL,
-                      gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
-
     button_signals[DOUBLED] = 
         g_signal_new ("toggle-double-size", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
                       G_STRUCT_OFFSET (UiSkinnedButtonClass, doubled), NULL, NULL,
@@ -455,6 +448,11 @@
 
         if (event->button == 1)
             ui_skinned_button_pressed (button);
+        else if (event->button == 3) {
+            event->x = event->x + button->x;
+            event->y = event->y + button->y;
+            return FALSE;
+        }
     }
 
     return TRUE;
@@ -465,10 +463,7 @@
     if (event->button == 1) {
             button = UI_SKINNED_BUTTON(widget);
             ui_skinned_button_released(button);
-    } else if (event->button == 3) {
-            g_signal_emit(widget, button_signals[RIGHT_CLICKED], 0);
     }
-
     return TRUE;
 }
 
--- a/src/audacious/ui_skinned_horizontal_slider.c	Sat Sep 22 22:50:57 2007 +0300
+++ b/src/audacious/ui_skinned_horizontal_slider.c	Sun Sep 23 15:36:35 2007 +0200
@@ -295,21 +295,25 @@
 
     if (event->type == GDK_BUTTON_PRESS) {
         if (event->button == 1) {
-        gint x;
+            gint x;
 
-        x = event->x - (priv->knob_width / (priv->double_size ? 1 : 2));
-        hs->pressed = TRUE;
+            x = event->x - (priv->knob_width / (priv->double_size ? 1 : 2));
+            hs->pressed = TRUE;
 
-        priv->position = x/(1+priv->double_size);
-        if (priv->position < priv->min)
-                    priv->position = priv->min;
-                if (priv->position > priv->max)
-                    priv->position = priv->max;
-                if (priv->frame_cb)
-                    priv->frame = priv->frame_cb(priv->position);
+            priv->position = x/(1+priv->double_size);
+            if (priv->position < priv->min)
+                priv->position = priv->min;
+            if (priv->position > priv->max)
+                priv->position = priv->max;
+            if (priv->frame_cb)
+                priv->frame = priv->frame_cb(priv->position);
 
-        g_signal_emit_by_name(widget, "motion", priv->position);
-        gtk_widget_queue_draw(widget);
+            g_signal_emit_by_name(widget, "motion", priv->position);
+            gtk_widget_queue_draw(widget);
+        } else if (event->button == 3) {
+            event->x = event->x + hs->x;
+            event->y = event->y + hs->y;
+            return FALSE;
         }
     }
     return TRUE;