# HG changeset patch # User Tomasz Mon # Date 1196001120 -3600 # Node ID fc85f7ce6969660255b6f18fc01df7b60927328a # Parent 8a3cee5c303b73d35b10524f6cf4b3b556d83212 introduce WIDGET_SPIN_BTN diff -r 8a3cee5c303b -r fc85f7ce6969 src/audacious/ui_preferences.c --- a/src/audacious/ui_preferences.c Sun Nov 25 13:57:18 2007 +0100 +++ b/src/audacious/ui_preferences.c Sun Nov 25 15:32:00 2007 +0100 @@ -172,15 +172,16 @@ WIDGET_CHK_BTN, WIDGET_LABEL, WIDGET_RADIO_BTN, + WIDGET_SPIN_BTN, WIDGET_CHARDET_TABLE /* 'fixed' widget, not for reuse */ }; typedef struct preferences_widgets_t { gint type; /* widget type */ - char *label; /* widget title */ + char *label; /* widget title (for SPIN_BTN it's text left to widget)*/ gboolean *cfg; /* connected config value */ void (*callback) (void); /* this func will be called after value change, can be NULL */ - char *tooltip; /* widget tooltip, can be NULL */ + char *tooltip; /* widget tooltip (for SPIN_BTN it's text right to widget), can be NULL */ gboolean child; } preferences_widgets; @@ -213,6 +214,8 @@ gettext_noop("When Audacious starts, automatically begin playing from the point where we stopped before."), FALSE}, {WIDGET_CHK_BTN, gettext_noop("Don't advance in the playlist"), &cfg.no_playlist_advance, NULL, gettext_noop("When finished playing a song, don't automatically advance to the next."), FALSE}, + {WIDGET_CHK_BTN, gettext_noop("Pause between songs"), &cfg.pause_between_songs, NULL, NULL, FALSE}, + {WIDGET_SPIN_BTN, gettext_noop("Pause for"), &cfg.pause_between_songs_time, NULL, gettext_noop("seconds"), TRUE}, }; static preferences_widgets playlist_page_widgets[] = { @@ -229,6 +232,12 @@ {WIDGET_CHK_BTN, gettext_noop("Always refresh directory when opening file dialog"), &cfg.refresh_file_list, NULL, gettext_noop("Always refresh the file dialog (this will slow opening the dialog on large directories, and Gnome VFS should handle automatically)."), FALSE}, }; +static preferences_widgets mouse_page_widgets[] = { + {WIDGET_LABEL, gettext_noop("Mouse wheel"), NULL, NULL, NULL, FALSE}, + {WIDGET_SPIN_BTN, gettext_noop("Changes volume by"), &cfg.mouse_change, NULL, gettext_noop("percent"), FALSE}, + {WIDGET_SPIN_BTN, gettext_noop("Scrolls playlist by"), &cfg.scroll_pl_by, NULL, gettext_noop("lines"), FALSE}, +}; + /* GLib 2.6 compatibility */ #if (! ((GLIB_MAJOR_VERSION > 2) || ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION >= 8)))) static const char * @@ -832,34 +841,6 @@ } static void -on_mouse_wheel_volume_realize(GtkSpinButton * button, - gpointer data) -{ - gtk_spin_button_set_value(button, cfg.mouse_change); -} - -static void -on_mouse_wheel_volume_changed(GtkSpinButton * button, - gpointer data) -{ - cfg.mouse_change = gtk_spin_button_get_value_as_int(button); -} - -static void -on_pause_between_songs_time_realize(GtkSpinButton * button, - gpointer data) -{ - gtk_spin_button_set_value(button, cfg.pause_between_songs_time); -} - -static void -on_pause_between_songs_time_changed(GtkSpinButton * button, - gpointer data) -{ - cfg.pause_between_songs_time = gtk_spin_button_get_value_as_int(button); -} - -static void on_enable_src_realize(GtkToggleButton * button, gpointer data) { @@ -956,17 +937,15 @@ } static void -on_mouse_wheel_scroll_pl_realize(GtkSpinButton * button, - gpointer data) +on_spin_btn_realize(GtkSpinButton *button, gboolean *cfg) { - gtk_spin_button_set_value(button, cfg.scroll_pl_by); + gtk_spin_button_set_value(button, *cfg); } static void -on_mouse_wheel_scroll_pl_changed(GtkSpinButton * button, - gpointer data) +on_spin_btn_changed(GtkSpinButton *button, gboolean *cfg) { - cfg.scroll_pl_by = gtk_spin_button_get_value_as_int(button); + *cfg = gtk_spin_button_get_value_as_int(button); } static void @@ -982,24 +961,6 @@ } static void -on_pause_between_songs_realize(GtkToggleButton * button, - gpointer data) -{ - gboolean state = cfg.pause_between_songs; - gtk_toggle_button_set_active(button, state); - gtk_widget_set_sensitive(GTK_WIDGET(data), state); -} - -static void -on_pause_between_songs_toggled(GtkToggleButton * button, - gpointer data) -{ - gboolean state = gtk_toggle_button_get_active(button); - cfg.pause_between_songs = state; - gtk_widget_set_sensitive(GTK_WIDGET(data), state); -} - -static void on_eq_dir_preset_entry_realize(GtkEntry * entry, gpointer data) { @@ -1684,22 +1645,23 @@ GtkWidget *alignment = NULL, *widget = NULL; GtkWidget *child_box = NULL; GSList *radio_btn_group = NULL; + int table_line=0; /* used for WIDGET_SPIN_BTN */ for (x = 0; x < amt; ++x) { if (widgets[x].child) { /* perhaps this logic can be better */ if (!child_box) { child_box = gtk_vbox_new(FALSE, 0); g_object_set_data(G_OBJECT(widget), "child", child_box); - } alignment = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_box_pack_start(box, alignment, FALSE, FALSE, 0); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 24, 0); gtk_container_add (GTK_CONTAINER (alignment), child_box); + } } else child_box = NULL; alignment = gtk_alignment_new (0.5, 0.5, 1, 1); - gtk_box_pack_start(child_box ? GTK_BOX(child_box) : box, alignment, TRUE, TRUE, 0); + gtk_box_pack_start(child_box ? GTK_BOX(child_box) : box, alignment, FALSE, FALSE, 0); if (radio_btn_group && widgets[x].type != WIDGET_RADIO_BTN) radio_btn_group = NULL; @@ -1732,6 +1694,51 @@ G_CALLBACK(on_toggle_button_realize), widgets[x].cfg); break; + case WIDGET_SPIN_BTN: + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0); + + if (x > 1 && widgets[x-1].type == WIDGET_SPIN_BTN) { + table_line++; + } else { + /* check how many WIDGET_SPIN_BTNs are there */ + gint lines = 0, i; + for (i=x; iMouse wheel")); - gtk_container_add (GTK_CONTAINER (alignment36), label51); - gtk_label_set_use_markup (GTK_LABEL (label51), TRUE); - gtk_misc_set_alignment (GTK_MISC (label51), 0, 0); - - alignment34 = gtk_alignment_new (0.5, 0.5, 1, 1); - gtk_box_pack_start (GTK_BOX (vbox20), alignment34, FALSE, FALSE, 0); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment34), 0, 0, 12, 0); - - table4 = gtk_table_new (2, 3, FALSE); - gtk_container_add (GTK_CONTAINER (alignment34), table4); - gtk_table_set_row_spacings (GTK_TABLE (table4), 6); - - mouse_wheel_volume_adj = gtk_adjustment_new (5, 0, 100, 1, 10, 10); - mouse_wheel_volume = gtk_spin_button_new (GTK_ADJUSTMENT (mouse_wheel_volume_adj), 1, 0); - gtk_table_attach (GTK_TABLE (table4), mouse_wheel_volume, 1, 2, 0, 1, - (GtkAttachOptions) (0), - (GtkAttachOptions) (0), 4, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (mouse_wheel_volume), TRUE); - - label35 = gtk_label_new (_("lines")); - gtk_table_attach (GTK_TABLE (table4), label35, 2, 3, 1, 2, - (GtkAttachOptions) (0), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label35), 0, 0.5); - gtk_misc_set_padding (GTK_MISC (label35), 4, 0); - - mouse_wheel_scroll_pl_adj = gtk_adjustment_new (1, 0, 100, 1, 10, 10); - mouse_wheel_scroll_pl = gtk_spin_button_new (GTK_ADJUSTMENT (mouse_wheel_scroll_pl_adj), 1, 0); - gtk_table_attach (GTK_TABLE (table4), mouse_wheel_scroll_pl, 1, 2, 1, 2, - (GtkAttachOptions) (0), - (GtkAttachOptions) (0), 4, 0); - - label34 = gtk_label_new (_("Scrolls playlist by")); - gtk_table_attach (GTK_TABLE (table4), label34, 0, 1, 1, 2, - (GtkAttachOptions) (0), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label34), 0, 0.5); - gtk_misc_set_padding (GTK_MISC (label34), 4, 0); - - label33 = gtk_label_new (_("percent")); - gtk_table_attach (GTK_TABLE (table4), label33, 2, 3, 0, 1, - (GtkAttachOptions) (0), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label33), 0, 0.5); - gtk_misc_set_padding (GTK_MISC (label33), 4, 0); - - label32 = gtk_label_new (_("Changes volume by")); - gtk_table_attach (GTK_TABLE (table4), label32, 0, 1, 0, 1, - (GtkAttachOptions) (0), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label32), 0, 0.5); - gtk_misc_set_padding (GTK_MISC (label32), 4, 0); + create_widgets(GTK_BOX(vbox20), mouse_page_widgets, G_N_ELEMENTS(mouse_page_widgets)); mouse_label = gtk_label_new (_("Mouse")); gtk_notebook_set_tab_label (GTK_NOTEBOOK (category_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (category_notebook), 2), mouse_label); @@ -2796,32 +2727,6 @@ create_widgets(GTK_BOX(audio_page_vbox), audio_page_widgets, G_N_ELEMENTS(audio_page_widgets)); - alignment80 = gtk_alignment_new (0.5, 0.5, 1, 1); - gtk_box_pack_start (GTK_BOX (audio_page_vbox), alignment80, FALSE, FALSE, 0); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment80), 0, 0, 12, 0); - - pause_between_songs = gtk_check_button_new_with_mnemonic (_("Pause between songs")); - gtk_container_add (GTK_CONTAINER (alignment80), pause_between_songs); - - alignment22 = gtk_alignment_new (0.5, 0.5, 1, 1); - gtk_box_pack_start (GTK_BOX (audio_page_vbox), alignment22, FALSE, FALSE, 0); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment22), 0, 0, 45, 0); - - pause_between_songs_box = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (alignment22), pause_between_songs_box); - - label41 = gtk_label_new (_("Pause for")); - gtk_box_pack_start (GTK_BOX (pause_between_songs_box), label41, FALSE, FALSE, 0); - gtk_misc_set_padding (GTK_MISC (label41), 4, 0); - - pause_between_songs_time_adj = gtk_adjustment_new (2, 0, 100, 1, 10, 10); - pause_between_songs_time = gtk_spin_button_new (GTK_ADJUSTMENT (pause_between_songs_time_adj), 1, 0); - gtk_box_pack_start (GTK_BOX (pause_between_songs_box), pause_between_songs_time, FALSE, FALSE, 0); - - label42 = gtk_label_new (_("seconds")); - gtk_box_pack_start (GTK_BOX (pause_between_songs_box), label42, FALSE, FALSE, 0); - gtk_misc_set_padding (GTK_MISC (label42), 4, 0); - alignment90 = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_box_pack_start (GTK_BOX (audio_page_vbox), alignment90, FALSE, FALSE, 0); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment90), 12, 12, 0, 0); @@ -3006,19 +2911,6 @@ g_signal_connect_after(G_OBJECT(checkbutton11), "realize", G_CALLBACK(on_use_bitmap_fonts_realize), NULL); - - g_signal_connect(G_OBJECT(mouse_wheel_volume), "value_changed", - G_CALLBACK(on_mouse_wheel_volume_changed), - NULL); - g_signal_connect_after(G_OBJECT(mouse_wheel_volume), "realize", - G_CALLBACK(on_mouse_wheel_volume_realize), - NULL); - g_signal_connect(G_OBJECT(mouse_wheel_scroll_pl), "value_changed", - G_CALLBACK(on_mouse_wheel_scroll_pl_changed), - NULL); - g_signal_connect_after(G_OBJECT(mouse_wheel_scroll_pl), "realize", - G_CALLBACK(on_mouse_wheel_scroll_pl_realize), - NULL); g_signal_connect(G_OBJECT(titlestring_entry), "changed", G_CALLBACK(on_titlestring_entry_changed), NULL); @@ -3091,12 +2983,6 @@ g_signal_connect_after(G_OBJECT(output_plugin_cbox), "realize", G_CALLBACK(on_output_plugin_cbox_realize), NULL); - g_signal_connect(G_OBJECT(pause_between_songs_time), "value_changed", - G_CALLBACK(on_pause_between_songs_time_changed), - NULL); - g_signal_connect_after(G_OBJECT(pause_between_songs_time), "realize", - G_CALLBACK(on_pause_between_songs_time_realize), - NULL); g_signal_connect(G_OBJECT(enable_src), "toggled", G_CALLBACK(on_enable_src_toggled), NULL); @@ -3231,13 +3117,6 @@ /* playlist page */ - g_signal_connect_after(G_OBJECT(pause_between_songs), "realize", - G_CALLBACK(on_pause_between_songs_realize), - pause_between_songs_box); - g_signal_connect(G_OBJECT(pause_between_songs), "toggled", - G_CALLBACK(on_pause_between_songs_toggled), - pause_between_songs_box); - g_signal_connect(skin_view, "drag-data-received", G_CALLBACK(on_skin_view_drag_data_received), NULL);