From 3a50ce20a56e47f6c1b4d12fb85fec6f2eeac924 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Mon, 9 Aug 2010 21:51:12 +0200 Subject: use bold font for currently playing track --- plugins/gtkui/callbacks.h | 4 ++++ plugins/gtkui/deadbeef.glade | 20 ++++++++++++++++++++ plugins/gtkui/drawing.h | 3 +++ plugins/gtkui/gdkdrawing.c | 13 +++++++++++++ plugins/gtkui/gtkui.c | 5 +++++ plugins/gtkui/gtkui.h | 1 + plugins/gtkui/interface.c | 9 +++++++++ plugins/gtkui/plcommon.c | 3 +++ plugins/gtkui/prefwin.c | 11 +++++++++++ 9 files changed, 69 insertions(+) diff --git a/plugins/gtkui/callbacks.h b/plugins/gtkui/callbacks.h index e7961bac..e067896d 100644 --- a/plugins/gtkui/callbacks.h +++ b/plugins/gtkui/callbacks.h @@ -942,3 +942,7 @@ on_proxypassword_changed (GtkEditable *editable, void on_hide_tray_icon_toggled (GtkToggleButton *togglebutton, gpointer user_data); + +void +on_embolden_current_toggled (GtkToggleButton *togglebutton, + gpointer user_data); diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade index 86867974..f28a845d 100644 --- a/plugins/gtkui/deadbeef.glade +++ b/plugins/gtkui/deadbeef.glade @@ -2781,6 +2781,26 @@ Album + + + True + True + Use bold font for currently playing track + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 0 + False + False + + + True diff --git a/plugins/gtkui/drawing.h b/plugins/gtkui/drawing.h index 1bf30767..82ab55c3 100644 --- a/plugins/gtkui/drawing.h +++ b/plugins/gtkui/drawing.h @@ -62,6 +62,9 @@ draw_get_font_size (void); void draw_init_font (GtkStyle *style); +void +draw_init_font_bold (void); + void draw_text (float x, float y, int width, int align, const char *text); diff --git a/plugins/gtkui/gdkdrawing.c b/plugins/gtkui/gdkdrawing.c index 2ccb27ae..b914b70b 100644 --- a/plugins/gtkui/gdkdrawing.c +++ b/plugins/gtkui/gdkdrawing.c @@ -114,8 +114,21 @@ draw_init_font (GtkStyle *new_font_style) { pango_layout_set_font_description (pangolayout, desc); pango_ready = 1; } + else if (new_font_style) { + PangoFontDescription *desc = font_style->font_desc; + pango_layout_set_font_description (pangolayout, desc); + } } +void +draw_init_font_bold (void) { + PangoFontDescription *desc = pango_font_description_copy (font_style->font_desc); + pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD); + pango_layout_set_font_description (pangolayout, desc); + pango_font_description_free(desc); +} + + float draw_get_font_size (void) { draw_init_font (NULL); diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 94db2ce7..2b6f9568 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -66,6 +66,8 @@ GtkWidget *traymenu; GtkWidget *theme_treeview; GtkWidget *theme_button; +int gtkui_embolden_current_track; + #define TRAY_ICON "deadbeef-tray-icon" // that must be called before gtk_init @@ -592,6 +594,9 @@ gtkui_on_configchanged (DB_event_t *ev, uintptr_t data) { int stop_after_current = deadbeef->conf_get_int ("playlist.stop_after_current", 0); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (lookup_widget (mainwin, "stop_after_current")), stop_after_current ? TRUE : FALSE); + // embolden current track + gtkui_embolden_current_track = deadbeef->conf_get_int ("gtkui.embolden_current_track", 0); + // tray icon g_idle_add (gtkui_update_status_icon, NULL); diff --git a/plugins/gtkui/gtkui.h b/plugins/gtkui/gtkui.h index 091331a1..3b03b0aa 100644 --- a/plugins/gtkui/gtkui.h +++ b/plugins/gtkui/gtkui.h @@ -48,6 +48,7 @@ extern DB_functions_t *deadbeef; extern GtkWidget *mainwin; extern GtkWidget *searchwin; +extern int gtkui_embolden_current_track; struct _GSList; diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c index 41d49496..9c3bf51a 100644 --- a/plugins/gtkui/interface.c +++ b/plugins/gtkui/interface.c @@ -1559,6 +1559,7 @@ create_prefwin (void) GtkWidget *pref_close_send_to_tray; GtkWidget *mmb_delete_playlist; GtkWidget *hide_tray_icon; + GtkWidget *embolden_current; GtkWidget *notebook4; GtkWidget *vbox21; GtkWidget *override_bar_colors; @@ -1805,6 +1806,10 @@ create_prefwin (void) gtk_widget_show (hide_tray_icon); gtk_box_pack_start (GTK_BOX (vbox9), hide_tray_icon, FALSE, FALSE, 0); + embolden_current = gtk_check_button_new_with_mnemonic (_("Use bold font for currently playing track")); + gtk_widget_show (embolden_current); + gtk_box_pack_start (GTK_BOX (vbox9), embolden_current, FALSE, FALSE, 0); + notebook4 = gtk_notebook_new (); gtk_widget_show (notebook4); gtk_box_pack_start (GTK_BOX (vbox9), notebook4, TRUE, TRUE, 0); @@ -2448,6 +2453,9 @@ create_prefwin (void) g_signal_connect ((gpointer) hide_tray_icon, "toggled", G_CALLBACK (on_hide_tray_icon_toggled), NULL); + g_signal_connect ((gpointer) embolden_current, "toggled", + G_CALLBACK (on_embolden_current_toggled), + NULL); g_signal_connect ((gpointer) override_bar_colors, "toggled", G_CALLBACK (on_override_bar_colors_toggled), NULL); @@ -2592,6 +2600,7 @@ create_prefwin (void) GLADE_HOOKUP_OBJECT (prefwin, pref_close_send_to_tray, "pref_close_send_to_tray"); GLADE_HOOKUP_OBJECT (prefwin, mmb_delete_playlist, "mmb_delete_playlist"); GLADE_HOOKUP_OBJECT (prefwin, hide_tray_icon, "hide_tray_icon"); + GLADE_HOOKUP_OBJECT (prefwin, embolden_current, "embolden_current"); GLADE_HOOKUP_OBJECT (prefwin, notebook4, "notebook4"); GLADE_HOOKUP_OBJECT (prefwin, vbox21, "vbox21"); GLADE_HOOKUP_OBJECT (prefwin, override_bar_colors, "override_bar_colors"); diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c index c5fe755c..bbf37875 100644 --- a/plugins/gtkui/plcommon.c +++ b/plugins/gtkui/plcommon.c @@ -174,6 +174,9 @@ void draw_column_data (DdbListview *listview, GdkDrawable *drawable, DdbListview draw_set_fg_color (fg); draw_init_font (GTK_WIDGET (listview)->style); + if (gtkui_embolden_current_track && it && it == playing_track) { + draw_init_font_bold (); + } if (calign_right) { draw_text (x+5, y + height/2 - draw_get_font_size ()/2 - 2, cwidth-10, 1, text); } diff --git a/plugins/gtkui/prefwin.c b/plugins/gtkui/prefwin.c index 69b25a0f..1b468737 100644 --- a/plugins/gtkui/prefwin.c +++ b/plugins/gtkui/prefwin.c @@ -1231,3 +1231,14 @@ on_prefwin_key_press_event (GtkWidget *widget, return FALSE; } + +void +on_embolden_current_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + int active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (togglebutton)); + deadbeef->conf_set_int ("gtkui.embolden_current_track", active); + gtkui_embolden_current_track = active; + playlist_refresh (); +} + -- cgit v1.2.3