changeset 2943:a8f2c99727eb trunk

replace Textbox in playlistwin with UiSkinnedTextbox, textbox.c no longer needed, temporary comment out g_usleep in textbox_scroll as it needs to be run as new thread
author Tomasz Mon <desowin@gmail.com>
date Sat, 30 Jun 2007 19:46:21 +0200
parents 1a59a0ced6a8
children 3c66c8d03c53
files src/audacious/ui_playlist.c src/audacious/ui_skinned_textbox.c src/audacious/ui_skinned_textbox.h src/audacious/widgets/Makefile src/audacious/widgets/widgetcore.h
diffstat 5 files changed, 50 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/ui_playlist.c	Sat Jun 30 18:44:20 2007 +0200
+++ b/src/audacious/ui_playlist.c	Sat Jun 30 19:46:21 2007 +0200
@@ -55,6 +55,7 @@
 
 #include "ui_skinned_window.h"
 #include "ui_skinned_button.h"
+#include "ui_skinned_textbox.h"
 
 #include "icons-stock.h"
 #include "images/audacious_playlist.xpm"
@@ -73,8 +74,8 @@
 static guint playlistwin_infopopup_sid = 0;
 
 static PlaylistSlider *playlistwin_slider = NULL;
-static TextBox *playlistwin_time_min, *playlistwin_time_sec;
-static TextBox *playlistwin_info, *playlistwin_sinfo;
+static GtkWidget *playlistwin_time_min, *playlistwin_time_sec;
+static GtkWidget *playlistwin_info, *playlistwin_sinfo;
 static GtkWidget *playlistwin_srew, *playlistwin_splay;
 static GtkWidget *playlistwin_spause, *playlistwin_sstop;
 static GtkWidget *playlistwin_sfwd, *playlistwin_seject;
@@ -179,7 +180,7 @@
     else
         tot_text = g_strdup("?");
     text = g_strconcat(sel_text, "/", tot_text, NULL);
-    textbox_set_text(playlistwin_info, text ? text : "");
+    ui_skinned_textbox_set_text(playlistwin_info, text ? text : "");
     g_free(text);
     g_free(tot_text);
     g_free(sel_text);
@@ -195,7 +196,7 @@
     title = playlist_get_songtitle(playlist, pos);
 
     if (!title) {
-        textbox_set_text(playlistwin_sinfo, "");
+        ui_skinned_textbox_set_text(playlistwin_sinfo, "");
         return;
     }
 
@@ -221,7 +222,7 @@
     g_free(title);
     g_free(timestr);
 
-    textbox_set_text(playlistwin_sinfo, info ? info : "");
+    ui_skinned_textbox_set_text(playlistwin_sinfo, info ? info : "");
     g_free(info);
 }
 
@@ -327,7 +328,7 @@
     tmp2 = g_strdup_printf("%s 8", tmp);
     g_return_if_fail(tmp2);
 
-    textbox_set_xfont(playlistwin_sinfo, cfg.mainwin_use_xfont, tmp2);
+    ui_skinned_textbox_set_xfont(playlistwin_sinfo, cfg.mainwin_use_xfont, tmp2);
 
     g_free(tmp);
     g_free(tmp2);
@@ -337,9 +338,9 @@
 playlistwin_set_sinfo_scroll(gboolean scroll)
 {
     if(playlistwin_is_shaded())
-        textbox_set_scroll(playlistwin_sinfo, cfg.autoscroll);
+        ui_skinned_textbox_set_scroll(playlistwin_sinfo, cfg.autoscroll);
     else
-        textbox_set_scroll(playlistwin_sinfo, FALSE);
+        ui_skinned_textbox_set_scroll(playlistwin_sinfo, FALSE);
 }
 
 void
@@ -350,7 +351,7 @@
     if (shaded) {
         playlistwin_set_sinfo_font(cfg.playlist_font);
         playlistwin_set_sinfo_scroll(cfg.autoscroll);
-        widget_show(WIDGET(playlistwin_sinfo));
+        gtk_widget_show(playlistwin_sinfo);
         UI_SKINNED_BUTTON(playlistwin_shade)->nx = 128;
         UI_SKINNED_BUTTON(playlistwin_shade)->ny = 45;
         UI_SKINNED_BUTTON(playlistwin_shade)->px = 150;
@@ -359,7 +360,7 @@
         UI_SKINNED_BUTTON(playlistwin_close)->ny = 45;
     }
     else {
-        widget_hide(WIDGET(playlistwin_sinfo));
+        gtk_widget_hide(playlistwin_sinfo);
         playlistwin_set_sinfo_scroll(FALSE);
         UI_SKINNED_BUTTON(playlistwin_shade)->nx = 157;
         UI_SKINNED_BUTTON(playlistwin_shade)->ny = 3;
@@ -664,14 +665,14 @@
     widget_move_relative(WIDGET(playlistwin_slider), dx, 0);
     widget_resize_relative(WIDGET(playlistwin_slider), 0, dy);
 
-    widget_resize_relative(WIDGET(playlistwin_sinfo), dx, 0);
+    ui_skinned_textbox_resize_relative(playlistwin_sinfo, dx, 0);
     playlistwin_update_sinfo(playlist_get_active());
 
     ui_skinned_button_move_relative(playlistwin_shade, dx, 0);
     ui_skinned_button_move_relative(playlistwin_close, dx, 0);
-    widget_move_relative(WIDGET(playlistwin_time_min), dx, dy);
-    widget_move_relative(WIDGET(playlistwin_time_sec), dx, dy);
-    widget_move_relative(WIDGET(playlistwin_info), dx, dy);
+    ui_skinned_textbox_move_relative(playlistwin_time_min, dx, dy);
+    ui_skinned_textbox_move_relative(playlistwin_time_sec, dx, dy);
+    ui_skinned_textbox_move_relative(playlistwin_info, dx, dy);
     ui_skinned_button_move_relative(playlistwin_srew, dx, dy);
     ui_skinned_button_move_relative(playlistwin_splay, dx, dy);
     ui_skinned_button_move_relative(playlistwin_spause, dx, dy);
@@ -1450,8 +1451,8 @@
 void
 playlistwin_hide_timer(void)
 {
-    textbox_set_text(playlistwin_time_min, "   ");
-    textbox_set_text(playlistwin_time_sec, "  ");
+    ui_skinned_textbox_set_text(playlistwin_time_min, "   ");
+    ui_skinned_textbox_set_text(playlistwin_time_sec, "  ");
 }
 
 void
@@ -1474,11 +1475,11 @@
         time /= 60;
 
     text = g_strdup_printf("%c%-2.2d", sign, time / 60);
-    textbox_set_text(playlistwin_time_min, text);
+    ui_skinned_textbox_set_text(playlistwin_time_min, text);
     g_free(text);
 
     text = g_strdup_printf("%-2.2d", time % 60);
-    textbox_set_text(playlistwin_time_sec, text);
+    ui_skinned_textbox_set_text(playlistwin_time_sec, text);
     g_free(text);
 }
 
@@ -1552,15 +1553,12 @@
     /* 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, SKINNED_WINDOW(playlistwin)->gc,
-                       4, 4, playlistwin_get_width() - 35, TRUE, SKIN_TEXT);
+    playlistwin_sinfo = ui_skinned_textbox_new();
+    ui_skinned_textbox_setup(playlistwin_sinfo, SKINNED_WINDOW(playlistwin)->fixed, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc,
+                             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));
-
     playlistwin_shade = ui_skinned_button_new();
     /* shade/unshade window push button */
     if (cfg.playlist_shaded)
@@ -1603,25 +1601,22 @@
     ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_slider));
 
     /* track time (minute) */
-    playlistwin_time_min =
-        create_textbox(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc,
+    playlistwin_time_min = ui_skinned_textbox_new();
+    ui_skinned_textbox_setup(playlistwin_time_min, SKINNED_WINDOW(playlistwin)->fixed, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc,
                        playlistwin_get_width() - 82,
                        cfg.playlist_height - 15, 15, FALSE, SKIN_TEXT);
-    ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_time_min));
 
     /* track time (second) */
-    playlistwin_time_sec =
-        create_textbox(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc,
+    playlistwin_time_sec = ui_skinned_textbox_new();
+    ui_skinned_textbox_setup(playlistwin_time_sec, SKINNED_WINDOW(playlistwin)->fixed, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc,
                        playlistwin_get_width() - 64,
                        cfg.playlist_height - 15, 10, FALSE, SKIN_TEXT);
-    ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_time_sec));
 
     /* playlist information (current track length / total track length) */
-    playlistwin_info =
-        create_textbox(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc,
+    playlistwin_info = ui_skinned_textbox_new();
+    ui_skinned_textbox_setup(playlistwin_info, SKINNED_WINDOW(playlistwin)->fixed, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc,
                        playlistwin_get_width() - 143,
                        cfg.playlist_height - 28, 90, FALSE, SKIN_TEXT);
-    ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_info));
 
     /* mini play control buttons at right bottom corner */
 
@@ -1807,6 +1802,9 @@
         50 , (GSourceFunc)playlistwin_fileinfopopup_probe , playlistwin_infopopup );
 
     gtk_widget_show_all(playlistwin);
+    if (!cfg.playlist_shaded)
+        gtk_widget_hide(playlistwin_sinfo);
+    ui_skinned_textbox_set_text(playlistwin_info, " ");
     gtk_window_present(GTK_WINDOW(playlistwin));
 }
 
--- a/src/audacious/ui_skinned_textbox.c	Sat Jun 30 18:44:20 2007 +0200
+++ b/src/audacious/ui_skinned_textbox.c	Sat Jun 30 19:46:21 2007 +0200
@@ -591,11 +591,11 @@
         if (priv->offset >= (priv->pixmap_width - priv->w)) {
             priv->scroll_back = TRUE;
             /* There are 1 million microseconds per second */
-            g_usleep(1000000);
+            //g_usleep(1000000);
         }
         if (priv->offset <= 0) {
             priv->scroll_back = FALSE;
-            g_usleep(1000000);
+            //g_usleep(1000000);
         }
         ui_skinned_textbox_redraw(textbox);
     }
@@ -839,3 +839,15 @@
     *x = tx * bmp_active_skin->properties.textbox_bitmap_font_width;
     *y = ty * bmp_active_skin->properties.textbox_bitmap_font_height;
 }
+
+void ui_skinned_textbox_move_relative(GtkWidget *widget, gint x, gint y) {
+        UiSkinnedTextbox *t = UI_SKINNED_TEXTBOX(widget);
+        UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE (widget);
+        gtk_fixed_move(GTK_FIXED(priv->fixed), widget, t->x+x, t->y+y);
+}
+
+void ui_skinned_textbox_resize_relative(GtkWidget *widget, gint w, gint h) {
+        UiSkinnedTextbox *t = UI_SKINNED_TEXTBOX(widget);
+        UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE (widget);
+        gtk_widget_set_size_request(widget, priv->w+w, t->height+h);
+}
--- a/src/audacious/ui_skinned_textbox.h	Sat Jun 30 18:44:20 2007 +0200
+++ b/src/audacious/ui_skinned_textbox.h	Sat Jun 30 19:46:21 2007 +0200
@@ -24,6 +24,9 @@
 #include <gtk/gtkenums.h>
 #include "widgets/skin.h"
 
+#define	TEXTBOX_SCROLL_TIMEOUT	       200
+#define TEXTBOX_SCROLL_SMOOTH_TIMEOUT  30
+
 #define UI_TYPE_SKINNED_TEXTBOX            (ui_skinned_textbox_get_type())
 #define UI_SKINNED_TEXTBOX(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), UI_TYPE_SKINNED_TEXTBOX, UiSkinnedTextbox))
 #define UI_SKINNED_TEXTBOX_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), UI_TYPE_SKINNED_TEXTBOX, UiSkinnedTextboxClass))
@@ -57,5 +60,7 @@
 void ui_skinned_textbox_set_text(GtkWidget *widget, const gchar *text);
 void ui_skinned_textbox_set_xfont(GtkWidget *widget, gboolean use_xfont, const gchar *fontname);
 void ui_skinned_textbox_set_scroll(GtkWidget *widget, gboolean scroll);
+void ui_skinned_textbox_move_relative(GtkWidget *widget, gint x, gint y);
+void ui_skinned_textbox_resize_relative(GtkWidget *widget, gint w, gint h);
 
 #endif
--- a/src/audacious/widgets/Makefile	Sat Jun 30 18:44:20 2007 +0200
+++ b/src/audacious/widgets/Makefile	Sat Jun 30 19:46:21 2007 +0200
@@ -20,7 +20,6 @@
 
 SOURCES = \
 	widget.c \
-	textbox.c \
 	hslider.c \
 	menurow.c \
 	monostereo.c \
--- a/src/audacious/widgets/widgetcore.h	Sat Jun 30 18:44:20 2007 +0200
+++ b/src/audacious/widgets/widgetcore.h	Sat Jun 30 19:46:21 2007 +0200
@@ -31,7 +31,6 @@
 #include "playstatus.h"
 #include "skin.h"
 #include "svis.h"
-#include "textbox.h"
 #include "vis.h"
 #include "widget.h"