Mercurial > audlegacy
changeset 3139:c7fca96bfc78 trunk
Automated merge with ssh://hg.atheme.org//hg/audacious
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Sat, 21 Jul 2007 15:50:38 -0500 |
parents | 3eca96f6a73f (current diff) 19908efce4e5 (diff) |
children | 732abc5c1714 |
files | |
diffstat | 10 files changed, 428 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/Makefile Sat Jul 21 15:50:13 2007 -0500 +++ b/src/audacious/Makefile Sat Jul 21 15:50:38 2007 -0500 @@ -120,6 +120,7 @@ ui_skinned_monostereo.c \ ui_skinned_equalizer_slider.c \ ui_skinned_equalizer_graph.c \ + ui_skinned_playlist_slider.c \ ui_skinselector.c \ ui_urlopener.c \ util.c \
--- a/src/audacious/ui_fileinfopopup.c Sat Jul 21 15:50:13 2007 -0500 +++ b/src/audacious/ui_fileinfopopup.c Sat Jul 21 15:50:38 2007 -0500 @@ -107,14 +107,14 @@ pos = playlist_get_position(pl); current_file = playlist_get_filename(pl , pos); - time = playback_get_time(); g_return_val_if_fail(current_file != NULL, FALSE); - if (time != -1 && length != -1 && + if (playback_get_playing() && length != -1 && current_file != NULL && tooltip_file != NULL && !strcmp(tooltip_file, current_file) && cfg.filepopup_showprogressbar) { + time = playback_get_time(); gchar *progress_time = g_strdup_printf("%d:%02d", time / 60000, (time / 1000) % 60); gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar),
--- a/src/audacious/ui_playlist.c Sat Jul 21 15:50:13 2007 -0500 +++ b/src/audacious/ui_playlist.c Sat Jul 21 15:50:38 2007 -0500 @@ -58,12 +58,15 @@ #include "ui_skinned_window.h" #include "ui_skinned_button.h" #include "ui_skinned_textbox.h" +#include "ui_skinned_playlist_slider.h" #include "icons-stock.h" #include "images/audacious_playlist.xpm" GtkWidget *playlistwin; +static GMutex *resize_mutex = NULL; + PlayList_List *playlistwin_list = NULL; GtkWidget *playlistwin_shade, *playlistwin_close; @@ -75,7 +78,7 @@ static GtkWidget *playlistwin_infopopup = NULL; static guint playlistwin_infopopup_sid = 0; -static PlaylistSlider *playlistwin_slider = NULL; +static GtkWidget *playlistwin_slider = NULL; static GtkWidget *playlistwin_time_min, *playlistwin_time_sec; static GtkWidget *playlistwin_info, *playlistwin_sinfo; static GtkWidget *playlistwin_srew, *playlistwin_splay; @@ -239,6 +242,22 @@ } gint +playlistwin_list_get_visible_count(void) +{ + if (playlistwin_list) + return playlistwin_list->pl_num_visible; + return (-1); +} + +gint +playlistwin_list_get_first(void) +{ + if (playlistwin_list) + return playlistwin_list->pl_first; + return (-1); +} + +gint playlistwin_get_toprow(void) { if (playlistwin_list) @@ -261,7 +280,7 @@ g_return_if_fail(playlistwin_list); widget_draw(WIDGET(playlistwin_list)); - widget_draw(WIDGET(playlistwin_slider)); + gtk_widget_queue_draw(playlistwin_slider); playlistwin_update_info(playlist); playlistwin_update_sinfo(playlist); } @@ -376,7 +395,6 @@ playlistwin_set_mask(); widget_draw(WIDGET(playlistwin_list)); - widget_draw(WIDGET(playlistwin_slider)); draw_playlist_window(TRUE); } @@ -653,11 +671,11 @@ cfg.playlist_width = width = tx; cfg.playlist_height = height = ty; - + g_mutex_lock(resize_mutex); widget_resize_relative(WIDGET(playlistwin_list), dx, dy); - widget_move_relative(WIDGET(playlistwin_slider), dx, 0); - widget_resize_relative(WIDGET(playlistwin_slider), 0, dy); + ui_skinned_playlist_slider_move_relative(playlistwin_slider, dx); + ui_skinned_playlist_slider_resize_relative(playlistwin_slider, dy); ui_skinned_textbox_resize_relative(playlistwin_sinfo, dx, 0); playlistwin_update_sinfo(playlist_get_active()); @@ -692,6 +710,7 @@ widget_list_draw(playlistwin_wlist, &redraw, TRUE); widget_list_clear_redraw(playlistwin_wlist); + g_mutex_unlock(resize_mutex); widget_list_unlock(playlistwin_wlist); gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); @@ -1589,11 +1608,8 @@ ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_list)); /* playlist list box slider */ - playlistwin_slider = - create_playlistslider(&playlistwin_wlist, playlistwin_bg, - SKINNED_WINDOW(playlistwin)->gc, playlistwin_get_width() - 15, - 20, cfg.playlist_height - 58, playlistwin_list); - ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_slider)); + playlistwin_slider = ui_skinned_playlist_slider_new(SKINNED_WINDOW(playlistwin)->fixed, playlistwin_get_width() - 15, + 20, cfg.playlist_height - 58); /* track time (minute) */ playlistwin_time_min = ui_skinned_textbox_new(SKINNED_WINDOW(playlistwin)->fixed, @@ -1758,6 +1774,7 @@ void playlistwin_create(void) { + resize_mutex = g_mutex_new(); playlistwin_create_window(); /* create GC and back pixmap for custom widget to draw on */
--- a/src/audacious/ui_playlist.h Sat Jul 21 15:50:13 2007 -0500 +++ b/src/audacious/ui_playlist.h Sat Jul 21 15:50:38 2007 -0500 @@ -73,6 +73,8 @@ void playlistwin_select_playlist_to_load(const gchar * default_filename); void playlistwin_set_sinfo_font(gchar *font); void playlistwin_set_sinfo_scroll(gboolean scroll); +gint playlistwin_list_get_visible_count(void); +gint playlistwin_list_get_first(void); extern GtkWidget *playlistwin; extern PlayList_List *playlistwin_list;
--- a/src/audacious/ui_skinned_button.c Sat Jul 21 15:50:13 2007 -0500 +++ b/src/audacious/ui_skinned_button.c Sat Jul 21 15:50:38 2007 -0500 @@ -25,8 +25,6 @@ #define UI_SKINNED_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ui_skinned_button_get_type(), UiSkinnedButtonPrivate)) typedef struct _UiSkinnedButtonPrivate UiSkinnedButtonPrivate; -static GMutex *mutex = NULL; - enum { PRESSED, RELEASED, @@ -170,7 +168,6 @@ static void ui_skinned_button_init (UiSkinnedButton *button) { UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); - mutex = g_mutex_new(); button->inside = FALSE; button->type = TYPE_NOT_SET; priv->move_x = 0; @@ -272,7 +269,6 @@ } static void ui_skinned_button_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { - g_mutex_lock(mutex); UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); widget->allocation = *allocation; @@ -287,12 +283,13 @@ gdk_window_move_resize(widget->window, allocation->x*(1+priv->double_size), allocation->y*(1+priv->double_size), allocation->width, allocation->height); } + if (button->x + priv->move_x == widget->allocation.x/(priv->double_size ? 2 : 1)) + priv->move_x = 0; + if (button->y + priv->move_y == widget->allocation.y/(priv->double_size ? 2 : 1)) + priv->move_y = 0; + button->x = widget->allocation.x/(priv->double_size ? 2 : 1); button->y = widget->allocation.y/(priv->double_size ? 2 : 1); - priv->move_x = 0; - priv->move_y = 0; - - g_mutex_unlock(mutex); } static gboolean ui_skinned_button_expose(GtkWidget *widget, GdkEventExpose *event) { @@ -523,13 +520,11 @@ } static void ui_skinned_button_redraw(UiSkinnedButton *button) { - g_mutex_lock(mutex); UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); if (priv->move_x || priv->move_y) gtk_fixed_move(GTK_FIXED(priv->fixed), GTK_WIDGET(button), button->x+priv->move_x, button->y+priv->move_y); gtk_widget_queue_draw(GTK_WIDGET(button)); - g_mutex_unlock(mutex); } @@ -557,9 +552,7 @@ } void ui_skinned_button_move_relative(GtkWidget *button, gint x, gint y) { - g_mutex_lock(mutex); UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); priv->move_x += x; priv->move_y += y; - g_mutex_unlock(mutex); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/ui_skinned_playlist_slider.c Sat Jul 21 15:50:38 2007 -0500 @@ -0,0 +1,323 @@ +/* + * Audacious - a cross-platform multimedia player + * Copyright (c) 2007 Audacious development team. + * + * Based on: + * BMP - Cross-platform multimedia player + * Copyright (C) 2003-2004 BMP development team. + * 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 "widgets/widgetcore.h" +#include "ui_skinned_playlist_slider.h" +#include "main.h" +#include "util.h" +#include "ui_playlist.h" + +#define UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ui_skinned_playlist_slider_get_type(), UiSkinnedPlaylistSliderPrivate)) +typedef struct _UiSkinnedPlaylistSliderPrivate UiSkinnedPlaylistSliderPrivate; + +enum { + REDRAW, + LAST_SIGNAL +}; + +struct _UiSkinnedPlaylistSliderPrivate { + GtkWidget *fixed; + SkinPixmapId skin_index; + gint width, height; + + gint resize_height; + gint move_x; +}; + +static void ui_skinned_playlist_slider_class_init (UiSkinnedPlaylistSliderClass *klass); +static void ui_skinned_playlist_slider_init (UiSkinnedPlaylistSlider *playlist_slider); +static void ui_skinned_playlist_slider_destroy (GtkObject *object); +static void ui_skinned_playlist_slider_realize (GtkWidget *widget); +static void ui_skinned_playlist_slider_size_request (GtkWidget *widget, GtkRequisition *requisition); +static void ui_skinned_playlist_slider_size_allocate (GtkWidget *widget, GtkAllocation *allocation); +static gboolean ui_skinned_playlist_slider_expose (GtkWidget *widget, GdkEventExpose *event); +static void ui_skinned_playlist_slider_set_position (GtkWidget *widget, gint y); +static gboolean ui_skinned_playlist_slider_button_press (GtkWidget *widget, GdkEventButton *event); +static gboolean ui_skinned_playlist_slider_button_release (GtkWidget *widget, GdkEventButton *event); +static gboolean ui_skinned_playlist_slider_motion_notify (GtkWidget *widget, GdkEventMotion *event); +static void ui_skinned_playlist_slider_redraw (UiSkinnedPlaylistSlider *playlist_slider); + +static GtkWidgetClass *parent_class = NULL; +static guint playlist_slider_signals[LAST_SIGNAL] = { 0 }; + +GType ui_skinned_playlist_slider_get_type() { + static GType playlist_slider_type = 0; + if (!playlist_slider_type) { + static const GTypeInfo playlist_slider_info = { + sizeof (UiSkinnedPlaylistSliderClass), + NULL, + NULL, + (GClassInitFunc) ui_skinned_playlist_slider_class_init, + NULL, + NULL, + sizeof (UiSkinnedPlaylistSlider), + 0, + (GInstanceInitFunc) ui_skinned_playlist_slider_init, + }; + playlist_slider_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedPlaylistSlider", &playlist_slider_info, 0); + } + + return playlist_slider_type; +} + +static void ui_skinned_playlist_slider_class_init(UiSkinnedPlaylistSliderClass *klass) { + GObjectClass *gobject_class; + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + + gobject_class = G_OBJECT_CLASS(klass); + object_class = (GtkObjectClass*) klass; + widget_class = (GtkWidgetClass*) klass; + parent_class = gtk_type_class (gtk_widget_get_type ()); + + object_class->destroy = ui_skinned_playlist_slider_destroy; + + widget_class->realize = ui_skinned_playlist_slider_realize; + widget_class->expose_event = ui_skinned_playlist_slider_expose; + widget_class->size_request = ui_skinned_playlist_slider_size_request; + widget_class->size_allocate = ui_skinned_playlist_slider_size_allocate; + widget_class->button_press_event = ui_skinned_playlist_slider_button_press; + widget_class->button_release_event = ui_skinned_playlist_slider_button_release; + widget_class->motion_notify_event = ui_skinned_playlist_slider_motion_notify; + + klass->redraw = ui_skinned_playlist_slider_redraw; + + playlist_slider_signals[REDRAW] = + g_signal_new ("redraw", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (UiSkinnedPlaylistSliderClass, redraw), NULL, NULL, + gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); + + g_type_class_add_private (gobject_class, sizeof (UiSkinnedPlaylistSliderPrivate)); +} + +static void ui_skinned_playlist_slider_init(UiSkinnedPlaylistSlider *playlist_slider) { + UiSkinnedPlaylistSliderPrivate *priv = UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(playlist_slider); + playlist_slider->pressed = FALSE; + priv->resize_height = 0; + priv->move_x = 0; +} + +GtkWidget* ui_skinned_playlist_slider_new(GtkWidget *fixed, gint x, gint y, gint h) { + + UiSkinnedPlaylistSlider *hs = g_object_new (ui_skinned_playlist_slider_get_type (), NULL); + UiSkinnedPlaylistSliderPrivate *priv = UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(hs); + + hs->x = x; + hs->y = y; + priv->width = 8; + priv->height = h; + priv->fixed = fixed; + priv->skin_index = SKIN_PLEDIT; + + gtk_fixed_put(GTK_FIXED(priv->fixed), GTK_WIDGET(hs), hs->x, hs->y); + + return GTK_WIDGET(hs); +} + +static void ui_skinned_playlist_slider_destroy(GtkObject *object) { + UiSkinnedPlaylistSlider *playlist_slider; + + g_return_if_fail (object != NULL); + g_return_if_fail (UI_SKINNED_IS_PLAYLIST_SLIDER (object)); + + playlist_slider = UI_SKINNED_PLAYLIST_SLIDER (object); + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + +static void ui_skinned_playlist_slider_realize(GtkWidget *widget) { + UiSkinnedPlaylistSlider *playlist_slider; + GdkWindowAttr attributes; + gint attributes_mask; + + g_return_if_fail (widget != NULL); + g_return_if_fail (UI_SKINNED_IS_PLAYLIST_SLIDER(widget)); + + GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); + playlist_slider = UI_SKINNED_PLAYLIST_SLIDER(widget); + + attributes.x = widget->allocation.x; + attributes.y = widget->allocation.y; + attributes.width = widget->allocation.width; + attributes.height = widget->allocation.height; + attributes.wclass = GDK_INPUT_OUTPUT; + attributes.window_type = GDK_WINDOW_CHILD; + attributes.event_mask = gtk_widget_get_events(widget); + attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK; + attributes.visual = gtk_widget_get_visual(widget); + attributes.colormap = gtk_widget_get_colormap(widget); + + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; + widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask); + + widget->style = gtk_style_attach(widget->style, widget->window); + gdk_window_set_user_data(widget->window, widget); +} + +static void ui_skinned_playlist_slider_size_request(GtkWidget *widget, GtkRequisition *requisition) { + UiSkinnedPlaylistSliderPrivate *priv = UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(widget); + + requisition->width = priv->width; + requisition->height = priv->height; +} + +static void ui_skinned_playlist_slider_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { + UiSkinnedPlaylistSlider *playlist_slider = UI_SKINNED_PLAYLIST_SLIDER (widget); + UiSkinnedPlaylistSliderPrivate *priv = UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(playlist_slider); + + widget->allocation = *allocation; + if (GTK_WIDGET_REALIZED (widget)) + gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); + + if (playlist_slider->x + priv->move_x == widget->allocation.x) + priv->move_x = 0; + playlist_slider->x = widget->allocation.x; + playlist_slider->y = widget->allocation.y; + + if (priv->height != widget->allocation.height) { + priv->height = priv->height + priv->resize_height; + priv->resize_height = 0; + gtk_widget_queue_draw(widget); + } +} + +static gboolean ui_skinned_playlist_slider_expose(GtkWidget *widget, GdkEventExpose *event) { + g_return_val_if_fail (widget != NULL, FALSE); + g_return_val_if_fail (UI_SKINNED_IS_PLAYLIST_SLIDER (widget), FALSE); + g_return_val_if_fail (event != NULL, FALSE); + + UiSkinnedPlaylistSlider *ps = UI_SKINNED_PLAYLIST_SLIDER (widget); + UiSkinnedPlaylistSliderPrivate *priv = UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(ps); + + GdkPixmap *obj = NULL; + GdkGC *gc; + + obj = gdk_pixmap_new(NULL, priv->width, priv->height, gdk_rgb_get_visual()->depth); + gc = gdk_gc_new(obj); + + gint num_visible; + num_visible = playlistwin_list_get_visible_count(); + + + Playlist *playlist = playlist_get_active(); + + gint y; + if (playlist_get_length(playlist) > num_visible) + y = (playlistwin_list_get_first() * (priv->height - 19)) / + (playlist_get_length(playlist) - num_visible); + else + y = 0; + + if (y < 0) y=0; + if (y > priv->height - 19) y = priv->height - 19; + + /* FIXME: uses bmp_active_skin->pixmaps directly and may need calibration */ + /* drawing background */ + gint c; + for (c = 0; c <= priv->height / 29; c++) { + gdk_draw_drawable(obj, gc, bmp_active_skin->pixmaps[SKIN_PLEDIT].pixmap, + 36, 42, 0, c*29, priv->width, 29); + } + + /* drawing knob */ + skin_draw_pixmap(bmp_active_skin, obj, gc, priv->skin_index, ps->pressed ? 61 : 52, 53, 0, y, priv->width, 18); + + gdk_draw_drawable(widget->window, gc, obj, 0, 0, 0, 0, priv->width, priv->height); + g_object_unref(obj); + g_object_unref(gc); + + return FALSE; +} + +static void ui_skinned_playlist_slider_set_position(GtkWidget *widget, gint y) { + gint pos; + Playlist *playlist = playlist_get_active(); + UiSkinnedPlaylistSliderPrivate *priv = UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(widget); + + y = CLAMP(y, 0, priv->height - 19); + + pos = (y * (playlist_get_length(playlist) - playlistwin_list_get_visible_count())) / (priv->height - 19); + playlistwin_set_toprow(pos); + + gtk_widget_queue_draw(widget); +} + +static gboolean ui_skinned_playlist_slider_button_press(GtkWidget *widget, GdkEventButton *event) { + UiSkinnedPlaylistSlider *ps = UI_SKINNED_PLAYLIST_SLIDER (widget); + + if (event->type == GDK_BUTTON_PRESS) { + if (event->button == 1) { + ps->pressed = TRUE; + gint y = event->y; + ui_skinned_playlist_slider_set_position(widget, y); + } + } + + return TRUE; +} + +static gboolean ui_skinned_playlist_slider_button_release(GtkWidget *widget, GdkEventButton *event) { + UiSkinnedPlaylistSlider *ps = UI_SKINNED_PLAYLIST_SLIDER(widget); + + if (event->button == 1) { + ps->pressed = FALSE; + gtk_widget_queue_draw(widget); + } + return TRUE; +} + +static gboolean ui_skinned_playlist_slider_motion_notify(GtkWidget *widget, GdkEventMotion *event) { + UiSkinnedPlaylistSlider *ps = UI_SKINNED_PLAYLIST_SLIDER(widget); + + if (ps->pressed) { + gint y = event->y; + ui_skinned_playlist_slider_set_position(widget, y); + } + return TRUE; +} + +static void ui_skinned_playlist_slider_redraw(UiSkinnedPlaylistSlider *playlist_slider) { + UiSkinnedPlaylistSliderPrivate *priv = UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(playlist_slider); + + if (priv->resize_height) + gtk_widget_set_size_request(GTK_WIDGET(playlist_slider), priv->width, priv->height+priv->resize_height); + if (priv->move_x) + gtk_fixed_move(GTK_FIXED(priv->fixed), GTK_WIDGET(playlist_slider), playlist_slider->x+priv->move_x, playlist_slider->y); + + gtk_widget_queue_draw(GTK_WIDGET(playlist_slider)); +} + +void ui_skinned_playlist_slider_move_relative(GtkWidget *widget, gint x) { + UiSkinnedPlaylistSliderPrivate *priv = UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(widget); + priv->move_x += x; +} + +void ui_skinned_playlist_slider_resize_relative(GtkWidget *widget, gint h) { + UiSkinnedPlaylistSliderPrivate *priv = UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(widget); + priv->resize_height += h; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/ui_skinned_playlist_slider.h Sat Jul 21 15:50:38 2007 -0500 @@ -0,0 +1,61 @@ +/* + * Audacious - a cross-platform multimedia player + * Copyright (c) 2007 Audacious development team. + * + * Based on: + * BMP - Cross-platform multimedia player + * Copyright (C) 2003-2004 BMP development team. + * 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 UISKINNEDPLAYLIST_SLIDER_H +#define UISKINNEDPLAYLIST_SLIDER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define UI_SKINNED_PLAYLIST_SLIDER(obj) GTK_CHECK_CAST (obj, ui_skinned_playlist_slider_get_type (), UiSkinnedPlaylistSlider) +#define UI_SKINNED_PLAYLIST_SLIDER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, ui_skinned_playlist_slider_get_type (), UiSkinnedPlaylistSliderClass) +#define UI_SKINNED_IS_PLAYLIST_SLIDER(obj) GTK_CHECK_TYPE (obj, ui_skinned_playlist_slider_get_type ()) + +typedef struct _UiSkinnedPlaylistSlider UiSkinnedPlaylistSlider; +typedef struct _UiSkinnedPlaylistSliderClass UiSkinnedPlaylistSliderClass; + +struct _UiSkinnedPlaylistSlider { + GtkWidget widget; + gboolean pressed; + gint x, y; +}; + +struct _UiSkinnedPlaylistSliderClass { + GtkWidgetClass parent_class; + void (* redraw) (UiSkinnedPlaylistSlider *playlist_slider); +}; + +GtkWidget* ui_skinned_playlist_slider_new(GtkWidget *fixed, gint x, gint y, gint h); +GtkType ui_skinned_playlist_slider_get_type(void); +void ui_skinned_playlist_slider_move_relative(GtkWidget *widget, gint x); +void ui_skinned_playlist_slider_resize_relative(GtkWidget *widget, gint h); + +#ifdef __cplusplus +} +#endif + +#endif
--- a/src/audacious/ui_skinned_textbox.c Sat Jul 21 15:50:13 2007 -0500 +++ b/src/audacious/ui_skinned_textbox.c Sat Jul 21 15:50:38 2007 -0500 @@ -34,8 +34,6 @@ #define UI_SKINNED_TEXTBOX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ui_skinned_textbox_get_type(), UiSkinnedTextboxPrivate)) typedef struct _UiSkinnedTextboxPrivate UiSkinnedTextboxPrivate; -static GMutex *mutex = NULL; - #define TEXTBOX_SCROLL_SMOOTH_TIMEOUT 30 #define TEXTBOX_SCROLL_WAIT 80 @@ -167,7 +165,6 @@ static void ui_skinned_textbox_init(UiSkinnedTextbox *textbox) { UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); - mutex = g_mutex_new(); priv->resize_width = 0; priv->resize_height = 0; priv->move_x = 0; @@ -252,7 +249,6 @@ } static void ui_skinned_textbox_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { - g_mutex_lock(mutex); UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX (widget); UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); @@ -262,21 +258,23 @@ if (GTK_WIDGET_REALIZED (widget)) gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); + if (textbox->x + priv->move_x == widget->allocation.x/(priv->double_size ? 2 : 1)) + priv->move_x = 0; + if (textbox->y + priv->move_y == widget->allocation.y/(priv->double_size ? 2 : 1)) + priv->move_y = 0; textbox->x = widget->allocation.x/(priv->double_size ? 2 : 1); textbox->y = widget->allocation.y/(priv->double_size ? 2 : 1); - priv->move_x = 0; - priv->move_y = 0; if (textbox->width != widget->allocation.width/(priv->double_size ? 2 : 1)) { + if (textbox->width + priv->resize_width == widget->allocation.width/(priv->double_size ? 2 : 1)) + priv->resize_width = 0; textbox->width = widget->allocation.width/(priv->double_size ? 2 : 1); - priv->resize_width = 0; priv->resize_height = 0; if (priv->pixmap_text) g_free(priv->pixmap_text); priv->pixmap_text = NULL; priv->offset = 0; gtk_widget_queue_draw(GTK_WIDGET(textbox)); } - g_mutex_unlock(mutex); } static gboolean ui_skinned_textbox_expose(GtkWidget *widget, GdkEventExpose *event) { @@ -431,7 +429,6 @@ } static void ui_skinned_textbox_redraw(UiSkinnedTextbox *textbox) { - g_mutex_lock(mutex); UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); if (priv->resize_width || priv->resize_height) @@ -442,7 +439,6 @@ gtk_fixed_move(GTK_FIXED(priv->fixed), GTK_WIDGET(textbox), textbox->x+priv->move_x, textbox->y+priv->move_y); gtk_widget_queue_draw(GTK_WIDGET(textbox)); - g_mutex_unlock(mutex); } static gboolean ui_skinned_textbox_should_scroll(UiSkinnedTextbox *textbox) { @@ -886,17 +882,13 @@ } void ui_skinned_textbox_move_relative(GtkWidget *widget, gint x, gint y) { - g_mutex_lock(mutex); UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(widget); priv->move_x += x; priv->move_y += y; - g_mutex_unlock(mutex); } void ui_skinned_textbox_resize_relative(GtkWidget *widget, gint w, gint h) { - g_mutex_lock(mutex); UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(widget); priv->resize_width += w; priv->resize_height += h; - g_mutex_unlock(mutex); }