Mercurial > audlegacy
changeset 3232:2453bf125b4f trunk
Automated merge with ssh://hg.atheme.org//hg/audacious
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Fri, 03 Aug 2007 20:39:42 -0500 |
parents | 06baa146fc1d (current diff) cfb76302b468 (diff) |
children | 88f602569477 |
files | src/audacious/plugin.h src/audacious/pluginenum.c src/audacious/widgets/playlist_list.c src/audacious/widgets/playlist_list.h src/audacious/widgets/playlist_slider.c src/audacious/widgets/playlist_slider.h src/audacious/widgets/widget.c src/audacious/widgets/widget.h |
diffstat | 41 files changed, 1621 insertions(+), 2063 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.ac Fri Aug 03 20:39:35 2007 -0500 +++ b/configure.ac Fri Aug 03 20:39:42 2007 -0500 @@ -389,9 +389,10 @@ GENERAL_PLUGIN_DIR=Plugins VISUALIZATION_PLUGIN_DIR=Plugins CONTAINER_PLUGIN_DIR=Plugins - TRANSPORTR_PLUGIN_DIR=Plugins + TRANSPORT_PLUGIN_DIR=Plugins + DISCOVERY_PLUGIN_DIR=Plugins else - pluginsubs="\\\"Output\\\",\\\"Input\\\",\\\"Effect\\\",\\\"General\\\",\\\"Visualization\\\",\\\"Container\\\",\\\"Transport\\\"" + pluginsubs="\\\"Output\\\",\\\"Input\\\",\\\"Effect\\\",\\\"General\\\",\\\"Visualization\\\",\\\"Container\\\",\\\"Transport\\\",\\\"Discovery\\\"" INPUT_PLUGIN_DIR=Input OUTPUT_PLUGIN_DIR=Output EFFECT_PLUGIN_DIR=Effect @@ -399,6 +400,7 @@ VISUALIZATION_PLUGIN_DIR=Visualization CONTAINER_PLUGIN_DIR=Container TRANSPORT_PLUGIN_DIR=Transport + DISCOVERY_PLUGIN_DIR=Discovery fi AC_SUBST(INPUT_PLUGIN_DIR)
--- a/src/audacious/Makefile Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/Makefile Fri Aug 03 20:39:42 2007 -0500 @@ -66,6 +66,7 @@ auddrct.c \ build_stamp.c \ configdb.c \ + discovery.c \ dnd.c \ dock.c \ effect.c \ @@ -125,6 +126,7 @@ ui_skinned_equalizer_slider.c \ ui_skinned_equalizer_graph.c \ ui_skinned_playlist_slider.c \ + ui_skinned_playlist.c \ ui_skinselector.c \ ui_urlopener.c \ util.c \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/discovery.c Fri Aug 03 20:39:42 2007 -0500 @@ -0,0 +1,168 @@ +/* BMP - Cross-platform multimedia player + * Copyright (C) 2003-2004 BMP development team. + * + * Based on XMMS: + * Copyright (C) 1998-2003 XMMS development team. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Discovery Public License as published by + * the Free Software Foundation; under version 3 of the License. + * + * 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 Discovery Public License for more details. + * + * You should have received a copy of the GNU Discovery Public License + * along with this program. If not, see <http://www.gnu.org/licenses>. + * + * The Audacious team does not consider modular code linking to + * Audacious or using our public API to be a derived work. + */ + +#include <glib.h> +#include <string.h> +#include "plugin.h" +#include "discovery.h" + +DiscoveryPluginData dp_data = { + NULL, + NULL +}; + +GList * +get_discovery_list(void) +{ + return dp_data.discovery_list; +} + +GList * +get_discovery_enabled_list(void) +{ + return dp_data.enabled_list; +} + +static DiscoveryPlugin * +get_discovery_plugin(gint i) +{ + GList *node = g_list_nth(get_discovery_list(), i); + + if (!node) + return NULL; + + return DISCOVERY_PLUGIN(node->data); +} + + +void +discovery_about(gint i) +{ + DiscoveryPlugin *plugin = get_discovery_plugin(i); + + if (!plugin || !plugin->about) + return; + + plugin->about(); +} + +void +discovery_configure(gint i) +{ + DiscoveryPlugin *plugin = get_discovery_plugin(i); + + if (!plugin || !plugin->configure) + return; + + plugin->configure(); +} + +static gboolean +discovery_plugin_is_enabled(DiscoveryPlugin * plugin) +{ + return (g_list_find(get_discovery_enabled_list(), plugin) != NULL); +} + +void +enable_discovery_plugin(gint i, gboolean enable) +{ + DiscoveryPlugin *plugin = get_discovery_plugin(i); + + if (!plugin) + return; + + if (enable && !discovery_plugin_is_enabled(plugin)) { + dp_data.enabled_list = g_list_append(dp_data.enabled_list, plugin); + if (plugin->init) + plugin->init(); + } + else if (!enable && discovery_plugin_is_enabled(plugin)) { + dp_data.enabled_list = g_list_remove(dp_data.enabled_list, plugin); + if (plugin->cleanup) + plugin->cleanup(); + } +} + +gboolean +discovery_enabled(gint i) +{ + return (g_list_find(dp_data.enabled_list, + get_discovery_plugin(i)) != NULL); +} + +gchar * +discovery_stringify_enabled_list(void) +{ + GString *enable_str; + gchar *name; + GList *node = get_discovery_enabled_list(); + + if (!node) + return NULL; + + name = g_path_get_basename(DISCOVERY_PLUGIN(node->data)->filename); + enable_str = g_string_new(name); + g_free(name); + + for (node = g_list_next(node); node; node = g_list_next(node)) { + name = g_path_get_basename(DISCOVERY_PLUGIN(node->data)->filename); + g_string_append_c(enable_str, ','); + g_string_append(enable_str, name); + g_free(name); + } + + return g_string_free(enable_str, FALSE); +} + +void +discovery_enable_from_stringified_list(const gchar * list_str) +{ + gchar **list, **str; + DiscoveryPlugin *plugin; + + if (!list_str || !strcmp(list_str, "")) + return; + + list = g_strsplit(list_str, ",", 0); + + for (str = list; *str; str++) { + GList *node; + + for (node = get_discovery_list(); node; node = g_list_next(node)) { + gchar *base; + + base = g_path_get_basename(DISCOVERY_PLUGIN(node->data)->filename); + + if (!strcmp(*str, base)) { + plugin = DISCOVERY_PLUGIN(node->data); + dp_data.enabled_list = g_list_append(dp_data.enabled_list, + plugin); + if (plugin->init) + plugin->init(); + } + + g_free(base); + } + } + + g_strfreev(list); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/discovery.h Fri Aug 03 20:39:42 2007 -0500 @@ -0,0 +1,46 @@ +/* BMP - Cross-platform multimedia player + * Copyright (C) 2003-2004 BMP development team. + * + * Based on XMMS: + * Copyright (C) 1998-2003 XMMS 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; under version 3 of the License. + * + * 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, see <http://www.gnu.org/licenses>. + * + * The Audacious team does not consider modular code linking to + * Audacious or using our public API to be a derived work. + */ + +#ifndef DISCOVERY_H +#define DISCOVERY_H + +#include <glib.h> + +typedef struct _DiscoveryPluginData DiscoveryPluginData; + +struct _DiscoveryPluginData { + GList *discovery_list; + GList *enabled_list; +}; + +GList *get_discovery_list(void); +GList *get_discovery_enabled_list(void); +void enable_discovery_plugin(gint i, gboolean enable); +void discovery_about(gint i); +void discovery_configure(gint i); +gboolean discovery_enabled(gint i); +gchar *discovery_stringify_enabled_list(void); +void discovery_enable_from_stringified_list(const gchar * list); + +extern DiscoveryPluginData dp_data; + +#endif
--- a/src/audacious/main.c Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/main.c Fri Aug 03 20:39:42 2007 -0500 @@ -163,8 +163,8 @@ TRUE, /* close dialog on open */ TRUE, /* close dialog on add */ 0.0, /* equalizer preamp */ - {0, 0, 0, 0, 0, /* equalizer bands */ - 0, 0, 0, 0, 0}, + {0.0, 0.0, 0.0, 0.0, 0.0, /* equalizer bands */ + 0.0, 0.0, 0.0, 0.0, 0.0}, NULL, /* skin */ NULL, /* output plugin */ NULL, /* file selector path */ @@ -175,6 +175,7 @@ NULL, /* enabled general plugins */ NULL, /* enabled visualization plugins */ NULL, /* enabled effect plugins */ + NULL, /* enabled discovery plugins */ NULL, /* equalizer preset default file */ NULL, /* equalizer preset extension */ NULL, /* URL history */ @@ -203,8 +204,8 @@ FALSE, /* resume playback on startup */ -1, /* resume playback on startup time */ TRUE, /* show seperators in pl */ - NULL, - NULL, + NULL, /* chardet_detector */ + NULL, /* chardet_fallback */ 3000, /* audio buffer size */ FALSE, /* whether or not to postpone format detection on initial add */ TRUE, /* show filepopup for tuple */
--- a/src/audacious/main.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/main.h Fri Aug 03 20:39:42 2007 -0500 @@ -84,7 +84,7 @@ gchar *playlist_path; gchar *playlist_font, *mainwin_font; gchar *disabled_iplugins; - gchar *enabled_gplugins, *enabled_vplugins, *enabled_eplugins; + gchar *enabled_gplugins, *enabled_vplugins, *enabled_eplugins, *enabled_dplugins ; gchar *eqpreset_default_file, *eqpreset_extension; GList *url_history; gint timer_mode;
--- a/src/audacious/playlist.c Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/playlist.c Fri Aug 03 20:39:42 2007 -0500 @@ -73,6 +73,7 @@ #include "playlist_evmessages.h" #include "playlist_evlisteners.h" +#include "ui_skinned_playlist.h" typedef gint (*PlaylistCompareFunc) (PlaylistEntry * a, PlaylistEntry * b); typedef void (*PlaylistSaveFunc) (FILE * file); @@ -1116,8 +1117,8 @@ } bottom = MAX(0, playlist_get_length(playlist) - - playlistwin_list->pl_num_visible); - row = CLAMP(pos - playlistwin_list->pl_num_visible / 2, 0, bottom); + UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible); + row = CLAMP(pos - UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible / 2, 0, bottom); PLAYLIST_UNLOCK(playlist->mutex); playlistwin_set_toprow(row); g_cond_signal(cond_scan);
--- a/src/audacious/plugin.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/plugin.h Fri Aug 03 20:39:42 2007 -0500 @@ -46,6 +46,7 @@ #define EFFECT_PLUGIN(x) ((EffectPlugin *)(x)) #define GENERAL_PLUGIN(x) ((GeneralPlugin *)(x)) #define VIS_PLUGIN(x) ((VisPlugin *)(x)) +#define DISCOVERY_PLUGIN(x) ((DiscoveryPlugin *)(x)) #define LOWLEVEL_PLUGIN(x) ((LowlevelPlugin *)(x)) @@ -78,7 +79,7 @@ typedef struct _EffectPlugin EffectPlugin; typedef struct _GeneralPlugin GeneralPlugin; typedef struct _VisPlugin VisPlugin; - +typedef struct _DiscoveryPlugin DiscoveryPlugin; typedef struct _LowlevelPlugin LowlevelPlugin; typedef struct _InputPlayback InputPlayback; @@ -102,15 +103,16 @@ EffectPlugin **ep_list; GeneralPlugin **gp_list; VisPlugin **vp_list; + DiscoveryPlugin **dp_list; } PluginHeader; #define PLUGIN_MAGIC 0x8EAC8DE2 -#define DECLARE_PLUGIN(name, init, fini, ip_list, op_list, ep_list, gp_list, vp_list) \ +#define DECLARE_PLUGIN(name, init, fini, ip_list, op_list, ep_list, gp_list, vp_list, dp_list) \ G_BEGIN_DECLS \ static PluginHeader _pluginInfo = { PLUGIN_MAGIC, __AUDACIOUS_PLUGIN_API__, \ (gchar *)#name, init, fini, NULL, ip_list, op_list, ep_list, gp_list, \ - vp_list }; \ + vp_list,dp_list }; \ G_MODULE_EXPORT PluginHeader *get_plugin_info(void) { \ return &_pluginInfo; \ } \ @@ -278,6 +280,17 @@ void (*render_freq) (gint16 freq_data[2][256]); }; +struct _DiscoveryPlugin { + gpointer handle; + gchar *filename; + gchar *description; + + void (*init) (void); + void (*cleanup) (void); + void (*about) (void); + void (*configure) (void); + gchar *(*get_devices); +}; G_BEGIN_DECLS
--- a/src/audacious/pluginenum.c Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/pluginenum.c Fri Aug 03 20:39:42 2007 -0500 @@ -50,7 +50,7 @@ #include "input.h" #include "output.h" #include "visualization.h" - +#include "discovery.h" const gchar *plugin_dir_list[] = { PLUGINSUBS, NULL @@ -58,7 +58,6 @@ GHashTable *plugin_matrix = NULL; GList *lowlevel_list = NULL; - extern GList *vfs_transports; static gint @@ -111,6 +110,16 @@ return 0; } +static gint +discoverylist_compare_func(gconstpointer a, gconstpointer b) +{ + const DiscoveryPlugin *ap = a, *bp = b; + if(ap->description && bp->description) + return strcasecmp(ap->description, bp->description); + else + return 0; +} + static gboolean plugin_is_duplicate(const gchar * filename) { @@ -140,7 +149,11 @@ return TRUE; for (l = lowlevel_list; l; l = g_list_next(l)) - if (!strcmp(basename, g_basename(VIS_PLUGIN(l->data)->filename))) + if (!strcmp(basename, g_basename(LOWLEVEL_PLUGIN(l->data)->filename))) + return TRUE; + + for (l = dp_data.discovery_list; l; l = g_list_next(l)) + if (!strcmp(basename, g_basename(DISCOVERY_PLUGIN(l->data)->filename))) return TRUE; return FALSE; @@ -200,6 +213,13 @@ vp_data.vis_list = g_list_append(vp_data.vis_list, p); } +static void +discovery_plugin_init(Plugin * plugin) +{ + DiscoveryPlugin *p = DISCOVERY_PLUGIN(plugin); + dp_data.discovery_list = g_list_append(dp_data.discovery_list, p); +} + /*******************************************************************/ static void @@ -224,6 +244,8 @@ EffectPlugin **ep_iter; GeneralPlugin **gp_iter; VisPlugin **vp_iter; + DiscoveryPlugin **dp_iter; + if (header->magic != PLUGIN_MAGIC) return plugin2_dispose(module, "plugin <%s> discarded, invalid module magic", filename); @@ -288,6 +310,17 @@ vis_plugin_init(PLUGIN(*vp_iter)); } } + + if (header->dp_list) + { + for (dp_iter = header->dp_list; *dp_iter != NULL; dp_iter++) + { + PLUGIN(*dp_iter)->filename = g_strdup(filename); + g_print("plugin2 '%s' provides DiscoveryPlugin <%p>\n", filename, *dp_iter); + discovery_plugin_init(PLUGIN(*dp_iter)); + } + } + } void @@ -372,6 +405,7 @@ OutputPlugin *op; InputPlugin *ip; LowlevelPlugin *lp; + DiscoveryPlugin *dp; gint dirsel = 0, i = 0; if (!g_module_supported()) { @@ -385,7 +419,8 @@ #ifndef DISABLE_USER_PLUGIN_DIR scan_plugins(bmp_paths[BMP_PATH_USER_PLUGIN_DIR]); /* - * This is in a separate loop so if the user puts them in the + * This is in a separate lo + * DiscoveryPlugin *dpop so if the user puts them in the * wrong dir we'll still get them in the right order (home dir * first) - Zinx */ @@ -421,9 +456,14 @@ vp_data.vis_list = g_list_sort(vp_data.vis_list, vislist_compare_func); vp_data.enabled_list = NULL; + dp_data.discovery_list = g_list_sort(dp_data.discovery_list, discoverylist_compare_func); + dp_data.enabled_list = NULL; + + general_enable_from_stringified_list(cfg.enabled_gplugins); vis_enable_from_stringified_list(cfg.enabled_vplugins); effect_enable_from_stringified_list(cfg.enabled_eplugins); + discovery_enable_from_stringified_list(cfg.enabled_dplugins); g_free(cfg.enabled_gplugins); cfg.enabled_gplugins = NULL; @@ -434,6 +474,10 @@ g_free(cfg.enabled_eplugins); cfg.enabled_eplugins = NULL; + g_free(cfg.enabled_dplugins); + cfg.enabled_dplugins = NULL; + + for (node = op_data.output_list; node; node = g_list_next(node)) { op = OUTPUT_PLUGIN(node->data); /* @@ -453,6 +497,13 @@ ip->init(); } + for (node = dp_data.discovery_list; node; node = g_list_next(node)) { + dp = DISCOVERY_PLUGIN(node->data); + if (dp->init) + dp->init(); + } + + for (node = lowlevel_list; node; node = g_list_next(node)) { lp = LOWLEVEL_PLUGIN(node->data); if (lp->init) @@ -483,6 +534,7 @@ GeneralPlugin *gp; VisPlugin *vp; LowlevelPlugin *lp; + DiscoveryPlugin *dp; GList *node; g_message("Shutting down plugin system"); @@ -591,6 +643,28 @@ vp_data.vis_list = NULL; } + + for (node = get_discovery_list(); node; node = g_list_next(node)) { + dp = DISCOVERY_PLUGIN(node->data); + if (dp && dp->cleanup) { + dp->cleanup(); + GDK_THREADS_LEAVE(); + while (g_main_context_iteration(NULL, FALSE)); + GDK_THREADS_ENTER(); + } + + if (dp->handle) + g_module_close(dp->handle); + } + + if (dp_data.discovery_list != NULL) + { + g_list_free(dp_data.discovery_list); + dp_data.discovery_list = NULL; + } + + + for (node = lowlevel_list; node; node = g_list_next(node)) { lp = LOWLEVEL_PLUGIN(node->data); if (lp && lp->cleanup) {
--- a/src/audacious/ui_equalizer.c Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_equalizer.c Fri Aug 03 20:39:42 2007 -0500 @@ -156,8 +156,6 @@ GtkWidget *child = child_data->widget; g_signal_emit_by_name(child, "toggle-double-size"); } - - draw_equalizer_window(TRUE); } void @@ -187,8 +185,6 @@ gtk_widget_hide(equalizerwin_volume); gtk_widget_hide(equalizerwin_balance); } - - draw_equalizer_window(TRUE); } static void @@ -253,61 +249,6 @@ cfg.equalizer_autoload = UI_SKINNED_BUTTON(equalizerwin_auto)->inside; } -static void equalizerwin_draw_titlebar() { - if (gtk_window_has_toplevel_focus(GTK_WINDOW(equalizerwin)) || - !cfg.dim_titlebar) { - if (!cfg.equalizer_shaded) - skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, - SKINNED_WINDOW(equalizerwin)->gc, SKIN_EQMAIN, 0, 134, 0, - 0, 275, 14); - else - skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, - SKINNED_WINDOW(equalizerwin)->gc, SKIN_EQ_EX, 0, 0, 0, 0, - 275, 14); - } - else { - if (!cfg.equalizer_shaded) - skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, - SKINNED_WINDOW(equalizerwin)->gc, SKIN_EQMAIN, 0, 149, 0, - 0, 275, 14); - else - skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, - SKINNED_WINDOW(equalizerwin)->gc, SKIN_EQ_EX, 0, 15, 0, 0, - 275, 14); - } -} - -void -draw_equalizer_window(gboolean force) -{ - if (!cfg.equalizer_visible) - return; - - if (force) { - if (!cfg.equalizer_shaded) - skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, SKINNED_WINDOW(equalizerwin)->gc, - SKIN_EQMAIN, 0, 0, 0, 0, 275, 116); - equalizerwin_draw_titlebar(); - - GList *iter; - for (iter = GTK_FIXED (SKINNED_WINDOW(equalizerwin)->fixed)->children; iter; iter = g_list_next (iter)) { - GtkFixedChild *child_data = (GtkFixedChild *) iter->data; - GtkWidget *child = child_data->widget; - gtk_widget_queue_draw(child); - } - - if (cfg.doublesize && cfg.eq_doublesize_linked) { - GdkPixmap *img2; - img2 = create_dblsize_pixmap(equalizerwin_bg); - gdk_draw_drawable(equalizerwin_bg_x2, SKINNED_WINDOW(equalizerwin)->gc, img2, 0, 0, 0, 0, 550, 232); - g_object_unref(img2); - } - - gdk_window_clear(equalizerwin->window); - gdk_flush(); - } -} - gboolean equalizerwin_press(GtkWidget * widget, GdkEventButton * event, gpointer callback_data) @@ -323,8 +264,7 @@ } if (event->button == 1 && event->type == GDK_BUTTON_PRESS && - ((cfg.easy_move || cfg.equalizer_shaded || event->y < 14) && - !ui_skinned_window_widgetlist_contained(equalizerwin, event->x, event->y))) { + (cfg.easy_move || cfg.equalizer_shaded || event->y < 14)) { equalizerwin_raise(); dock_move_press(dock_window_list, GTK_WINDOW(equalizerwin), event, FALSE); @@ -368,8 +308,6 @@ dock_move_release(GTK_WINDOW(equalizerwin)); } - draw_equalizer_window(FALSE); - return FALSE; } @@ -713,8 +651,6 @@ else gtk_widget_set_size_request(equalizerwin, 275, (cfg.equalizer_shaded ? 14 : 116)); - gdk_flush(); - draw_equalizer_window(TRUE); cfg.equalizer_visible = TRUE; UI_SKINNED_BUTTON(mainwin_eq)->inside = TRUE; gtk_widget_show_all(equalizerwin);
--- a/src/audacious/ui_main.c Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_main.c Fri Aug 03 20:39:42 2007 -0500 @@ -89,6 +89,7 @@ #include "ui_skinned_menurow.h" #include "ui_skinned_playstatus.h" #include "ui_skinned_monostereo.h" +#include "ui_skinned_playlist.h" #include "ui_jumptotrack.h" #include "ui_main_evlisteners.h" @@ -126,8 +127,6 @@ gint seek_state = MAINWIN_SEEK_NIL; gint seek_initial_pos = 0; -static GdkPixmap *mainwin_bg = NULL, *mainwin_bg_x2 = NULL; - static GtkWidget *mainwin_menubtn; static GtkWidget *mainwin_minimize, *mainwin_shade, *mainwin_close; @@ -166,7 +165,6 @@ static gint mainwin_timeout_id; -static gboolean mainwin_force_redraw = FALSE; static gboolean mainwin_info_text_locked = FALSE; static int ab_position_a = -1; @@ -180,7 +178,6 @@ static void set_timer_mode_menu_cb(TimerMode mode); static void set_timer_mode(TimerMode mode); static void change_timer_mode(void); -static void mainwin_refresh_hints(void); void mainwin_position_motion_cb(GtkWidget *widget, gint pos); void mainwin_position_release_cb(GtkWidget *widget, gint pos); @@ -338,7 +335,6 @@ } ui_skinned_set_push_button_data(mainwin_shade, 0, cfg.player_shaded ? 27 : 18, 9, cfg.player_shaded ? 27 : 18); - draw_main_window(TRUE); } static void @@ -536,55 +532,6 @@ mainwin_quit_cb(); } -static void -mainwin_draw_titlebar(gboolean focus) -{ - /* FIXME: uses SkinnedWindow::gc directly. -nenolod */ - skin_draw_mainwin_titlebar(bmp_active_skin, mainwin_bg, - SKINNED_WINDOW(mainwin)->gc, - cfg.player_shaded, focus || !cfg.dim_titlebar); -} - -void -draw_main_window(gboolean force) -{ - if (!cfg.player_visible) - return; - - if (force) - mainwin_refresh_hints(); - - if (force) { - if (!cfg.player_shaded) - skin_draw_pixmap(bmp_active_skin, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, - SKIN_MAIN, 0, 0, 0, 0, bmp_active_skin->properties.mainwin_width, - bmp_active_skin->properties.mainwin_height); - mainwin_draw_titlebar(gtk_window_has_toplevel_focus - (GTK_WINDOW(mainwin))); - } - - if (force) { - if (cfg.doublesize) { - GdkPixmap *img2x = NULL; - img2x = create_dblsize_pixmap(mainwin_bg); - gdk_draw_drawable(mainwin_bg_x2, SKINNED_WINDOW(mainwin)->gc, img2x, 0, 0, - 0, 0, bmp_active_skin->properties.mainwin_width * 2, - cfg.player_shaded ? MAINWIN_SHADED_HEIGHT * - 2 : bmp_active_skin->properties.mainwin_height * 2); - g_object_unref(img2x); - } - GList *iter; - for (iter = GTK_FIXED (SKINNED_WINDOW(mainwin)->fixed)->children; iter; iter = g_list_next (iter)) { - GtkFixedChild *child_data = (GtkFixedChild *) iter->data; - GtkWidget *child = child_data->widget; - gtk_widget_queue_draw(child); - } - - gdk_flush(); - } -} - - static gchar *mainwin_tb_old_text = NULL; void @@ -634,7 +581,7 @@ gtk_window_set_title(GTK_WINDOW(mainwin), mainwin_title_text); } -static void +void mainwin_refresh_hints(void) { if (bmp_active_skin && bmp_active_skin->properties.mainwin_othertext @@ -798,15 +745,6 @@ bmp_active_skin->properties.mainwin_width * (cfg.doublesize + 1), bmp_active_skin->properties.mainwin_height * (cfg.doublesize + 1)); - g_object_unref(mainwin_bg); - g_object_unref(mainwin_bg_x2); - mainwin_bg = gdk_pixmap_new(mainwin->window, - bmp_active_skin->properties.mainwin_width, - bmp_active_skin->properties.mainwin_height, -1); - mainwin_bg_x2 = gdk_pixmap_new(mainwin->window, - bmp_active_skin->properties.mainwin_width * 2, - bmp_active_skin->properties.mainwin_height * 2, -1); - mainwin_set_back_pixmap(); gdk_flush(); } } @@ -822,6 +760,7 @@ playback_set_sample_params(bitrate, frequency, n_channels); + GDK_THREADS_ENTER(); if (bitrate != -1) { bitrate /= 1000; @@ -873,7 +812,7 @@ title = playlist_get_info_text(playlist); mainwin_set_song_title(title); g_free(title); - mainwin_force_redraw = TRUE; + GDK_THREADS_LEAVE(); } void @@ -946,11 +885,8 @@ if (dock_is_moving(GTK_WINDOW(mainwin))) { dock_move_release(GTK_WINDOW(mainwin)); - draw_playlist_window(TRUE); } - draw_main_window(FALSE); - return FALSE; } @@ -984,8 +920,6 @@ event->y /= 2; } - draw_main_window(FALSE); - gdk_flush(); return FALSE; @@ -1036,21 +970,16 @@ } if (event->button == 1 && event->type == GDK_BUTTON_PRESS && - !ui_skinned_window_widgetlist_contained(mainwin, event->x, event->y) && (cfg.easy_move || event->y < 14)) { gtk_window_present(GTK_WINDOW(mainwin)); dock_move_press(dock_window_list, GTK_WINDOW(mainwin), event, TRUE); } - else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && - event->y < 14 && !ui_skinned_window_widgetlist_contained(mainwin, event->x, event->y)) { + else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && event->y < 14) { mainwin_set_shade(!cfg.player_shaded); if (dock_is_moving(GTK_WINDOW(mainwin))) dock_move_release(GTK_WINDOW(mainwin)); } - else { - draw_main_window(FALSE); - } if (event->button == 3) { if ( (event->y > 70) && (event->x < 128) ) @@ -1284,16 +1213,6 @@ return FALSE; } -void -mainwin_set_back_pixmap(void) -{ - if (cfg.doublesize) - gdk_window_set_back_pixmap(mainwin->window, mainwin_bg_x2, 0); - else - gdk_window_set_back_pixmap(mainwin->window, mainwin_bg, 0); - gdk_window_clear(mainwin->window); -} - /* * Rewritten 09/13/06: * @@ -1327,7 +1246,7 @@ return; cfg.playlist_font = g_strconcat(decoded, strrchr(cfg.playlist_font, ' '), NULL); - playlist_list_set_font(cfg.playlist_font); + ui_skinned_playlist_set_font(cfg.playlist_font); playlistwin_update_list(playlist); g_free(decoded); @@ -1857,8 +1776,6 @@ !bmp_active_skin->properties.mainwin_height ? PLAYER_HEIGHT : bmp_active_skin->properties.mainwin_height); - draw_main_window(TRUE); - if (cfg.player_x != -1 && cfg.save_window_position) gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); @@ -1894,6 +1811,11 @@ gtk_widget_show(mainwin_vis); else gtk_widget_hide(mainwin_vis); + + if (bmp_active_skin->properties.mainwin_menurow_visible) + gtk_widget_show(mainwin_menurow); + else + gtk_widget_hide(mainwin_menurow); } void @@ -1953,13 +1875,6 @@ cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : bmp_active_skin->properties.mainwin_height, bmp_active_skin->properties.mainwin_width * 2, bmp_active_skin->properties.mainwin_height * 2); - if (cfg.doublesize) { - gdk_window_set_back_pixmap(mainwin->window, mainwin_bg_x2, 0); - } - else { - gdk_window_set_back_pixmap(mainwin->window, mainwin_bg, 0); - } - GList *iter; for (iter = GTK_FIXED (SKINNED_WINDOW(mainwin)->fixed)->children; iter; iter = g_list_next (iter)) { GtkFixedChild *child_data = (GtkFixedChild *) iter->data; @@ -1967,7 +1882,7 @@ g_signal_emit_by_name(child, "toggle-double-size"); } - draw_main_window(TRUE); + mainwin_refresh_hints(); } void @@ -2861,8 +2776,6 @@ G_CALLBACK(mainwin_motion), NULL); g_signal_connect(mainwin, "configure_event", G_CALLBACK(mainwin_configure), NULL); - g_signal_connect(mainwin, "style_set", - G_CALLBACK(mainwin_set_back_pixmap), NULL); bmp_drag_dest_set(mainwin); @@ -2879,13 +2792,6 @@ gtk_window_add_accel_group( GTK_WINDOW(mainwin) , ui_manager_get_accel_group() ); - mainwin_bg = gdk_pixmap_new(mainwin->window, - bmp_active_skin->properties.mainwin_width, - bmp_active_skin->properties.mainwin_height, -1); - mainwin_bg_x2 = gdk_pixmap_new(mainwin->window, - bmp_active_skin->properties.mainwin_width * 2, - bmp_active_skin->properties.mainwin_height * 2, -1); - mainwin_set_back_pixmap(); mainwin_create_widgets(); } @@ -2984,8 +2890,6 @@ GDK_THREADS_ENTER(); - draw_main_window(mainwin_force_redraw); - if (!count) { read_volume(VOLSET_UPDATE); count = 10; @@ -2993,10 +2897,6 @@ else count--; - mainwin_force_redraw = FALSE; - draw_equalizer_window(FALSE); - draw_playlist_window(FALSE); - /* tristate buttons seek */ if ( seek_state != MAINWIN_SEEK_NIL ) {
--- a/src/audacious/ui_main.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_main.h Fri Aug 03 20:39:42 2007 -0500 @@ -150,6 +150,7 @@ void mainwin_vis_set_type(VisType mode); +void mainwin_refresh_hints(void); void mainwin_set_info_text(void); void mainwin_set_song_info(gint rate, gint freq, gint nch); void mainwin_clear_song_info(void);
--- a/src/audacious/ui_playlist.c Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_playlist.c Fri Aug 03 20:39:42 2007 -0500 @@ -59,6 +59,7 @@ #include "ui_skinned_button.h" #include "ui_skinned_textbox.h" #include "ui_skinned_playlist_slider.h" +#include "ui_skinned_playlist.h" #include "icons-stock.h" #include "images/audacious_playlist.xpm" @@ -67,7 +68,7 @@ static GMutex *resize_mutex = NULL; -PlayList_List *playlistwin_list = NULL; +GtkWidget *playlistwin_list = NULL; GtkWidget *playlistwin_shade, *playlistwin_close; static GdkPixmap *playlistwin_bg; @@ -86,15 +87,11 @@ static GtkWidget *playlistwin_sfwd, *playlistwin_seject; static GtkWidget *playlistwin_sscroll_up, *playlistwin_sscroll_down; -static GList *playlistwin_wlist = NULL; - void playlistwin_select_search_cbt_cb( GtkWidget *called_cbt , gpointer other_cbt ); static gboolean playlistwin_select_search_kp_cb( GtkWidget *entry , GdkEventKey *event , gpointer searchdlg_win ); -static void playlistwin_draw_frame(void); - static gboolean playlistwin_fileinfopopup_probe(gpointer * filepopup_win); static gboolean playlistwin_resizing = FALSE; @@ -234,9 +231,9 @@ gboolean playlistwin_item_visible(gint index) { - if (index >= playlistwin_list->pl_first + if (index >= UI_SKINNED_PLAYLIST(playlistwin_list)->first && index < - (playlistwin_list->pl_first + playlistwin_list->pl_num_visible)) + (UI_SKINNED_PLAYLIST(playlistwin_list)->first + UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible)) return TRUE; return FALSE; } @@ -245,7 +242,7 @@ playlistwin_list_get_visible_count(void) { if (playlistwin_list) - return playlistwin_list->pl_num_visible; + return UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible; return (-1); } @@ -253,7 +250,7 @@ playlistwin_list_get_first(void) { if (playlistwin_list) - return playlistwin_list->pl_first; + return UI_SKINNED_PLAYLIST(playlistwin_list)->first; return (-1); } @@ -261,7 +258,7 @@ playlistwin_get_toprow(void) { if (playlistwin_list) - return (playlistwin_list->pl_first); + return (UI_SKINNED_PLAYLIST(playlistwin_list)->first); return (-1); } @@ -269,7 +266,7 @@ playlistwin_set_toprow(gint toprow) { if (playlistwin_list) - playlistwin_list->pl_first = toprow; + UI_SKINNED_PLAYLIST(playlistwin_list)->first = toprow; playlistwin_update_list(playlist_get_active()); } @@ -279,7 +276,7 @@ /* this can happen early on. just bail gracefully. */ g_return_if_fail(playlistwin_list); - widget_queue_redraw(WIDGET(playlistwin_list)); + gtk_widget_queue_draw(playlistwin_list); gtk_widget_queue_draw(playlistwin_slider); playlistwin_update_info(playlist); playlistwin_update_sinfo(playlist); @@ -393,10 +390,6 @@ playlistwin_get_height()); playlistwin_set_mask(); - - widget_queue_redraw(WIDGET(playlistwin_list)); - - draw_playlist_window(TRUE); } static void @@ -430,17 +423,12 @@ if (dock_is_moving(GTK_WINDOW(playlistwin))) dock_move_release(GTK_WINDOW(playlistwin)); - else - { - handle_release_cb(playlistwin_wlist, widget, event); - draw_playlist_window(FALSE); - } } void playlistwin_scroll(gint num) { - playlistwin_list->pl_first += num; + UI_SKINNED_PLAYLIST(playlistwin_list)->first += num; playlistwin_update_list(playlist_get_active()); } @@ -462,9 +450,9 @@ Playlist *playlist = playlist_get_active(); playlist_select_all(playlist, TRUE); - playlistwin_list->pl_prev_selected = 0; - playlistwin_list->pl_prev_min = 0; - playlistwin_list->pl_prev_max = playlist_get_length(playlist) - 1; + UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected = 0; + UI_SKINNED_PLAYLIST(playlistwin_list)->prev_min = 0; + UI_SKINNED_PLAYLIST(playlistwin_list)->prev_max = playlist_get_length(playlist) - 1; playlistwin_update_list(playlist); } @@ -472,8 +460,8 @@ playlistwin_select_none(void) { playlist_select_all(playlist_get_active(), FALSE); - playlistwin_list->pl_prev_selected = -1; - playlistwin_list->pl_prev_min = -1; + UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected = -1; + UI_SKINNED_PLAYLIST(playlistwin_list)->prev_min = -1; playlistwin_update_list(playlist_get_active()); } @@ -632,8 +620,8 @@ playlistwin_inverse_selection(void) { playlist_select_invert_all(playlist_get_active()); - playlistwin_list->pl_prev_selected = -1; - playlistwin_list->pl_prev_min = -1; + UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected = -1; + UI_SKINNED_PLAYLIST(playlistwin_list)->prev_min = -1; playlistwin_update_list(playlist_get_active()); } @@ -642,7 +630,6 @@ { gint tx, ty; gint dx, dy; - gboolean redraw; g_return_if_fail(width > 0 && height > 0); @@ -672,12 +659,12 @@ cfg.playlist_height = height = ty; g_mutex_lock(resize_mutex); - widget_resize_relative(WIDGET(playlistwin_list), dx, dy); + ui_skinned_playlist_resize_relative(playlistwin_list, dx, dy); ui_skinned_playlist_slider_move_relative(playlistwin_slider, dx); ui_skinned_playlist_slider_resize_relative(playlistwin_slider, dy); - ui_skinned_textbox_resize_relative(playlistwin_sinfo, dx, 0); + ui_skinned_textbox_resize_relative(playlistwin_sinfo, dx); playlistwin_update_sinfo(playlist_get_active()); ui_skinned_button_move_relative(playlistwin_shade, dx, 0); @@ -698,23 +685,13 @@ playlistwin_bg = gdk_pixmap_new(playlistwin->window, width, height, -1); playlistwin_set_mask(); - widget_list_lock(playlistwin_wlist); GList *iter; for (iter = GTK_FIXED (SKINNED_WINDOW(playlistwin)->fixed)->children; iter; iter = g_list_next (iter)) { GtkFixedChild *child_data = (GtkFixedChild *) iter->data; GtkWidget *child = child_data->widget; g_signal_emit_by_name(child, "redraw"); } - widget_list_change_pixmap(playlistwin_wlist, playlistwin_bg); - playlistwin_draw_frame(); - widget_list_draw(playlistwin_wlist, &redraw, TRUE); - widget_list_clear_redraw(playlistwin_wlist); - - widget_list_unlock(playlistwin_wlist); g_mutex_unlock(resize_mutex); - - gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); - gdk_window_clear(playlistwin->window); } static void @@ -741,33 +718,12 @@ } else if (dock_is_moving(GTK_WINDOW(playlistwin))) dock_move_motion(GTK_WINDOW(playlistwin), event); - else - { - handle_motion_cb(playlistwin_wlist, widget, event); - draw_playlist_window(FALSE); - } gdk_flush(); while ((gevent = gdk_event_get()) != NULL) gdk_event_free(gevent); } static void -playlistwin_enter(GtkWidget * widget, - GdkEventMotion * event, - gpointer callback_data) -{ - playlistwin_list->pl_tooltips = TRUE; -} - -static void -playlistwin_leave(GtkWidget * widget, - GdkEventMotion * event, - gpointer callback_data) -{ - playlistwin_list->pl_tooltips = FALSE; -} - -static void playlistwin_show_filebrowser(void) { run_filebrowser(NO_PLAY_BUTTON); @@ -1133,22 +1089,14 @@ else cfg.timer_mode = TIMER_ELAPSED; } - else if (event->button == 2 && (event->type == GDK_BUTTON_PRESS) && - widget_contains(WIDGET(playlistwin_list), event->x, event->y)) { - gtk_selection_convert(widget, GDK_SELECTION_PRIMARY, - GDK_TARGET_STRING, event->time); - } else if (event->button == 1 && event->type == GDK_BUTTON_PRESS && - !ui_skinned_window_widgetlist_contained(playlistwin, event->x, - event->y) && (cfg.easy_move || event->y < 14)) { dock_move_press(dock_window_list, GTK_WINDOW(playlistwin), event, FALSE); gtk_window_present(GTK_WINDOW(playlistwin)); } - else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && - !ui_skinned_window_widgetlist_contained(playlistwin, event->x, event->y) + else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && event->y < 14) { /* double click on title bar */ playlistwin_shade_toggle(); @@ -1157,7 +1105,6 @@ return TRUE; } else if (event->button == 3 && - !(widget_contains(WIDGET(playlistwin_list), event->x, event->y) || (event->y >= cfg.playlist_height - 29 && event->y < cfg.playlist_height - 11 && ((event->x >= 12 && event->x < 37) || @@ -1165,7 +1112,7 @@ (event->x >= 70 && event->x < 95) || (event->x >= 99 && event->x < 124) || (event->x >= playlistwin_get_width() - 46 && - event->x < playlistwin_get_width() - 23))))) { + event->x < playlistwin_get_width() - 23)))) { /* * Pop up the main menu a few pixels down to avoid * anything to be selected initially. @@ -1174,21 +1121,10 @@ event->y_root + 2, 3, event->time); grab = FALSE; } - else if (event->button == 3 && - widget_contains(WIDGET(playlistwin_list), event->x, event->y)) { - handle_press_cb(playlistwin_wlist, widget, event); - ui_manager_popup_menu_show(GTK_MENU(playlistwin_popup_menu), - event->x_root, event->y_root + 5, - event->button, event->time); - grab = FALSE; - } else if (event->button == 1 && (event->state & GDK_MOD1_MASK)) { GList *node; - handle_press_cb(playlistwin_wlist, widget, event); - draw_playlist_window(FALSE); - node = playlist_get_selected(playlist); if (node != NULL) @@ -1199,10 +1135,6 @@ grab = FALSE; } - else { - handle_press_cb(playlistwin_wlist, widget, event); - draw_playlist_window(FALSE); - } if (grab) gdk_pointer_grab(playlistwin->window, FALSE, @@ -1215,28 +1147,6 @@ } static gboolean -playlistwin_focus_in(GtkWidget * widget, GdkEvent * event, gpointer data) -{ - draw_playlist_window(TRUE); - return FALSE; -} - -static gboolean -playlistwin_focus_out(GtkWidget * widget, - GdkEventButton * event, gpointer data) -{ - draw_playlist_window(TRUE); - return FALSE; -} - -void -playlistwin_set_back_pixmap(void) -{ - gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); - gdk_window_clear(playlistwin->window); -} - -static gboolean playlistwin_delete(GtkWidget * w, gpointer data) { playlistwin_hide(); @@ -1244,7 +1154,7 @@ } static void -playlistwin_keypress_up_down_handler(PlayList_List * pl, +playlistwin_keypress_up_down_handler(UiSkinnedPlaylist * pl, gboolean up, guint state) { Playlist *playlist = playlist_get_active(); @@ -1254,52 +1164,52 @@ if (!(state & GDK_MOD1_MASK)) playlist_select_all(playlist, FALSE); - if (pl->pl_prev_selected == -1 || - (!playlistwin_item_visible(pl->pl_prev_selected) && - !(state & GDK_SHIFT_MASK && pl->pl_prev_min != -1))) { - pl->pl_prev_selected = pl->pl_first; + if (pl->prev_selected == -1 || + (!playlistwin_item_visible(pl->prev_selected) && + !(state & GDK_SHIFT_MASK && pl->prev_min != -1))) { + pl->prev_selected = pl->first; } else if (state & GDK_SHIFT_MASK) { - if (pl->pl_prev_min == -1) { - pl->pl_prev_max = pl->pl_prev_selected; - pl->pl_prev_min = pl->pl_prev_selected; + if (pl->prev_min == -1) { + pl->prev_max = pl->prev_selected; + pl->prev_min = pl->prev_selected; } - pl->pl_prev_max += (up ? -1 : 1); - pl->pl_prev_max = - CLAMP(pl->pl_prev_max, 0, playlist_get_length(playlist) - 1); + pl->prev_max += (up ? -1 : 1); + pl->prev_max = + CLAMP(pl->prev_max, 0, playlist_get_length(playlist) - 1); - pl->pl_first = MIN(pl->pl_first, pl->pl_prev_max); - pl->pl_first = MAX(pl->pl_first, pl->pl_prev_max - - pl->pl_num_visible + 1); - playlist_select_range(playlist, pl->pl_prev_min, pl->pl_prev_max, TRUE); + pl->first = MIN(pl->first, pl->prev_max); + pl->first = MAX(pl->first, pl->prev_max - + pl->num_visible + 1); + playlist_select_range(playlist, pl->prev_min, pl->prev_max, TRUE); return; } else if (state & GDK_MOD1_MASK) { if (up) - playlist_list_move_up(pl); + ui_skinned_playlist_move_up(pl); else - playlist_list_move_down(pl); - if (pl->pl_prev_min < pl->pl_first) - pl->pl_first = pl->pl_prev_min; - else if (pl->pl_prev_max >= (pl->pl_first + pl->pl_num_visible)) - pl->pl_first = pl->pl_prev_max - pl->pl_num_visible + 1; + ui_skinned_playlist_move_down(pl); + if (pl->prev_min < pl->first) + pl->first = pl->prev_min; + else if (pl->prev_max >= (pl->first + pl->num_visible)) + pl->first = pl->prev_max - pl->num_visible + 1; return; } else if (up) - pl->pl_prev_selected--; + pl->prev_selected--; else - pl->pl_prev_selected++; + pl->prev_selected++; - pl->pl_prev_selected = - CLAMP(pl->pl_prev_selected, 0, playlist_get_length(playlist) - 1); + pl->prev_selected = + CLAMP(pl->prev_selected, 0, playlist_get_length(playlist) - 1); - if (pl->pl_prev_selected < pl->pl_first) - pl->pl_first--; - else if (pl->pl_prev_selected >= (pl->pl_first + pl->pl_num_visible)) - pl->pl_first++; + if (pl->prev_selected < pl->first) + pl->first--; + else if (pl->prev_selected >= (pl->first + pl->num_visible)) + pl->first++; - playlist_select_range(playlist, pl->pl_prev_selected, pl->pl_prev_selected, TRUE); - pl->pl_prev_min = -1; + playlist_select_range(playlist, pl->prev_selected, pl->prev_selected, TRUE); + pl->prev_min = -1; } /* FIXME: Handle the keys through menu */ @@ -1320,33 +1230,33 @@ case GDK_KP_Down: case GDK_Up: case GDK_Down: - playlistwin_keypress_up_down_handler(playlistwin_list, + playlistwin_keypress_up_down_handler(UI_SKINNED_PLAYLIST(playlistwin_list), keyval == GDK_Up || keyval == GDK_KP_Up, event->state); refresh = TRUE; break; case GDK_Page_Up: - playlistwin_scroll(-playlistwin_list->pl_num_visible); + playlistwin_scroll(-UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible); refresh = TRUE; break; case GDK_Page_Down: - playlistwin_scroll(playlistwin_list->pl_num_visible); + playlistwin_scroll(UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible); refresh = TRUE; break; case GDK_Home: - playlistwin_list->pl_first = 0; + UI_SKINNED_PLAYLIST(playlistwin_list)->first = 0; refresh = TRUE; break; case GDK_End: - playlistwin_list->pl_first = - playlist_get_length(playlist) - playlistwin_list->pl_num_visible; + UI_SKINNED_PLAYLIST(playlistwin_list)->first = + playlist_get_length(playlist) - UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible; refresh = TRUE; break; case GDK_Return: - if (playlistwin_list->pl_prev_selected > -1 - && playlistwin_item_visible(playlistwin_list->pl_prev_selected)) { - playlist_set_position(playlist, playlistwin_list->pl_prev_selected); + if (UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected > -1 + && playlistwin_item_visible(UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected)) { + playlist_set_position(playlist, UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected); if (!playback_get_playing()) playback_initiate(); } @@ -1405,69 +1315,6 @@ return TRUE; } -static void -playlistwin_draw_frame(void) -{ - gboolean focus = - gtk_window_has_toplevel_focus(GTK_WINDOW(playlistwin)) || - !cfg.dim_titlebar; - - if (cfg.playlist_shaded) { - skin_draw_playlistwin_shaded(bmp_active_skin, - playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, - playlistwin_get_width(), focus); - } - else { - skin_draw_playlistwin_frame(bmp_active_skin, - playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, - playlistwin_get_width(), - cfg.playlist_height, focus); - } -} - -void -draw_playlist_window(gboolean force) -{ - gboolean redraw; - GList *wl; - Widget *w; - - if (force) - playlistwin_draw_frame(); - - widget_list_lock(playlistwin_wlist); - widget_list_draw(playlistwin_wlist, &redraw, force); - - if (redraw || force) { - if (force) { - widget_list_unlock(playlistwin_wlist); - gdk_window_clear(playlistwin->window); - GList *iter; - for (iter = GTK_FIXED (SKINNED_WINDOW(playlistwin)->fixed)->children; iter; iter = g_list_next (iter)) { - GtkFixedChild *child_data = (GtkFixedChild *) iter->data; - GtkWidget *child = child_data->widget; - gtk_widget_queue_draw(child); - } - } - else { - for (wl = playlistwin_wlist; wl; wl = g_list_next(wl)) { - w = WIDGET(wl->data); - if (w->redraw && w->visible) { - gdk_window_clear_area(playlistwin->window, w->x, w->y, - w->width, w->height); - w->redraw = FALSE; - } - } - widget_list_unlock(playlistwin_wlist); - } - - gdk_flush(); - } - - widget_list_unlock(playlistwin_wlist); -} - - void playlistwin_hide_timer(void) { @@ -1510,9 +1357,9 @@ GtkSelectionData * selection_data, guint info, guint time, gpointer user_data) { - playlistwin_list->pl_drag_motion = TRUE; - playlistwin_list->drag_motion_x = x; - playlistwin_list->drag_motion_y = y; + UI_SKINNED_PLAYLIST(playlistwin_list)->drag_motion = TRUE; + UI_SKINNED_PLAYLIST(playlistwin_list)->drag_motion_x = x; + UI_SKINNED_PLAYLIST(playlistwin_list)->drag_motion_y = y; playlistwin_update_list(playlist_get_active()); playlistwin_hint_flag = TRUE; } @@ -1521,7 +1368,7 @@ playlistwin_drag_end(GtkWidget * widget, GdkDragContext * context, gpointer user_data) { - playlistwin_list->pl_drag_motion = FALSE; + UI_SKINNED_PLAYLIST(playlistwin_list)->drag_motion = FALSE; playlistwin_hint_flag = FALSE; playlistwin_update_list(playlist_get_active()); } @@ -1543,10 +1390,8 @@ g_message("Received no DND data!"); return; } - - if (widget_contains(WIDGET(playlistwin_list), x, y)) { - pos = (y - WIDGET(playlistwin_list)->y) / - playlistwin_list->pl_fheight + playlistwin_list->pl_first; + if (x < playlistwin_get_width() - 20 || y < cfg.playlist_height - 38) { + pos = y / UI_SKINNED_PLAYLIST(playlistwin_list)->fheight + UI_SKINNED_PLAYLIST(playlistwin_list)->first; pos = MIN(pos, playlist_get_length(playlist)); playlist_ins_url(playlist, (gchar *) selection_data->data, pos); @@ -1601,13 +1446,10 @@ g_signal_connect(playlistwin_close, "clicked", playlistwin_hide, NULL ); /* playlist list box */ - playlistwin_list = - create_playlist_list(&playlistwin_wlist, playlistwin_bg, - SKINNED_WINDOW(playlistwin)->gc, 12, 20, + playlistwin_list = ui_skinned_playlist_new(SKINNED_WINDOW(playlistwin)->fixed, 12, 20, playlistwin_get_width() - 31, cfg.playlist_height - 58); - playlist_list_set_font(cfg.playlist_font); - ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_list)); + ui_skinned_playlist_set_font(cfg.playlist_font); /* playlist list box slider */ playlistwin_slider = ui_skinned_playlist_slider_new(SKINNED_WINDOW(playlistwin)->fixed, playlistwin_get_width() - 15, @@ -1738,16 +1580,6 @@ G_CALLBACK(playlistwin_scrolled), NULL); g_signal_connect(playlistwin, "motion_notify_event", G_CALLBACK(playlistwin_motion), NULL); - g_signal_connect(playlistwin, "enter_notify_event", - G_CALLBACK(playlistwin_enter), NULL); - g_signal_connect(playlistwin, "leave_notify_event", - G_CALLBACK(playlistwin_leave), NULL); - g_signal_connect_after(playlistwin, "focus_in_event", - G_CALLBACK(playlistwin_focus_in), NULL); - g_signal_connect_after(playlistwin, "focus_out_event", - G_CALLBACK(playlistwin_focus_out), NULL); - g_signal_connect(playlistwin, "style_set", - G_CALLBACK(playlistwin_set_back_pixmap), NULL); bmp_drag_dest_set(playlistwin); @@ -1779,12 +1611,6 @@ resize_mutex = g_mutex_new(); playlistwin_create_window(); - /* create GC and back pixmap for custom widget to draw on */ - playlistwin_bg = gdk_pixmap_new(playlistwin->window, - playlistwin_get_width(), - playlistwin_get_height_unshaded(), -1); - gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); - playlistwin_create_widgets(); playlistwin_update_info(playlist_get_active()); @@ -2182,13 +2008,13 @@ win = gdk_window_at_pointer(NULL, NULL); gdk_window_get_pointer(GDK_WINDOW(playlistwin->window), &x, &y, NULL); - pos = playlist_list_get_playlist_position(playlistwin_list, x, y); + pos = ui_skinned_playlist_get_position(playlistwin_list, x - 12, y - 20); if (win == NULL || cfg.show_filepopup_for_tuple == FALSE - || playlistwin_list->pl_tooltips == FALSE + || UI_SKINNED_PLAYLIST(playlistwin_list)->tooltips == FALSE || pos != prev_pos - || win != GDK_WINDOW(playlistwin->window)) + || win != playlistwin_list->window) { prev_pos = pos; ctr = 0;
--- a/src/audacious/ui_playlist.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_playlist.h Fri Aug 03 20:39:42 2007 -0500 @@ -61,7 +61,6 @@ void playlistwin_set_shade(gboolean shaded); void playlistwin_shade_toggle(void); void playlistwin_create(void); -void draw_playlist_window(gboolean force); void playlistwin_hide_timer(void); void playlistwin_set_time(gint time, gint length, TimerMode mode); void playlistwin_show(void); @@ -77,7 +76,7 @@ gint playlistwin_list_get_first(void); extern GtkWidget *playlistwin; -extern PlayList_List *playlistwin_list; +extern GtkWidget *playlistwin_list; extern gboolean playlistwin_focus;
--- a/src/audacious/ui_preferences.c Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_preferences.c Fri Aug 03 20:39:42 2007 -0500 @@ -61,6 +61,8 @@ #include "ui_skinselector.h" #include "ui_preferences.h" #include "ui_equalizer.h" +#include "ui_skinned_playlist.h" +#include "ui_skinned_window.h" #include "build_stamp.h" @@ -890,7 +892,6 @@ cfg.mainwin_font = g_strdup(gtk_font_button_get_font_name(button)); ui_skinned_textbox_set_xfont(mainwin_info, cfg.mainwin_use_xfont, cfg.mainwin_font); - draw_main_window(TRUE); } static void @@ -910,10 +911,9 @@ ui_skinned_textbox_set_xfont(mainwin_info, cfg.mainwin_use_xfont, cfg.mainwin_font); playlistwin_set_sinfo_font(cfg.playlist_font); - draw_main_window(TRUE); if (cfg.playlist_shaded) { playlistwin_update_list(playlist_get_active()); - draw_playlist_window(TRUE); + ui_skinned_window_draw_all(playlistwin); } } @@ -931,10 +931,10 @@ g_free(cfg.playlist_font); cfg.playlist_font = g_strdup(gtk_font_button_get_font_name(button)); - playlist_list_set_font(cfg.playlist_font); + ui_skinned_playlist_set_font(cfg.playlist_font); playlistwin_set_sinfo_font(cfg.playlist_font); /* propagate font setting to playlistwin_sinfo */ playlistwin_update_list(playlist_get_active()); - draw_playlist_window(TRUE); + gtk_widget_queue_draw(playlistwin_list); } static void @@ -957,7 +957,7 @@ { cfg.show_numbers_in_pl = gtk_toggle_button_get_active(button); playlistwin_update_list(playlist_get_active()); - draw_playlist_window(TRUE); + gtk_widget_queue_draw(playlistwin_list); } static void @@ -973,7 +973,7 @@ { cfg.show_separator_in_pl = gtk_toggle_button_get_active(button); playlistwin_update_list(playlist_get_active()); - draw_playlist_window(TRUE); + gtk_widget_queue_draw(playlistwin_list); } /* format detection */ @@ -2131,9 +2131,9 @@ /* reload the skin to apply the change */ skin_reload_forced(); - draw_main_window(TRUE); - draw_equalizer_window(TRUE); - draw_playlist_window(TRUE); + ui_skinned_window_draw_all(mainwin); + ui_skinned_window_draw_all(equalizerwin); + ui_skinned_window_draw_all(playlistwin); } } @@ -2152,9 +2152,9 @@ /* reload the skin to apply the change */ skin_reload_forced(); - draw_main_window(TRUE); - draw_equalizer_window(TRUE); - draw_playlist_window(TRUE); + ui_skinned_window_draw_all(mainwin); + ui_skinned_window_draw_all(equalizerwin); + ui_skinned_window_draw_all(playlistwin); } } @@ -2173,9 +2173,9 @@ /* reload the skin to apply the change */ skin_reload_forced(); - draw_main_window(TRUE); - draw_equalizer_window(TRUE); - draw_playlist_window(TRUE); + ui_skinned_window_draw_all(mainwin); + ui_skinned_window_draw_all(equalizerwin); + ui_skinned_window_draw_all(playlistwin); } }
--- a/src/audacious/ui_skinned_button.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_skinned_button.h Fri Aug 03 20:39:42 2007 -0500 @@ -21,6 +21,8 @@ #ifndef UISKINNEDBUTTON_H #define UISKINNEDBUTTON_H +#include <gtk/gtk.h> + #define UI_SKINNED_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ui_skinned_button_get_type(), UiSkinnedButton)) #define UI_SKINNED_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ui_skinned_button_get_type(), UiSkinnedButtonClass)) #define UI_SKINNED_IS_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ui_skinned_button_get_type()))
--- a/src/audacious/ui_skinned_equalizer_graph.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_skinned_equalizer_graph.h Fri Aug 03 20:39:42 2007 -0500 @@ -27,6 +27,8 @@ #ifndef UISKINNEDEQUALIZERGRAPH_H #define UISKINNEDEQUALIZERGRAPH_H +#include <gtk/gtk.h> + #ifdef __cplusplus extern "C" { #endif
--- a/src/audacious/ui_skinned_equalizer_slider.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_skinned_equalizer_slider.h Fri Aug 03 20:39:42 2007 -0500 @@ -24,6 +24,8 @@ #ifndef UISKINNEDEQUALIZER_SLIDER_H #define UISKINNEDEQUALIZER_SLIDER_H +#include <gtk/gtk.h> + #ifdef __cplusplus extern "C" { #endif
--- a/src/audacious/ui_skinned_horizontal_slider.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_skinned_horizontal_slider.h Fri Aug 03 20:39:42 2007 -0500 @@ -27,6 +27,8 @@ #ifndef UISKINNEDHORIZONTAL_SLIDER_H #define UISKINNEDHORIZONTAL_SLIDER_H +#include <gtk/gtk.h> + #ifdef __cplusplus extern "C" { #endif
--- a/src/audacious/ui_skinned_menurow.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_skinned_menurow.h Fri Aug 03 20:39:42 2007 -0500 @@ -27,6 +27,8 @@ #ifndef UISKINNEDMENUROW_H #define UISKINNEDMENUROW_H +#include <gtk/gtk.h> + #ifdef __cplusplus extern "C" { #endif
--- a/src/audacious/ui_skinned_monostereo.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_skinned_monostereo.h Fri Aug 03 20:39:42 2007 -0500 @@ -27,6 +27,8 @@ #ifndef UISKINNEDMONOSTEREO_H #define UISKINNEDMONOSTEREO_H +#include <gtk/gtk.h> + #ifdef __cplusplus extern "C" { #endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/ui_skinned_playlist.c Fri Aug 03 20:39:42 2007 -0500 @@ -0,0 +1,974 @@ +/* + * Audacious - a cross-platform multimedia player + * Copyright (c) 2007 Audacious development team. + * + * Based on: + * BMP - Cross-platform multimedia player + * Copyright (C) 2003-2004 BMP development team. + * XMMS: + * Copyright (C) 1998-2003 XMMS 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; under version 3 of the License. + * + * 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, see <http://www.gnu.org/licenses>. + * + * The Audacious team does not consider modular code linking to + * Audacious or using our public API to be a derived work. + */ + +/* + * A note about Pango and some funky spacey fonts: Weirdly baselined + * fonts, or fonts with weird ascents or descents _will_ display a + * little bit weird in the playlist widget, but the display engine + * won't make it look too bad, just a little deranged. I honestly + * don't think it's worth fixing (around...), it doesn't have to be + * perfectly fitting, just the general look has to be ok, which it + * IMHO is. + * + * A second note: The numbers aren't perfectly aligned, but in the + * end it looks better when using a single Pango layout for each + * number. + */ + + +#include "widgets/widgetcore.h" +#include "ui_skinned_playlist.h" +#include "main.h" +#include "util.h" +#include "ui_playlist.h" + +#include "input.h" +#include "strings.h" +#include "playback.h" +#include "playlist.h" +#include "ui_manager.h" + +#include "debug.h" +static PangoFontDescription *playlist_list_font = NULL; +static gint ascent, descent, width_delta_digit_one; +static gboolean has_slant; +static guint padding; + +/* FIXME: the following globals should not be needed. */ +static gint width_approx_letters; +static gint width_colon, width_colon_third; +static gint width_approx_digits, width_approx_digits_half; + +#define UI_SKINNED_PLAYLIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ui_skinned_playlist_get_type(), UiSkinnedPlaylistPrivate)) +typedef struct _UiSkinnedPlaylistPrivate UiSkinnedPlaylistPrivate; + +enum { + REDRAW, + LAST_SIGNAL +}; + +struct _UiSkinnedPlaylistPrivate { + GtkWidget *fixed; + SkinPixmapId skin_index; + gint width, height; + gint resize_width, resize_height; + gint drag_pos; + gboolean dragging, auto_drag_down, auto_drag_up; + gint auto_drag_up_tag, auto_drag_down_tag; +}; + +static void ui_skinned_playlist_class_init (UiSkinnedPlaylistClass *klass); +static void ui_skinned_playlist_init (UiSkinnedPlaylist *playlist); +static void ui_skinned_playlist_destroy (GtkObject *object); +static void ui_skinned_playlist_realize (GtkWidget *widget); +static void ui_skinned_playlist_size_request (GtkWidget *widget, GtkRequisition *requisition); +static void ui_skinned_playlist_size_allocate (GtkWidget *widget, GtkAllocation *allocation); +static gboolean ui_skinned_playlist_expose (GtkWidget *widget, GdkEventExpose *event); +static gboolean ui_skinned_playlist_button_press (GtkWidget *widget, GdkEventButton *event); +static gboolean ui_skinned_playlist_button_release (GtkWidget *widget, GdkEventButton *event); +static gboolean ui_skinned_playlist_motion_notify (GtkWidget *widget, GdkEventMotion *event); +static void ui_skinned_playlist_redraw (UiSkinnedPlaylist *playlist); + +static GtkWidgetClass *parent_class = NULL; +static guint playlist_signals[LAST_SIGNAL] = { 0 }; + +GType ui_skinned_playlist_get_type() { + static GType playlist_type = 0; + if (!playlist_type) { + static const GTypeInfo playlist_info = { + sizeof (UiSkinnedPlaylistClass), + NULL, + NULL, + (GClassInitFunc) ui_skinned_playlist_class_init, + NULL, + NULL, + sizeof (UiSkinnedPlaylist), + 0, + (GInstanceInitFunc) ui_skinned_playlist_init, + }; + playlist_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedPlaylist", &playlist_info, 0); + } + + return playlist_type; +} + +static void ui_skinned_playlist_class_init(UiSkinnedPlaylistClass *klass) { + GObjectClass *gobject_class; + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + + gobject_class = G_OBJECT_CLASS(klass); + object_class = (GtkObjectClass*) klass; + widget_class = (GtkWidgetClass*) klass; + parent_class = gtk_type_class (gtk_widget_get_type ()); + + object_class->destroy = ui_skinned_playlist_destroy; + + widget_class->realize = ui_skinned_playlist_realize; + widget_class->expose_event = ui_skinned_playlist_expose; + widget_class->size_request = ui_skinned_playlist_size_request; + widget_class->size_allocate = ui_skinned_playlist_size_allocate; + widget_class->button_press_event = ui_skinned_playlist_button_press; + widget_class->button_release_event = ui_skinned_playlist_button_release; + widget_class->motion_notify_event = ui_skinned_playlist_motion_notify; + + klass->redraw = ui_skinned_playlist_redraw; + + playlist_signals[REDRAW] = + g_signal_new ("redraw", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (UiSkinnedPlaylistClass, redraw), NULL, NULL, + gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); + + g_type_class_add_private (gobject_class, sizeof (UiSkinnedPlaylistPrivate)); +} + +static void ui_skinned_playlist_init(UiSkinnedPlaylist *playlist) { + UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(playlist); + playlist->pressed = FALSE; + priv->resize_width = 0; + priv->resize_height = 0; + playlist->prev_selected = -1; + playlist->prev_min = -1; + playlist->prev_max = -1; + playlist->tooltips = TRUE; +} + +GtkWidget* ui_skinned_playlist_new(GtkWidget *fixed, gint x, gint y, gint w, gint h) { + + UiSkinnedPlaylist *hs = g_object_new (ui_skinned_playlist_get_type (), NULL); + UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(hs); + + hs->x = x; + hs->y = y; + priv->width = w; + priv->height = h; + priv->fixed = fixed; + priv->skin_index = SKIN_PLEDIT; + + gtk_fixed_put(GTK_FIXED(priv->fixed), GTK_WIDGET(hs), hs->x, hs->y); + + return GTK_WIDGET(hs); +} + +static void ui_skinned_playlist_destroy(GtkObject *object) { + UiSkinnedPlaylist *playlist; + + g_return_if_fail (object != NULL); + g_return_if_fail (UI_SKINNED_IS_PLAYLIST (object)); + + playlist = UI_SKINNED_PLAYLIST (object); + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + +static void ui_skinned_playlist_realize(GtkWidget *widget) { + UiSkinnedPlaylist *playlist; + GdkWindowAttr attributes; + gint attributes_mask; + + g_return_if_fail (widget != NULL); + g_return_if_fail (UI_SKINNED_IS_PLAYLIST(widget)); + + GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); + playlist = UI_SKINNED_PLAYLIST(widget); + + attributes.x = widget->allocation.x; + attributes.y = widget->allocation.y; + attributes.width = widget->allocation.width; + attributes.height = widget->allocation.height; + attributes.wclass = GDK_INPUT_OUTPUT; + attributes.window_type = GDK_WINDOW_CHILD; + attributes.event_mask = gtk_widget_get_events(widget); + attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK; + attributes.visual = gtk_widget_get_visual(widget); + attributes.colormap = gtk_widget_get_colormap(widget); + + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; + widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask); + + widget->style = gtk_style_attach(widget->style, widget->window); + gdk_window_set_user_data(widget->window, widget); +} + +static void ui_skinned_playlist_size_request(GtkWidget *widget, GtkRequisition *requisition) { + UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(widget); + + requisition->width = priv->width; + requisition->height = priv->height; +} + +static void ui_skinned_playlist_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { + UiSkinnedPlaylist *playlist = UI_SKINNED_PLAYLIST (widget); + UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(playlist); + + widget->allocation = *allocation; + if (GTK_WIDGET_REALIZED (widget)) + gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); + + playlist->x = widget->allocation.x; + playlist->y = widget->allocation.y; + + if (priv->height != widget->allocation.height || priv->width != widget->allocation.width) { + priv->width = priv->width + priv->resize_width; + priv->height = priv->height + priv->resize_height; + priv->resize_width = 0; + priv->resize_height = 0; + gtk_widget_queue_draw(widget); + } +} + +static gboolean ui_skinned_playlist_auto_drag_down_func(gpointer data) { + UiSkinnedPlaylist *pl = UI_SKINNED_PLAYLIST(data); + UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(data); + + if (priv->auto_drag_down) { + ui_skinned_playlist_move_down(pl); + pl->first++; + playlistwin_update_list(playlist_get_active()); + return TRUE; + } + return FALSE; +} + +static gboolean ui_skinned_playlist_auto_drag_up_func(gpointer data) { + UiSkinnedPlaylist *pl = UI_SKINNED_PLAYLIST(data); + UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(data); + + if (priv->auto_drag_up) { + ui_skinned_playlist_move_up(pl); + pl->first--; + playlistwin_update_list(playlist_get_active()); + return TRUE; + + } + return FALSE; +} + +void ui_skinned_playlist_move_up(UiSkinnedPlaylist * pl) { + GList *list; + Playlist *playlist = playlist_get_active(); + + if (!playlist) + return; + + PLAYLIST_LOCK(playlist->mutex); + if ((list = playlist->entries) == NULL) { + PLAYLIST_UNLOCK(playlist->mutex); + return; + } + if (PLAYLIST_ENTRY(list->data)->selected) { + /* We are at the top */ + PLAYLIST_UNLOCK(playlist->mutex); + return; + } + while (list) { + if (PLAYLIST_ENTRY(list->data)->selected) + glist_moveup(list); + list = g_list_next(list); + } + PLAYLIST_UNLOCK(playlist->mutex); + if (pl->prev_selected != -1) + pl->prev_selected--; + if (pl->prev_min != -1) + pl->prev_min--; + if (pl->prev_max != -1) + pl->prev_max--; +} + +void ui_skinned_playlist_move_down(UiSkinnedPlaylist * pl) { + GList *list; + Playlist *playlist = playlist_get_active(); + + if (!playlist) + return; + + PLAYLIST_LOCK(playlist->mutex); + + if (!(list = g_list_last(playlist->entries))) { + PLAYLIST_UNLOCK(playlist->mutex); + return; + } + + if (PLAYLIST_ENTRY(list->data)->selected) { + /* We are at the bottom */ + PLAYLIST_UNLOCK(playlist->mutex); + return; + } + + while (list) { + if (PLAYLIST_ENTRY(list->data)->selected) + glist_movedown(list); + list = g_list_previous(list); + } + + PLAYLIST_UNLOCK(playlist->mutex); + + if (pl->prev_selected != -1) + pl->prev_selected++; + if (pl->prev_min != -1) + pl->prev_min++; + if (pl->prev_max != -1) + pl->prev_max++; +} + +static void +playlist_list_draw_string(GdkPixmap *obj, GdkGC *gc, UiSkinnedPlaylist *pl, + PangoFontDescription * font, + gint line, + gint width, + const gchar * text, + guint ppos) +{ + guint plist_length_int; + Playlist *playlist = playlist_get_active(); + PangoLayout *layout; + + REQUIRE_LOCK(playlist->mutex); + + if (cfg.show_numbers_in_pl) { + gchar *pos_string = g_strdup_printf(cfg.show_separator_in_pl == TRUE ? "%d" : "%d.", ppos); + plist_length_int = + gint_count_digits(playlist_get_length(playlist)) + !cfg.show_separator_in_pl + 1; /* cf.show_separator_in_pl will be 0 if false */ + + padding = plist_length_int; + padding = ((padding + 1) * width_approx_digits); + + layout = gtk_widget_create_pango_layout(playlistwin, pos_string); + pango_layout_set_font_description(layout, playlist_list_font); + pango_layout_set_width(layout, plist_length_int * 100); + + pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT); + + + gdk_draw_layout(obj, gc, (width_approx_digits * + (-1 + plist_length_int - strlen(pos_string))) + + (width_approx_digits / 4), + (line - 1) * pl->fheight + + ascent + abs(descent), layout); + g_free(pos_string); + g_object_unref(layout); + + if (!cfg.show_separator_in_pl) + padding -= (width_approx_digits * 1.5); + } else { + padding = 3; + } + + width -= padding; + + layout = gtk_widget_create_pango_layout(playlistwin, text); + + pango_layout_set_font_description(layout, playlist_list_font); + pango_layout_set_width(layout, width * PANGO_SCALE); + pango_layout_set_single_paragraph_mode(layout, TRUE); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); + gdk_draw_layout(obj, gc, + padding + (width_approx_letters / 4), + (line - 1) * pl->fheight + + ascent + abs(descent), layout); + + g_object_unref(layout); +} + +static gboolean ui_skinned_playlist_expose(GtkWidget *widget, GdkEventExpose *event) { + g_return_val_if_fail (widget != NULL, FALSE); + g_return_val_if_fail (UI_SKINNED_IS_PLAYLIST (widget), FALSE); + g_return_val_if_fail (event != NULL, FALSE); + + UiSkinnedPlaylist *pl = UI_SKINNED_PLAYLIST (widget); + UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(pl); + + Playlist *playlist = playlist_get_active(); + GList *list; + PangoLayout *layout; + gchar *title; + gint width, height; + gint i, max_first; + guint padding, padding_dwidth, padding_plength; + guint max_time_len = 0; + gfloat queue_tailpadding = 0; + gint tpadding; + gsize tpadding_dwidth = 0; + gint x, y; + guint tail_width; + guint tail_len; + + gchar tail[100]; + gchar queuepos[255]; + gchar length[40]; + + gchar **frags; + gchar *frag0; + + gint plw_w, plw_h; + + GdkPixmap *obj = NULL; + GdkGC *gc; + + obj = gdk_pixmap_new(NULL, priv->width, priv->height, gdk_rgb_get_visual()->depth); + gc = gdk_gc_new(obj); + + GdkRectangle *playlist_rect; + + width = priv->width; + height = priv->height; + + plw_w = playlistwin_get_width(); + plw_h = playlistwin_get_height(); + + playlist_rect = g_new0(GdkRectangle, 1); + + playlist_rect->x = 0; + playlist_rect->y = 0; + playlist_rect->width = plw_w - 17; + playlist_rect->height = plw_h - 36; + + gdk_gc_set_clip_origin(gc, 31, 58); + gdk_gc_set_clip_rectangle(gc, playlist_rect); + + gdk_gc_set_foreground(gc, + skin_get_color(bmp_active_skin, + SKIN_PLEDIT_NORMALBG)); + gdk_draw_rectangle(obj, gc, TRUE, 0, 0, + width, height); + + if (!playlist_list_font) { + g_critical("Couldn't open playlist font"); + return FALSE; + } + + pl->fheight = (ascent + abs(descent)); + pl->num_visible = height / pl->fheight; + + max_first = playlist_get_length(playlist) - pl->num_visible; + max_first = MAX(max_first, 0); + + pl->first = CLAMP(pl->first, 0, max_first); + + PLAYLIST_LOCK(playlist->mutex); + list = playlist->entries; + list = g_list_nth(list, pl->first); + + /* It sucks having to run the iteration twice but this is the only + way you can reliably get the maximum width so we can get our + playlist nice and aligned... -- plasmaroo */ + + for (i = pl->first; + list && i < pl->first + pl->num_visible; + list = g_list_next(list), i++) { + PlaylistEntry *entry = list->data; + + if (entry->length != -1) + { + g_snprintf(length, sizeof(length), "%d:%-2.2d", + entry->length / 60000, (entry->length / 1000) % 60); + tpadding_dwidth = MAX(tpadding_dwidth, strlen(length)); + } + } + + /* Reset */ + list = playlist->entries; + list = g_list_nth(list, pl->first); + + for (i = pl->first; + list && i < pl->first + pl->num_visible; + list = g_list_next(list), i++) { + gint pos; + PlaylistEntry *entry = list->data; + + if (entry->selected) { + gdk_gc_set_foreground(gc, + skin_get_color(bmp_active_skin, + SKIN_PLEDIT_SELECTEDBG)); + gdk_draw_rectangle(obj, gc, TRUE, 0, + ((i - pl->first) * pl->fheight), + width, pl->fheight); + } + + /* FIXME: entry->title should NEVER be NULL, and there should + NEVER be a need to do a UTF-8 conversion. Playlist title + strings should be kept properly. */ + + if (!entry->title) { + gchar *realfn = g_filename_from_uri(entry->filename, NULL, NULL); + gchar *basename = g_path_get_basename(realfn ? realfn : entry->filename); + title = filename_to_utf8(basename); + g_free(basename); g_free(realfn); + } + else + title = str_to_utf8(entry->title); + + title = convert_title_text(title); + + pos = playlist_get_queue_position(playlist, entry); + + tail[0] = 0; + queuepos[0] = 0; + length[0] = 0; + + if (pos != -1) + g_snprintf(queuepos, sizeof(queuepos), "%d", pos + 1); + + if (entry->length != -1) + { + g_snprintf(length, sizeof(length), "%d:%-2.2d", + entry->length / 60000, (entry->length / 1000) % 60); + } + + strncat(tail, length, sizeof(tail) - 1); + tail_len = strlen(tail); + + max_time_len = MAX(max_time_len, tail_len); + + if (pos != -1 && tpadding_dwidth <= 0) + tail_width = width - (width_approx_digits * (strlen(queuepos) + 2.25)); + else if (pos != -1) + tail_width = width - (width_approx_digits * (tpadding_dwidth + strlen(queuepos) + 4)); + else if (tpadding_dwidth > 0) + tail_width = width - (width_approx_digits * (tpadding_dwidth + 2.5)); + else + tail_width = width; + + if (i == playlist_get_position_nolock(playlist)) + gdk_gc_set_foreground(gc, + skin_get_color(bmp_active_skin, + SKIN_PLEDIT_CURRENT)); + else + gdk_gc_set_foreground(gc, + skin_get_color(bmp_active_skin, + SKIN_PLEDIT_NORMAL)); + playlist_list_draw_string(obj, gc, pl, playlist_list_font, + i - pl->first, tail_width, title, + i + 1); + + x = width - width_approx_digits * 2; + y = ((i - pl->first) - 1) * pl->fheight + ascent; + + frags = NULL; + frag0 = NULL; + + if ((strlen(tail) > 0) && (tail != NULL)) { + frags = g_strsplit(tail, ":", 0); + frag0 = g_strconcat(frags[0], ":", NULL); + + layout = gtk_widget_create_pango_layout(playlistwin, frags[1]); + pango_layout_set_font_description(layout, playlist_list_font); + pango_layout_set_width(layout, tail_len * 100); + pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT); + gdk_draw_layout(obj, gc, x - (0.5 * width_approx_digits), + y + abs(descent), layout); + g_object_unref(layout); + + layout = gtk_widget_create_pango_layout(playlistwin, frag0); + pango_layout_set_font_description(layout, playlist_list_font); + pango_layout_set_width(layout, tail_len * 100); + pango_layout_set_alignment(layout, PANGO_ALIGN_RIGHT); + gdk_draw_layout(obj, gc, x - (0.75 * width_approx_digits), + y + abs(descent), layout); + g_object_unref(layout); + + g_free(frag0); + g_strfreev(frags); + } + + if (pos != -1) { + + /* DON'T remove the commented code yet please -- Milosz */ + + if (tpadding_dwidth > 0) + queue_tailpadding = tpadding_dwidth + 1; + else + queue_tailpadding = -0.75; + + gdk_draw_rectangle(obj, gc, FALSE, + x - + (((queue_tailpadding + + strlen(queuepos)) * + width_approx_digits) + + (width_approx_digits / 4)), + y + abs(descent), + (strlen(queuepos)) * + width_approx_digits + + (width_approx_digits / 2), + pl->fheight - 2); + + layout = + gtk_widget_create_pango_layout(playlistwin, queuepos); + pango_layout_set_font_description(layout, playlist_list_font); + pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); + + gdk_draw_layout(obj, gc, + x - + ((queue_tailpadding + + strlen(queuepos)) * width_approx_digits) + + (width_approx_digits / 4), + y + abs(descent), layout); + g_object_unref(layout); + } + + g_free(title); + } + + + /* + * Drop target hovering over the playlist, so draw some hint where the + * drop will occur. + * + * This is (currently? unfixably?) broken when dragging files from Qt/KDE apps, + * probably due to DnD signaling problems (actually i have no clue). + * + */ + + if (pl->drag_motion) { + guint pos, plength, lpadding; + gint x, y, plx, ply; + + if (cfg.show_numbers_in_pl) { + lpadding = gint_count_digits(playlist_get_length(playlist)) + 1; + lpadding = ((lpadding + 1) * width_approx_digits); + } + else { + lpadding = 3; + }; + + /* We already hold the mutex and have the playlist locked, so call + the non-locking function. */ + plength = playlist_get_length(playlist); + + x = pl->drag_motion_x; + y = pl->drag_motion_y; + + plx = pl->x; + ply = pl->y; + + if ((x > pl->x) && !(x > priv->width)) { + + if ((y > pl->y) + && !(y > (priv->height + ply))) { + + pos = ((y - pl->y) / pl->fheight) + + pl->first; + + if (pos > (plength)) { + pos = plength; + } + + gdk_gc_set_foreground(gc, + skin_get_color(bmp_active_skin, + SKIN_PLEDIT_CURRENT)); + + gdk_draw_line(obj, gc, 0, + ((pos - pl->first) * pl->fheight), + priv->width - 1, + ((pos - pl->first) * pl->fheight)); + } + + } + + /* When dropping on the borders of the playlist, outside the text area, + * files get appended at the end of the list. Show that too. + */ + + if ((y < ply) || (y > priv->height + ply)) { + if ((y >= 0) || (y <= (priv->height + ply))) { + pos = plength; + gdk_gc_set_foreground(gc, skin_get_color(bmp_active_skin, SKIN_PLEDIT_CURRENT)); + + gdk_draw_line(obj, gc, 0, ((pos - pl->first) * pl->fheight), + priv->width - 1, ((pos - pl->first) * pl->fheight)); + + } + } + } + + gdk_gc_set_foreground(gc, skin_get_color(bmp_active_skin, SKIN_PLEDIT_NORMAL)); + + if (cfg.show_numbers_in_pl) + { + padding_plength = playlist_get_length(playlist); + + if (padding_plength == 0) { + padding_dwidth = 0; + } + else { + padding_dwidth = gint_count_digits(playlist_get_length(playlist)); + } + + padding = + (padding_dwidth * + width_approx_digits) + width_approx_digits; + + + /* For italic or oblique fonts we add another half of the + * approximate width */ + if (has_slant) + padding += width_approx_digits_half; + + if (cfg.show_separator_in_pl) { + gdk_draw_line(obj, gc, padding, 0, padding, priv->height - 1); + } + } + + if (tpadding_dwidth != 0) + { + tpadding = (tpadding_dwidth * width_approx_digits) + (width_approx_digits * 1.5); + + if (has_slant) + tpadding += width_approx_digits_half; + + if (cfg.show_separator_in_pl) { + gdk_draw_line(obj, gc, priv->width - tpadding, 0, priv->width - tpadding, priv->height - 1); + } + } + + gdk_gc_set_clip_origin(gc, 0, 0); + gdk_gc_set_clip_rectangle(gc, NULL); + + PLAYLIST_UNLOCK(playlist->mutex); + + gdk_draw_drawable(widget->window, gc, obj, 0, 0, 0, 0, priv->width, priv->height); + + g_object_unref(obj); + g_object_unref(gc); + g_free(playlist_rect); + + return FALSE; +} + +gint ui_skinned_playlist_get_position(GtkWidget *widget, gint x, gint y) { + gint iy, length; + gint ret; + Playlist *playlist = playlist_get_active(); + UiSkinnedPlaylist *pl = UI_SKINNED_PLAYLIST (widget); + + if (!pl->fheight) + return -1; + + if ((length = playlist_get_length(playlist)) == 0) + return -1; + iy = y; + + ret = (iy / pl->fheight) + pl->first; + + if (ret > length - 1) + ret = -1; + + return ret; +} + +static gboolean ui_skinned_playlist_button_press(GtkWidget *widget, GdkEventButton *event) { + UiSkinnedPlaylist *pl = UI_SKINNED_PLAYLIST (widget); + UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(widget); + + if (event->button == 3) { + ui_manager_popup_menu_show(GTK_MENU(playlistwin_popup_menu), + event->x_root, event->y_root + 5, + event->button, event->time); + } + gint nr; + Playlist *playlist = playlist_get_active(); + + nr = ui_skinned_playlist_get_position(widget, event->x, event->y); + if (nr == -1) + return FALSE; + + pl->tooltips = FALSE; + if (event->button == 3) { + GList* selection = playlist_get_selected(playlist); + if (g_list_find(selection, GINT_TO_POINTER(nr)) == NULL) { + playlist_select_all(playlist, FALSE); + playlist_select_range(playlist, nr, nr, TRUE); + } + } else if (event->button == 1) { + if (!(event->state & GDK_CONTROL_MASK)) + playlist_select_all(playlist, FALSE); + + if (event->state & GDK_SHIFT_MASK && pl->prev_selected != -1) { + playlist_select_range(playlist, pl->prev_selected, nr, TRUE); + pl->prev_min = pl->prev_selected; + pl->prev_max = nr; + priv->drag_pos = nr - pl->first; + } + else { + if (playlist_select_invert(playlist, nr)) { + if (event->state & GDK_CONTROL_MASK) { + if (pl->prev_min == -1) { + pl->prev_min = pl->prev_selected; + pl->prev_max = pl->prev_selected; + } + if (nr < pl->prev_min) + pl->prev_min = nr; + else if (nr > pl->prev_max) + pl->prev_max = nr; + } + else + pl->prev_min = -1; + pl->prev_selected = nr; + priv->drag_pos = nr - pl->first; + } + } + if (event->type == GDK_2BUTTON_PRESS) { + /* + * Ungrab the pointer to prevent us from + * hanging on to it during the sometimes slow + * playback_initiate(). + */ + gdk_pointer_ungrab(GDK_CURRENT_TIME); + playlist_set_position(playlist, nr); + if (!playback_get_playing()) + playback_initiate(); + } + + priv->dragging = TRUE; + } + playlistwin_update_list(playlist); + + return TRUE; +} + +static gboolean ui_skinned_playlist_button_release(GtkWidget *widget, GdkEventButton *event) { + UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(widget); + + if (event->button == 1) { + priv->dragging = FALSE; + priv->auto_drag_down = FALSE; + priv->auto_drag_up = FALSE; + UI_SKINNED_PLAYLIST(widget)->tooltips = TRUE; + gtk_widget_queue_draw(widget); + } + return TRUE; +} + +static gboolean ui_skinned_playlist_motion_notify(GtkWidget *widget, GdkEventMotion *event) { + UiSkinnedPlaylist *pl = UI_SKINNED_PLAYLIST(widget); + UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(widget); + + gint nr, y, off, i; + if (priv->dragging) { + y = event->y; + nr = (y / pl->fheight); + if (nr < 0) { + nr = 0; + if (!priv->auto_drag_up) { + priv->auto_drag_up = TRUE; + priv->auto_drag_up_tag = + g_timeout_add(100, ui_skinned_playlist_auto_drag_up_func, pl); + } + } + else if (priv->auto_drag_up) + priv->auto_drag_up = FALSE; + + if (nr >= pl->num_visible) { + nr = pl->num_visible - 1; + if (!priv->auto_drag_down) { + priv->auto_drag_down = TRUE; + priv->auto_drag_down_tag = + g_timeout_add(100, ui_skinned_playlist_auto_drag_down_func, pl); + } + } + else if (priv->auto_drag_down) + priv->auto_drag_down = FALSE; + + off = nr - priv->drag_pos; + if (off) { + for (i = 0; i < abs(off); i++) { + if (off < 0) + ui_skinned_playlist_move_up(pl); + else + ui_skinned_playlist_move_down(pl); + + } + playlistwin_update_list(playlist_get_active()); + } + priv->drag_pos = nr; + } + return TRUE; +} + +static void ui_skinned_playlist_redraw(UiSkinnedPlaylist *playlist) { + UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(playlist); + + if (priv->resize_height || priv->resize_width) + gtk_widget_set_size_request(GTK_WIDGET(playlist), priv->width+priv->resize_width, priv->height+priv->resize_height); + + gtk_widget_queue_draw(GTK_WIDGET(playlist)); +} + +void ui_skinned_playlist_set_font(const gchar * font) { + /* Welcome to bad hack central 2k3 */ + gchar *font_lower; + gint width_temp; + gint width_temp_0; + + playlist_list_font = pango_font_description_from_string(font); + + text_get_extents(font, + "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz ", + &width_approx_letters, NULL, &ascent, &descent); + + width_approx_letters = (width_approx_letters / 53); + + /* Experimental: We don't weigh the 1 into total because it's width is almost always + * very different from the rest + */ + text_get_extents(font, "023456789", &width_approx_digits, NULL, NULL, + NULL); + width_approx_digits = (width_approx_digits / 9); + + /* Precache some often used calculations */ + width_approx_digits_half = width_approx_digits / 2; + + /* FIXME: We assume that any other number is broader than the "1" */ + text_get_extents(font, "1", &width_temp, NULL, NULL, NULL); + text_get_extents(font, "2", &width_temp_0, NULL, NULL, NULL); + + if (abs(width_temp_0 - width_temp) < 2) { + width_delta_digit_one = 0; + } + else { + width_delta_digit_one = ((width_temp_0 - width_temp) / 2) + 2; + } + + text_get_extents(font, ":", &width_colon, NULL, NULL, NULL); + width_colon_third = width_colon / 4; + + font_lower = g_utf8_strdown(font, strlen(font)); + /* This doesn't take any i18n into account, but i think there is none with TTF fonts + * FIXME: This can probably be retrieved trough Pango too + */ + has_slant = g_strstr_len(font_lower, strlen(font_lower), "oblique") + || g_strstr_len(font_lower, strlen(font_lower), "italic"); + + g_free(font_lower); +} + +void ui_skinned_playlist_resize_relative(GtkWidget *widget, gint w, gint h) { + UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(widget); + priv->resize_width += w; + priv->resize_height += h; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/ui_skinned_playlist.h Fri Aug 03 20:39:42 2007 -0500 @@ -0,0 +1,73 @@ +/* + * Audacious - a cross-platform multimedia player + * Copyright (c) 2007 Audacious development team. + * + * Based on: + * BMP - Cross-platform multimedia player + * Copyright (C) 2003-2004 BMP development team. + * XMMS: + * Copyright (C) 1998-2003 XMMS 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; under version 3 of the License. + * + * 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, see <http://www.gnu.org/licenses>. + * + * The Audacious team does not consider modular code linking to + * Audacious or using our public API to be a derived work. + */ + +#ifndef UISKINNEDPLAYLIST_H +#define UISKINNEDPLAYLIST_H + +#include <gtk/gtk.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define UI_SKINNED_PLAYLIST(obj) GTK_CHECK_CAST (obj, ui_skinned_playlist_get_type (), UiSkinnedPlaylist) +#define UI_SKINNED_PLAYLIST_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, ui_skinned_playlist_get_type (), UiSkinnedPlaylistClass) +#define UI_SKINNED_IS_PLAYLIST(obj) GTK_CHECK_TYPE (obj, ui_skinned_playlist_get_type ()) + +typedef struct _UiSkinnedPlaylist UiSkinnedPlaylist; +typedef struct _UiSkinnedPlaylistClass UiSkinnedPlaylistClass; + +struct _UiSkinnedPlaylist { + GtkWidget widget; + gboolean pressed; + gint x, y; + gint first; + gint num_visible; + gint prev_selected, prev_min, prev_max; + gboolean tooltips; + gboolean drag_motion; + gint drag_motion_x, drag_motion_y; + gint fheight; +}; + +struct _UiSkinnedPlaylistClass { + GtkWidgetClass parent_class; + void (* redraw) (UiSkinnedPlaylist *playlist); +}; + +GtkWidget* ui_skinned_playlist_new(GtkWidget *fixed, gint x, gint y, gint w, gint h); +GtkType ui_skinned_playlist_get_type(void); +void ui_skinned_playlist_resize_relative(GtkWidget *widget, gint w, gint h); +void ui_skinned_playlist_set_font(const gchar * font); +void ui_skinned_playlist_move_up(UiSkinnedPlaylist *pl); +void ui_skinned_playlist_move_down(UiSkinnedPlaylist *pl); +gint ui_skinned_playlist_get_position(GtkWidget *widget, gint x, gint y); + +#ifdef __cplusplus +} +#endif + +#endif
--- a/src/audacious/ui_skinned_playlist_slider.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_skinned_playlist_slider.h Fri Aug 03 20:39:42 2007 -0500 @@ -27,6 +27,8 @@ #ifndef UISKINNEDPLAYLIST_SLIDER_H #define UISKINNEDPLAYLIST_SLIDER_H +#include <gtk/gtk.h> + #ifdef __cplusplus extern "C" { #endif
--- a/src/audacious/ui_skinned_playstatus.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_skinned_playstatus.h Fri Aug 03 20:39:42 2007 -0500 @@ -27,9 +27,7 @@ #ifndef UISKINNEDPLAYSTATUS_H #define UISKINNEDPLAYSTATUS_H -#include <gdk/gdk.h> -#include <gtk/gtkadjustment.h> -#include <gtk/gtkwidget.h> +#include <gtk/gtk.h> #ifdef __cplusplus extern "C" {
--- a/src/audacious/ui_skinned_textbox.c Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_skinned_textbox.c Fri Aug 03 20:39:42 2007 -0500 @@ -64,7 +64,7 @@ GdkPixmap *pixmap; gboolean scroll_allowed, scroll_enabled; gint scroll_dummy; - gint resize_width, resize_height; + gint resize_width; gint move_x, move_y; }; @@ -166,7 +166,6 @@ static void ui_skinned_textbox_init(UiSkinnedTextbox *textbox) { UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); priv->resize_width = 0; - priv->resize_height = 0; priv->move_x = 0; priv->move_y = 0; } @@ -266,14 +265,16 @@ textbox->y = widget->allocation.y/(priv->double_size ? 2 : 1); if (textbox->width != widget->allocation.width/(priv->double_size ? 2 : 1)) { - if (textbox->width + priv->resize_width == widget->allocation.width/(priv->double_size ? 2 : 1)) + if (textbox->width + priv->resize_width == widget->allocation.width/(priv->double_size ? 2 : 1)) { + textbox->width += priv->resize_width; priv->resize_width = 0; - textbox->width = widget->allocation.width/(priv->double_size ? 2 : 1); - priv->resize_height = 0; - if (priv->pixmap_text) g_free(priv->pixmap_text); - priv->pixmap_text = NULL; - priv->offset = 0; - gtk_widget_queue_draw(GTK_WIDGET(textbox)); + if (priv->pixmap_text) g_free(priv->pixmap_text); + priv->pixmap_text = NULL; + priv->offset = 0; + gtk_widget_set_size_request(widget, textbox->width, textbox->height); + gtk_widget_queue_draw(GTK_WIDGET(textbox)); + } else if (priv->resize_width == 0) + textbox->width = widget->allocation.width/(priv->double_size ? 2 : 1); } } @@ -373,7 +374,10 @@ priv->is_dragging = FALSE; } else if (event->type == GDK_2BUTTON_PRESS) { if (event->button == 1) { - g_signal_emit(widget, textbox_signals[DOUBLE_CLICKED], 0); + if (g_signal_has_handler_pending(widget, textbox_signals[DOUBLE_CLICKED], 0, TRUE)) + g_signal_emit(widget, textbox_signals[DOUBLE_CLICKED], 0); + else + return FALSE; } } @@ -431,10 +435,10 @@ static void ui_skinned_textbox_redraw(UiSkinnedTextbox *textbox) { UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); - if (priv->resize_width || priv->resize_height) + if (priv->resize_width) gtk_widget_set_size_request(GTK_WIDGET(textbox), (textbox->width+priv->resize_width)*(1+priv->double_size), - (textbox->height+priv->resize_height)*(1+priv->double_size)); + (textbox->height)*(1+priv->double_size)); if (priv->move_x || priv->move_y) gtk_fixed_move(GTK_FIXED(priv->fixed), GTK_WIDGET(textbox), textbox->x+priv->move_x, textbox->y+priv->move_y); @@ -887,8 +891,7 @@ priv->move_y += y; } -void ui_skinned_textbox_resize_relative(GtkWidget *widget, gint w, gint h) { +void ui_skinned_textbox_resize_relative(GtkWidget *widget, gint w) { UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(widget); priv->resize_width += w; - priv->resize_height += h; }
--- a/src/audacious/ui_skinned_textbox.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_skinned_textbox.h Fri Aug 03 20:39:42 2007 -0500 @@ -27,6 +27,8 @@ #ifndef UISKINNEDTEXTBOX_H #define UISKINNEDTEXTBOX_H +#include <gtk/gtk.h> + #ifdef __cplusplus extern "C" { #endif @@ -60,7 +62,7 @@ void ui_skinned_textbox_set_text(GtkWidget *widget, const gchar *text); 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); +void ui_skinned_textbox_resize_relative(GtkWidget *widget, gint w); #ifdef __cplusplus }
--- a/src/audacious/ui_skinned_window.c Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_skinned_window.c Fri Aug 03 20:39:42 2007 -0500 @@ -26,11 +26,14 @@ #include <glib/gmacros.h> #include <gtk/gtkmarshal.h> #include <gtk/gtkwindow.h> +#include <string.h> #include "main.h" #include "dock.h" #include "ui_skinned_window.h" #include "ui_skinned_cursor.h" +#include "util.h" +#include "ui_playlist.h" static void ui_skinned_window_class_init(SkinnedWindowClass *klass); static void ui_skinned_window_init(GtkWidget *widget); @@ -99,6 +102,79 @@ return FALSE; } +static gboolean ui_skinned_window_expose(GtkWidget *widget, GdkEventExpose *event) { + SkinnedWindow *window = SKINNED_WINDOW(widget); + + GdkPixmap *obj = NULL; + GdkGC *gc; + + gint width = 0, height = 0; + switch (window->type) { + case WINDOW_MAIN: + width = bmp_active_skin->properties.mainwin_width; + height = bmp_active_skin->properties.mainwin_height; + break; + case WINDOW_EQ: + width = 275; + height = 116; + break; + case WINDOW_PLAYLIST: + width = playlistwin_get_width(); + height = cfg.playlist_height; + break; + default: + return FALSE; + } + obj = gdk_pixmap_new(NULL, width, height, gdk_rgb_get_visual()->depth); + gc = gdk_gc_new(obj); + + gboolean focus = gtk_window_has_toplevel_focus(GTK_WINDOW(widget)); + + switch (window->type) { + case WINDOW_MAIN: + skin_draw_pixmap(bmp_active_skin, obj, gc, SKIN_MAIN, 0, 0, 0, 0, width, height); + skin_draw_mainwin_titlebar(bmp_active_skin, obj, gc, cfg.player_shaded, focus || !cfg.dim_titlebar); + break; + case WINDOW_EQ: + skin_draw_pixmap(bmp_active_skin, obj, gc, SKIN_EQMAIN, 0, 0, 0, 0, width, height); + if (focus || !cfg.dim_titlebar) { + if (!cfg.equalizer_shaded) + skin_draw_pixmap(bmp_active_skin, obj, gc, SKIN_EQMAIN, 0, 134, 0, 0, width, 14); + else + skin_draw_pixmap(bmp_active_skin, obj, gc, SKIN_EQ_EX, 0, 0, 0, 0, width, 14); + } else { + if (!cfg.equalizer_shaded) + skin_draw_pixmap(bmp_active_skin, obj, gc, SKIN_EQMAIN, 0, 149, 0, 0, width, 14); + else + skin_draw_pixmap(bmp_active_skin, obj, gc, SKIN_EQ_EX, 0, 15, 0, 0, width, 14); + } + break; + case WINDOW_PLAYLIST: + focus |= !cfg.dim_titlebar; + if (cfg.playlist_shaded) { + skin_draw_playlistwin_shaded(bmp_active_skin, obj, gc, playlistwin_get_width(), focus); + } else { + skin_draw_playlistwin_frame(bmp_active_skin, obj, gc, playlistwin_get_width(), cfg.playlist_height, focus); + } + break; + } + + GdkPixmap *image = NULL; + + if (window->type != WINDOW_PLAYLIST && cfg.doublesize) { + image = create_dblsize_pixmap(obj); + } else { + image = gdk_pixmap_new(NULL, width, height, gdk_rgb_get_visual()->depth); + gdk_draw_drawable (image, gc, obj, 0, 0, 0, 0, width, height); + } + g_object_unref(obj); + gdk_draw_drawable (widget->window, gc, image, 0, 0, 0, 0, width*(1+cfg.doublesize), height*(1+cfg.doublesize)); + g_object_unref(gc); + g_object_unref(image); + + return FALSE; +} + static void ui_skinned_window_class_init(SkinnedWindowClass *klass) { @@ -110,6 +186,7 @@ widget_class->configure_event = ui_skinned_window_configure; widget_class->motion_notify_event = ui_skinned_window_motion_notify_event; + widget_class->expose_event = ui_skinned_window_expose; } void @@ -154,7 +231,7 @@ GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK | GDK_KEY_PRESS_MASK | - GDK_VISIBILITY_NOTIFY_MASK); + GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK); gtk_widget_realize(GTK_WIDGET(widget)); dock_window_list = dock_window_set_decorated(dock_window_list, @@ -163,7 +240,12 @@ ui_skinned_cursor_set(GTK_WIDGET(widget)); - SKINNED_WINDOW(widget)->gc = gdk_gc_new(widget->window); + if (!strcmp(wmclass_name, "player")) + SKINNED_WINDOW(widget)->type = WINDOW_MAIN; + if (!strcmp(wmclass_name, "equalizer")) + SKINNED_WINDOW(widget)->type = WINDOW_EQ; + if (!strcmp(wmclass_name, "playlist")) + SKINNED_WINDOW(widget)->type = WINDOW_PLAYLIST; /* GtkFixed hasn't got its GdkWindow, this means that it can be used to display widgets while the logo below will be displayed anyway; @@ -179,50 +261,15 @@ return widget; } -void -ui_skinned_window_widgetlist_associate(GtkWidget * widget, Widget * w) -{ - SkinnedWindow *sw; - - g_return_if_fail(widget != NULL); - g_return_if_fail(w != NULL); - - sw = SKINNED_WINDOW(widget); - - sw->widget_list = g_list_append(sw->widget_list, w); -} - -void -ui_skinned_window_widgetlist_dissociate(GtkWidget * widget, Widget * w) -{ - SkinnedWindow *sw; - - g_return_if_fail(widget != NULL); - g_return_if_fail(w != NULL); - - sw = SKINNED_WINDOW(widget); +void ui_skinned_window_draw_all(GtkWidget *widget) { + if (SKINNED_WINDOW(widget)->type == WINDOW_MAIN) + mainwin_refresh_hints(); - sw->widget_list = g_list_remove(sw->widget_list, w); + gtk_widget_queue_draw(widget); + GList *iter; + for (iter = GTK_FIXED (SKINNED_WINDOW(widget)->fixed)->children; iter; iter = g_list_next (iter)) { + GtkFixedChild *child_data = (GtkFixedChild *) iter->data; + GtkWidget *child = child_data->widget; + gtk_widget_queue_draw(child); + } } - -gboolean -ui_skinned_window_widgetlist_contained(GtkWidget * widget, gint x, gint y) -{ - SkinnedWindow *sw; - GList *l; - - g_return_val_if_fail(widget != NULL, FALSE); - - sw = SKINNED_WINDOW(widget); - - for (l = sw->widget_list; l != NULL; l = g_list_next(l)) - { - Widget *w = WIDGET(l->data); - - if (widget_contains(WIDGET(w), x, y) == TRUE) - return TRUE; - } - - return FALSE; -} -
--- a/src/audacious/ui_skinned_window.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_skinned_window.h Fri Aug 03 20:39:42 2007 -0500 @@ -32,6 +32,12 @@ # define SKINNED_WINDOW_TYPE GTK_WINDOW_TOPLEVEL #endif +enum { + WINDOW_MAIN, + WINDOW_EQ, + WINDOW_PLAYLIST +}; + typedef struct _SkinnedWindow SkinnedWindow; typedef struct _SkinnedWindowClass SkinnedWindowClass; @@ -42,8 +48,7 @@ GtkWidget *canvas; gint x,y; - GList *widget_list; - GdkGC *gc; + gint type; GtkWidget *fixed; }; @@ -54,8 +59,6 @@ extern GType ui_skinned_window_get_type(void); extern GtkWidget *ui_skinned_window_new(const gchar *wmclass_name); -extern void ui_skinned_window_widgetlist_associate(GtkWidget * widget, Widget * w); -extern void ui_skinned_window_widgetlist_dissociate(GtkWidget * widget, Widget * w); -extern gboolean ui_skinned_window_widgetlist_contained(GtkWidget * widget, gint x, gint y); +extern void ui_skinned_window_draw_all(GtkWidget *widget); #endif
--- a/src/audacious/ui_svis.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_svis.h Fri Aug 03 20:39:42 2007 -0500 @@ -21,9 +21,7 @@ #ifndef UISVIS_H #define UISVIS_H -#include <gdk/gdk.h> -#include <gtk/gtkadjustment.h> -#include <gtk/gtkwidget.h> +#include <gtk/gtk.h> #ifdef __cplusplus extern "C" {
--- a/src/audacious/ui_vis.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/ui_vis.h Fri Aug 03 20:39:42 2007 -0500 @@ -21,6 +21,8 @@ #ifndef UIVIS_H #define UIVIS_H +#include <gtk/gtk.h> + #ifdef __cplusplus extern "C" { #endif
--- a/src/audacious/widgets/Makefile Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/widgets/Makefile Fri Aug 03 20:39:42 2007 -0500 @@ -19,8 +19,6 @@ -I../../intl SOURCES = \ - widget.c \ - playlist_list.c \ skin.c OBJECTS = ${SOURCES:.c=.o}
--- a/src/audacious/widgets/playlist_list.c Fri Aug 03 20:39:35 2007 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,834 +0,0 @@ -/* Audacious - Cross-platform multimedia player - * Copyright (C) 2005-2006 Audacious development team. - * - * BMP - Cross-platform multimedia player - * Copyright (C) 2003-2004 BMP development team. - * - * Based on XMMS: - * Copyright (C) 1998-2003 XMMS 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; under version 3 of the License. - * - * 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, see <http://www.gnu.org/licenses>. - * - * The Audacious team does not consider modular code linking to - * Audacious or using our public API to be a derived work. - */ - -/* - * A note about Pango and some funky spacey fonts: Weirdly baselined - * fonts, or fonts with weird ascents or descents _will_ display a - * little bit weird in the playlist widget, but the display engine - * won't make it look too bad, just a little deranged. I honestly - * don't think it's worth fixing (around...), it doesn't have to be - * perfectly fitting, just the general look has to be ok, which it - * IMHO is. - * - * A second note: The numbers aren't perfectly aligned, but in the - * end it looks better when using a single Pango layout for each - * number. - */ - -#include "widgetcore.h" - -#include <stdlib.h> -#include <string.h> - -#include "main.h" -#include "input.h" -#include "strings.h" -#include "playback.h" -#include "playlist.h" -#include "ui_playlist.h" -#include "util.h" - -#include "debug.h" - -static PangoFontDescription *playlist_list_font = NULL; -static gint ascent, descent, width_delta_digit_one; -static gboolean has_slant; -static guint padding; - -/* FIXME: the following globals should not be needed. */ -static gint width_approx_letters; -static gint width_colon, width_colon_third; -static gint width_approx_digits, width_approx_digits_half; - -void playlist_list_draw(Widget * w); - -static gboolean -playlist_list_auto_drag_down_func(gpointer data) -{ - PlayList_List *pl = data; - - if (pl->pl_auto_drag_down) { - playlist_list_move_down(pl); - pl->pl_first++; - playlistwin_update_list(playlist_get_active()); - return TRUE; - } - return FALSE; -} - -static gboolean -playlist_list_auto_drag_up_func(gpointer data) -{ - PlayList_List *pl = data; - - if (pl->pl_auto_drag_up) { - playlist_list_move_up(pl); - pl->pl_first--; - playlistwin_update_list(playlist_get_active()); - return TRUE; - - } - return FALSE; -} - -void -playlist_list_move_up(PlayList_List * pl) -{ - GList *list; - Playlist *playlist = playlist_get_active(); - - if (!playlist) - return; - - PLAYLIST_LOCK(playlist->mutex); - if ((list = playlist->entries) == NULL) { - PLAYLIST_UNLOCK(playlist->mutex); - return; - } - if (PLAYLIST_ENTRY(list->data)->selected) { - /* We are at the top */ - PLAYLIST_UNLOCK(playlist->mutex); - return; - } - while (list) { - if (PLAYLIST_ENTRY(list->data)->selected) - glist_moveup(list); - list = g_list_next(list); - } - PLAYLIST_UNLOCK(playlist->mutex); - if (pl->pl_prev_selected != -1) - pl->pl_prev_selected--; - if (pl->pl_prev_min != -1) - pl->pl_prev_min--; - if (pl->pl_prev_max != -1) - pl->pl_prev_max--; -} - -void -playlist_list_move_down(PlayList_List * pl) -{ - GList *list; - Playlist *playlist = playlist_get_active(); - - if (!playlist) - return; - - PLAYLIST_LOCK(playlist->mutex); - - if (!(list = g_list_last(playlist->entries))) { - PLAYLIST_UNLOCK(playlist->mutex); - return; - } - - if (PLAYLIST_ENTRY(list->data)->selected) { - /* We are at the bottom */ - PLAYLIST_UNLOCK(playlist->mutex); - return; - } - - while (list) { - if (PLAYLIST_ENTRY(list->data)->selected) - glist_movedown(list); - list = g_list_previous(list); - } - - PLAYLIST_UNLOCK(playlist->mutex); - - if (pl->pl_prev_selected != -1) - pl->pl_prev_selected++; - if (pl->pl_prev_min != -1) - pl->pl_prev_min++; - if (pl->pl_prev_max != -1) - pl->pl_prev_max++; -} - -static void -playlist_list_button_press_cb(GtkWidget * widget, - GdkEventButton * event, - PlayList_List * pl) -{ - gint nr; - Playlist *playlist = playlist_get_active(); - - nr = playlist_list_get_playlist_position(pl, event->x, event->y); - if (nr == -1) - return; - - if (event->button == 3) - { - GList* selection = playlist_get_selected(playlist); - if (g_list_find(selection, GINT_TO_POINTER(nr)) == NULL) - { - playlist_select_all(playlist, FALSE); - playlist_select_range(playlist, nr, nr, TRUE); - } - } - else if (event->button == 1) - { - if (!(event->state & GDK_CONTROL_MASK)) - playlist_select_all(playlist, FALSE); - - if (event->state & GDK_SHIFT_MASK && pl->pl_prev_selected != -1) { - playlist_select_range(playlist, pl->pl_prev_selected, nr, TRUE); - pl->pl_prev_min = pl->pl_prev_selected; - pl->pl_prev_max = nr; - pl->pl_drag_pos = nr - pl->pl_first; - } - else { - if (playlist_select_invert(playlist, nr)) { - if (event->state & GDK_CONTROL_MASK) { - if (pl->pl_prev_min == -1) { - pl->pl_prev_min = pl->pl_prev_selected; - pl->pl_prev_max = pl->pl_prev_selected; - } - if (nr < pl->pl_prev_min) - pl->pl_prev_min = nr; - else if (nr > pl->pl_prev_max) - pl->pl_prev_max = nr; - } - else - pl->pl_prev_min = -1; - pl->pl_prev_selected = nr; - pl->pl_drag_pos = nr - pl->pl_first; - } - } - if (event->type == GDK_2BUTTON_PRESS) { - /* - * Ungrab the pointer to prevent us from - * hanging on to it during the sometimes slow - * playback_initiate(). - */ - gdk_pointer_ungrab(GDK_CURRENT_TIME); - gdk_flush(); - playlist_set_position(playlist, nr); - if (!playback_get_playing()) - playback_initiate(); - } - - pl->pl_dragging = TRUE; - } - - playlistwin_update_list(playlist); -} - -gint -playlist_list_get_playlist_position(PlayList_List * pl, - gint x, - gint y) -{ - gint iy, length; - gint ret; - Playlist *playlist = playlist_get_active(); - - if (!widget_contains(WIDGET(pl), x, y) || !pl->pl_fheight) - return -1; - - if ((length = playlist_get_length(playlist)) == 0) - return -1; - iy = y - pl->pl_widget.y; - - ret = (iy / pl->pl_fheight) + pl->pl_first; - - if (ret > length - 1) - ret = -1; - - return ret; -} - -static void -playlist_list_motion_cb(GtkWidget * widget, - GdkEventMotion * event, - PlayList_List * pl) -{ - gint nr, y, off, i; - - if (pl->pl_dragging) { - y = event->y - pl->pl_widget.y; - nr = (y / pl->pl_fheight); - if (nr < 0) { - nr = 0; - if (!pl->pl_auto_drag_up) { - pl->pl_auto_drag_up = TRUE; - pl->pl_auto_drag_up_tag = - g_timeout_add(100, playlist_list_auto_drag_up_func, pl); - } - } - else if (pl->pl_auto_drag_up) - pl->pl_auto_drag_up = FALSE; - - if (nr >= pl->pl_num_visible) { - nr = pl->pl_num_visible - 1; - if (!pl->pl_auto_drag_down) { - pl->pl_auto_drag_down = TRUE; - pl->pl_auto_drag_down_tag = - g_timeout_add(100, playlist_list_auto_drag_down_func, - pl); - } - } - else if (pl->pl_auto_drag_down) - pl->pl_auto_drag_down = FALSE; - - off = nr - pl->pl_drag_pos; - if (off) { - for (i = 0; i < abs(off); i++) { - if (off < 0) - playlist_list_move_up(pl); - else - playlist_list_move_down(pl); - - } - playlistwin_update_list(playlist_get_active()); - } - pl->pl_drag_pos = nr; - } -} - -static void -playlist_list_button_release_cb(GtkWidget * widget, - GdkEventButton * event, - PlayList_List * pl) -{ - pl->pl_dragging = FALSE; - pl->pl_auto_drag_down = FALSE; - pl->pl_auto_drag_up = FALSE; -} - -static void -playlist_list_draw_string(PlayList_List * pl, - PangoFontDescription * font, - gint line, - gint width, - const gchar * text, - guint ppos) -{ - guint plist_length_int; - Playlist *playlist = playlist_get_active(); - - PangoLayout *layout; - - REQUIRE_LOCK(playlist->mutex); - - if (cfg.show_numbers_in_pl) { - gchar *pos_string = g_strdup_printf(cfg.show_separator_in_pl == TRUE ? "%d" : "%d.", ppos); - plist_length_int = - gint_count_digits(playlist_get_length(playlist)) + !cfg.show_separator_in_pl + 1; /* cf.show_separator_in_pl will be 0 if false */ - - padding = plist_length_int; - padding = ((padding + 1) * width_approx_digits); - - layout = gtk_widget_create_pango_layout(playlistwin, pos_string); - pango_layout_set_font_description(layout, playlist_list_font); - pango_layout_set_width(layout, plist_length_int * 100); - - pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT); - gdk_draw_layout(pl->pl_widget.parent, pl->pl_widget.gc, - pl->pl_widget.x + - (width_approx_digits * - (-1 + plist_length_int - strlen(pos_string))) + - (width_approx_digits / 4), - pl->pl_widget.y + (line - 1) * pl->pl_fheight + - ascent + abs(descent), layout); - g_free(pos_string); - g_object_unref(layout); - - if (!cfg.show_separator_in_pl) - padding -= (width_approx_digits * 1.5); - } - else { - padding = 3; - } - - width -= padding; - - layout = gtk_widget_create_pango_layout(playlistwin, text); - - pango_layout_set_font_description(layout, playlist_list_font); - pango_layout_set_width(layout, width * PANGO_SCALE); - pango_layout_set_single_paragraph_mode(layout, TRUE); - pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); - gdk_draw_layout(pl->pl_widget.parent, pl->pl_widget.gc, - pl->pl_widget.x + padding + (width_approx_letters / 4), - pl->pl_widget.y + (line - 1) * pl->pl_fheight + - ascent + abs(descent), layout); - - g_object_unref(layout); -} - -void -playlist_list_draw(Widget * w) -{ - Playlist *playlist = playlist_get_active(); - PlayList_List *pl = PLAYLIST_LIST(w); - GList *list; - GdkGC *gc; - GdkPixmap *obj; - PangoLayout *layout; - gchar *title; - gint width, height; - gint i, max_first; - guint padding, padding_dwidth, padding_plength; - guint max_time_len = 0; - gfloat queue_tailpadding = 0; - gint tpadding; - gsize tpadding_dwidth = 0; - gint x, y; - guint tail_width; - guint tail_len; - - gchar tail[100]; - gchar queuepos[255]; - gchar length[40]; - - gchar **frags; - gchar *frag0; - - gint plw_w, plw_h; - - GdkRectangle *playlist_rect; - - gc = pl->pl_widget.gc; - - width = pl->pl_widget.width; - height = pl->pl_widget.height; - - obj = pl->pl_widget.parent; - - plw_w = playlistwin_get_width(); - plw_h = playlistwin_get_height(); - - playlist_rect = g_new0(GdkRectangle, 1); - - playlist_rect->x = 0; - playlist_rect->y = 0; - playlist_rect->width = plw_w - 17; - playlist_rect->height = plw_h - 36; - - gdk_gc_set_clip_origin(gc, 31, 58); - gdk_gc_set_clip_rectangle(gc, playlist_rect); - - gdk_gc_set_foreground(gc, - skin_get_color(bmp_active_skin, - SKIN_PLEDIT_NORMALBG)); - gdk_draw_rectangle(obj, gc, TRUE, pl->pl_widget.x, pl->pl_widget.y, - width, height); - - if (!playlist_list_font) { - g_critical("Couldn't open playlist font"); - return; - } - - pl->pl_fheight = (ascent + abs(descent)); - pl->pl_num_visible = height / pl->pl_fheight; - - max_first = playlist_get_length(playlist) - pl->pl_num_visible; - max_first = MAX(max_first, 0); - - pl->pl_first = CLAMP(pl->pl_first, 0, max_first); - - PLAYLIST_LOCK(playlist->mutex); - list = playlist->entries; - list = g_list_nth(list, pl->pl_first); - - /* It sucks having to run the iteration twice but this is the only - way you can reliably get the maximum width so we can get our - playlist nice and aligned... -- plasmaroo */ - - for (i = pl->pl_first; - list && i < pl->pl_first + pl->pl_num_visible; - list = g_list_next(list), i++) { - PlaylistEntry *entry = list->data; - - if (entry->length != -1) - { - g_snprintf(length, sizeof(length), "%d:%-2.2d", - entry->length / 60000, (entry->length / 1000) % 60); - tpadding_dwidth = MAX(tpadding_dwidth, strlen(length)); - } - } - - /* Reset */ - list = playlist->entries; - list = g_list_nth(list, pl->pl_first); - - for (i = pl->pl_first; - list && i < pl->pl_first + pl->pl_num_visible; - list = g_list_next(list), i++) { - gint pos; - PlaylistEntry *entry = list->data; - - if (entry->selected) { - gdk_gc_set_foreground(gc, - skin_get_color(bmp_active_skin, - SKIN_PLEDIT_SELECTEDBG)); - gdk_draw_rectangle(obj, gc, TRUE, pl->pl_widget.x, - pl->pl_widget.y + - ((i - pl->pl_first) * pl->pl_fheight), - width, pl->pl_fheight); - } - - /* FIXME: entry->title should NEVER be NULL, and there should - NEVER be a need to do a UTF-8 conversion. Playlist title - strings should be kept properly. */ - - if (!entry->title) { - gchar *realfn = g_filename_from_uri(entry->filename, NULL, NULL); - gchar *basename = g_path_get_basename(realfn ? realfn : entry->filename); - title = filename_to_utf8(basename); - g_free(basename); g_free(realfn); - } - else - title = str_to_utf8(entry->title); - - title = convert_title_text(title); - - pos = playlist_get_queue_position(playlist, entry); - - tail[0] = 0; - queuepos[0] = 0; - length[0] = 0; - - if (pos != -1) - g_snprintf(queuepos, sizeof(queuepos), "%d", pos + 1); - - if (entry->length != -1) - { - g_snprintf(length, sizeof(length), "%d:%-2.2d", - entry->length / 60000, (entry->length / 1000) % 60); - } - - strncat(tail, length, sizeof(tail) - 1); - tail_len = strlen(tail); - - max_time_len = MAX(max_time_len, tail_len); - - if (pos != -1 && tpadding_dwidth <= 0) - tail_width = width - (width_approx_digits * (strlen(queuepos) + 2.25)); - else if (pos != -1) - tail_width = width - (width_approx_digits * (tpadding_dwidth + strlen(queuepos) + 4)); - else if (tpadding_dwidth > 0) - tail_width = width - (width_approx_digits * (tpadding_dwidth + 2.5)); - else - tail_width = width; - - if (i == playlist_get_position_nolock(playlist)) - gdk_gc_set_foreground(gc, - skin_get_color(bmp_active_skin, - SKIN_PLEDIT_CURRENT)); - else - gdk_gc_set_foreground(gc, - skin_get_color(bmp_active_skin, - SKIN_PLEDIT_NORMAL)); - playlist_list_draw_string(pl, playlist_list_font, - i - pl->pl_first, tail_width, title, - i + 1); - - x = pl->pl_widget.x + width - width_approx_digits * 2; - y = pl->pl_widget.y + ((i - pl->pl_first) - - 1) * pl->pl_fheight + ascent; - - frags = NULL; - frag0 = NULL; - - if ((strlen(tail) > 0) && (tail != NULL)) { - frags = g_strsplit(tail, ":", 0); - frag0 = g_strconcat(frags[0], ":", NULL); - - layout = gtk_widget_create_pango_layout(playlistwin, frags[1]); - pango_layout_set_font_description(layout, playlist_list_font); - pango_layout_set_width(layout, tail_len * 100); - pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT); - gdk_draw_layout(obj, gc, x - (0.5 * width_approx_digits), - y + abs(descent), layout); - g_object_unref(layout); - - layout = gtk_widget_create_pango_layout(playlistwin, frag0); - pango_layout_set_font_description(layout, playlist_list_font); - pango_layout_set_width(layout, tail_len * 100); - pango_layout_set_alignment(layout, PANGO_ALIGN_RIGHT); - gdk_draw_layout(obj, gc, x - (0.75 * width_approx_digits), - y + abs(descent), layout); - g_object_unref(layout); - - g_free(frag0); - g_strfreev(frags); - } - - if (pos != -1) { - - /* DON'T remove the commented code yet please -- Milosz */ - - if (tpadding_dwidth > 0) - queue_tailpadding = tpadding_dwidth + 1; - else - queue_tailpadding = -0.75; - - gdk_draw_rectangle(obj, gc, FALSE, - x - - (((queue_tailpadding + - strlen(queuepos)) * - width_approx_digits) + - (width_approx_digits / 4)), - y + abs(descent), - (strlen(queuepos)) * - width_approx_digits + - (width_approx_digits / 2), - pl->pl_fheight - 2); - - layout = - gtk_widget_create_pango_layout(playlistwin, queuepos); - pango_layout_set_font_description(layout, playlist_list_font); - pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); - - gdk_draw_layout(obj, gc, - x - - ((queue_tailpadding + - strlen(queuepos)) * width_approx_digits) + - (width_approx_digits / 4), - y + abs(descent), layout); - g_object_unref(layout); - } - - g_free(title); - } - - - /* - * Drop target hovering over the playlist, so draw some hint where the - * drop will occur. - * - * This is (currently? unfixably?) broken when dragging files from Qt/KDE apps, - * probably due to DnD signaling problems (actually i have no clue). - * - */ - - if (pl->pl_drag_motion) { - guint pos, plength, lpadding; - gint x, y, plx, ply; - - if (cfg.show_numbers_in_pl) { - lpadding = gint_count_digits(playlist_get_length(playlist)) + 1; - lpadding = ((lpadding + 1) * width_approx_digits); - } - else { - lpadding = 3; - }; - - /* We already hold the mutex and have the playlist locked, so call - the non-locking function. */ - plength = playlist_get_length(playlist); - - x = pl->drag_motion_x; - y = pl->drag_motion_y; - - plx = pl->pl_widget.x; - ply = pl->pl_widget.y; - - if ((x > pl->pl_widget.x) && !(x > pl->pl_widget.width)) { - - if ((y > pl->pl_widget.y) - && !(y > (pl->pl_widget.height + ply))) { - - pos = ((y - ((Widget *) pl)->y) / pl->pl_fheight) + - pl->pl_first; - - if (pos > (plength)) { - pos = plength; - } - - gdk_gc_set_foreground(gc, - skin_get_color(bmp_active_skin, - SKIN_PLEDIT_CURRENT)); - - gdk_draw_line(obj, gc, pl->pl_widget.x, - pl->pl_widget.y + ((pos - pl->pl_first) * pl->pl_fheight), - pl->pl_widget.width + pl->pl_widget.x - 1, - pl->pl_widget.y + - ((pos - pl->pl_first) * pl->pl_fheight)); - } - - } - - /* When dropping on the borders of the playlist, outside the text area, - * files get appended at the end of the list. Show that too. - */ - - if ((y < ply) || (y > pl->pl_widget.height + ply)) { - if ((y >= 0) || (y <= (pl->pl_widget.height + ply))) { - pos = plength; - gdk_gc_set_foreground(gc, - skin_get_color(bmp_active_skin, - SKIN_PLEDIT_CURRENT)); - - gdk_draw_line(obj, gc, pl->pl_widget.x, - pl->pl_widget.y + - ((pos - pl->pl_first) * pl->pl_fheight), - pl->pl_widget.width + pl->pl_widget.x - 1, - pl->pl_widget.y + - ((pos - pl->pl_first) * pl->pl_fheight)); - - } - } - } - - gdk_gc_set_foreground(gc, - skin_get_color(bmp_active_skin, - SKIN_PLEDIT_NORMAL)); - - if (cfg.show_numbers_in_pl) - { - padding_plength = playlist_get_length(playlist); - - if (padding_plength == 0) { - padding_dwidth = 0; - } - else { - padding_dwidth = gint_count_digits(playlist_get_length(playlist)); - } - - padding = - (padding_dwidth * - width_approx_digits) + width_approx_digits; - - - /* For italic or oblique fonts we add another half of the - * approximate width */ - if (has_slant) - padding += width_approx_digits_half; - - if (cfg.show_separator_in_pl) { - gdk_draw_line(obj, gc, - pl->pl_widget.x + padding, - pl->pl_widget.y, - pl->pl_widget.x + padding, - pl->pl_widget.y + pl->pl_widget.height - 1); - } - } - - if (tpadding_dwidth != 0) - { - tpadding = (tpadding_dwidth * width_approx_digits) + (width_approx_digits * 1.5); - - if (has_slant) - tpadding += width_approx_digits_half; - - if (cfg.show_separator_in_pl) { - gdk_draw_line(obj, gc, - pl->pl_widget.x + pl->pl_widget.width - tpadding, - pl->pl_widget.y, - pl->pl_widget.x + pl->pl_widget.width - tpadding, - pl->pl_widget.y + pl->pl_widget.height - 1); - } - } - - gdk_gc_set_clip_origin(gc, 0, 0); - gdk_gc_set_clip_rectangle(gc, NULL); - - PLAYLIST_UNLOCK(playlist->mutex); - - gdk_flush(); - - g_free(playlist_rect); -} - - -PlayList_List * -create_playlist_list(GList ** wlist, - GdkPixmap * parent, - GdkGC * gc, - gint x, gint y, - gint w, gint h) -{ - PlayList_List *pl; - - pl = g_new0(PlayList_List, 1); - widget_init(&pl->pl_widget, parent, gc, x, y, w, h, TRUE); - - pl->pl_widget.button_press_cb = - (WidgetButtonPressFunc) playlist_list_button_press_cb; - pl->pl_widget.button_release_cb = - (WidgetButtonReleaseFunc) playlist_list_button_release_cb; - pl->pl_widget.motion_cb = (WidgetMotionFunc) playlist_list_motion_cb; - pl->pl_widget.draw = playlist_list_draw; - - pl->pl_prev_selected = -1; - pl->pl_prev_min = -1; - pl->pl_prev_max = -1; - - widget_list_add(wlist, WIDGET(pl)); - - return pl; -} - -void -playlist_list_set_font(const gchar * font) -{ - - /* Welcome to bad hack central 2k3 */ - - gchar *font_lower; - gint width_temp; - gint width_temp_0; - - playlist_list_font = pango_font_description_from_string(font); - - text_get_extents(font, - "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz ", - &width_approx_letters, NULL, &ascent, &descent); - - width_approx_letters = (width_approx_letters / 53); - - /* Experimental: We don't weigh the 1 into total because it's width is almost always - * very different from the rest - */ - text_get_extents(font, "023456789", &width_approx_digits, NULL, NULL, - NULL); - width_approx_digits = (width_approx_digits / 9); - - /* Precache some often used calculations */ - width_approx_digits_half = width_approx_digits / 2; - - /* FIXME: We assume that any other number is broader than the "1" */ - text_get_extents(font, "1", &width_temp, NULL, NULL, NULL); - text_get_extents(font, "2", &width_temp_0, NULL, NULL, NULL); - - if (abs(width_temp_0 - width_temp) < 2) { - width_delta_digit_one = 0; - } - else { - width_delta_digit_one = ((width_temp_0 - width_temp) / 2) + 2; - } - - text_get_extents(font, ":", &width_colon, NULL, NULL, NULL); - width_colon_third = width_colon / 4; - - font_lower = g_utf8_strdown(font, strlen(font)); - /* This doesn't take any i18n into account, but i think there is none with TTF fonts - * FIXME: This can probably be retrieved trough Pango too - */ - has_slant = g_strstr_len(font_lower, strlen(font_lower), "oblique") - || g_strstr_len(font_lower, strlen(font_lower), "italic"); - - g_free(font_lower); -}
--- a/src/audacious/widgets/playlist_list.h Fri Aug 03 20:39:35 2007 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* Audacious - * Copyright (C) 2005-2007 Audacious development team. - * - * BMP - Cross-platform multimedia player - * Copyright (C) 2003-2004 BMP development team. - * - * Based on XMMS: - * Copyright (C) 1998-2003 XMMS 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; under version 3 of the License. - * - * 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, see <http://www.gnu.org/licenses>. - * - * The Audacious team does not consider modular code linking to - * Audacious or using our public API to be a derived work. - */ - -#ifndef _WIDGETCORE_H_ -#error Please do not include me directly! Use widgetcore.h instead! -#endif - -#ifndef PLAYLIST_LIST_H -#define PLAYLIST_LIST_H - -#include <glib.h> -#include <gtk/gtk.h> -#include <gdk/gdk.h> - -#include "widget.h" - -#define PLAYLIST_LIST(x) ((PlayList_List *)(x)) -struct _PlayList_List { - Widget pl_widget; - gint pl_first, pl_fheight, pl_prev_selected, pl_prev_min, pl_prev_max; - gint pl_num_visible, pl_drag_pos; - gboolean pl_dragging, pl_auto_drag_down, pl_auto_drag_up; - gint pl_auto_drag_up_tag, pl_auto_drag_down_tag; - gboolean pl_drag_motion; - gint drag_motion_x, drag_motion_y; - gboolean pl_tooltips; -}; - -typedef struct _PlayList_List PlayList_List; - -PlayList_List *create_playlist_list(GList ** wlist, GdkPixmap * parent, - GdkGC * gc, gint x, gint y, gint w, - gint h); -void playlist_list_move_up(PlayList_List * pl); -void playlist_list_move_down(PlayList_List * pl); -int playlist_list_get_playlist_position(PlayList_List * pl, gint x, gint y); -void playlist_list_set_font(const gchar * font); -GdkPixmap *rootpix; -GdkPixmap *shade_pixmap(GdkDrawable *in, gint x, gint y, gint x_offset, gint y_offset, gint w, gint h, GdkColor *shade_color); -GdkDrawable *get_transparency_pixmap(void); - -#endif
--- a/src/audacious/widgets/playlist_slider.c Fri Aug 03 20:39:35 2007 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,177 +0,0 @@ -/* Audacious - * Copyright (C) 2005-2007 Audacious development team. - * - * BMP - Cross-platform multimedia player - * Copyright (C) 2003-2004 BMP development team. - * - * Based on XMMS: - * Copyright (C) 1998-2003 XMMS 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; under version 3 of the License. - * - * 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, see <http://www.gnu.org/licenses>. - * - * The Audacious team does not consider modular code linking to - * Audacious or using our public API to be a derived work. - */ - -#include "widgetcore.h" - -#include <glib.h> - -#include "playlist.h" -#include "ui_playlist.h" -#include "skin.h" -#include "widget.h" - -extern GCond *cond_scan; - -void -playlistslider_draw(Widget * w) -{ - PlaylistSlider *ps = (PlaylistSlider *) w; - GdkPixmap *obj; - gint y, skinx; - Playlist *playlist = playlist_get_active(); - - g_return_if_fail(ps != NULL); - g_return_if_fail(ps->ps_list != NULL); - - if (playlist_get_length(playlist) > ps->ps_list->pl_num_visible) - y = (ps->ps_list->pl_first * (ps->ps_widget.height - 19)) / - (playlist_get_length(playlist) - ps->ps_list->pl_num_visible); - else - y = 0; - - obj = ps->ps_widget.parent; - - if (ps->ps_back_image) { - if (skin_get_id() != ps->ps_skin_id) - ps->ps_skin_id = skin_get_id(); - else if (ps->ps_widget.height == ps->ps_prev_height) - gdk_draw_image(obj, ps->ps_widget.gc, - ps->ps_back_image, 0, 0, - ps->ps_widget.x, - ps->ps_widget.y + ps->ps_prev_y, 8, 18); - g_object_unref(ps->ps_back_image); - } - - ps->ps_prev_y = y; - ps->ps_prev_height = ps->ps_widget.height; - ps->ps_back_image = gdk_drawable_get_image(obj, ps->ps_widget.x, - ps->ps_widget.y + y, 8, 18); - if (ps->ps_is_draging) - skinx = 61; - else - skinx = 52; - - skin_draw_pixmap(bmp_active_skin, obj, ps->ps_widget.gc, SKIN_PLEDIT, - skinx, 53, ps->ps_widget.x, ps->ps_widget.y + y, 8, 18); -} - -static void -playlistslider_set_pos(PlaylistSlider * ps, gint y) -{ - gint pos; - Playlist *playlist = playlist_get_active(); - - y = CLAMP(y, 0, ps->ps_widget.height - 19); - - pos = (y * (playlist_get_length(playlist) - ps->ps_list->pl_num_visible)) / - (ps->ps_widget.height - 19); - playlistwin_set_toprow(pos); -} - -void -playlistslider_button_press_cb(GtkWidget * widget, - GdkEventButton * event, PlaylistSlider * ps) -{ - gint y = event->y - ps->ps_widget.y; - - if (!widget_contains(&ps->ps_widget, event->x, event->y)) - return; - - if (event->button != 1 && event->button != 2) - return; - - if ((y >= ps->ps_prev_y && y < ps->ps_prev_y + 18)) { - ps->ps_is_draging |= event->button; - ps->ps_drag_y = y - ps->ps_prev_y; - widget_draw(WIDGET(ps)); - } - else if (event->button == 2) { - playlistslider_set_pos(ps, y); - ps->ps_is_draging |= event->button; - ps->ps_drag_y = 0; - widget_draw(WIDGET(ps)); - } - else { - gint n = ps->ps_list->pl_num_visible / 2; - if (y < ps->ps_prev_y) - n *= -1; - playlistwin_scroll(n); - } - g_cond_signal(cond_scan); -} - -void -playlistslider_button_release_cb(GtkWidget * widget, - GdkEventButton * event, - PlaylistSlider * ps) -{ - if (ps->ps_is_draging) { - ps->ps_is_draging &= ~event->button; - widget_draw(WIDGET(ps)); - } -} - -void -playlistslider_motion_cb(GtkWidget * widget, GdkEventMotion * event, - PlaylistSlider * ps) -{ - gint y; - - if (!ps->ps_is_draging) - return; - - y = event->y - ps->ps_widget.y - ps->ps_drag_y; - playlistslider_set_pos(ps, y); - g_cond_signal(cond_scan); -} - -PlaylistSlider * -create_playlistslider(GList ** wlist, GdkPixmap * parent, - GdkGC * gc, gint x, gint y, gint h, - PlayList_List * list) -{ - PlaylistSlider *ps; - - ps = g_new0(PlaylistSlider, 1); - widget_init(&ps->ps_widget, parent, gc, x, y, 8, h, 1); - - ps->ps_widget.button_press_cb = - (void (*)(GtkWidget *, GdkEventButton *, gpointer)) - playlistslider_button_press_cb; - - ps->ps_widget.button_release_cb = - (void (*)(GtkWidget *, GdkEventButton *, gpointer)) - playlistslider_button_release_cb; - - ps->ps_widget.motion_cb = - (void (*)(GtkWidget *, GdkEventMotion *, gpointer)) - playlistslider_motion_cb; - - ps->ps_widget.draw = playlistslider_draw; - ps->ps_list = list; - - widget_list_add(wlist, WIDGET(ps)); - return ps; -}
--- a/src/audacious/widgets/playlist_slider.h Fri Aug 03 20:39:35 2007 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* Audacious - * Copyright (C) 2005-2007 Audacious development team. - * - * BMP - Cross-platform multimedia player - * Copyright (C) 2003-2004 BMP development team. - * - * Based on XMMS: - * Copyright (C) 1998-2003 XMMS 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; under version 3 of the License. - * - * 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, see <http://www.gnu.org/licenses>. - * - * The Audacious team does not consider modular code linking to - * Audacious or using our public API to be a derived work. - */ - -#ifndef _WIDGETCORE_H_ -#error Please do not include me directly! Use widgetcore.h instead! -#endif - -#ifndef PLAYLIST_SLIDER_H -#define PLAYLIST_SLIDER_H - -#include <glib.h> -#include <gdk/gdk.h> - -#include "playlist_list.h" -#include "widget.h" - -#define PLAYLIST_SLIDER(x) ((PlayerlistSlider *)(x)) -struct _PlaylistSlider { - Widget ps_widget; - PlayList_List *ps_list; - gboolean ps_is_draging; - gint ps_drag_y, ps_prev_y, ps_prev_height; - GdkImage *ps_back_image; - gint ps_skin_id; -}; - -typedef struct _PlaylistSlider PlaylistSlider; - -PlaylistSlider *create_playlistslider(GList ** wlist, GdkPixmap * parent, - GdkGC * gc, gint x, gint y, gint h, - PlayList_List * list); - -#endif
--- a/src/audacious/widgets/skin.c Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/widgets/skin.c Fri Aug 03 20:39:42 2007 -0500 @@ -168,9 +168,9 @@ skin_setup_masks(bmp_active_skin); - draw_main_window(TRUE); - draw_playlist_window(TRUE); - draw_equalizer_window(TRUE); + ui_skinned_window_draw_all(mainwin); + ui_skinned_window_draw_all(equalizerwin); + ui_skinned_window_draw_all(playlistwin); playlistwin_update_list(playlist_get_active()); @@ -322,8 +322,10 @@ pixbuf2 = audacious_create_colorized_pixbuf(pixbuf, cfg.colorize_r, cfg.colorize_g, cfg.colorize_b); g_object_unref(pixbuf); - gdk_draw_pixbuf(pixmap, SKINNED_WINDOW(mainwin)->gc, pixbuf2, 0, 0, 0, 0, width, height, - GDK_RGB_DITHER_MAX, 0, 0); + GdkGC *gc; + gc = gdk_gc_new(pixmap); + gdk_draw_pixbuf(pixmap, gc, pixbuf2, 0, 0, 0, 0, width, height, GDK_RGB_DITHER_MAX, 0, 0); + g_object_unref(gc); g_object_unref(pixbuf2); return pixmap;
--- a/src/audacious/widgets/widget.c Fri Aug 03 20:39:35 2007 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,282 +0,0 @@ -/* Audacious - * Copyright (C) 2005-2007 Audacious development team. - * - * BMP - Cross-platform multimedia player - * Copyright (C) 2003-2004 BMP development team. - * - * Based on XMMS: - * Copyright (C) 1998-2003 XMMS 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; under version 3 of the License. - * - * 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, see <http://www.gnu.org/licenses>. - * - * The Audacious team does not consider modular code linking to - * Audacious or using our public API to be a derived work. - */ - -#include "widgetcore.h" - -#include <glib.h> -#include <gdk/gdk.h> - -#include "debug.h" - - -void -widget_init(Widget * widget, GdkPixmap * parent, GdkGC * gc, - gint x, gint y, gint width, gint height, gint visible) -{ - widget->parent = parent; - widget->gc = gc; - widget_set_position(widget, x, y); - widget_set_size(widget, width, height); - widget->visible = visible; - widget->redraw = TRUE; - widget->mutex = g_mutex_new(); -} - -void -widget_set_position(Widget * widget, gint x, gint y) -{ - widget->x = x; - widget->y = y; - widget_queue_redraw(widget); -} - -void -widget_set_size(Widget * widget, gint width, gint height) -{ - widget->width = width; - widget->height = height; - widget_queue_redraw(widget); -} - -void -widget_queue_redraw(Widget * widget) -{ - widget->redraw = TRUE; -} - -gboolean -widget_contains(Widget * widget, gint x, gint y) -{ - return (widget->visible && - x >= widget->x && - y >= widget->y && - x < widget->x + widget->width && - y < widget->y + widget->height); -} - -void -widget_show(Widget * widget) -{ - if (!widget) - return; - - widget->visible = TRUE; - widget_draw(widget); -} - -void -widget_hide(Widget * widget) -{ - if (!widget) - return; - - widget->visible = FALSE; -} - -gboolean -widget_is_visible(Widget * widget) -{ - if (!widget) - return FALSE; - - return widget->visible; -} - -void -widget_resize(Widget * widget, gint width, gint height) -{ - widget_set_size(widget, width, height); -} - -void -widget_resize_relative(Widget * widget, gint width, gint height) -{ - widget_resize(widget, widget->width + width, widget->height + height); -} - -void -widget_move(Widget * widget, gint x, gint y) -{ - widget_lock(widget); - widget_set_position(widget, x, y); - widget_unlock(widget); -} - -void -widget_move_relative(Widget * widget, gint x, gint y) -{ - widget_move(widget, widget->x + x, widget->y + y); -} - -void -widget_draw(Widget * widget) -{ - if (widget->visible != TRUE) - return; - - widget_lock(widget); - WIDGET(widget)->redraw = TRUE; - widget_unlock(widget); -} - -void -widget_draw_quick(Widget * widget) -{ - widget_lock(widget); - if (WIDGET(widget)->draw != NULL) - { - WIDGET(widget)->draw(widget); - gdk_flush(); - } - widget_unlock(widget); -} - -void -widget_list_add(GList ** list, Widget * widget) -{ - (*list) = g_list_append(*list, widget); -} - -void -handle_press_cb(GList * widget_list, GtkWidget * widget, - GdkEventButton * event) -{ - GList *wl; - - for (wl = widget_list; wl; wl = g_list_next(wl)) { - if (WIDGET(wl->data)->button_press_cb) - WIDGET(wl->data)->button_press_cb(widget, event, wl->data); - } -} - -void -handle_release_cb(GList * widget_list, GtkWidget * widget, - GdkEventButton * event) -{ - GList *wl; - - for (wl = widget_list; wl; wl = g_list_next(wl)) { - if (WIDGET(wl->data)->button_release_cb) - WIDGET(wl->data)->button_release_cb(widget, event, wl->data); - } -} - -void -handle_motion_cb(GList * widget_list, GtkWidget * widget, - GdkEventMotion * event) -{ - GList *wl; - - for (wl = widget_list; wl; wl = g_list_next(wl)) { - if (WIDGET(wl->data)->motion_cb) - WIDGET(wl->data)->motion_cb(widget, event, wl->data); - } -} - -void -handle_scroll_cb(GList * wlist, GtkWidget * widget, GdkEventScroll * event) -{ - GList *wl; - - for (wl = wlist; wl; wl = g_list_next(wl)) { - if (WIDGET(wl->data)->mouse_scroll_cb) - WIDGET(wl->data)->mouse_scroll_cb(widget, event, wl->data); - } -} - -void -widget_list_draw(GList * widget_list, gboolean * redraw, gboolean force) -{ - GList *wl; - Widget *w; - - *redraw = FALSE; - wl = widget_list; - - for (wl = widget_list; wl; wl = g_list_next(wl)) { - w = WIDGET(wl->data); - - REQUIRE_LOCK(w->mutex); - - if (!w->draw) - continue; - - if (!w->visible) - continue; - - if (w->redraw || force) { - w->draw(w); -/* w->redraw = FALSE; */ - *redraw = TRUE; - } - } -} - -void -widget_list_change_pixmap(GList * widget_list, GdkPixmap * pixmap) -{ - GList *wl; - - for (wl = widget_list; wl; wl = g_list_next(wl)) { - Widget *widget = wl->data; - widget->parent = pixmap; - widget_queue_redraw(widget); - } -} - -void -widget_list_clear_redraw(GList * widget_list) -{ - GList *wl; - - for (wl = widget_list; wl; wl = g_list_next(wl)) { - REQUIRE_LOCK(WIDGET(wl->data)->mutex); - WIDGET(wl->data)->redraw = FALSE; - } -} - -void -widget_lock(Widget * widget) -{ - g_mutex_lock(WIDGET(widget)->mutex); -} - -void -widget_unlock(Widget * widget) -{ - g_mutex_unlock(WIDGET(widget)->mutex); -} - -void -widget_list_lock(GList * widget_list) -{ - g_list_foreach(widget_list, (GFunc) widget_lock, NULL); -} - -void -widget_list_unlock(GList * widget_list) -{ - g_list_foreach(widget_list, (GFunc) widget_unlock, NULL); -}
--- a/src/audacious/widgets/widget.h Fri Aug 03 20:39:35 2007 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -/* Audacious - * Copyright (C) 2005-2007 Audacious development team. - * - * BMP - Cross-platform multimedia player - * Copyright (C) 2003-2004 BMP development team. - * - * Based on XMMS: - * Copyright (C) 1998-2003 XMMS 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; under version 3 of the License. - * - * 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, see <http://www.gnu.org/licenses>. - * - * The Audacious team does not consider modular code linking to - * Audacious or using our public API to be a derived work. - */ - -#ifndef _WIDGETCORE_H_ -#error Please do not include me directly! Use widgetcore.h instead! -#endif - -#ifndef WIDGET_H -#define WIDGET_H - - -#include <glib.h> -#include <gdk/gdk.h> -#include <gtk/gtk.h> - - -typedef struct _Widget Widget; - - -typedef void (*WidgetButtonPressFunc) (GtkWidget *, GdkEventButton *, - gpointer); -typedef void (*WidgetButtonReleaseFunc) (GtkWidget *, GdkEventButton *, - gpointer); -typedef void (*WidgetMotionFunc) (GtkWidget *, GdkEventMotion *, gpointer); -typedef void (*WidgetDrawFunc) (Widget *); -typedef void (*WidgetScrollFunc) (GtkWidget *, GdkEventScroll *, gpointer); - - -#define WIDGET(x) ((Widget *)(x)) -struct _Widget { - GdkPixmap *parent; - GdkGC *gc; - - gint x, y; - gint width, height; - - gint visible; - gboolean redraw; - - GMutex *mutex; - - WidgetButtonPressFunc button_press_cb; - WidgetButtonReleaseFunc button_release_cb; - WidgetMotionFunc motion_cb; - WidgetDrawFunc draw; - WidgetScrollFunc mouse_scroll_cb; -}; - - -void widget_init(Widget * widget, GdkPixmap * parent, GdkGC * gc, - gint x, gint y, gint width, gint height, gint visible); - -void widget_set_position(Widget * widget, gint x, gint y); -void widget_set_size(Widget * widget, gint width, gint height); -void widget_queue_redraw(Widget * widget); - -void widget_lock(Widget * widget); -void widget_unlock(Widget * widget); - -gboolean widget_contains(Widget * widget, gint x, gint y); - -void widget_show(Widget * widget); -void widget_hide(Widget * widget); -gboolean widget_is_visible(Widget * widget); - -void widget_resize(Widget * widget, gint width, gint height); -void widget_resize_relative(Widget * widget, gint width, gint height); -void widget_move(Widget * widget, gint x, gint y); -void widget_move_relative(Widget * widget, gint x, gint y); -void widget_draw(Widget * widget); -void widget_draw_quick(Widget * widget); - -void handle_press_cb(GList * wlist, GtkWidget * widget, - GdkEventButton * event); -void handle_release_cb(GList * wlist, GtkWidget * widget, - GdkEventButton * event); -void handle_motion_cb(GList * wlist, GtkWidget * widget, - GdkEventMotion * event); -void handle_scroll_cb(GList * wlist, GtkWidget * widget, - GdkEventScroll * event); - -void widget_list_add(GList ** list, Widget * widget); -void widget_list_draw(GList * list, gboolean * redraw, gboolean force); -void widget_list_change_pixmap(GList * list, GdkPixmap * pixmap); -void widget_list_clear_redraw(GList * list); -void widget_list_lock(GList * list); -void widget_list_unlock(GList * list); - -#endif
--- a/src/audacious/widgets/widgetcore.h Fri Aug 03 20:39:35 2007 -0500 +++ b/src/audacious/widgets/widgetcore.h Fri Aug 03 20:39:42 2007 -0500 @@ -21,8 +21,6 @@ #ifndef _WIDGETCORE_H_ #define _WIDGETCORE_H_ -#include "playlist_list.h" #include "skin.h" -#include "widget.h" #endif
--- a/src/libguess/russian_impl.c Fri Aug 03 20:39:35 2007 -0500 +++ b/src/libguess/russian_impl.c Fri Aug 03 20:39:42 2007 -0500 @@ -203,7 +203,7 @@ fprintf(stderr,"End. Win: %lf, Koi: %lf, Alt: %lf\n",winestat,koiestat,altestat); fprintf(stderr,"Final. Win: %lf, Koi: %lf, Alt: %lf\n",calculate(winsstat,winstat,winestat),calculate(koisstat,koistat,koiestat),calculate(altsstat,altstat,altestat)); #endif - if ((calculate(altsstat,altstat,altestat)>calculate(koisstat,koistat,koiestat))&&(calculate(altsstat,altstat,altestat)>calculate(winsstat,winstat,winestat))) "CP866"; + if ((calculate(altsstat,altstat,altestat)>calculate(koisstat,koistat,koiestat))&&(calculate(altsstat,altstat,altestat)>calculate(winsstat,winstat,winestat))) return "CP866"; if (calculate(koisstat,koistat,koiestat)>calculate(winsstat,winstat,winestat)) return "KOI8-R"; return "CP1251"; }