# HG changeset patch # User Tomasz Mon # Date 1182088439 -7200 # Node ID 91ef09fe793684f3c2bea7e954c7be5d531bde4d # Parent c2622a939e9ee4d9663460e1423e752f66a9c55f UiSkinnedButton can now work as TButton diff -r c2622a939e9e -r 91ef09fe7936 src/audacious/ui_equalizer.c --- a/src/audacious/ui_equalizer.c Sun Jun 17 12:54:59 2007 +0200 +++ b/src/audacious/ui_equalizer.c Sun Jun 17 15:53:59 2007 +0200 @@ -841,7 +841,7 @@ gdk_flush(); draw_equalizer_window(TRUE); cfg.equalizer_visible = TRUE; - tbutton_set_toggled(mainwin_eq, TRUE); + //FIXME: set mainwin_eq->inside as TRUE and redraw it gtk_widget_show(equalizerwin); } @@ -855,7 +855,7 @@ */ gtk_widget_hide(equalizerwin); cfg.equalizer_visible = FALSE; - tbutton_set_toggled(mainwin_eq, FALSE); + //FIXME: set mainwin_eq->inside as FALSE and redraw it } static EqualizerPreset * diff -r c2622a939e9e -r 91ef09fe7936 src/audacious/ui_main.c --- a/src/audacious/ui_main.c Sun Jun 17 12:54:59 2007 +0200 +++ b/src/audacious/ui_main.c Sun Jun 17 15:53:59 2007 +0200 @@ -133,7 +133,8 @@ static GtkWidget *mainwin_eject; static GtkWidget *mainwin_play, *mainwin_pause, *mainwin_stop; -TButton *mainwin_shuffle, *mainwin_repeat, *mainwin_eq, *mainwin_pl; +static GtkWidget *mainwin_shuffle, *mainwin_repeat, *mainwin_eq, *mainwin_pl; + TextBox *mainwin_info; TextBox *mainwin_stime_min, *mainwin_stime_sec; @@ -184,7 +185,8 @@ void mainwin_position_release_cb(gint pos); void set_doublesize(gboolean doublesize); - +void mainwin_eq_pushed(gboolean toggled); +void mainwin_pl_pushed(gboolean toggled); /* FIXME: placed here for now */ @@ -740,19 +742,19 @@ bmp_active_skin->properties.mainwin_eject_y); if (bmp_active_skin->properties.mainwin_eqbutton_x && bmp_active_skin->properties.mainwin_eqbutton_y) - widget_move(WIDGET(mainwin_eq), bmp_active_skin->properties.mainwin_eqbutton_x, + gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_eq), bmp_active_skin->properties.mainwin_eqbutton_x, bmp_active_skin->properties.mainwin_eqbutton_y); if (bmp_active_skin->properties.mainwin_plbutton_x && bmp_active_skin->properties.mainwin_plbutton_y) - widget_move(WIDGET(mainwin_pl), bmp_active_skin->properties.mainwin_plbutton_x, + gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_pl), bmp_active_skin->properties.mainwin_plbutton_x, bmp_active_skin->properties.mainwin_plbutton_y); if (bmp_active_skin->properties.mainwin_shuffle_x && bmp_active_skin->properties.mainwin_shuffle_y) - widget_move(WIDGET(mainwin_shuffle), bmp_active_skin->properties.mainwin_shuffle_x, + gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_shuffle), bmp_active_skin->properties.mainwin_shuffle_x, bmp_active_skin->properties.mainwin_shuffle_y); if (bmp_active_skin->properties.mainwin_repeat_x && bmp_active_skin->properties.mainwin_repeat_y) - widget_move(WIDGET(mainwin_repeat), bmp_active_skin->properties.mainwin_repeat_x, + gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_repeat), bmp_active_skin->properties.mainwin_repeat_x, bmp_active_skin->properties.mainwin_repeat_y); if (bmp_active_skin->properties.mainwin_about_x && bmp_active_skin->properties.mainwin_about_y) @@ -1678,12 +1680,34 @@ check_set( toggleaction_group_others , "playback shuffle" , toggled ); } +void mainwin_shuffle_pushed_cb(void) { + mainwin_shuffle_pushed(UI_SKINNED_BUTTON(mainwin_shuffle)->inside); +} + void mainwin_repeat_pushed(gboolean toggled) { check_set( toggleaction_group_others , "playback repeat" , toggled ); } +void mainwin_repeat_pushed_cb(void) { + mainwin_repeat_pushed(UI_SKINNED_BUTTON(mainwin_repeat)->inside); +} + +void mainwin_equalizer_pushed_cb(void) { + mainwin_eq_pushed(UI_SKINNED_BUTTON(mainwin_eq)->inside); +} + +void mainwin_playlist_pushed_cb(void) { + mainwin_pl_pushed(UI_SKINNED_BUTTON(mainwin_pl)->inside); +} + +void +mainwin_eq_pushed(gboolean toggled) +{ + equalizerwin_show(toggled); +} + void mainwin_pl_pushed(gboolean toggled) { @@ -2761,26 +2785,31 @@ create_sbutton(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 216, 4, 9, 7, mainwin_eject_pushed); - mainwin_shuffle = - create_tbutton(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 164, 89, 46, - 15, 28, 0, 28, 15, 28, 30, 28, 45, - mainwin_shuffle_pushed, SKIN_SHUFREP); - - mainwin_repeat = - create_tbutton(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 210, 89, 28, - 15, 0, 0, 0, 15, 0, 30, 0, 45, - mainwin_repeat_pushed, SKIN_SHUFREP); - - mainwin_eq = - create_tbutton(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 219, 58, 23, - 12, 0, 61, 46, 61, 0, 73, 46, 73, equalizerwin_show, - SKIN_SHUFREP); - tbutton_set_toggled(mainwin_eq, cfg.equalizer_visible); - mainwin_pl = - create_tbutton(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 242, 58, 23, - 12, 23, 61, 69, 61, 23, 73, 69, 73, - mainwin_pl_pushed, SKIN_SHUFREP); - tbutton_set_toggled(mainwin_pl, cfg.playlist_visible); + mainwin_shuffle = ui_skinned_button_new(); + ui_skinned_toggle_button_setup(mainwin_shuffle, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 164, 89, 46, + 15, 28, 0, 28, 15, 28, 30, 28, 45, SKIN_SHUFREP); + g_signal_connect(mainwin_shuffle, "clicked", mainwin_shuffle_pushed_cb, NULL); + + mainwin_repeat = ui_skinned_button_new(); + ui_skinned_toggle_button_setup(mainwin_repeat, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 210, 89, 28, + 15, 0, 0, 0, 15, 0, 30, 0, 45, SKIN_SHUFREP); + g_signal_connect(mainwin_repeat, "clicked", mainwin_repeat_pushed_cb, NULL); + + mainwin_eq = ui_skinned_button_new(); + ui_skinned_toggle_button_setup(mainwin_eq, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 219, 58, 23, + 12, 0, 61, 46, 61, 0, 73, 46, 73, SKIN_SHUFREP); + g_signal_connect(mainwin_eq, "clicked", mainwin_equalizer_pushed_cb, NULL); + UI_SKINNED_BUTTON(mainwin_eq)->inside = cfg.equalizer_visible; + + mainwin_pl = ui_skinned_button_new(); + ui_skinned_toggle_button_setup(mainwin_pl, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 242, 58, 23, + 12, 23, 61, 69, 61, 23, 73, 69, 73, SKIN_SHUFREP); + g_signal_connect(mainwin_pl, "clicked", mainwin_playlist_pushed_cb, NULL); + UI_SKINNED_BUTTON(mainwin_pl)->inside = cfg.playlist_visible; mainwin_info = create_textbox(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 112, 27, @@ -2911,12 +2940,6 @@ 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)); @@ -3236,7 +3259,7 @@ action_playback_repeat( GtkToggleAction * action ) { cfg.repeat = gtk_toggle_action_get_active( action ); - tbutton_set_toggled(mainwin_repeat, cfg.repeat); + UI_SKINNED_BUTTON(mainwin_repeat)->inside = cfg.repeat; } void @@ -3244,7 +3267,7 @@ { cfg.shuffle = gtk_toggle_action_get_active( action ); playlist_set_shuffle(cfg.shuffle); - tbutton_set_toggled(mainwin_shuffle, cfg.shuffle); + UI_SKINNED_BUTTON(mainwin_shuffle)->inside = cfg.shuffle; } void diff -r c2622a939e9e -r 91ef09fe7936 src/audacious/ui_main.h --- a/src/audacious/ui_main.h Sun Jun 17 12:54:59 2007 +0200 +++ b/src/audacious/ui_main.h Sun Jun 17 15:53:59 2007 +0200 @@ -101,7 +101,6 @@ extern TextBox *mainwin_stime_min, *mainwin_stime_sec; extern TextBox *mainwin_info; -extern TButton *mainwin_shuffle, *mainwin_repeat, *mainwin_eq, *mainwin_pl; extern Vis *active_vis; extern Vis *mainwin_vis; diff -r c2622a939e9e -r 91ef09fe7936 src/audacious/ui_playlist.c --- a/src/audacious/ui_playlist.c Sun Jun 17 12:54:59 2007 +0200 +++ b/src/audacious/ui_playlist.c Sun Jun 17 15:53:59 2007 +0200 @@ -1788,8 +1788,8 @@ toggleaction_group_others , "show playlist editor" ); gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , TRUE ); - tbutton_set_toggled(mainwin_pl, TRUE); cfg.playlist_visible = TRUE; + //FIXME: set mainwin_pl->inside as TRUE and redraw it playlistwin_set_toprow(0); playlist_check_pos_current(playlist_get_active()); @@ -1809,8 +1809,8 @@ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , FALSE ); gtk_widget_hide(playlistwin); - tbutton_set_toggled(mainwin_pl, FALSE); cfg.playlist_visible = FALSE; + //FIXME: set mainwin_pl->inside as FALSE and redraw it /* no point in probing for playlistwin_infopopup trigger when the playlistwin is hidden */ if ( playlistwin_infopopup_sid != 0 ) diff -r c2622a939e9e -r 91ef09fe7936 src/audacious/ui_skinned_button.c --- a/src/audacious/ui_skinned_button.c Sun Jun 17 12:54:59 2007 +0200 +++ b/src/audacious/ui_skinned_button.c Sun Jun 17 15:53:59 2007 +0200 @@ -160,6 +160,8 @@ UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); priv->image = gtk_image_new(); button->redraw = TRUE; + button->inside = FALSE; + button->type = TYPE_NOT_SET; g_object_set (priv->image, "visible", TRUE, NULL); gtk_container_add(GTK_CONTAINER(GTK_WIDGET(button)), priv->image); @@ -253,6 +255,34 @@ sbutton->ny = ny; sbutton->px = px; sbutton->py = py; + sbutton->type = TYPE_PUSH; + priv->skin_index1 = si; + priv->skin_index2 = si; + priv->fixed = fixed; + priv->double_size = FALSE; + + gtk_widget_set_size_request(button, priv->w, priv->h); + gtk_fixed_put(GTK_FIXED(priv->fixed),GTK_WIDGET(button), sbutton->x, sbutton->y); +} + +void ui_skinned_toggle_button_setup(GtkWidget *button, GtkWidget *fixed, GdkPixmap *parent, GdkGC *gc, gint x, gint y, gint w, gint h, gint nx, gint ny, gint px, gint py, gint pnx, gint pny, gint ppx, gint ppy, SkinPixmapId si) { + + UiSkinnedButton *sbutton = UI_SKINNED_BUTTON(button); + UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE(sbutton); + priv->gc = gc; + priv->w = w; + priv->h = h; + sbutton->x = x; + sbutton->y = y; + sbutton->nx = nx; + sbutton->ny = ny; + sbutton->px = px; + sbutton->py = py; + sbutton->pnx = pnx; + sbutton->pny = pny; + sbutton->ppx = ppx; + sbutton->ppy = ppy; + sbutton->type = TYPE_TOGGLE; priv->skin_index1 = si; priv->skin_index2 = si; priv->fixed = fixed; @@ -340,6 +370,7 @@ static void ui_skinned_button_clicked(UiSkinnedButton *button) { g_return_if_fail(UI_IS_SKINNED_BUTTON(button)); + button->inside = !button->inside; g_signal_emit(button, button_signals[CLICKED], 0); } @@ -383,14 +414,37 @@ GtkWidget *widget = GTK_WIDGET (button); UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); + if (button->type == TYPE_SMALL || button->type == TYPE_NOT_SET) + return; + if (button->redraw == TRUE) { button->redraw = FALSE; + GdkPixmap *obj; obj = gdk_pixmap_new(NULL, priv->w, priv->h, gdk_rgb_get_visual()->depth); - skin_draw_pixmap(bmp_active_skin, obj, priv->gc, priv->skin_index2, - button->pressed ? button->px : button->nx, - button->pressed ? button->py : button->ny, - 0, 0, priv->w, priv->h); + switch (button->type) { + case TYPE_PUSH: + skin_draw_pixmap(bmp_active_skin, obj, priv->gc, priv->skin_index2, + button->pressed ? button->px : button->nx, + button->pressed ? button->py : button->ny, + 0, 0, priv->w, priv->h); + break; + case TYPE_TOGGLE: + if (button->inside) + skin_draw_pixmap(bmp_active_skin, obj, priv->gc, priv->skin_index2, + button->pressed ? button->ppx : button->pnx, + button->pressed ? button->ppy : button->pny, + 0, 0, priv->w, priv->h); + else + skin_draw_pixmap(bmp_active_skin, obj, priv->gc, priv->skin_index2, + button->pressed ? button->px : button->nx, + button->pressed ? button->py : button->ny, + 0, 0, priv->w, priv->h); + break; + default: + break; + } + if(priv->double_size) { GdkImage *img, *img2x; img = gdk_drawable_get_image(obj, 0, 0, priv->w, priv->h); @@ -400,8 +454,9 @@ g_object_unref(img); } else gtk_image_set_from_pixmap(GTK_IMAGE(priv->image), obj, NULL); - g_object_unref(obj); - gtk_widget_queue_resize(widget); + + g_object_unref(obj); + gtk_widget_queue_resize(widget); } } diff -r c2622a939e9e -r 91ef09fe7936 src/audacious/ui_skinned_button.h --- a/src/audacious/ui_skinned_button.h Sun Jun 17 12:54:59 2007 +0200 +++ b/src/audacious/ui_skinned_button.h Sun Jun 17 15:53:59 2007 +0200 @@ -44,6 +44,13 @@ LAST_SIGNAL }; +enum { + TYPE_NOT_SET, + TYPE_PUSH, + TYPE_TOGGLE, + TYPE_SMALL +}; + struct _UiSkinnedButton { GtkBin bin; @@ -52,9 +59,14 @@ gboolean button_down : 1; gboolean pressed : 1; gboolean hover : 1; + gboolean inside : 1; + gint type; //Skinned part, used in ui_playlist.c gint x, y, nx, ny, px, py; + //Toogle button needs also those + gint pnx, pny, ppx, ppy; + gboolean redraw; }; @@ -70,5 +82,6 @@ GType ui_skinned_button_get_type(void) G_GNUC_CONST; GtkWidget* ui_skinned_button_new(); void ui_skinned_push_button_setup(GtkWidget *button, GtkWidget *fixed, GdkPixmap * parent, GdkGC * gc, gint x, gint y, gint w, gint h, gint nx, gint ny, gint px, gint py, SkinPixmapId si); +void ui_skinned_toggle_button_setup(GtkWidget *button, GtkWidget *fixed, GdkPixmap *parent, GdkGC *gc, gint x, gint y, gint w, gint h, gint nx, gint ny, gint px, gint py, gint pnx, gint pny, gint ppx, gint ppy, SkinPixmapId si); #endif