commit 99c6f2cf258acaba842a694db07b5e02786026e5 Author: phantomjinx <p.g.richard...@phantomjinx.co.uk> Date: Wed Dec 29 22:16:46 2010 +0000
Fix toolbar being lost when scrolling playlist view * Playlist display scrollbar originally located outside both toolbar and playlist treeview. So, when scrolliing the toolbar is scrolled out of sight. * Takes scrolled window lower in hierarchy so only surrounds treeview. Thus when treeview becomes over-populated for size, only it will be scrollable rather than the whole widget plugins/playlist_display/display_playlists.c | 27 +++++++++++++++---------- plugins/playlist_display/plugin.c | 24 +++++++--------------- plugins/playlist_display/plugin.h | 1 - 3 files changed, 24 insertions(+), 28 deletions(-) --- diff --git a/plugins/playlist_display/display_playlists.c b/plugins/playlist_display/display_playlists.c index a46dabd..9e90c23 100644 --- a/plugins/playlist_display/display_playlists.c +++ b/plugins/playlist_display/display_playlists.c @@ -55,8 +55,6 @@ #define gdk_drag_context_get_suggested_action(x) ((x)->suggested_action) #endif -/* Container containing both toolbar and view */ -static GtkWidget *playlist_viewport = NULL; /* pointer to the playlist display's toolbar */ static GtkToolbar *playlist_toolbar = NULL; /* pointer to the treeview for the playlist display */ @@ -1874,10 +1872,12 @@ static void pm_add_columns(void) { /* Free the playlist listview */ void pm_destroy_playlist_view(void) { - if (GTK_IS_WIDGET(playlist_viewport)) { - gtk_widget_destroy(GTK_WIDGET(playlist_viewport)); - } - playlist_viewport = NULL; + if (GTK_IS_WIDGET(playlist_toolbar)) + gtk_widget_destroy(GTK_WIDGET(playlist_toolbar)); + + if (GTK_IS_WIDGET(playlist_treeview)) + gtk_widget_destroy(GTK_WIDGET(playlist_treeview)); + playlist_toolbar = NULL; playlist_treeview = NULL; } @@ -1892,6 +1892,7 @@ static void pm_create_treeview(void) { /* create new one */ playlist_treeview = GTK_TREE_VIEW (gtk_tree_view_new()); gtk_widget_set_events(GTK_WIDGET(playlist_treeview), GDK_KEY_RELEASE_MASK); + gtk_tree_view_set_headers_visible(playlist_treeview, FALSE); } else { model = GTK_TREE_STORE (gtk_tree_view_get_model(playlist_treeview)); g_return_if_fail (model); @@ -1989,6 +1990,7 @@ static void pm_create_toolbar(GtkActionGroup *action_group) { GtkWidget *pm_create_playlist_view(GtkActionGroup *action_group) { GtkBox *vbox; + GtkScrolledWindow *scrolledwin; vbox = GTK_BOX(gtk_vbox_new (FALSE, 0)); @@ -1998,12 +2000,15 @@ GtkWidget *pm_create_playlist_view(GtkActionGroup *action_group) { pm_create_treeview(); pm_sort(prefs_get_int("pm_sort")); - gtk_box_pack_start(vbox, GTK_WIDGET(playlist_treeview), TRUE, TRUE, 0); - - playlist_viewport = gtk_viewport_new (0, 0); - gtk_container_add (GTK_CONTAINER(playlist_viewport), GTK_WIDGET(vbox)); + // Add only the tree view to a scrolled window so that toolbar is always visible + scrolledwin = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL)); + gtk_scrolled_window_set_policy(scrolledwin, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type(scrolledwin, GTK_SHADOW_IN); + gtk_widget_set_size_request(GTK_WIDGET(scrolledwin), 250, -1); + gtk_container_add(GTK_CONTAINER(scrolledwin), GTK_WIDGET(playlist_treeview)); + gtk_box_pack_start(vbox, GTK_WIDGET(scrolledwin), TRUE, TRUE, 0); - return playlist_viewport; + return GTK_WIDGET(vbox); } Playlist* pm_get_selected_playlist(void) { diff --git a/plugins/playlist_display/plugin.c b/plugins/playlist_display/plugin.c index 34414c9..45a74f0 100644 --- a/plugins/playlist_display/plugin.c +++ b/plugins/playlist_display/plugin.c @@ -326,12 +326,6 @@ static gboolean activate_plugin(AnjutaPlugin *plugin) { playlist_display_plugin->uiid = anjuta_ui_merge(ui, uipath); g_free(uipath); - /* Add widget in Shell. Any number of widgets can be added */ - playlist_display_plugin->pl_window = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (playlist_display_plugin->pl_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (playlist_display_plugin->pl_window), GTK_SHADOW_IN); - gtk_widget_set_size_request(playlist_display_plugin->pl_window, 250, -1); - playlist_display_plugin->playlist_view = pm_create_playlist_view(action_group); g_signal_connect (gtkpod_app, SIGNAL_PLAYLIST_SELECTED, G_CALLBACK (playlist_display_select_playlist_cb), NULL); @@ -344,9 +338,9 @@ static gboolean activate_plugin(AnjutaPlugin *plugin) { g_signal_connect (gtkpod_app, SIGNAL_ITDB_DATA_CHANGED, G_CALLBACK (playlist_display_itdb_data_changed_cb), NULL); g_signal_connect (gtkpod_app, SIGNAL_ITDB_DATA_SAVED, G_CALLBACK (playlist_display_itdb_data_changed_cb), NULL); - gtk_container_add(GTK_CONTAINER (playlist_display_plugin->pl_window), GTK_WIDGET (playlist_display_plugin->playlist_view)); - gtk_widget_show_all(playlist_display_plugin->pl_window); - anjuta_shell_add_widget(plugin->shell, playlist_display_plugin->pl_window, "PlaylistDisplayPlugin", _(" iPod Repositories"), PLAYLIST_DISPLAY_PLAYLIST_ICON_STOCK_ID, ANJUTA_SHELL_PLACEMENT_LEFT, NULL); + gtk_widget_show_all(playlist_display_plugin->playlist_view); + // Add widget directly as scrolling is handled internally by the widget + anjuta_shell_add_widget(plugin->shell, playlist_display_plugin->playlist_view, "PlaylistDisplayPlugin", _(" iPod Repositories"), PLAYLIST_DISPLAY_PLAYLIST_ICON_STOCK_ID, ANJUTA_SHELL_PLACEMENT_LEFT, NULL); return TRUE; /* FALSE if activation failed */ } @@ -368,10 +362,6 @@ static gboolean deactivate_plugin(AnjutaPlugin *plugin) { g_signal_handlers_disconnect_by_func (plugin->shell, G_CALLBACK (playlist_display_itdb_data_changed_cb), plugin); g_signal_handlers_disconnect_by_func (plugin->shell, G_CALLBACK (playlist_display_itdb_data_changed_cb), plugin); - /* Destroy the treeview */ - pm_destroy_playlist_view(); - playlist_display_plugin->playlist_view = NULL; - /* Unmerge UI */ anjuta_ui_unmerge(ui, playlist_display_plugin->uiid); @@ -379,8 +369,11 @@ static gboolean deactivate_plugin(AnjutaPlugin *plugin) { anjuta_ui_remove_action_group(ui, playlist_display_plugin->action_group); /* Remove widgets from Shell */ - anjuta_shell_remove_widget(plugin->shell, playlist_display_plugin->pl_window, NULL); - playlist_display_plugin->pl_window = NULL; + anjuta_shell_remove_widget(plugin->shell, playlist_display_plugin->playlist_view, NULL); + + /* Destroy the treeview */ + pm_destroy_playlist_view(); + playlist_display_plugin->playlist_view = NULL; /* FALSE if plugin doesn't want to deactivate */ return TRUE; @@ -389,7 +382,6 @@ static gboolean deactivate_plugin(AnjutaPlugin *plugin) { static void playlist_display_plugin_instance_init(GObject *obj) { PlaylistDisplayPlugin *plugin = (PlaylistDisplayPlugin*) obj; plugin->uiid = 0; - plugin->pl_window = NULL; plugin->playlist_view = NULL; plugin->action_group = NULL; } diff --git a/plugins/playlist_display/plugin.h b/plugins/playlist_display/plugin.h index 62ea4a1..1d64f28 100644 --- a/plugins/playlist_display/plugin.h +++ b/plugins/playlist_display/plugin.h @@ -66,7 +66,6 @@ typedef struct _PlaylistDisplayPluginClass PlaylistDisplayPluginClass; struct _PlaylistDisplayPlugin { AnjutaPlugin parent; - GtkWidget *pl_window; GtkWidget *playlist_view; gint uiid; GtkActionGroup *action_group; ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ gtkpod-cvs2 mailing list gtkpod-cvs2@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2