Mercurial > audlegacy
changeset 3069:093759970e44
replace Menurow with UiSkinnedMenurow
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Fri, 13 Jul 2007 21:43:17 +0200 |
parents | a0f79856693b |
children | be5375dd588f |
files | src/audacious/Makefile src/audacious/ui_main.c src/audacious/widgets/Makefile src/audacious/widgets/menurow.c src/audacious/widgets/menurow.h src/audacious/widgets/widgetcore.h |
diffstat | 6 files changed, 20 insertions(+), 275 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/Makefile Fri Jul 13 12:53:30 2007 +0200 +++ b/src/audacious/Makefile Fri Jul 13 21:43:17 2007 +0200 @@ -114,6 +114,7 @@ ui_skinned_horizontal_slider.c \ ui_vis.c \ ui_svis.c \ + ui_skinned_menurow.c \ ui_skinselector.c \ ui_urlopener.c \ util.c \
--- a/src/audacious/ui_main.c Fri Jul 13 12:53:30 2007 +0200 +++ b/src/audacious/ui_main.c Fri Jul 13 21:43:17 2007 +0200 @@ -85,6 +85,7 @@ #include "ui_skinned_textbox.h" #include "ui_skinned_number.h" #include "ui_skinned_horizontal_slider.h" +#include "ui_skinned_menurow.h" #include "ui_jumptotrack.h" static GTimeVal cb_time; /* click delay for tristate is defined by TRISTATE_THRESHOLD */ @@ -152,7 +153,7 @@ GtkWidget *mainwin_sposition = NULL; -static MenuRow *mainwin_menurow; +static GtkWidget *mainwin_menurow; static GtkWidget *mainwin_volume, *mainwin_balance; GtkWidget *mainwin_position; @@ -852,9 +853,9 @@ /* visibility attributes */ if (bmp_active_skin->properties.mainwin_menurow_visible) - widget_show(WIDGET(mainwin_menurow)); + gtk_widget_show(mainwin_menurow); else - widget_hide(WIDGET(mainwin_menurow)); + gtk_widget_hide(mainwin_menurow); /* window size, mainwinWidth && mainwinHeight properties */ if (bmp_active_skin->properties.mainwin_height && bmp_active_skin->properties.mainwin_width) @@ -1028,11 +1029,6 @@ draw_playlist_window(TRUE); } - if (mainwin_menurow->mr_doublesize_selected) { - event->x /= 2; - event->y /= 2; - } - handle_release_cb(mainwin_wlist, widget, event); draw_main_window(FALSE); @@ -2186,7 +2182,7 @@ } static void -mainwin_mr_change(MenuRowItem i) +mainwin_mr_change(GtkWidget *widget, MenuRowItem i) { switch (i) { case MENUROW_NONE: @@ -2196,7 +2192,7 @@ mainwin_lock_info_text(_("OPTIONS MENU")); break; case MENUROW_ALWAYS: - if (mainwin_menurow->mr_always_selected) + if (UI_SKINNED_MENUROW(mainwin_menurow)->always_selected) mainwin_lock_info_text(_("DISABLE ALWAYS ON TOP")); else mainwin_lock_info_text(_("ENABLE ALWAYS ON TOP")); @@ -2205,7 +2201,7 @@ mainwin_lock_info_text(_("FILE INFO BOX")); break; case MENUROW_DOUBLESIZE: - if (mainwin_menurow->mr_doublesize_selected) + if (UI_SKINNED_MENUROW(mainwin_menurow)->doublesize_selected) mainwin_lock_info_text(_("DISABLE DOUBLESIZE")); else mainwin_lock_info_text(_("ENABLE DOUBLESIZE")); @@ -2217,7 +2213,7 @@ } static void -mainwin_mr_release(MenuRowItem i) +mainwin_mr_release(GtkWidget *widget, MenuRowItem i) { GdkModifierType modmask; gint x, y; @@ -2232,7 +2228,7 @@ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(gtk_action_group_get_action( toggleaction_group_others , "view always on top" )) , - mainwin_menurow->mr_always_selected ); + UI_SKINNED_MENUROW(mainwin_menurow)->always_selected ); break; case MENUROW_FILEINFOBOX: playlist_fileinfo_current(playlist_get_active()); @@ -2241,7 +2237,7 @@ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(gtk_action_group_get_action( toggleaction_group_others , "view doublesize" )) , - mainwin_menurow->mr_doublesize_selected ); + UI_SKINNED_MENUROW(mainwin_menurow)->doublesize_selected ); break; case MENUROW_VISUALIZATION: gdk_window_get_pointer(NULL, &x, &y, &modmask); @@ -2818,12 +2814,9 @@ mainwin_freq_text = ui_skinned_textbox_new(SKINNED_WINDOW(mainwin)->fixed, 156, 43, 10, 0, SKIN_TEXT); - mainwin_menurow = - create_menurow(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 10, 22, 304, - 0, 304, 44, mainwin_mr_change, mainwin_mr_release, - SKIN_TITLEBAR); - mainwin_menurow->mr_doublesize_selected = cfg.doublesize; - mainwin_menurow->mr_always_selected = cfg.always_on_top; + mainwin_menurow = ui_skinned_menurow_new(SKINNED_WINDOW(mainwin)->fixed, 10, 22, 304, 0, 304, 44, SKIN_TITLEBAR); + g_signal_connect(mainwin_menurow, "change", G_CALLBACK(mainwin_mr_change), NULL); + g_signal_connect(mainwin_menurow, "release", G_CALLBACK(mainwin_mr_release), NULL); mainwin_volume = ui_skinned_horizontal_slider_new(SKINNED_WINDOW(mainwin)->fixed, 107, 57, 68, 13, 15, 422, 0, 422, 14, 11, 15, 0, 0, 51, @@ -2898,8 +2891,6 @@ /* XXX: eventually update widgetcore API to not need this */ - ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_menurow)); - ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_monostereo)); ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_playstatus)); } @@ -3242,18 +3233,18 @@ void action_view_always_on_top( GtkToggleAction * action ) { - mainwin_menurow->mr_always_selected = gtk_toggle_action_get_active( action ); - cfg.always_on_top = mainwin_menurow->mr_always_selected; - widget_draw(WIDGET(mainwin_menurow)); + UI_SKINNED_MENUROW(mainwin_menurow)->always_selected = gtk_toggle_action_get_active( action ); + cfg.always_on_top = UI_SKINNED_MENUROW(mainwin_menurow)->always_selected; + gtk_widget_queue_draw(mainwin_menurow); hint_set_always(cfg.always_on_top); } void action_view_doublesize( GtkToggleAction * action ) { - mainwin_menurow->mr_doublesize_selected = gtk_toggle_action_get_active( action ); - widget_draw(WIDGET(mainwin_menurow)); - set_doublesize(mainwin_menurow->mr_doublesize_selected); + UI_SKINNED_MENUROW(mainwin_menurow)->doublesize_selected = gtk_toggle_action_get_active( action ); + gtk_widget_queue_draw(mainwin_menurow); + set_doublesize(UI_SKINNED_MENUROW(mainwin_menurow)->doublesize_selected); gdk_flush(); }
--- a/src/audacious/widgets/Makefile Fri Jul 13 12:53:30 2007 +0200 +++ b/src/audacious/widgets/Makefile Fri Jul 13 21:43:17 2007 +0200 @@ -20,7 +20,6 @@ SOURCES = \ widget.c \ - menurow.c \ monostereo.c \ playstatus.c \ playlist_list.c \
--- a/src/audacious/widgets/menurow.c Fri Jul 13 12:53:30 2007 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,185 +0,0 @@ -/* 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 2 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "widgetcore.h" - -#include <glib.h> -#include <gdk/gdk.h> - -#include "main.h" -#include "menurow.h" -#include "widget.h" - -void -menurow_draw(Widget * widget) -{ - MenuRow *mr = MENU_ROW(widget); - - GdkPixmap *obj = mr->mr_widget.parent; - - if (mr->mr_selected == MENUROW_NONE) { - if (cfg.always_show_cb || mr->mr_bpushed) - skin_draw_pixmap(bmp_active_skin, obj, - mr->mr_widget.gc, - mr->mr_skin_index, - mr->mr_nx, mr->mr_ny, - mr->mr_widget.x, mr->mr_widget.y, 8, 43); - else - skin_draw_pixmap(bmp_active_skin, obj, - mr->mr_widget.gc, - mr->mr_skin_index, - mr->mr_nx + 8, mr->mr_ny, - mr->mr_widget.x, mr->mr_widget.y, 8, 43); - } - else { - skin_draw_pixmap(bmp_active_skin, obj, - mr->mr_widget.gc, - mr->mr_skin_index, - mr->mr_sx + ((mr->mr_selected - 1) * 8), - mr->mr_sy, mr->mr_widget.x, mr->mr_widget.y, 8, 43); - } - if (cfg.always_show_cb || mr->mr_bpushed) { - if (mr->mr_always_selected) - skin_draw_pixmap(bmp_active_skin, obj, - mr->mr_widget.gc, - mr->mr_skin_index, - mr->mr_sx + 8, mr->mr_sy + 10, - mr->mr_widget.x, mr->mr_widget.y + 10, 8, 8); - if (mr->mr_doublesize_selected) - skin_draw_pixmap(bmp_active_skin, obj, - mr->mr_widget.gc, - mr->mr_skin_index, - mr->mr_sx + 24, mr->mr_sy + 26, - mr->mr_widget.x, mr->mr_widget.y + 26, 8, 8); - } - -} - -MenuRowItem -menurow_find_selected(MenuRow * mr, gint x, gint y) -{ - MenuRowItem ret = MENUROW_NONE; - - x -= mr->mr_widget.x; - y -= mr->mr_widget.y; - if (x > 0 && x < 8) { - if (y >= 0 && y <= 10) - ret = MENUROW_OPTIONS; - if (y >= 10 && y <= 17) - ret = MENUROW_ALWAYS; - if (y >= 18 && y <= 25) - ret = MENUROW_FILEINFOBOX; - if (y >= 26 && y <= 33) - ret = MENUROW_DOUBLESIZE; - if (y >= 34 && y <= 42) - ret = MENUROW_VISUALIZATION; - } - return ret; -} - -void -menurow_button_press(GtkWidget * widget, - GdkEventButton * event, - gpointer data) -{ - MenuRow *mr = MENU_ROW(data); - - if (event->button != 1) - return; - - if (widget_contains(&mr->mr_widget, event->x, event->y)) { - mr->mr_bpushed = TRUE; - mr->mr_selected = menurow_find_selected(mr, event->x, event->y); - - widget_draw(WIDGET(mr)); - - if (mr->mr_change_callback) - mr->mr_change_callback(mr->mr_selected); - } -} - -void -menurow_motion(GtkWidget * widget, - GdkEventMotion * event, - gpointer data) -{ - MenuRow *mr = MENU_ROW(data); - - if (mr->mr_bpushed) { - mr->mr_selected = menurow_find_selected(mr, event->x, event->y); - - widget_draw(WIDGET(mr)); - - if (mr->mr_change_callback) - mr->mr_change_callback(mr->mr_selected); - } -} - -void -menurow_button_release(GtkWidget * widget, - GdkEventButton * event, - gpointer data) -{ - MenuRow *mr = MENU_ROW(data); - - if (mr->mr_bpushed) { - mr->mr_bpushed = FALSE; - - if (mr->mr_selected == MENUROW_ALWAYS) - mr->mr_always_selected = !mr->mr_always_selected; - - if (mr->mr_selected == MENUROW_DOUBLESIZE) - mr->mr_doublesize_selected = !mr->mr_doublesize_selected; - - if ((int)(mr->mr_selected) != -1 && mr->mr_release_callback) - mr->mr_release_callback(mr->mr_selected); - - mr->mr_selected = MENUROW_NONE; - - widget_draw(WIDGET(mr)); - } -} - -MenuRow * -create_menurow(GList ** wlist, GdkPixmap * parent, GdkGC * gc, - gint x, gint y, gint nx, gint ny, gint sx, gint sy, - void (*ccb) (MenuRowItem), - void (*rcb) (MenuRowItem), SkinPixmapId si) -{ - MenuRow *mr; - - mr = g_new0(MenuRow, 1); - widget_init(&mr->mr_widget, parent, gc, x, y, 8, 43, 1); - mr->mr_widget.draw = menurow_draw; - mr->mr_widget.button_press_cb = menurow_button_press; - mr->mr_widget.motion_cb = menurow_motion; - mr->mr_widget.button_release_cb = menurow_button_release; - mr->mr_nx = nx; - mr->mr_ny = ny; - mr->mr_sx = sx; - mr->mr_sy = sy; - mr->mr_selected = MENUROW_NONE; - mr->mr_change_callback = ccb; - mr->mr_release_callback = rcb; - mr->mr_skin_index = si; - - widget_list_add(wlist, WIDGET(mr)); - return mr; -}
--- a/src/audacious/widgets/menurow.h Fri Jul 13 12:53:30 2007 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* 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 2 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef _WIDGETCORE_H_ -#error Please do not include me directly! Use widgetcore.h instead! -#endif - -#ifndef MENUROW_H -#define MENUROW_H - -#include <glib.h> -#include <gdk/gdk.h> - -#include "skin.h" -#include "widget.h" - -typedef enum { - MENUROW_NONE, MENUROW_OPTIONS, MENUROW_ALWAYS, MENUROW_FILEINFOBOX, - MENUROW_DOUBLESIZE, MENUROW_VISUALIZATION -} MenuRowItem; - -#define MENU_ROW(x) ((MenuRow *)(x)) -struct _MenuRow { - Widget mr_widget; - gint mr_nx, mr_ny; - gint mr_sx, mr_sy; - MenuRowItem mr_selected; - gboolean mr_bpushed; - gboolean mr_always_selected; - gboolean mr_doublesize_selected; - void (*mr_change_callback) (MenuRowItem); - void (*mr_release_callback) (MenuRowItem); - SkinPixmapId mr_skin_index; -}; - -typedef struct _MenuRow MenuRow; - -MenuRow *create_menurow(GList ** wlist, GdkPixmap * parent, GdkGC * gc, - gint x, gint y, gint nx, gint ny, gint sx, gint sy, - void (*ccb) (MenuRowItem), - void (*rcb) (MenuRowItem), SkinPixmapId si); - -#endif
--- a/src/audacious/widgets/widgetcore.h Fri Jul 13 12:53:30 2007 +0200 +++ b/src/audacious/widgets/widgetcore.h Fri Jul 13 21:43:17 2007 +0200 @@ -21,7 +21,6 @@ #include "eq_graph.h" #include "eq_slider.h" -#include "menurow.h" #include "monostereo.h" #include "playlist_list.h" #include "playlist_slider.h"