changeset 3218:018b37cf0730 trunk

hasta la vista old widgetcore
author Tomasz Mon <desowin@gmail.com>
date Thu, 02 Aug 2007 14:28:37 +0200
parents 764e8f87c186
children 2f08ee945857
files src/audacious/ui_equalizer.c src/audacious/ui_main.c src/audacious/ui_playlist.c src/audacious/ui_skinned_playlist.c src/audacious/ui_skinned_window.c src/audacious/ui_skinned_window.h src/audacious/widgets/Makefile src/audacious/widgets/widget.c src/audacious/widgets/widget.h src/audacious/widgets/widgetcore.h
diffstat 10 files changed, 12 insertions(+), 514 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/ui_equalizer.c	Thu Aug 02 14:14:32 2007 +0200
+++ b/src/audacious/ui_equalizer.c	Thu Aug 02 14:28:37 2007 +0200
@@ -323,8 +323,7 @@
     }
 
     if (event->button == 1 && event->type == GDK_BUTTON_PRESS &&
-        ((cfg.easy_move || cfg.equalizer_shaded || event->y < 14) &&
-         !ui_skinned_window_widgetlist_contained(equalizerwin, event->x, event->y))) {
+        (cfg.easy_move || cfg.equalizer_shaded || event->y < 14)) {
          equalizerwin_raise();
          dock_move_press(dock_window_list, GTK_WINDOW(equalizerwin), event,
                          FALSE);
--- a/src/audacious/ui_main.c	Thu Aug 02 14:14:32 2007 +0200
+++ b/src/audacious/ui_main.c	Thu Aug 02 14:28:37 2007 +0200
@@ -1037,14 +1037,12 @@
     }
 
     if (event->button == 1 && event->type == GDK_BUTTON_PRESS &&
-        !ui_skinned_window_widgetlist_contained(mainwin, event->x, event->y) &&
         (cfg.easy_move || event->y < 14)) {
         gtk_window_present(GTK_WINDOW(mainwin));
         dock_move_press(dock_window_list, GTK_WINDOW(mainwin), event,
                         TRUE);
     }
-    else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS &&
-             event->y < 14 && !ui_skinned_window_widgetlist_contained(mainwin, event->x, event->y)) {
+    else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && event->y < 14) {
         mainwin_set_shade(!cfg.player_shaded);
         if (dock_is_moving(GTK_WINDOW(mainwin)))
             dock_move_release(GTK_WINDOW(mainwin));
--- a/src/audacious/ui_playlist.c	Thu Aug 02 14:14:32 2007 +0200
+++ b/src/audacious/ui_playlist.c	Thu Aug 02 14:28:37 2007 +0200
@@ -87,8 +87,6 @@
 static GtkWidget *playlistwin_sfwd, *playlistwin_seject;
 static GtkWidget *playlistwin_sscroll_up, *playlistwin_sscroll_down;
 
-static GList *playlistwin_wlist = NULL;
-
 void playlistwin_select_search_cbt_cb( GtkWidget *called_cbt ,
                                               gpointer other_cbt );
 static gboolean playlistwin_select_search_kp_cb( GtkWidget *entry , GdkEventKey *event ,
@@ -429,11 +427,6 @@
 
     if (dock_is_moving(GTK_WINDOW(playlistwin)))
        dock_move_release(GTK_WINDOW(playlistwin));
-    else
-    {
-       handle_release_cb(playlistwin_wlist, widget, event);
-       draw_playlist_window(FALSE);
-    }
 }
 
 void
@@ -641,7 +634,6 @@
 {
     gint tx, ty;
     gint dx, dy;
-    gboolean redraw;
 
     g_return_if_fail(width > 0 && height > 0);
 
@@ -697,19 +689,14 @@
     playlistwin_bg = gdk_pixmap_new(playlistwin->window, width, height, -1);
     playlistwin_set_mask();
 
-    widget_list_lock(playlistwin_wlist);
     GList *iter;
     for (iter = GTK_FIXED (SKINNED_WINDOW(playlistwin)->fixed)->children; iter; iter = g_list_next (iter)) {
          GtkFixedChild *child_data = (GtkFixedChild *) iter->data;
          GtkWidget *child = child_data->widget;
          g_signal_emit_by_name(child, "redraw");
     }
-    widget_list_change_pixmap(playlistwin_wlist, playlistwin_bg);
     playlistwin_draw_frame();
-    widget_list_draw(playlistwin_wlist, &redraw, TRUE);
-    widget_list_clear_redraw(playlistwin_wlist);
 
-    widget_list_unlock(playlistwin_wlist);
     g_mutex_unlock(resize_mutex);
 
     gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0);
@@ -740,11 +727,6 @@
     }
     else if (dock_is_moving(GTK_WINDOW(playlistwin)))
         dock_move_motion(GTK_WINDOW(playlistwin), event);
-    else
-    {
-        handle_motion_cb(playlistwin_wlist, widget, event);
-        draw_playlist_window(FALSE);
-    }
     gdk_flush();
 
     while ((gevent = gdk_event_get()) != NULL) gdk_event_free(gevent);
@@ -1133,16 +1115,13 @@
             cfg.timer_mode = TIMER_ELAPSED;
     }
     else if (event->button == 1 && event->type == GDK_BUTTON_PRESS &&
-             !ui_skinned_window_widgetlist_contained(playlistwin, event->x,
-                                                     event->y) &&
              (cfg.easy_move || event->y < 14))
     {
         dock_move_press(dock_window_list, GTK_WINDOW(playlistwin), event,
                         FALSE);
         gtk_window_present(GTK_WINDOW(playlistwin));
     }
-    else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS &&
-             !ui_skinned_window_widgetlist_contained(playlistwin, event->x, event->y)
+    else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS
              && event->y < 14) {
         /* double click on title bar */
         playlistwin_shade_toggle();
@@ -1171,9 +1150,6 @@
     {
         GList *node;
 
-        handle_press_cb(playlistwin_wlist, widget, event);
-        draw_playlist_window(FALSE);
-
         node = playlist_get_selected(playlist);
 
         if (node != NULL)
@@ -1184,10 +1160,6 @@
 
         grab = FALSE;
     }
-    else {
-        handle_press_cb(playlistwin_wlist, widget, event);
-        draw_playlist_window(FALSE);
-    }
 
     if (grab)
         gdk_pointer_grab(playlistwin->window, FALSE,
@@ -1413,43 +1385,18 @@
 void
 draw_playlist_window(gboolean force)
 {
-    gboolean redraw;
-    GList *wl;
-    Widget *w;
 
-    if (force)
+    if (force) {
         playlistwin_draw_frame();
-
-    widget_list_lock(playlistwin_wlist);
-    widget_list_draw(playlistwin_wlist, &redraw, force);
-
-    if (redraw || force) {
-        if (force) {
-            widget_list_unlock(playlistwin_wlist);
-            gdk_window_clear(playlistwin->window);
-            GList *iter;
-            for (iter = GTK_FIXED (SKINNED_WINDOW(playlistwin)->fixed)->children; iter; iter = g_list_next (iter)) {
-                GtkFixedChild *child_data = (GtkFixedChild *) iter->data;
-                GtkWidget *child = child_data->widget;
-                gtk_widget_queue_draw(child);
-            }
+        gdk_window_clear(playlistwin->window);
+        GList *iter;
+        for (iter = GTK_FIXED (SKINNED_WINDOW(playlistwin)->fixed)->children; iter; iter = g_list_next (iter)) {
+            GtkFixedChild *child_data = (GtkFixedChild *) iter->data;
+            GtkWidget *child = child_data->widget;
+            gtk_widget_queue_draw(child);
         }
-        else {
-            for (wl = playlistwin_wlist; wl; wl = g_list_next(wl)) {
-                w = WIDGET(wl->data);
-                if (w->redraw && w->visible) {
-                    gdk_window_clear_area(playlistwin->window, w->x, w->y,
-                                          w->width, w->height);
-                    w->redraw = FALSE;
-                }
-            }
-            widget_list_unlock(playlistwin_wlist);
-        }
-
         gdk_flush();
     }
-
-    widget_list_unlock(playlistwin_wlist);
 }
 
 
--- a/src/audacious/ui_skinned_playlist.c	Thu Aug 02 14:14:32 2007 +0200
+++ b/src/audacious/ui_skinned_playlist.c	Thu Aug 02 14:28:37 2007 +0200
@@ -670,7 +670,7 @@
             if ((y > pl->y)
                 && !(y > (priv->height + ply))) {
 
-                pos = ((y - ((Widget *) pl)->y) / pl->fheight) +
+                pos = ((y - pl->y) / pl->fheight) +
                     pl->first;
 
                 if (pos > (plength)) {
--- a/src/audacious/ui_skinned_window.c	Thu Aug 02 14:14:32 2007 +0200
+++ b/src/audacious/ui_skinned_window.c	Thu Aug 02 14:28:37 2007 +0200
@@ -178,51 +178,3 @@
     gtk_container_add(GTK_CONTAINER(widget), GTK_WIDGET(SKINNED_WINDOW(widget)->fixed));
     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	Thu Aug 02 14:14:32 2007 +0200
+++ b/src/audacious/ui_skinned_window.h	Thu Aug 02 14:28:37 2007 +0200
@@ -42,7 +42,6 @@
   GtkWidget *canvas;
   gint x,y;
 
-  GList *widget_list;
   GdkGC *gc;
   GtkWidget *fixed;
 };
@@ -54,8 +53,5 @@
 
 extern GType ui_skinned_window_get_type(void);
 extern GtkWidget *ui_skinned_window_new(const gchar *wmclass_name);
-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
--- a/src/audacious/widgets/Makefile	Thu Aug 02 14:14:32 2007 +0200
+++ b/src/audacious/widgets/Makefile	Thu Aug 02 14:28:37 2007 +0200
@@ -19,7 +19,6 @@
 	-I../../intl
 
 SOURCES = \
-	widget.c \
 	skin.c
 
 OBJECTS = ${SOURCES:.c=.o}
--- a/src/audacious/widgets/widget.c	Thu Aug 02 14:14:32 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,282 +0,0 @@
-/*  Audacious
- *  Copyright (C) 2005-2007  Audacious development team.
- *
- *  BMP - Cross-platform multimedia player
- *  Copyright (C) 2003-2004  BMP development team.
- *
- *  Based on XMMS:
- *  Copyright (C) 1998-2003  XMMS development team.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; under version 3 of the License.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses>.
- *
- *  The Audacious team does not consider modular code linking to
- *  Audacious or using our public API to be a derived work.
- */
-
-#include "widgetcore.h"
-
-#include <glib.h>
-#include <gdk/gdk.h>
-
-#include "debug.h"
-
-
-void
-widget_init(Widget * widget, GdkPixmap * parent, GdkGC * gc,
-            gint x, gint y, gint width, gint height, gint visible)
-{
-    widget->parent = parent;
-    widget->gc = gc;
-    widget_set_position(widget, x, y);
-    widget_set_size(widget, width, height);
-    widget->visible = visible;
-    widget->redraw = TRUE;
-    widget->mutex = g_mutex_new();
-}
-
-void
-widget_set_position(Widget * widget, gint x, gint y)
-{
-    widget->x = x;
-    widget->y = y;
-    widget_queue_redraw(widget);
-}
-
-void
-widget_set_size(Widget * widget, gint width, gint height)
-{
-    widget->width = width;
-    widget->height = height;
-    widget_queue_redraw(widget);
-}
-
-void
-widget_queue_redraw(Widget * widget)
-{
-    widget->redraw = TRUE;
-}
-
-gboolean
-widget_contains(Widget * widget, gint x, gint y)
-{
-    return (widget->visible &&
-            x >= widget->x && 
-            y >= widget->y && 
-            x <  widget->x + widget->width && 
-            y <  widget->y + widget->height);
-}
-
-void
-widget_show(Widget * widget)
-{
-    if (!widget)
-        return;
-
-    widget->visible = TRUE;
-    widget_draw(widget);
-}
-
-void
-widget_hide(Widget * widget)
-{
-    if (!widget)
-        return;
-
-    widget->visible = FALSE;
-}
-
-gboolean
-widget_is_visible(Widget * widget)
-{
-    if (!widget)
-        return FALSE;
-
-    return widget->visible;
-}
-
-void
-widget_resize(Widget * widget, gint width, gint height)
-{
-    widget_set_size(widget, width, height);
-}
-
-void
-widget_resize_relative(Widget * widget, gint width, gint height)
-{
-    widget_resize(widget, widget->width + width, widget->height + height);
-}
-
-void
-widget_move(Widget * widget, gint x, gint y)
-{
-    widget_lock(widget);
-    widget_set_position(widget, x, y);
-    widget_unlock(widget);
-}
-
-void
-widget_move_relative(Widget * widget, gint x, gint y)
-{
-    widget_move(widget, widget->x + x, widget->y + y);
-}
-
-void
-widget_draw(Widget * widget)
-{
-    if (widget->visible != TRUE)
-        return;
-
-    widget_lock(widget);
-    WIDGET(widget)->redraw = TRUE;
-    widget_unlock(widget);
-}
-
-void
-widget_draw_quick(Widget * widget)
-{
-    widget_lock(widget);
-    if (WIDGET(widget)->draw != NULL)
-    {
-        WIDGET(widget)->draw(widget);
-        gdk_flush();
-    }
-    widget_unlock(widget);
-}
-
-void
-widget_list_add(GList ** list, Widget * widget)
-{
-    (*list) = g_list_append(*list, widget);
-}
-
-void
-handle_press_cb(GList * widget_list, GtkWidget * widget,
-                GdkEventButton * event)
-{
-    GList *wl;
-
-    for (wl = widget_list; wl; wl = g_list_next(wl)) {
-        if (WIDGET(wl->data)->button_press_cb)
-            WIDGET(wl->data)->button_press_cb(widget, event, wl->data);
-    }
-}
-
-void
-handle_release_cb(GList * widget_list, GtkWidget * widget,
-                  GdkEventButton * event)
-{
-    GList *wl;
-
-    for (wl = widget_list; wl; wl = g_list_next(wl)) {
-        if (WIDGET(wl->data)->button_release_cb)
-            WIDGET(wl->data)->button_release_cb(widget, event, wl->data);
-    }
-}
-
-void
-handle_motion_cb(GList * widget_list, GtkWidget * widget,
-                 GdkEventMotion * event)
-{
-    GList *wl;
-
-    for (wl = widget_list; wl; wl = g_list_next(wl)) {
-        if (WIDGET(wl->data)->motion_cb)
-            WIDGET(wl->data)->motion_cb(widget, event, wl->data);
-    }
-}
-
-void
-handle_scroll_cb(GList * wlist, GtkWidget * widget, GdkEventScroll * event)
-{
-    GList *wl;
-
-    for (wl = wlist; wl; wl = g_list_next(wl)) {
-        if (WIDGET(wl->data)->mouse_scroll_cb)
-            WIDGET(wl->data)->mouse_scroll_cb(widget, event, wl->data);
-    }
-}
-
-void
-widget_list_draw(GList * widget_list, gboolean * redraw, gboolean force)
-{
-    GList *wl;
-    Widget *w;
-
-    *redraw = FALSE;
-    wl = widget_list;
-
-    for (wl = widget_list; wl; wl = g_list_next(wl)) {
-        w = WIDGET(wl->data);
-
-        REQUIRE_LOCK(w->mutex);
-
-        if (!w->draw)
-            continue;
-
-        if (!w->visible)
-            continue;
-
-        if (w->redraw || force) {
-            w->draw(w);
-/*             w->redraw = FALSE; */
-            *redraw = TRUE;
-        }
-    }
-}
-
-void
-widget_list_change_pixmap(GList * widget_list, GdkPixmap * pixmap)
-{
-    GList *wl;
-
-    for (wl = widget_list; wl; wl = g_list_next(wl)) {
-        Widget *widget = wl->data;
-        widget->parent = pixmap;
-        widget_queue_redraw(widget);
-    }
-}
-
-void
-widget_list_clear_redraw(GList * widget_list)
-{
-    GList *wl;
-
-    for (wl = widget_list; wl; wl = g_list_next(wl)) {
-        REQUIRE_LOCK(WIDGET(wl->data)->mutex);
-        WIDGET(wl->data)->redraw = FALSE;
-    }
-}
-
-void
-widget_lock(Widget * widget)
-{
-    g_mutex_lock(WIDGET(widget)->mutex);
-}
-
-void
-widget_unlock(Widget * widget)
-{
-    g_mutex_unlock(WIDGET(widget)->mutex);
-}
-
-void
-widget_list_lock(GList * widget_list)
-{
-    g_list_foreach(widget_list, (GFunc) widget_lock, NULL);
-}
-
-void
-widget_list_unlock(GList * widget_list)
-{
-    g_list_foreach(widget_list, (GFunc) widget_unlock, NULL);
-}
--- a/src/audacious/widgets/widget.h	Thu Aug 02 14:14:32 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-/*  Audacious
- *  Copyright (C) 2005-2007  Audacious development team.
- *
- *  BMP - Cross-platform multimedia player
- *  Copyright (C) 2003-2004  BMP development team.
- *
- *  Based on XMMS:
- *  Copyright (C) 1998-2003  XMMS development team.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; under version 3 of the License.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses>.
- *
- *  The Audacious team does not consider modular code linking to
- *  Audacious or using our public API to be a derived work.
- */
-
-#ifndef _WIDGETCORE_H_
-#error Please do not include me directly! Use widgetcore.h instead!
-#endif
-
-#ifndef WIDGET_H
-#define WIDGET_H
-
-
-#include <glib.h>
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-
-typedef struct _Widget Widget;
-
-
-typedef void (*WidgetButtonPressFunc) (GtkWidget *, GdkEventButton *,
-                                       gpointer);
-typedef void (*WidgetButtonReleaseFunc) (GtkWidget *, GdkEventButton *,
-                                         gpointer);
-typedef void (*WidgetMotionFunc) (GtkWidget *, GdkEventMotion *, gpointer);
-typedef void (*WidgetDrawFunc) (Widget *);
-typedef void (*WidgetScrollFunc) (GtkWidget *, GdkEventScroll *, gpointer);
-
-
-#define WIDGET(x)  ((Widget *)(x))
-struct _Widget {
-    GdkPixmap *parent;
-    GdkGC *gc;
-
-    gint x, y;
-    gint width, height;
-
-    gint visible;
-    gboolean redraw;
-
-    GMutex *mutex;
-
-    WidgetButtonPressFunc button_press_cb;
-    WidgetButtonReleaseFunc button_release_cb;
-    WidgetMotionFunc motion_cb;
-    WidgetDrawFunc draw;
-    WidgetScrollFunc mouse_scroll_cb;
-};
-
-
-void widget_init(Widget * widget, GdkPixmap * parent, GdkGC * gc,
-                 gint x, gint y, gint width, gint height, gint visible);
-
-void widget_set_position(Widget * widget, gint x, gint y);
-void widget_set_size(Widget * widget, gint width, gint height);
-void widget_queue_redraw(Widget * widget);
-
-void widget_lock(Widget * widget);
-void widget_unlock(Widget * widget);
-
-gboolean widget_contains(Widget * widget, gint x, gint y);
-
-void widget_show(Widget * widget);
-void widget_hide(Widget * widget);
-gboolean widget_is_visible(Widget * widget);
-
-void widget_resize(Widget * widget, gint width, gint height);
-void widget_resize_relative(Widget * widget, gint width, gint height);
-void widget_move(Widget * widget, gint x, gint y);
-void widget_move_relative(Widget * widget, gint x, gint y);
-void widget_draw(Widget * widget);
-void widget_draw_quick(Widget * widget);
-
-void handle_press_cb(GList * wlist, GtkWidget * widget,
-                     GdkEventButton * event);
-void handle_release_cb(GList * wlist, GtkWidget * widget,
-                       GdkEventButton * event);
-void handle_motion_cb(GList * wlist, GtkWidget * widget,
-                      GdkEventMotion * event);
-void handle_scroll_cb(GList * wlist, GtkWidget * widget,
-                      GdkEventScroll * event);
-
-void widget_list_add(GList ** list, Widget * widget);
-void widget_list_draw(GList * list, gboolean * redraw, gboolean force);
-void widget_list_change_pixmap(GList * list, GdkPixmap * pixmap);
-void widget_list_clear_redraw(GList * list);
-void widget_list_lock(GList * list);
-void widget_list_unlock(GList * list);
-
-#endif
--- a/src/audacious/widgets/widgetcore.h	Thu Aug 02 14:14:32 2007 +0200
+++ b/src/audacious/widgets/widgetcore.h	Thu Aug 02 14:28:37 2007 +0200
@@ -22,6 +22,6 @@
 #define _WIDGETCORE_H_
 
 #include "skin.h"
-#include "widget.h"
+#include <gtk/gtk.h>
 
 #endif