changeset 3024:883713b145f8

use button-press-event signals
author Tomasz Mon <desowin@gmail.com>
date Tue, 10 Jul 2007 17:00:43 +0200
parents 49ce30748980
children bd32633b4de2
files src/audacious/ui_main.c src/audacious/ui_skinned_number.c src/audacious/ui_skinned_number.h src/audacious/ui_vis.c src/audacious/ui_vis.h
diffstat 5 files changed, 34 insertions(+), 98 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/ui_main.c	Tue Jul 10 17:13:24 2007 +0300
+++ b/src/audacious/ui_main.c	Tue Jul 10 17:00:43 2007 +0200
@@ -477,24 +477,34 @@
     exit(EXIT_SUCCESS);
 }
 
-void
-mainwin_vis_cb(void)
+gboolean
+mainwin_num_clicked(GtkWidget *widget, GdkEventButton *event)
+{
+    if (event->button == 1) {
+        change_timer_mode();
+    } else if (event->button == 3)
+        return FALSE;
+
+    return TRUE;
+}
+
+gboolean
+mainwin_vis_cb(GtkWidget *widget, GdkEventButton *event)
 {
-    cfg.vis_type++;
-
-    if (cfg.vis_type > VIS_OFF)
-        cfg.vis_type = VIS_ANALYZER;
-
-    mainwin_vis_set_type(cfg.vis_type);
-}
-
-void
-mainwin_vis_menu_cb(void)
-{
-    gint x, y;
-    gdk_window_get_pointer(NULL, &x, &y, NULL);
-    ui_manager_popup_menu_show(GTK_MENU(mainwin_visualization_menu),
-                               x, y, 3, GDK_CURRENT_TIME);
+    if (event->button == 1) {
+        cfg.vis_type++;
+
+        if (cfg.vis_type > VIS_OFF)
+            cfg.vis_type = VIS_ANALYZER;
+
+        mainwin_vis_set_type(cfg.vis_type);
+    } else if (event->button == 3) {
+        gint x, y;
+        gdk_window_get_pointer(NULL, &x, &y, NULL);
+        ui_manager_popup_menu_show(GTK_MENU(mainwin_visualization_menu),
+                                   x, y, 3, event->time);
+    }
+    return TRUE;
 }
 
 static void
@@ -1121,7 +1131,7 @@
 
     if ((event->button == 1) && event->type != GDK_2BUTTON_PRESS &&
          widget_contains(WIDGET(mainwin_svis), event->x, event->y) ) {
-         mainwin_vis_cb();
+         /* it'll get sorted out when svis will become UiSvis */
     }
 
     if (event->button == 3) {
@@ -2833,19 +2843,19 @@
         create_playstatus(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 24, 28);
 
     mainwin_minus_num = ui_skinned_number_new(SKINNED_WINDOW(mainwin)->fixed, 36, 26, SKIN_NUMBERS);
-    g_signal_connect(mainwin_minus_num, "clicked", change_timer_mode, NULL);
+    g_signal_connect(mainwin_minus_num, "button-press-event", G_CALLBACK(mainwin_num_clicked), NULL);
 
     mainwin_10min_num = ui_skinned_number_new(SKINNED_WINDOW(mainwin)->fixed, 48, 26, SKIN_NUMBERS);
-    g_signal_connect(mainwin_10min_num, "clicked", change_timer_mode, NULL);
+    g_signal_connect(mainwin_10min_num, "button-press-event", G_CALLBACK(mainwin_num_clicked), NULL);
 
     mainwin_min_num = ui_skinned_number_new(SKINNED_WINDOW(mainwin)->fixed, 60, 26, SKIN_NUMBERS);
-    g_signal_connect(mainwin_min_num, "clicked", change_timer_mode, NULL);
+    g_signal_connect(mainwin_min_num, "button-press-event", G_CALLBACK(mainwin_num_clicked), NULL);
 
     mainwin_10sec_num = ui_skinned_number_new(SKINNED_WINDOW(mainwin)->fixed, 78, 26, SKIN_NUMBERS);
-    g_signal_connect(mainwin_10sec_num, "clicked", change_timer_mode, NULL);
+    g_signal_connect(mainwin_10sec_num, "button-press-event", G_CALLBACK(mainwin_num_clicked), NULL);
 
     mainwin_sec_num = ui_skinned_number_new(SKINNED_WINDOW(mainwin)->fixed, 90, 26, SKIN_NUMBERS);
-    g_signal_connect(mainwin_sec_num, "clicked", change_timer_mode, NULL);
+    g_signal_connect(mainwin_sec_num, "button-press-event", G_CALLBACK(mainwin_num_clicked), NULL);
 
     mainwin_about = ui_skinned_button_new();
     ui_skinned_small_button_setup(mainwin_about, SKINNED_WINDOW(mainwin)->fixed, 247, 83, 20, 25);
@@ -2853,9 +2863,7 @@
     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, "clicked", mainwin_vis_cb, NULL);
-    g_signal_connect(mainwin_vis, "right-clicked", mainwin_vis_menu_cb, NULL);
-
+    g_signal_connect(mainwin_vis, "button-press-event", G_CALLBACK(mainwin_vis_cb), NULL);
     mainwin_svis = create_svis(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 79, 5);
 
     mainwin_position =
--- a/src/audacious/ui_skinned_number.c	Tue Jul 10 17:13:24 2007 +0300
+++ b/src/audacious/ui_skinned_number.c	Tue Jul 10 17:00:43 2007 +0200
@@ -36,9 +36,7 @@
 #define UI_TYPE_SKINNED_NUMBER           (ui_skinned_number_get_type())
 
 enum {
-    CLICKED,
     DOUBLED,
-    REDRAW,
     LAST_SIGNAL
 };
 
@@ -49,7 +47,6 @@
 static void ui_skinned_number_size_request       (GtkWidget *widget, GtkRequisition *requisition);
 static void ui_skinned_number_size_allocate      (GtkWidget *widget, GtkAllocation *allocation);
 static gboolean ui_skinned_number_expose         (GtkWidget *widget, GdkEventExpose *event);
-static gboolean ui_skinned_number_button_press   (GtkWidget *widget, GdkEventButton *event);
 static void ui_skinned_number_toggle_doublesize  (UiSkinnedNumber *number);
 
 static GtkWidgetClass *parent_class = NULL;
@@ -89,16 +86,9 @@
     widget_class->expose_event = ui_skinned_number_expose;
     widget_class->size_request = ui_skinned_number_size_request;
     widget_class->size_allocate = ui_skinned_number_size_allocate;
-    widget_class->button_press_event = ui_skinned_number_button_press;
 
-    klass->clicked = NULL;
     klass->doubled = ui_skinned_number_toggle_doublesize;
 
-    number_signals[CLICKED] = 
-        g_signal_new ("clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
-                      G_STRUCT_OFFSET (UiSkinnedNumberClass, clicked), NULL, NULL,
-                      gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
-
     number_signals[DOUBLED] = 
         g_signal_new ("toggle-double-size", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
                       G_STRUCT_OFFSET (UiSkinnedNumberClass, doubled), NULL, NULL,
@@ -232,21 +222,6 @@
     return FALSE;
 }
 
-static gboolean ui_skinned_number_button_press(GtkWidget *widget, GdkEventButton *event) {
-    g_return_val_if_fail (widget != NULL, FALSE);
-    g_return_val_if_fail (UI_SKINNED_IS_NUMBER (widget), FALSE);
-    g_return_val_if_fail (event != NULL, FALSE);
-
-    if (event->type == GDK_BUTTON_PRESS) {
-        if (event->button == 1) {
-                g_signal_emit(widget, number_signals[CLICKED], 0);
-        } else if (event->button == 3)
-                   return FALSE;
-    }
-
-    return TRUE;
-}
-
 static void ui_skinned_number_toggle_doublesize(UiSkinnedNumber *number) {
     GtkWidget *widget = GTK_WIDGET (number);
     number->double_size = !number->double_size;
--- a/src/audacious/ui_skinned_number.h	Tue Jul 10 17:13:24 2007 +0300
+++ b/src/audacious/ui_skinned_number.h	Tue Jul 10 17:00:43 2007 +0200
@@ -47,7 +47,6 @@
 
 struct _UiSkinnedNumberClass {
     GtkWidgetClass          parent_class;
-    void (* clicked)        (UiSkinnedNumber *textbox);
     void (* doubled)        (UiSkinnedNumber *textbox);
 };
 
--- a/src/audacious/ui_vis.c	Tue Jul 10 17:13:24 2007 +0300
+++ b/src/audacious/ui_vis.c	Tue Jul 10 17:00:43 2007 +0200
@@ -44,10 +44,7 @@
 static guchar voiceprint_data[76*16];
 
 enum {
-    CLICKED,
-    RIGHT_CLICKED,
     DOUBLED,
-    REDRAW,
     LAST_SIGNAL
 };
 
@@ -59,8 +56,6 @@
 static void ui_vis_size_request       (GtkWidget *widget, GtkRequisition *requisition);
 static void ui_vis_size_allocate      (GtkWidget *widget, GtkAllocation *allocation);
 static gboolean ui_vis_expose         (GtkWidget *widget, GdkEventExpose *event);
-static gboolean ui_vis_button_press   (GtkWidget *widget, GdkEventButton *event);
-static gboolean ui_vis_button_release (GtkWidget *widget, GdkEventButton *event);
 static void ui_vis_toggle_doublesize  (UiVis *vis);
 
 static GtkWidgetClass *parent_class = NULL;
@@ -101,23 +96,9 @@
     widget_class->expose_event = ui_vis_expose;
     widget_class->size_request = ui_vis_size_request;
     widget_class->size_allocate = ui_vis_size_allocate;
-    widget_class->button_press_event = ui_vis_button_press;
-    widget_class->button_release_event = ui_vis_button_release;
 
-    klass->clicked = NULL;
-    klass->right_clicked = NULL;
     klass->doubled = ui_vis_toggle_doublesize;
 
-    vis_signals[CLICKED] = 
-        g_signal_new ("clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
-                      G_STRUCT_OFFSET (UiVisClass, clicked), NULL, NULL,
-                      gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
-
-    vis_signals[RIGHT_CLICKED] = 
-        g_signal_new ("right-clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
-                      G_STRUCT_OFFSET (UiVisClass, right_clicked), NULL, NULL,
-                      gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
-
     vis_signals[DOUBLED] = 
         g_signal_new ("toggle-double-size", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
                       G_STRUCT_OFFSET (UiVisClass, doubled), NULL, NULL,
@@ -560,31 +541,6 @@
     return FALSE;
 }
 
-static gboolean ui_vis_button_press(GtkWidget *widget, GdkEventButton *event) {
-    g_return_val_if_fail (widget != NULL, FALSE);
-    g_return_val_if_fail (UI_IS_VIS (widget), FALSE);
-    g_return_val_if_fail (event != NULL, FALSE);
-
-    if (event->type == GDK_BUTTON_PRESS) {
-        if (event->button == 1) {
-                g_signal_emit(widget, vis_signals[CLICKED], 0);
-        }
-    }
-
-    return TRUE;
-}
-
-static gboolean ui_vis_button_release(GtkWidget *widget, GdkEventButton *event) {
-    g_return_val_if_fail (widget != NULL, FALSE);
-    g_return_val_if_fail (UI_IS_VIS (widget), FALSE);
-    g_return_val_if_fail (event != NULL, FALSE);
-
-    if (event->button == 3)
-        g_signal_emit(widget, vis_signals[RIGHT_CLICKED], 0);
-
-    return TRUE;
-}
-
 static void ui_vis_toggle_doublesize(UiVis *vis) {
     GtkWidget *widget = GTK_WIDGET (vis);
     vis->double_size = !vis->double_size;
--- a/src/audacious/ui_vis.h	Tue Jul 10 17:13:24 2007 +0300
+++ b/src/audacious/ui_vis.h	Tue Jul 10 17:00:43 2007 +0200
@@ -80,8 +80,6 @@
 
 struct _UiVisClass {
     GtkWidgetClass          parent_class;
-    void (* clicked)        (UiVis *vis);
-    void (* right_clicked)  (UiVis *vis);
     void (* doubled)        (UiVis *vis);
 };