changeset 1775:7d32dff734da trunk

[svn] improvement of shaded playlist window - title string does auto scroll. - format and font of the string follow playlist configuration. - filepopup will appear on shaded playlist window. - now shaded playlist window displays multi byte characters correctly. - no more "textbox_set_text: assertion `text != NULL' failed" assertion in the log file.
author yaz
date Wed, 04 Oct 2006 02:15:22 -0700
parents 2d97cd03319e
children 1f8b12f14dfa
files ChangeLog audacious/mainwin.c audacious/prefswin.c audacious/ui_fileinfo.c audacious/ui_playlist.c audacious/ui_playlist.h
diffstat 6 files changed, 97 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Oct 04 01:45:01 2006 -0700
+++ b/ChangeLog	Wed Oct 04 02:15:22 2006 -0700
@@ -1,3 +1,11 @@
+2006-10-04 08:45:01 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [2505]
+  - allow elements to be repositioned if they are mentioned in skin.hints
+  
+  trunk/audacious/mainwin.c |   12 ++++++++++++
+  1 file changed, 12 insertions(+)
+
+
 2006-10-04 08:38:46 +0000  William Pitcock <nenolod@nenolod.net>
   revision [2503]
   - text and infobar
--- a/audacious/mainwin.c	Wed Oct 04 01:45:01 2006 -0700
+++ b/audacious/mainwin.c	Wed Oct 04 02:15:22 2006 -0700
@@ -423,6 +423,8 @@
      MAINWIN_OPT_ALWAYS, "<ToggleItem>", NULL},
     {N_("/Put on All Workspaces"), "<control>S",
      mainwin_view_menu_callback, MAINWIN_OPT_STICKY, "<ToggleItem>", NULL},
+    {N_("/Autoscroll Songname"), NULL, mainwin_view_menu_callback,
+     MAINWIN_SONGNAME_SCROLL, "<ToggleItem>", NULL},
     {"/-", NULL, NULL, 0, "<Separator>", NULL},
     {N_("/Roll up Player"), "<control>W", mainwin_view_menu_callback,
      MAINWIN_OPT_WS, "<ToggleItem>", NULL},
@@ -2489,6 +2491,8 @@
     case MAINWIN_SONGNAME_SCROLL:
         check = GTK_CHECK_MENU_ITEM(item);
         mainwin_set_title_scroll(gtk_check_menu_item_get_active(check));
+        check_set(mainwin_view_menu, "/Autoscroll Songname", cfg.autoscroll);
+	playlistwin_set_sinfo_scroll(cfg.autoscroll); /* propagate scroll setting to playlistwin_sinfo */
         break;
     case MAINWIN_SONGNAME_STOPAFTERSONG:
         check = GTK_CHECK_MENU_ITEM(item);
@@ -2538,6 +2542,8 @@
                            guint action,
                            GtkWidget * item)
 {
+    GtkCheckMenuItem *check;
+
     switch (action) {
     case MAINWIN_OPT_TELAPSED:
         set_timer_mode_menu_cb(TIMER_ELAPSED);
@@ -2567,6 +2573,12 @@
     case MAINWIN_OPT_EQWS:
         equalizerwin_set_shade_menu_cb(GTK_CHECK_MENU_ITEM(item)->active);
         break;
+    case MAINWIN_SONGNAME_SCROLL:
+        check = GTK_CHECK_MENU_ITEM(item);
+        mainwin_set_title_scroll(gtk_check_menu_item_get_active(check));
+        check_set(mainwin_songname_menu, "/Autoscroll Songname", cfg.autoscroll);
+	playlistwin_set_sinfo_scroll(cfg.autoscroll); /* propagate scroll setting to playlistwin_sinfo */
+        break;
     }
 }
 
--- a/audacious/prefswin.c	Wed Oct 04 01:45:01 2006 -0700
+++ b/audacious/prefswin.c	Wed Oct 04 02:15:22 2006 -0700
@@ -927,6 +927,7 @@
     cfg.playlist_font = g_strdup(gtk_font_button_get_font_name(button));
 
     playlist_list_set_font(cfg.playlist_font);
+    playlistwin_set_sinfo_font(cfg.playlist_font);  /* propagate font setting to playlistwin_sinfo */
     playlistwin_update_list();
     draw_playlist_window(TRUE);
 }
--- a/audacious/ui_fileinfo.c	Wed Oct 04 01:45:01 2006 -0700
+++ b/audacious/ui_fileinfo.c	Wed Oct 04 02:15:22 2006 -0700
@@ -207,6 +207,7 @@
 	gint x, y, pos;
 	TitleInput *tuple;
 	static gint prev_x = 0, prev_y = 0, ctr = 0, prev_pos = -1;
+	static gint shaded_pos = -1, shaded_prev_pos = -1;
 	gboolean skip = FALSE;
 	GdkWindow *win;
 
@@ -218,8 +219,7 @@
 		|| cfg.show_filepopup_for_tuple == FALSE
 		|| playlistwin_list->pl_tooltips == FALSE
 		|| pos != prev_pos
-		|| win != GDK_WINDOW(playlistwin->window)
-		|| playlistwin_is_shaded())
+		|| win != GDK_WINDOW(playlistwin->window))
 	{
 		prev_pos = pos;
 		ctr = 0;
@@ -243,13 +243,23 @@
 	if (filepopup_win->window == NULL)
 		skip = TRUE;
 
-        if (ctr >= cfg.filepopup_delay && (skip == TRUE || gdk_window_is_viewable(GDK_WINDOW(filepopup_win->window)) != TRUE))
-        {
-		if (pos == -1)
-  		{
+	if (playlistwin_is_shaded()) {
+		shaded_pos = playlist_get_position();
+		if (shaded_prev_pos != shaded_pos)
+			skip = TRUE;
+	}
+
+        if (ctr >= cfg.filepopup_delay && (skip == TRUE || gdk_window_is_viewable(GDK_WINDOW(filepopup_win->window)) != TRUE)) {
+		if (pos == -1 && !playlistwin_is_shaded()) {
 			filepopup_hide(NULL);
 			return TRUE;
 	    	}
+		else { /* shaded mode */
+			tuple = playlist_get_tuple(shaded_pos);
+			filepopup_hide(NULL);
+			filepopup_show_for_tuple(tuple);
+			shaded_prev_pos = shaded_pos;
+		}
 
 		prev_pos = pos;
 
--- a/audacious/ui_playlist.c	Wed Oct 04 01:45:01 2006 -0700
+++ b/audacious/ui_playlist.c	Wed Oct 04 02:15:22 2006 -0700
@@ -367,7 +367,7 @@
     else
         tot_text = g_strdup("?");
     text = g_strconcat(sel_text, "/", tot_text, NULL);
-    textbox_set_text(playlistwin_info, text);
+    textbox_set_text(playlistwin_info, text ? text : "");
     g_free(text);
     g_free(tot_text);
     g_free(sel_text);
@@ -376,52 +376,48 @@
 static void
 playlistwin_update_sinfo(void)
 {
-    gchar *posstr, *timestr, *title, *info, *dots;
+    gchar *posstr, *timestr, *title, *info;
     gint pos, time;
-    guint max_len;
+    TitleInput *tuple = NULL;
 
     pos = playlist_get_position();
-    title = playlist_get_songtitle(pos);
-    time = playlist_get_songtime(pos);
+    tuple = playlist_get_tuple(pos);
+
+    if(tuple){
+        title = xmms_get_titlestring(tuple->formatter ? tuple->formatter : xmms_get_gentitle_format(), tuple);
+    }
+    else {
+        title = playlist_get_songtitle(pos);
+    }
 
     if (!title) {
         textbox_set_text(playlistwin_sinfo, "");
         return;
     }
 
+    convert_title_text(title);
+
+    time = playlist_get_songtime(pos);
+
     if (cfg.show_numbers_in_pl)
         posstr = g_strdup_printf("%d. ", pos + 1);
     else
         posstr = g_strdup("");
 
-    max_len = (playlistwin_get_width() - 35) / 5 - strlen(posstr);
-
     if (time != -1) {
         timestr = g_strdup_printf(" %d:%-2.2d", time / 60000,
-                                  (time / 1000) % 60);
-        max_len -= strlen(timestr);
+                                      (time / 1000) % 60);
     }
     else
         timestr = g_strdup("");
 
-    convert_title_text(title);
+    info = g_strdup_printf("%s%s%s", posstr, title, timestr);
 
-    if (strlen(title) > max_len) {
-        max_len -= 1;
-        dots = "\r";
-        /* textbox.c interprets \r as the ellipsis character, as there 
-           is none in ASCII. */
-    }
-    else
-        dots = "";
-
-    info = g_strdup_printf("%s%-*.*s%s%s", posstr, max_len, max_len,
-                           title, dots, timestr);
     g_free(posstr);
     g_free(title);
     g_free(timestr);
 
-    textbox_set_text(playlistwin_sinfo, info);
+    textbox_set_text(playlistwin_sinfo, info ? info : "");
     g_free(info);
 }
 
@@ -525,11 +521,45 @@
 }
 
 void
+playlistwin_set_sinfo_font(gchar *font)
+{
+    gchar *tmp = NULL, *tmp2 = NULL;
+
+    if(!font)
+        return;
+
+    tmp = g_strdup(font);
+    if(!tmp)
+        return;
+
+    *strrchr(tmp, ' ') = '\0';
+    tmp2 = g_strdup_printf("%s 8", tmp);
+    if(!tmp2)
+        return;
+    textbox_set_xfont(playlistwin_sinfo, cfg.mainwin_use_xfont, tmp2);
+
+    g_free(tmp); g_free(tmp2);
+}
+
+void
+playlistwin_set_sinfo_scroll(gboolean scroll)
+{
+    GtkWidget *item;
+
+    if(playlistwin_is_shaded())
+        textbox_set_scroll(playlistwin_sinfo, cfg.autoscroll);
+    else
+        textbox_set_scroll(playlistwin_sinfo, FALSE);
+}
+
+void
 playlistwin_set_shade(gboolean shaded)
 {
     cfg.playlist_shaded = shaded;
 
     if (shaded) {
+        playlistwin_set_sinfo_font(cfg.playlist_font);
+        playlistwin_set_sinfo_scroll(cfg.autoscroll);
         widget_show(WIDGET(playlistwin_sinfo));
         playlistwin_shade->pb_nx = 128;
         playlistwin_shade->pb_ny = 45;
@@ -540,6 +570,7 @@
     }
     else {
         widget_hide(WIDGET(playlistwin_sinfo));
+        playlistwin_set_sinfo_scroll(FALSE);
         playlistwin_shade->pb_nx = 157;
         playlistwin_shade->pb_ny = 3;
         playlistwin_shade->pb_px = 62;
@@ -575,6 +606,7 @@
     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), shaded);
 
     playlistwin_set_shade(shaded);
+    playlistwin_update_list();
 }
 
 void
@@ -1588,12 +1620,15 @@
 static void
 playlistwin_create_widgets(void)
 {
+    gchar *font = NULL, *tmp = NULL;
     /* This function creates the custom widgets used by the playlist editor */
 
     /* text box for displaying song title in shaded mode */
     playlistwin_sinfo =
         create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc,
-                       4, 4, playlistwin_get_width() - 35, FALSE, SKIN_TEXT);
+                       4, 4, playlistwin_get_width() - 35, TRUE, SKIN_TEXT);
+
+    playlistwin_set_sinfo_font(cfg.playlist_font);
 
     if (!cfg.playlist_shaded)
         widget_hide(WIDGET(playlistwin_sinfo));
--- a/audacious/ui_playlist.h	Wed Oct 04 01:45:01 2006 -0700
+++ b/audacious/ui_playlist.h	Wed Oct 04 02:15:22 2006 -0700
@@ -67,6 +67,8 @@
 void playlistwin_scroll_up_pushed(void);
 void playlistwin_scroll_down_pushed(void);
 void playlistwin_select_playlist_to_load(const gchar * default_filename);
+void playlistwin_set_sinfo_font(gchar *font);
+void playlistwin_set_sinfo_scroll(gboolean scroll);
 
 extern GtkWidget *playlistwin;
 extern PlayList_List *playlistwin_list;