Mercurial > audlegacy
changeset 2848:9373f9ec469d trunk
Automated merge from ssh://hg.atheme.org//hg/audacious.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Tue, 19 Jun 2007 15:36:44 -0500 |
parents | 7b4b8e135cb9 (current diff) 89c3fef7ae1f (diff) |
children | 97dc42683fc6 |
files | src/audacious/widgets/audacious_pbutton.c src/audacious/widgets/audacious_pbutton.h |
diffstat | 14 files changed, 788 insertions(+), 652 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/Makefile Tue Jun 19 15:36:09 2007 -0500 +++ b/src/audacious/Makefile Tue Jun 19 15:36:44 2007 -0500 @@ -104,6 +104,7 @@ ui_preferences.c \ ui_skinned_cursor.c \ ui_skinned_window.c \ + ui_skinned_button.c \ ui_skinselector.c \ ui_urlopener.c \ urldecode.c \
--- a/src/audacious/main.c Tue Jun 19 15:36:09 2007 -0500 +++ b/src/audacious/main.c Tue Jun 19 15:36:44 2007 -0500 @@ -53,6 +53,7 @@ # include "audctrl.h" #endif +#include "auddrct.h" #include "dnd.h" #include "effect.h" #include "ui_equalizer.h" @@ -998,6 +999,40 @@ if (options->playcd) play_medium(); + } else { + if (options->rew) + audacious_drct_playlist_prev(); + + if (options->play) + audacious_drct_play(); + + if (options->pause) + audacious_drct_pause(); + + if (options->stop) + audacious_drct_stop(); + + if (options->fwd) + audacious_drct_playlist_next(); + + if (options->play_pause) { + if (audacious_drct_get_paused()) + audacious_drct_play(); + else + audacious_drct_pause(); + } + + if (options->show_jump_box) + audacious_drct_show_jtf_box(); + + if (options->mainwin) + audacious_drct_main_win_toggle(TRUE); + + if (options->activate) + audacious_drct_activate(); + + if (options->playcd) + play_medium(); } if(remote) {
--- a/src/audacious/plugin.h Tue Jun 19 15:36:09 2007 -0500 +++ b/src/audacious/plugin.h Tue Jun 19 15:36:44 2007 -0500 @@ -108,7 +108,7 @@ #define DECLARE_PLUGIN(name, init, fini, ip_list, op_list, ep_list, gp_list, vp_list) \ G_BEGIN_DECLS \ static PluginHeader _pluginInfo = { PLUGIN_MAGIC, __AUDACIOUS_PLUGIN_API__, \ - #name, init, fini, NULL, ip_list, op_list, ep_list, gp_list, \ + (gchar *)#name, init, fini, NULL, ip_list, op_list, ep_list, gp_list, \ vp_list }; \ PluginHeader *get_plugin_info(void) { \ return &_pluginInfo; \
--- a/src/audacious/ui_equalizer.c Tue Jun 19 15:36:09 2007 -0500 +++ b/src/audacious/ui_equalizer.c Tue Jun 19 15:36:44 2007 -0500 @@ -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 *
--- a/src/audacious/ui_main.c Tue Jun 19 15:36:09 2007 -0500 +++ b/src/audacious/ui_main.c Tue Jun 19 15:36:44 2007 -0500 @@ -81,6 +81,7 @@ #include "visualization.h" #include "ui_skinned_window.h" +#include "ui_skinned_button.h" #include "ui_jumptotrack.h" static GTimeVal cb_time; /* click delay for tristate is defined by TRISTATE_THRESHOLD */ @@ -132,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; @@ -155,8 +157,8 @@ static MenuRow *mainwin_menurow; static HSlider *mainwin_volume, *mainwin_balance, *mainwin_position; static MonoStereo *mainwin_monostereo; -static SButton *mainwin_srew, *mainwin_splay, *mainwin_spause; -static SButton *mainwin_sstop, *mainwin_sfwd, *mainwin_seject, *mainwin_about; +static GtkWidget *mainwin_srew, *mainwin_splay, *mainwin_spause; +static GtkWidget *mainwin_sstop, *mainwin_sfwd, *mainwin_seject, *mainwin_about; static gint mainwin_timeout_id; @@ -183,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 */ @@ -269,12 +272,12 @@ widget_show(WIDGET(mainwin_svis)); vis_clear_data(mainwin_vis); - widget_show(WIDGET(mainwin_srew)); - widget_show(WIDGET(mainwin_splay)); - widget_show(WIDGET(mainwin_spause)); - widget_show(WIDGET(mainwin_sstop)); - widget_show(WIDGET(mainwin_sfwd)); - widget_show(WIDGET(mainwin_seject)); + gtk_widget_show(mainwin_srew); + gtk_widget_show(mainwin_splay); + gtk_widget_show(mainwin_spause); + gtk_widget_show(mainwin_sstop); + gtk_widget_show(mainwin_sfwd); + gtk_widget_show(mainwin_seject); textbox_set_scroll(mainwin_info, FALSE); if (playback_get_playing()) @@ -300,12 +303,12 @@ widget_hide(WIDGET(mainwin_svis)); svis_clear_data(mainwin_svis); - widget_hide(WIDGET(mainwin_srew)); - widget_hide(WIDGET(mainwin_splay)); - widget_hide(WIDGET(mainwin_spause)); - widget_hide(WIDGET(mainwin_sstop)); - widget_hide(WIDGET(mainwin_sfwd)); - widget_hide(WIDGET(mainwin_seject)); + gtk_widget_hide(mainwin_srew); + gtk_widget_hide(mainwin_splay); + gtk_widget_hide(mainwin_spause); + gtk_widget_hide(mainwin_sstop); + gtk_widget_hide(mainwin_sfwd); + gtk_widget_hide(mainwin_seject); widget_hide(WIDGET(mainwin_stime_min)); widget_hide(WIDGET(mainwin_stime_sec)); @@ -518,10 +521,6 @@ g_object_unref(img); } - gdk_window_clear(mainwin->window); - - } - else { GList *iter; for (iter = GTK_FIXED (SKINNED_WINDOW(mainwin)->fixed)->children; iter; iter = g_list_next (iter)) { GtkFixedChild *child_data = (GtkFixedChild *) iter->data; @@ -529,6 +528,8 @@ g_signal_emit_by_name(child, "redraw"); } + } + else { for (wl = mainwin_wlist; wl; wl = g_list_next(wl)) { w = WIDGET(wl->data); @@ -741,23 +742,23 @@ 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) - widget_move(WIDGET(mainwin_about), bmp_active_skin->properties.mainwin_about_x, + gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_about), bmp_active_skin->properties.mainwin_about_x, bmp_active_skin->properties.mainwin_about_y); if (bmp_active_skin->properties.mainwin_minimize_x && bmp_active_skin->properties.mainwin_minimize_y) @@ -793,6 +794,17 @@ else widget_hide(WIDGET(mainwin_vis)); + if (!cfg.player_shaded) { + gtk_widget_hide(mainwin_srew); + gtk_widget_hide(mainwin_splay); + gtk_widget_hide(mainwin_spause); + gtk_widget_hide(mainwin_sstop); + gtk_widget_hide(mainwin_sfwd); + gtk_widget_hide(mainwin_seject); + widget_hide(WIDGET(mainwin_stime_min)); + widget_hide(WIDGET(mainwin_stime_sec)); + } + /* window size, mainwinWidth && mainwinHeight properties */ if (bmp_active_skin->properties.mainwin_height && bmp_active_skin->properties.mainwin_width) { @@ -1679,12 +1691,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) { @@ -2690,98 +2724,114 @@ static void mainwin_create_widgets(void) { - mainwin_menubtn = audacious_pbutton_new(); - audacious_pbutton_setup(mainwin_menubtn, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, - SKINNED_WINDOW(mainwin)->gc, 6, 3, 9, 9, 0, 0, 0, 9, SKIN_TITLEBAR); - g_signal_connect(mainwin_menubtn, "clicked", mainwin_menubtn_cb, NULL ); - - mainwin_minimize = audacious_pbutton_new(); - audacious_pbutton_setup(mainwin_minimize, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, - SKINNED_WINDOW(mainwin)->gc, 244, 3, 9, 9, 9, 0, 9, 9, SKIN_TITLEBAR); - g_signal_connect(mainwin_minimize, "clicked", mainwin_minimize_cb, NULL ); - - mainwin_shade = audacious_pbutton_new(); - audacious_pbutton_setup(mainwin_shade, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, - SKINNED_WINDOW(mainwin)->gc, 254, 3, 9, 9, 0, - cfg.player_shaded ? 27 : 18, 9, cfg.player_shaded ? 27 : 18, SKIN_TITLEBAR); - g_signal_connect(mainwin_shade, "clicked", mainwin_shade_toggle, NULL ); - - mainwin_close = audacious_pbutton_new(); - audacious_pbutton_setup(mainwin_close, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, - SKINNED_WINDOW(mainwin)->gc, 264, 3, 9, 9, 18, 0, 18, 9, SKIN_TITLEBAR); - g_signal_connect(mainwin_close, "clicked", mainwin_quit_cb, NULL ); - - mainwin_rew = audacious_pbutton_new(); - audacious_pbutton_setup(mainwin_rew, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, - SKINNED_WINDOW(mainwin)->gc, 16, 88, 23, 18, 0, 0, 0, 18, SKIN_CBUTTONS); - g_signal_connect(mainwin_rew, "pressed", mainwin_rev_pushed, NULL); - g_signal_connect(mainwin_rew, "released", mainwin_rev_release, NULL); - - mainwin_fwd = audacious_pbutton_new(); - audacious_pbutton_setup(mainwin_fwd, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, - SKINNED_WINDOW(mainwin)->gc, 108, 88, 22, 18, 92, 0, 92, 18, SKIN_CBUTTONS); - g_signal_connect(mainwin_fwd, "pressed", mainwin_fwd_pushed, NULL); - g_signal_connect(mainwin_fwd, "released", mainwin_fwd_release, NULL); - - mainwin_play = audacious_pbutton_new(); - audacious_pbutton_setup(mainwin_play, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, - SKINNED_WINDOW(mainwin)->gc, 39, 88, 23, 18, 23, 0, 23, 18, SKIN_CBUTTONS); - g_signal_connect(mainwin_play, "clicked", mainwin_play_pushed, NULL ); - - mainwin_pause = audacious_pbutton_new(); - audacious_pbutton_setup(mainwin_pause, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, - SKINNED_WINDOW(mainwin)->gc, 62, 88, 23, 18, 46, 0, 46, 18, SKIN_CBUTTONS); - g_signal_connect(mainwin_pause, "clicked", playback_pause, NULL ); - - mainwin_stop = audacious_pbutton_new(); - audacious_pbutton_setup(mainwin_stop, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, - SKINNED_WINDOW(mainwin)->gc, 85, 88, 23, 18, 69, 0, 69, 18, SKIN_CBUTTONS); - g_signal_connect(mainwin_stop, "clicked", mainwin_stop_pushed, NULL ); - - mainwin_eject = audacious_pbutton_new(); - audacious_pbutton_setup(mainwin_eject, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, - SKINNED_WINDOW(mainwin)->gc, 136, 89, 22, 16, 114, 0, 114, 16, SKIN_CBUTTONS); - g_signal_connect(mainwin_eject, "clicked", mainwin_eject_pushed, NULL); - - mainwin_srew = - create_sbutton(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 169, 4, 8, - 7, mainwin_playlist_prev); - mainwin_splay = - create_sbutton(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 177, 4, 10, - 7, mainwin_play_pushed); - mainwin_spause = - create_sbutton(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 187, 4, 10, - 7, playback_pause); - mainwin_sstop = - create_sbutton(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 197, 4, 9, - 7, mainwin_stop_pushed); - mainwin_sfwd = - create_sbutton(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 206, 4, 8, - 7, mainwin_playlist_next); - mainwin_seject = - 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_menubtn = ui_skinned_button_new(); + ui_skinned_push_button_setup(mainwin_menubtn, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 6, 3, 9, 9, 0, 0, 0, 9, SKIN_TITLEBAR); + g_signal_connect(mainwin_menubtn, "clicked", mainwin_menubtn_cb, NULL ); + + mainwin_minimize = ui_skinned_button_new(); + ui_skinned_push_button_setup(mainwin_minimize, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 244, 3, 9, 9, 9, 0, 9, 9, SKIN_TITLEBAR); + g_signal_connect(mainwin_minimize, "clicked", mainwin_minimize_cb, NULL ); + + mainwin_shade = ui_skinned_button_new(); + ui_skinned_push_button_setup(mainwin_shade, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 254, 3, 9, 9, 0, + cfg.player_shaded ? 27 : 18, 9, cfg.player_shaded ? 27 : 18, SKIN_TITLEBAR); + g_signal_connect(mainwin_shade, "clicked", mainwin_shade_toggle, NULL ); + + mainwin_close = ui_skinned_button_new(); + ui_skinned_push_button_setup(mainwin_close, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 264, 3, 9, 9, 18, 0, 18, 9, SKIN_TITLEBAR); + g_signal_connect(mainwin_close, "clicked", mainwin_quit_cb, NULL ); + + mainwin_rew = ui_skinned_button_new(); + ui_skinned_push_button_setup(mainwin_rew, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 16, 88, 23, 18, 0, 0, 0, 18, SKIN_CBUTTONS); + g_signal_connect(mainwin_rew, "pressed", mainwin_rev_pushed, NULL); + g_signal_connect(mainwin_rew, "released", mainwin_rev_release, NULL); + + mainwin_fwd = ui_skinned_button_new(); + ui_skinned_push_button_setup(mainwin_fwd, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 108, 88, 22, 18, 92, 0, 92, 18, SKIN_CBUTTONS); + g_signal_connect(mainwin_fwd, "pressed", mainwin_fwd_pushed, NULL); + g_signal_connect(mainwin_fwd, "released", mainwin_fwd_release, NULL); + + mainwin_play = ui_skinned_button_new(); + ui_skinned_push_button_setup(mainwin_play, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 39, 88, 23, 18, 23, 0, 23, 18, SKIN_CBUTTONS); + g_signal_connect(mainwin_play, "clicked", mainwin_play_pushed, NULL ); + + mainwin_pause = ui_skinned_button_new(); + ui_skinned_push_button_setup(mainwin_pause, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 62, 88, 23, 18, 46, 0, 46, 18, SKIN_CBUTTONS); + g_signal_connect(mainwin_pause, "clicked", playback_pause, NULL ); + + mainwin_stop = ui_skinned_button_new(); + ui_skinned_push_button_setup(mainwin_stop, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 85, 88, 23, 18, 69, 0, 69, 18, SKIN_CBUTTONS); + g_signal_connect(mainwin_stop, "clicked", mainwin_stop_pushed, NULL ); + + mainwin_eject = ui_skinned_button_new(); + ui_skinned_push_button_setup(mainwin_eject, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 136, 89, 22, 16, 114, 0, 114, 16, SKIN_CBUTTONS); + g_signal_connect(mainwin_eject, "clicked", mainwin_eject_pushed, NULL); + + mainwin_srew = ui_skinned_button_new(); + ui_skinned_small_button_setup(mainwin_srew, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 169, 4, 8, 7); + g_signal_connect(mainwin_srew, "clicked", mainwin_playlist_prev, NULL); + + mainwin_splay = ui_skinned_button_new(); + ui_skinned_small_button_setup(mainwin_splay, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 177, 4, 10, 7); + g_signal_connect(mainwin_splay, "clicked", mainwin_play_pushed, NULL); + + mainwin_spause = ui_skinned_button_new(); + ui_skinned_small_button_setup(mainwin_spause, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 187, 4, 10, 7); + g_signal_connect(mainwin_spause, "clicked", playback_pause, NULL); + + mainwin_sstop = ui_skinned_button_new(); + ui_skinned_small_button_setup(mainwin_sstop, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 197, 4, 9, 7); + g_signal_connect(mainwin_sstop, "clicked", mainwin_stop_pushed, NULL); + + mainwin_sfwd = ui_skinned_button_new(); + ui_skinned_small_button_setup(mainwin_sfwd, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 206, 4, 8, 7); + g_signal_connect(mainwin_sfwd, "clicked", mainwin_playlist_next, NULL); + + mainwin_seject = ui_skinned_button_new(); + ui_skinned_small_button_setup(mainwin_seject, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 216, 4, 9, 7); + g_signal_connect(mainwin_seject, "clicked", mainwin_eject_pushed, NULL); + + 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, @@ -2849,9 +2899,10 @@ SKIN_NUMBERS); widget_hide(WIDGET(mainwin_sec_num)); - mainwin_about = - create_sbutton(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 247, 83, 20, - 25, show_about_window); + mainwin_about = ui_skinned_button_new(); + ui_skinned_small_button_setup(mainwin_about, SKINNED_WINDOW(mainwin)->fixed, mainwin_bg, + SKINNED_WINDOW(mainwin)->gc, 247, 83, 20, 25); + g_signal_connect(mainwin_about, "clicked", show_about_window, NULL); mainwin_vis = create_vis(&mainwin_wlist, mainwin_bg, mainwin->window, SKINNED_WINDOW(mainwin)->gc, @@ -2880,18 +2931,6 @@ create_textbox(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 147, 4, 10, FALSE, SKIN_TEXT); - if (!cfg.player_shaded) { - widget_hide(WIDGET(mainwin_svis)); - widget_hide(WIDGET(mainwin_srew)); - widget_hide(WIDGET(mainwin_splay)); - widget_hide(WIDGET(mainwin_spause)); - widget_hide(WIDGET(mainwin_sstop)); - widget_hide(WIDGET(mainwin_sfwd)); - widget_hide(WIDGET(mainwin_seject)); - widget_hide(WIDGET(mainwin_stime_min)); - widget_hide(WIDGET(mainwin_stime_sec)); - } - err = gtk_message_dialog_new(GTK_WINDOW(mainwin), GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Error in Audacious.")); @@ -2901,24 +2940,8 @@ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(err), "Boo! Bad stuff! Booga Booga!"); - gtk_container_add(GTK_CONTAINER(mainwin), GTK_WIDGET(SKINNED_WINDOW(mainwin)->fixed)); /* XXX: eventually update widgetcore API to not need this */ - 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)); @@ -2939,8 +2962,6 @@ 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)); @@ -3238,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 @@ -3246,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
--- a/src/audacious/ui_main.h Tue Jun 19 15:36:09 2007 -0500 +++ b/src/audacious/ui_main.h Tue Jun 19 15:36:44 2007 -0500 @@ -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;
--- a/src/audacious/ui_playlist.c Tue Jun 19 15:36:09 2007 -0500 +++ b/src/audacious/ui_playlist.c Tue Jun 19 15:36:44 2007 -0500 @@ -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 )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/ui_skinned_button.c Tue Jun 19 15:36:44 2007 -0500 @@ -0,0 +1,484 @@ +/* + * Audacious - a cross-platform multimedia player + * Copyright (c) 2007 Audacious 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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 "widgets/widgetcore.h" +#include "ui_skinned_button.h" +#include "util.h" + +#include <gtk/gtkmain.h> +#include <gtk/gtkmarshal.h> +#include <gtk/gtkimage.h> + +#define UI_SKINNED_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UI_TYPE_SKINNED_BUTTON, UiSkinnedButtonPrivate)) +typedef struct _UiSkinnedButtonPrivate UiSkinnedButtonPrivate; + +struct _UiSkinnedButtonPrivate { + //Skinned part + GtkWidget *image; + GdkGC *gc; + gint w; + gint h; + SkinPixmapId skin_index1; + SkinPixmapId skin_index2; + GtkWidget *fixed; + gboolean double_size; +}; + + +static GtkBinClass *parent_class = NULL; +static void ui_skinned_button_class_init(UiSkinnedButtonClass *klass); +static void ui_skinned_button_init(UiSkinnedButton *button); +static GObject* ui_skinned_button_constructor(GType type, guint n_construct_properties, GObjectConstructParam *construct_params); +static void ui_skinned_button_destroy(GtkObject *object); +static void ui_skinned_button_realize(GtkWidget *widget); +static void ui_skinned_button_unrealize(GtkWidget *widget); +static void ui_skinned_button_map(GtkWidget *widget); +static void ui_skinned_button_unmap(GtkWidget *widget); +static gint ui_skinned_button_expose(GtkWidget *widget,GdkEventExpose *event); + +static void ui_skinned_button_size_allocate(GtkWidget *widget, GtkAllocation *allocation); +static void ui_skinned_button_update_state(UiSkinnedButton *button); + +static guint button_signals[LAST_SIGNAL] = { 0 }; +static gint ui_skinned_button_button_press(GtkWidget *widget, GdkEventButton *event); +static gint ui_skinned_button_button_release(GtkWidget *widget, GdkEventButton *event); +static void button_pressed(UiSkinnedButton *button); +static void button_released(UiSkinnedButton *button); +static void ui_skinned_button_pressed(UiSkinnedButton *button); +static void ui_skinned_button_released(UiSkinnedButton *button); +static void ui_skinned_button_clicked(UiSkinnedButton *button); +static void ui_skinned_button_set_pressed (UiSkinnedButton *button, gboolean pressed); + +static void ui_skinned_button_add(GtkContainer *container, GtkWidget *widget); +static void ui_skinned_button_toggle_doublesize(UiSkinnedButton *button); + +static gint ui_skinned_button_enter_notify(GtkWidget *widget, GdkEventCrossing *event); +static gint ui_skinned_button_leave_notify(GtkWidget *widget, GdkEventCrossing *event); +static void ui_skinned_button_paint(UiSkinnedButton *button); +static void ui_skinned_button_redraw(UiSkinnedButton *button); + +GType ui_skinned_button_get_type (void) { + static GType button_type = 0; + + if (!button_type) { + static const GTypeInfo button_info = { + sizeof (UiSkinnedButtonClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ui_skinned_button_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (UiSkinnedButton), + 16, /* n_preallocs */ + (GInstanceInitFunc) ui_skinned_button_init, + }; + + button_type = g_type_register_static (GTK_TYPE_BIN, "UiSkinnedButton", &button_info, 0); + } + return button_type; +} + +static void ui_skinned_button_class_init (UiSkinnedButtonClass *klass) { + GObjectClass *gobject_class; + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + GtkContainerClass *container_class; + + gobject_class = G_OBJECT_CLASS(klass); + object_class = (GtkObjectClass*)klass; + widget_class = (GtkWidgetClass*)klass; + container_class = (GtkContainerClass*)klass; + + parent_class = g_type_class_peek_parent(klass); + gobject_class->constructor = ui_skinned_button_constructor; + object_class->destroy = ui_skinned_button_destroy; + + widget_class->realize = ui_skinned_button_realize; + widget_class->unrealize = ui_skinned_button_unrealize; + widget_class->map = ui_skinned_button_map; + widget_class->unmap = ui_skinned_button_unmap; + widget_class->size_allocate = ui_skinned_button_size_allocate; + widget_class->expose_event = ui_skinned_button_expose; + widget_class->button_press_event = ui_skinned_button_button_press; + widget_class->button_release_event = ui_skinned_button_button_release; + widget_class->enter_notify_event = ui_skinned_button_enter_notify; + widget_class->leave_notify_event = ui_skinned_button_leave_notify; + + container_class->add = ui_skinned_button_add; + + klass->pressed = button_pressed; + klass->released = button_released; + klass->clicked = NULL; + klass->doubled = ui_skinned_button_toggle_doublesize; + klass->redraw = ui_skinned_button_redraw; + + button_signals[PRESSED] = + g_signal_new ("pressed", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (UiSkinnedButtonClass, pressed), NULL, NULL, + gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); + + button_signals[RELEASED] = + g_signal_new ("released", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (UiSkinnedButtonClass, released), NULL, NULL, + gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); + + button_signals[CLICKED] = + g_signal_new ("clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (UiSkinnedButtonClass, clicked), NULL, NULL, + gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); + + button_signals[DOUBLED] = + g_signal_new ("toggle-double-size", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (UiSkinnedButtonClass, doubled), NULL, NULL, + gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); + + button_signals[REDRAW] = + g_signal_new ("redraw", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (UiSkinnedButtonClass, redraw), NULL, NULL, + gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); + + g_type_class_add_private (gobject_class, sizeof (UiSkinnedButtonPrivate)); +} + +static void ui_skinned_button_init (UiSkinnedButton *button) { + 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); + + GTK_WIDGET_SET_FLAGS (button, GTK_CAN_FOCUS); + GTK_WIDGET_SET_FLAGS (button, GTK_NO_WINDOW); +} + +static void ui_skinned_button_destroy (GtkObject *object) { + (*GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + +static GObject* ui_skinned_button_constructor(GType type, guint n_construct_properties, GObjectConstructParam *construct_params) { + GObject *object = (*G_OBJECT_CLASS (parent_class)->constructor)(type, n_construct_properties, construct_params); + + return object; +} + +static void ui_skinned_button_realize (GtkWidget *widget) { + UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); + GdkWindowAttr attrib; + + GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + + attrib.window_type = GDK_WINDOW_CHILD; + attrib.x = widget->allocation.x; + attrib.y = widget->allocation.y; + attrib.width = widget->allocation.width; + attrib.height = widget->allocation.height; + attrib.wclass = GDK_INPUT_ONLY; + attrib.event_mask = gtk_widget_get_events (widget); + attrib.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); + + widget->window = gtk_widget_get_parent_window(widget); + g_object_ref(widget->window); + + button->event_window = gdk_window_new(gtk_widget_get_parent_window(widget), &attrib, GDK_WA_X | GDK_WA_Y); + gdk_window_set_user_data (button->event_window, button); +} + +static void ui_skinned_button_unrealize(GtkWidget *widget) { + UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); + + if (button->event_window) { + gdk_window_set_user_data (button->event_window, NULL); + gdk_window_destroy (button->event_window); + button->event_window = NULL; + } + + GTK_WIDGET_CLASS (parent_class)->unrealize (widget); +} + +static void ui_skinned_button_map(GtkWidget *widget) { + UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); + g_return_if_fail (UI_IS_SKINNED_BUTTON (widget)); + GTK_WIDGET_CLASS (parent_class)->map(widget); + gdk_window_show (button->event_window); +} + +static void ui_skinned_button_unmap (GtkWidget *widget) { + UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); + g_return_if_fail (UI_IS_SKINNED_BUTTON(widget)); + + if (button->event_window) + gdk_window_hide (button->event_window); + + GTK_WIDGET_CLASS (parent_class)->unmap (widget); +} + +static gboolean ui_skinned_button_expose(GtkWidget *widget, GdkEventExpose *event) { + if (GTK_WIDGET_DRAWABLE (widget)) + (*GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); + + return FALSE; +} + +GtkWidget* ui_skinned_button_new () { + return g_object_new (UI_TYPE_SKINNED_BUTTON, NULL); +} + +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) { + + 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->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; + 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_small_button_setup(GtkWidget *button, GtkWidget *fixed, GdkPixmap *parent, GdkGC *gc, gint x, gint y, gint w, gint h) { + + 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->type = TYPE_SMALL; + 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); +} + +static void ui_skinned_button_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { + UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); + GtkAllocation child_alloc; + + widget->allocation = *allocation; + if (GTK_BIN (button)->child) { //image should fill whole widget + child_alloc.x = widget->allocation.x; + child_alloc.y = widget->allocation.y; + child_alloc.width = MAX (1, widget->allocation.width); + child_alloc.height = MAX (1, widget->allocation.height); + + gtk_widget_size_allocate (GTK_BIN (button)->child, &child_alloc); + } + + if (GDK_IS_WINDOW(button->event_window)) + gdk_window_move_resize (button->event_window, widget->allocation.x, widget->allocation.y, + widget->allocation.width, widget->allocation.height); +} + +static void button_pressed(UiSkinnedButton *button) { + button->button_down = TRUE; + ui_skinned_button_update_state(button); +} + +static void button_released(UiSkinnedButton *button) { + button->button_down = FALSE; + if(button->hover) ui_skinned_button_clicked(button); + ui_skinned_button_update_state(button); +} + +static void ui_skinned_button_update_state(UiSkinnedButton *button) { + ui_skinned_button_set_pressed(button, button->button_down); +} + +static void ui_skinned_button_set_pressed (UiSkinnedButton *button, gboolean pressed) { + if (pressed != button->pressed) { + button->pressed = pressed; + button->redraw = TRUE; + ui_skinned_button_paint(button); + } +} + +static gboolean ui_skinned_button_button_press(GtkWidget *widget, GdkEventButton *event) { + UiSkinnedButton *button; + + if (event->type == GDK_BUTTON_PRESS) { + button = UI_SKINNED_BUTTON(widget); + + if (event->button == 1) + ui_skinned_button_pressed (button); + } + + return TRUE; +} + +static gboolean ui_skinned_button_button_release(GtkWidget *widget, GdkEventButton *event) { + UiSkinnedButton *button; + if (event->button == 1) { + button = UI_SKINNED_BUTTON(widget); + button->redraw = TRUE; + ui_skinned_button_released(button); + } + + return TRUE; +} + +static void ui_skinned_button_pressed(UiSkinnedButton *button) { + g_return_if_fail(UI_IS_SKINNED_BUTTON(button)); + g_signal_emit(button, button_signals[PRESSED], 0); +} + +static void ui_skinned_button_released(UiSkinnedButton *button) { + g_return_if_fail(UI_IS_SKINNED_BUTTON(button)); + g_signal_emit(button, button_signals[RELEASED], 0); +} + +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); +} + +static gboolean ui_skinned_button_enter_notify(GtkWidget *widget, GdkEventCrossing *event) { + UiSkinnedButton *button; + + button = UI_SKINNED_BUTTON(widget); + button->hover = TRUE; + if(button->button_down) ui_skinned_button_set_pressed(button, TRUE); + + return FALSE; +} + +static gboolean ui_skinned_button_leave_notify(GtkWidget *widget, GdkEventCrossing *event) { + UiSkinnedButton *button; + + button = UI_SKINNED_BUTTON (widget); + button->hover = FALSE; + if(button->button_down) ui_skinned_button_set_pressed(button, FALSE); + + return FALSE; +} + +static void ui_skinned_button_add(GtkContainer *container, GtkWidget *widget) { + GTK_CONTAINER_CLASS (parent_class)->add(container, widget); +} + +static void ui_skinned_button_toggle_doublesize(UiSkinnedButton *button) { + GtkWidget *widget = GTK_WIDGET (button); + UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); + priv->double_size = !priv->double_size; + + gtk_widget_set_size_request(widget, priv->w*(1+priv->double_size), priv->h*(1+priv->double_size)); + gtk_widget_set_uposition(widget, button->x*(1+priv->double_size), button->y*(1+priv->double_size)); + + button->redraw = TRUE; + ui_skinned_button_paint(button); +} + +static void ui_skinned_button_paint(UiSkinnedButton *button) { + GtkWidget *widget = GTK_WIDGET (button); + UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); + + //TYPE_SMALL doesn't have its own face + 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); + 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); + img2x = create_dblsize_image(img); + gtk_image_set(GTK_IMAGE(priv->image), img2x, NULL); + g_object_unref(img2x); + 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); + } +} + +static void ui_skinned_button_redraw(UiSkinnedButton *button) { + button->redraw = TRUE; + ui_skinned_button_paint(button); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/ui_skinned_button.h Tue Jun 19 15:36:44 2007 -0500 @@ -0,0 +1,88 @@ +/* + * Audacious - a cross-platform multimedia player + * Copyright (c) 2007 Audacious 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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 UISKINNEDBUTTON_H +#define UISKINNEDBUTTON_H + +#include <gdk/gdk.h> +#include <gtk/gtkbin.h> +#include <gtk/gtkenums.h> +#include "widgets/skin.h" + +#define UI_TYPE_SKINNED_BUTTON (ui_skinned_button_get_type()) +#define UI_SKINNED_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UI_TYPE_SKINNED_BUTTON, UiSkinnedButton)) +#define UI_SKINNED_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UI_TYPE_SKINNED_BUTTON, UiSkinnedButtonClass)) +#define UI_IS_SKINNED_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UI_TYPE_SKINNED_BUTTON)) +#define UI_IS_SKINNED_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UI_TYPE_SKINNED_BUTTON)) +#define UI_SKINNED_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UI_TYPE_SKINNED_BUTTON, GtkFlatButtonClass)) + +typedef struct _UiSkinnedButton UiSkinnedButton; +typedef struct _UiSkinnedButtonClass UiSkinnedButtonClass; + +enum { + PRESSED, + RELEASED, + CLICKED, + DOUBLED, + REDRAW, + LAST_SIGNAL +}; + +enum { + TYPE_NOT_SET, + TYPE_PUSH, + TYPE_TOGGLE, + TYPE_SMALL +}; + +struct _UiSkinnedButton { + GtkBin bin; + + GdkWindow *event_window; + + 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; +}; + +struct _UiSkinnedButtonClass { + GtkBinClass parent_class; + void (* pressed) (UiSkinnedButton *button); + void (* released) (UiSkinnedButton *button); + void (* clicked) (UiSkinnedButton *button); + void (* doubled) (UiSkinnedButton *button); + void (* redraw) (UiSkinnedButton *button); +}; + +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); +void ui_skinned_small_button_setup(GtkWidget *button, GtkWidget *fixed, GdkPixmap *parent, GdkGC *gc, gint x, gint y, gint w, gint h); + +#endif
--- a/src/audacious/ui_skinned_window.c Tue Jun 19 15:36:09 2007 -0500 +++ b/src/audacious/ui_skinned_window.c Tue Jun 19 15:36:44 2007 -0500 @@ -175,7 +175,7 @@ means that the logo must be drawn on the container widget, instead of the window; otherwise, it won't be displayed correctly */ SKINNED_WINDOW(widget)->fixed = gtk_fixed_new(); - + gtk_container_add(GTK_CONTAINER(widget), GTK_WIDGET(SKINNED_WINDOW(widget)->fixed)); return widget; }
--- a/src/audacious/widgets/Makefile Tue Jun 19 15:36:09 2007 -0500 +++ b/src/audacious/widgets/Makefile Tue Jun 19 15:36:44 2007 -0500 @@ -35,8 +35,7 @@ playlist_slider.c \ eq_graph.c \ eq_slider.c \ - skin.c \ - audacious_pbutton.c + skin.c OBJECTS = ${SOURCES:.c=.o}
--- a/src/audacious/widgets/audacious_pbutton.c Tue Jun 19 15:36:09 2007 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,411 +0,0 @@ -/* - * Audacious - a cross-platform multimedia player - * Copyright (c) 2007 Audacious 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; either version 2 of the License, or - * (at your option) any later version. - * - * 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 "audacious_pbutton.h" -#include "../util.h" - -#include <gtk/gtkmain.h> -#include <gtk/gtkmarshal.h> -#include <gtk/gtkimage.h> - -#define AUDACIOUS_PBUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), AUDACIOUS_TYPE_PBUTTON, AudaciousPButtonPrivate)) -typedef struct _AudaciousPButtonPrivate AudaciousPButtonPrivate; - -struct _AudaciousPButtonPrivate { - //Skinned part - GtkWidget *image; - GdkGC *gc; - gint w; - gint h; - SkinPixmapId skin_index1; - SkinPixmapId skin_index2; - GtkWidget *fixed; - gboolean double_size; -}; - - -static GtkBinClass *parent_class = NULL; -static void audacious_pbutton_class_init(AudaciousPButtonClass *klass); -static void audacious_pbutton_init(AudaciousPButton *button); -static GObject* audacious_pbutton_constructor(GType type, guint n_construct_properties, GObjectConstructParam *construct_params); -static void audacious_pbutton_destroy(GtkObject *object); -static void audacious_pbutton_realize(GtkWidget *widget); -static void audacious_pbutton_unrealize(GtkWidget *widget); -static void audacious_pbutton_map(GtkWidget *widget); -static void audacious_pbutton_unmap(GtkWidget *widget); -static gint audacious_pbutton_expose(GtkWidget *widget,GdkEventExpose *event); - -static void audacious_pbutton_size_allocate(GtkWidget *widget, GtkAllocation *allocation); -static void audacious_pbutton_update_state(AudaciousPButton *button); - -static guint button_signals[LAST_SIGNAL] = { 0 }; -static gint audacious_pbutton_button_press(GtkWidget *widget, GdkEventButton *event); -static gint audacious_pbutton_button_release(GtkWidget *widget, GdkEventButton *event); -static void button_pressed(AudaciousPButton *button); -static void button_released(AudaciousPButton *button); -static void audacious_pbutton_pressed(AudaciousPButton *button); -static void audacious_pbutton_released(AudaciousPButton *button); -static void audacious_pbutton_clicked(AudaciousPButton *button); -static void audacious_pbutton_set_pressed (AudaciousPButton *button, gboolean pressed); - -static void audacious_pbutton_add(GtkContainer *container, GtkWidget *widget); -static void audacious_pbutton_toggle_doublesize(AudaciousPButton *button); - -static gint audacious_pbutton_enter_notify(GtkWidget *widget, GdkEventCrossing *event); -static gint audacious_pbutton_leave_notify(GtkWidget *widget, GdkEventCrossing *event); -static void audacious_pbutton_paint(AudaciousPButton *button); -static void audacious_pbutton_redraw(AudaciousPButton *button); - -GType audacious_pbutton_get_type (void) { - static GType button_type = 0; - - if (!button_type) { - static const GTypeInfo button_info = { - sizeof (AudaciousPButtonClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) audacious_pbutton_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (AudaciousPButton), - 16, /* n_preallocs */ - (GInstanceInitFunc) audacious_pbutton_init, - }; - - button_type = g_type_register_static (GTK_TYPE_BIN, "AudaciousPButton", &button_info, 0); - } - return button_type; -} - -static void audacious_pbutton_class_init (AudaciousPButtonClass *klass) { - GObjectClass *gobject_class; - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - gobject_class = G_OBJECT_CLASS(klass); - object_class = (GtkObjectClass*)klass; - widget_class = (GtkWidgetClass*)klass; - container_class = (GtkContainerClass*)klass; - - parent_class = g_type_class_peek_parent(klass); - gobject_class->constructor = audacious_pbutton_constructor; - object_class->destroy = audacious_pbutton_destroy; - - widget_class->realize = audacious_pbutton_realize; - widget_class->unrealize = audacious_pbutton_unrealize; - widget_class->map = audacious_pbutton_map; - widget_class->unmap = audacious_pbutton_unmap; - widget_class->size_allocate = audacious_pbutton_size_allocate; - widget_class->expose_event = audacious_pbutton_expose; - widget_class->button_press_event = audacious_pbutton_button_press; - widget_class->button_release_event = audacious_pbutton_button_release; - widget_class->enter_notify_event = audacious_pbutton_enter_notify; - widget_class->leave_notify_event = audacious_pbutton_leave_notify; - - container_class->add = audacious_pbutton_add; - - klass->pressed = button_pressed; - klass->released = button_released; - klass->clicked = NULL; - klass->doubled = audacious_pbutton_toggle_doublesize; - klass->redraw = audacious_pbutton_redraw; - - button_signals[PRESSED] = - g_signal_new ("pressed", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (AudaciousPButtonClass, pressed), NULL, NULL, - gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - - button_signals[RELEASED] = - g_signal_new ("released", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (AudaciousPButtonClass, released), NULL, NULL, - gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - - button_signals[CLICKED] = - g_signal_new ("clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (AudaciousPButtonClass, clicked), NULL, NULL, - gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - - button_signals[DOUBLED] = - g_signal_new ("toggle-double-size", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (AudaciousPButtonClass, doubled), NULL, NULL, - gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - - button_signals[REDRAW] = - g_signal_new ("redraw", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (AudaciousPButtonClass, redraw), NULL, NULL, - gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (gobject_class, sizeof (AudaciousPButtonPrivate)); -} - -static void audacious_pbutton_init (AudaciousPButton *button) { - AudaciousPButtonPrivate *priv = AUDACIOUS_PBUTTON_GET_PRIVATE (button); - priv->image = gtk_image_new(); - button->redraw = TRUE; - - g_object_set (priv->image, "visible", TRUE, NULL); - gtk_container_add(GTK_CONTAINER(GTK_WIDGET(button)), priv->image); - - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_FOCUS); - GTK_WIDGET_SET_FLAGS (button, GTK_NO_WINDOW); -} - -static void audacious_pbutton_destroy (GtkObject *object) { - (*GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -static GObject* audacious_pbutton_constructor(GType type, guint n_construct_properties, GObjectConstructParam *construct_params) { - GObject *object = (*G_OBJECT_CLASS (parent_class)->constructor)(type, n_construct_properties, construct_params); - - return object; -} - -static void audacious_pbutton_realize (GtkWidget *widget) { - AudaciousPButton *button = AUDACIOUS_PBUTTON (widget); - GdkWindowAttr attrib; - - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - - attrib.window_type = GDK_WINDOW_CHILD; - attrib.x = widget->allocation.x; - attrib.y = widget->allocation.y; - attrib.width = widget->allocation.width; - attrib.height = widget->allocation.height; - attrib.wclass = GDK_INPUT_ONLY; - attrib.event_mask = gtk_widget_get_events (widget); - attrib.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); - - widget->window = gtk_widget_get_parent_window(widget); - g_object_ref(widget->window); - - button->event_window = gdk_window_new(gtk_widget_get_parent_window(widget), &attrib, GDK_WA_X | GDK_WA_Y); - gdk_window_set_user_data (button->event_window, button); -} - -static void audacious_pbutton_unrealize(GtkWidget *widget) { - AudaciousPButton *button = AUDACIOUS_PBUTTON (widget); - - if (button->event_window) { - gdk_window_set_user_data (button->event_window, NULL); - gdk_window_destroy (button->event_window); - button->event_window = NULL; - } - - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); -} - -static void audacious_pbutton_map(GtkWidget *widget) { - AudaciousPButton *button = AUDACIOUS_PBUTTON (widget); - g_return_if_fail (AUDACIOUS_IS_PBUTTON (widget)); - GTK_WIDGET_CLASS (parent_class)->map(widget); - gdk_window_show (button->event_window); -} - -static void audacious_pbutton_unmap (GtkWidget *widget) { - AudaciousPButton *button = AUDACIOUS_PBUTTON (widget); - g_return_if_fail (AUDACIOUS_IS_PBUTTON(widget)); - - if (button->event_window) - gdk_window_hide (button->event_window); - - GTK_WIDGET_CLASS (parent_class)->unmap (widget); -} - -static gboolean audacious_pbutton_expose(GtkWidget *widget, GdkEventExpose *event) { - if (GTK_WIDGET_DRAWABLE (widget)) - (*GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); - - return FALSE; -} - -GtkWidget* audacious_pbutton_new () { - return g_object_new (AUDACIOUS_TYPE_PBUTTON, NULL); -} - -void audacious_pbutton_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) { - - AudaciousPButton *pbutton = AUDACIOUS_PBUTTON(button); - AudaciousPButtonPrivate *priv = AUDACIOUS_PBUTTON_GET_PRIVATE(pbutton); - priv->gc = gc; - priv->w = w; - priv->h = h; - pbutton->x = x; - pbutton->y = y; - pbutton->nx = nx; - pbutton->ny = ny; - pbutton->px = px; - pbutton->py = py; - 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), pbutton->x, pbutton->y); -} - -static void audacious_pbutton_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { - AudaciousPButton *button = AUDACIOUS_PBUTTON (widget); - GtkAllocation child_alloc; - - widget->allocation = *allocation; - if (GTK_BIN (button)->child) { //image should fill whole widget - child_alloc.x = widget->allocation.x; - child_alloc.y = widget->allocation.y; - child_alloc.width = MAX (1, widget->allocation.width); - child_alloc.height = MAX (1, widget->allocation.height); - - gtk_widget_size_allocate (GTK_BIN (button)->child, &child_alloc); - } - - if (GDK_IS_WINDOW(button->event_window)) - gdk_window_move_resize (button->event_window, widget->allocation.x, widget->allocation.y, - widget->allocation.width, widget->allocation.height); -} - -static void button_pressed(AudaciousPButton *button) { - button->button_down = TRUE; - audacious_pbutton_update_state(button); -} - -static void button_released(AudaciousPButton *button) { - button->button_down = FALSE; - if(button->hover) audacious_pbutton_clicked(button); - audacious_pbutton_update_state(button); -} - -static void audacious_pbutton_update_state(AudaciousPButton *button) { - audacious_pbutton_set_pressed(button, button->button_down); -} - -static void audacious_pbutton_set_pressed (AudaciousPButton *button, gboolean pressed) { - if (pressed != button->pressed) { - button->pressed = pressed; - button->redraw = TRUE; - audacious_pbutton_paint(button); - } -} - -static gboolean audacious_pbutton_button_press(GtkWidget *widget, GdkEventButton *event) { - AudaciousPButton *button; - - if (event->type == GDK_BUTTON_PRESS) { - button = AUDACIOUS_PBUTTON(widget); - - if (event->button == 1) - audacious_pbutton_pressed (button); - } - - return TRUE; -} - -static gboolean audacious_pbutton_button_release(GtkWidget *widget, GdkEventButton *event) { - AudaciousPButton *button; - if (event->button == 1) { - button = AUDACIOUS_PBUTTON(widget); - button->redraw = TRUE; - audacious_pbutton_released(button); - } - - return TRUE; -} - -static void audacious_pbutton_pressed(AudaciousPButton *button) { - g_return_if_fail(AUDACIOUS_IS_PBUTTON(button)); - g_signal_emit(button, button_signals[PRESSED], 0); -} - -static void audacious_pbutton_released(AudaciousPButton *button) { - g_return_if_fail(AUDACIOUS_IS_PBUTTON(button)); - g_signal_emit(button, button_signals[RELEASED], 0); -} - -static void audacious_pbutton_clicked(AudaciousPButton *button) { - g_return_if_fail(AUDACIOUS_IS_PBUTTON(button)); - g_signal_emit(button, button_signals[CLICKED], 0); -} - -static gboolean audacious_pbutton_enter_notify(GtkWidget *widget, GdkEventCrossing *event) { - AudaciousPButton *button; - - button = AUDACIOUS_PBUTTON(widget); - button->hover = TRUE; - if(button->button_down) audacious_pbutton_set_pressed(button, TRUE); - - return FALSE; -} - -static gboolean audacious_pbutton_leave_notify(GtkWidget *widget, GdkEventCrossing *event) { - AudaciousPButton *button; - - button = AUDACIOUS_PBUTTON (widget); - button->hover = FALSE; - if(button->button_down) audacious_pbutton_set_pressed(button, FALSE); - - return FALSE; -} - -static void audacious_pbutton_add(GtkContainer *container, GtkWidget *widget) { - GTK_CONTAINER_CLASS (parent_class)->add(container, widget); -} - -static void audacious_pbutton_toggle_doublesize(AudaciousPButton *button) { - GtkWidget *widget = GTK_WIDGET (button); - AudaciousPButtonPrivate *priv = AUDACIOUS_PBUTTON_GET_PRIVATE (button); - priv->double_size = !priv->double_size; - - gtk_widget_set_size_request(widget, priv->w*(1+priv->double_size), priv->h*(1+priv->double_size)); - gtk_widget_set_uposition(widget, button->x*(1+priv->double_size), button->y*(1+priv->double_size)); - - button->redraw = TRUE; - audacious_pbutton_paint(button); -} - -static void audacious_pbutton_paint(AudaciousPButton *button) { - GtkWidget *widget = GTK_WIDGET (button); - AudaciousPButtonPrivate *priv = AUDACIOUS_PBUTTON_GET_PRIVATE (button); - - 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); - if(priv->double_size) { - GdkImage *img, *img2x; - img = gdk_drawable_get_image(obj, 0, 0, priv->w, priv->h); - img2x = create_dblsize_image(img); - gtk_image_set(GTK_IMAGE(priv->image), img2x, NULL); - g_object_unref(img2x); - 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); - } -} - -static void audacious_pbutton_redraw(AudaciousPButton *button) { - button->redraw = TRUE; - audacious_pbutton_paint(button); -}
--- a/src/audacious/widgets/audacious_pbutton.h Tue Jun 19 15:36:09 2007 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* - * Audacious - a cross-platform multimedia player - * Copyright (c) 2007 Audacious 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; either version 2 of the License, or - * (at your option) any later version. - * - * 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 AUDAPBUTTON_H -#define AUDAPBUTTON_H - -#include <gdk/gdk.h> -#include <gtk/gtkbin.h> -#include <gtk/gtkenums.h> -#include "skin.h" -#include "widget.h" - -#define AUDACIOUS_TYPE_PBUTTON (audacious_pbutton_get_type()) -#define AUDACIOUS_PBUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AUDACIOUS_TYPE_PBUTTON, AudaciousPButton)) -#define AUDACIOUS_PBUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AUDACIOUS_TYPE_PBUTTON, AudaciousPButtonClass)) -#define AUDACIOUS_IS_PBUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AUDACIOUS_TYPE_PBUTTON)) -#define AUDACIOUS_IS_PBUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AUDACIOUS_TYPE_PBUTTON)) -#define AUDACIOUS_PBUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AUDACIOUS_TYPE_PBUTTON, GtkFlatButtonClass)) - -typedef struct _AudaciousPButton AudaciousPButton; -typedef struct _AudaciousPButtonClass AudaciousPButtonClass; - -enum { - PRESSED, - RELEASED, - CLICKED, - DOUBLED, - REDRAW, - LAST_SIGNAL -}; - -struct _AudaciousPButton { - GtkBin bin; - - GdkWindow *event_window; - - gboolean button_down : 1; - gboolean pressed : 1; - gboolean hover : 1; - //Skinned part, used in ui_playlist.c - gint x, y, nx, ny, px, py; - - gboolean redraw; -}; - -struct _AudaciousPButtonClass { - GtkBinClass parent_class; - void (* pressed) (AudaciousPButton *button); - void (* released) (AudaciousPButton *button); - void (* clicked) (AudaciousPButton *button); - void (* doubled) (AudaciousPButton *button); - void (* redraw) (AudaciousPButton *button); -}; - -GType audacious_pbutton_get_type(void) G_GNUC_CONST; -GtkWidget* audacious_pbutton_new(); -void audacious_pbutton_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); - -#endif
--- a/src/audacious/widgets/widgetcore.h Tue Jun 19 15:36:09 2007 -0500 +++ b/src/audacious/widgets/widgetcore.h Tue Jun 19 15:36:44 2007 -0500 @@ -20,7 +20,6 @@ #ifndef _WIDGETCORE_H_ #define _WIDGETCORE_H_ -#include "audacious_pbutton.h" #include "tbutton.h" #include "eq_graph.h" #include "eq_slider.h"