changeset 2496:71bee08db1c6 trunk

[svn] - widgetlist -> SkinnedWindow class + basic conversion in ui_main, other skinned windows remain
author nenolod
date Sat, 10 Feb 2007 20:09:23 -0800
parents 6fb56e6bc6ec
children 204d1bab71f9
files ChangeLog src/audacious/build_stamp.c src/audacious/ui_main.c src/audacious/ui_skinned_window.c src/audacious/ui_skinned_window.h
diffstat 5 files changed, 137 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Feb 10 17:04:31 2007 -0800
+++ b/ChangeLog	Sat Feb 10 20:09:23 2007 -0800
@@ -1,3 +1,14 @@
+2007-02-11 01:04:31 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [4000]
+  - remove debugging notices
+  - remove some more common dock code that is part of SkinnedWindow now.
+  
+  trunk/src/audacious/ui_equalizer.c |    4 ----
+  trunk/src/audacious/ui_main.c      |    4 ----
+  trunk/src/audacious/ui_playlist.c  |    5 -----
+  3 files changed, 13 deletions(-)
+
+
 2007-02-11 01:01:44 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [3998]
   Try to put some skinned window code in a common place.
--- a/src/audacious/build_stamp.c	Sat Feb 10 17:04:31 2007 -0800
+++ b/src/audacious/build_stamp.c	Sat Feb 10 20:09:23 2007 -0800
@@ -1,2 +1,2 @@
 #include <glib.h>
-const gchar *svn_stamp = "20070211-3998";
+const gchar *svn_stamp = "20070211-4000";
--- a/src/audacious/ui_main.c	Sat Feb 10 17:04:31 2007 -0800
+++ b/src/audacious/ui_main.c	Sat Feb 10 20:09:23 2007 -0800
@@ -111,6 +111,7 @@
     gint n_channels;
 };
 
+static GList *mainwin_wlist = NULL;
 
 GtkWidget *mainwin = NULL;
 GtkWidget *err = NULL; /* an error dialog for miscellaneous error messages */
@@ -160,8 +161,6 @@
 static SButton *mainwin_srew, *mainwin_splay, *mainwin_spause;
 static SButton *mainwin_sstop, *mainwin_sfwd, *mainwin_seject, *mainwin_about;
 
-static GList *mainwin_wlist = NULL;
-
 static gint mainwin_timeout_id;
 
 G_LOCK_DEFINE_STATIC(mainwin_title);
@@ -534,9 +533,9 @@
                 if (!w->redraw || !w->visible)
                     continue;
 
-            if (w->x > bmp_active_skin->properties.mainwin_width ||
-            w->y > bmp_active_skin->properties.mainwin_height)
-            continue;
+                if (w->x > bmp_active_skin->properties.mainwin_width ||
+                    w->y > bmp_active_skin->properties.mainwin_height)
+                    continue;
 
                 if (cfg.doublesize) {
                     gint width, height;
@@ -1051,52 +1050,6 @@
     return FALSE;
 }
 
-static gboolean
-inside_sensitive_widgets(gint x, gint y)
-{
-    return (widget_contains(WIDGET(mainwin_menubtn), x, y)
-            || widget_contains(WIDGET(mainwin_minimize), x, y)
-            || widget_contains(WIDGET(mainwin_shade), x, y)
-            || widget_contains(WIDGET(mainwin_close), x, y)
-            || widget_contains(WIDGET(mainwin_rew), x, y)
-            || widget_contains(WIDGET(mainwin_play), x, y)
-            || widget_contains(WIDGET(mainwin_pause), x, y)
-            || widget_contains(WIDGET(mainwin_stop), x, y)
-            || widget_contains(WIDGET(mainwin_fwd), x, y)
-            || widget_contains(WIDGET(mainwin_eject), x, y)
-            || widget_contains(WIDGET(mainwin_shuffle), x, y)
-            || widget_contains(WIDGET(mainwin_repeat), x, y)
-            || widget_contains(WIDGET(mainwin_pl), x, y)
-            || widget_contains(WIDGET(mainwin_eq), x, y)
-            || widget_contains(WIDGET(mainwin_info), x, y)
-            || widget_contains(WIDGET(mainwin_menurow), x, y)
-            || widget_contains(WIDGET(mainwin_volume), x, y)
-            || widget_contains(WIDGET(mainwin_balance), x, y)
-            || (widget_contains(WIDGET(mainwin_position), x, y) &&
-                widget_is_visible(WIDGET(mainwin_position)))
-            || widget_contains(WIDGET(mainwin_minus_num), x, y)
-            || widget_contains(WIDGET(mainwin_10min_num), x, y)
-            || widget_contains(WIDGET(mainwin_min_num), x, y)
-            || widget_contains(WIDGET(mainwin_10sec_num), x, y)
-            || widget_contains(WIDGET(mainwin_sec_num), x, y)
-            || widget_contains(WIDGET(mainwin_vis), x, y)
-            || widget_contains(WIDGET(mainwin_minimize), x, y)
-            || widget_contains(WIDGET(mainwin_shade), x, y)
-            || widget_contains(WIDGET(mainwin_close), x, y)
-            || widget_contains(WIDGET(mainwin_menubtn), x, y)
-            || widget_contains(WIDGET(mainwin_sposition), x, y)
-            || widget_contains(WIDGET(mainwin_stime_min), x, y)
-            || widget_contains(WIDGET(mainwin_stime_sec), x, y)
-            || widget_contains(WIDGET(mainwin_srew), x, y)
-            || widget_contains(WIDGET(mainwin_splay), x, y)
-            || widget_contains(WIDGET(mainwin_spause), x, y)
-            || widget_contains(WIDGET(mainwin_sstop), x, y)
-            || widget_contains(WIDGET(mainwin_sfwd), x, y)
-            || widget_contains(WIDGET(mainwin_seject), x, y)
-            || widget_contains(WIDGET(mainwin_svis), x, y)
-            || widget_contains(WIDGET(mainwin_about), x, y));
-}
-
 void
 mainwin_scrolled(GtkWidget *widget, GdkEventScroll *event,
     gpointer callback_data)
@@ -1142,7 +1095,7 @@
     }
 
     if (event->button == 1 && event->type == GDK_BUTTON_PRESS &&
-        !inside_sensitive_widgets(event->x, event->y) &&
+        !ui_skinned_window_widgetlist_contained(mainwin, event->x, event->y) &&
         (cfg.easy_move || event->y < 14)) {
         if (0 && hint_move_resize_available()) {
             hint_move_resize(mainwin, event->x_root, event->y_root, TRUE);
@@ -1155,7 +1108,7 @@
         }
     }
     else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS &&
-             event->y < 14 && !inside_sensitive_widgets(event->x, event->y)) {
+             event->y < 14 && !ui_skinned_window_widgetlist_contained(mainwin, event->x, event->y)) {
         mainwin_set_shade(!cfg.player_shaded);
         if (dock_is_moving(GTK_WINDOW(mainwin)))
             dock_move_release(GTK_WINDOW(mainwin));
@@ -1645,10 +1598,10 @@
                            0, row, 1, desc_buf, -1);
         row++;
 
-    if(desc_buf) {
-        g_free(desc_buf);
-        desc_buf = NULL;
-    }
+        if(desc_buf) {
+            g_free(desc_buf);
+            desc_buf = NULL;
+        }
     }
 
     gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
@@ -1743,10 +1696,11 @@
         }
 
         song_index++;
-    if (filename) {
-        g_free(filename);
-        filename = NULL;
-    }
+
+        if (filename) {
+            g_free(filename);
+            filename = NULL;
+        }
     }
 
     PLAYLIST_UNLOCK(playlist->mutex);
@@ -3220,11 +3174,6 @@
     mainwin_stop =
         create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 85, 88, 23,
                        18, 69, 0, 69, 18, mainwin_stop_pushed, SKIN_CBUTTONS);
-#if 0
-    mainwin_fwd =
-        create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 108, 88, 22,
-                       18, 92, 0, 92, 18, playlist_next, SKIN_CBUTTONS);
-#endif
     mainwin_fwd =
         create_pbutton_ex(&mainwin_wlist, mainwin_bg, mainwin_gc, 108, 88, 22,
                        18, 92, 0, 92, 18, mainwin_fwd_pushed, mainwin_fwd_release,
@@ -3393,6 +3342,62 @@
     gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(err),
                                              "Boo! Bad stuff! Booga Booga!");
 
+    /* XXX: eventually update widgetcore API to not need this */
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_menubtn));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_minimize));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_shade));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_close));
+
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_rew));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_play));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_pause));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_stop));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_fwd));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_eject));
+
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_srew));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_splay));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_spause));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_sstop));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_sfwd));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_seject));
+
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_shuffle));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_repeat));
+
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_eq));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_pl));
+
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_info));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_othertext));
+
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_rate_text));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_freq_text));
+
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_menurow));
+
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_volume));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_balance));
+
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_monostereo));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_playstatus));
+
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_minus_num));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_10min_num));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_min_num));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_10sec_num));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_sec_num));
+
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_about));
+
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_vis));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_svis));
+
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_position));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_sposition));
+
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_stime_min));
+    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_stime_sec));
 }
 
 static void
--- a/src/audacious/ui_skinned_window.c	Sat Feb 10 17:04:31 2007 -0800
+++ b/src/audacious/ui_skinned_window.c	Sat Feb 10 20:09:23 2007 -0800
@@ -18,6 +18,7 @@
  */
 
 #include "platform/smartinclude.h"
+#include "widgets/widgetcore.h"
 
 #include <gtk/gtkmain.h>
 #include <glib-object.h>
@@ -155,3 +156,51 @@
 
     return widget;
 }
+
+void
+ui_skinned_window_widgetlist_associate(GtkWidget * widget, Widget * w)
+{
+    SkinnedWindow *sw;
+
+    g_return_if_fail(widget != NULL);
+    g_return_if_fail(w != NULL);
+
+    sw = SKINNED_WINDOW(widget);
+
+    sw->widget_list = g_list_append(sw->widget_list, w);
+}
+
+void
+ui_skinned_window_widgetlist_dissociate(GtkWidget * widget, Widget * w)
+{
+    SkinnedWindow *sw;
+
+    g_return_if_fail(widget != NULL);
+    g_return_if_fail(w != NULL);
+
+    sw = SKINNED_WINDOW(widget);
+
+    sw->widget_list = g_list_remove(sw->widget_list, w);
+}
+
+gboolean
+ui_skinned_window_widgetlist_contained(GtkWidget * widget, gint x, gint y)
+{
+    SkinnedWindow *sw;
+    GList *l;
+
+    g_return_val_if_fail(widget != NULL, FALSE);
+
+    sw = SKINNED_WINDOW(widget);
+
+    for (l = sw->widget_list; l != NULL; l = g_list_next(l))
+    {
+        Widget *w = WIDGET(l->data);
+
+        if (widget_contains(WIDGET(w), x, y) == TRUE)
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
--- a/src/audacious/ui_skinned_window.h	Sat Feb 10 17:04:31 2007 -0800
+++ b/src/audacious/ui_skinned_window.h	Sat Feb 10 20:09:23 2007 -0800
@@ -34,6 +34,8 @@
 
   GtkWidget *canvas;
   gint x,y;
+
+  GList *widget_list;
 };
 
 struct _SkinnedWindowClass
@@ -42,5 +44,8 @@
 };
 
 extern GtkWidget *ui_skinned_window_new(GtkWindowType type);
+extern void ui_skinned_window_widgetlist_associate(GtkWidget * widget, Widget * w);
+extern void ui_skinned_window_widgetlist_dissociate(GtkWidget * widget, Widget * w);
+extern gboolean ui_skinned_window_widgetlist_contained(GtkWidget * widget, gint x, gint y);
 
 #endif