[Xfce4-commits] <parole:master> Expand window when showing playlist to prevent jarring resize and movement of playlist button (bug 9755)

Sean Davis noreply at xfce.org
Wed Jan 16 00:50:01 CET 2013


Updating branch refs/heads/master
         to f0139f37b5e29a8d56b4daf74d1afd3c44758825 (commit)
       from 3fad1eed4013dd301f01454c923f69574c0353c0 (commit)

commit f0139f37b5e29a8d56b4daf74d1afd3c44758825
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Tue Jan 15 18:48:31 2013 -0500

    Expand window when showing playlist to prevent jarring resize and movement of playlist button (bug 9755)

 data/interfaces/parole.ui   |   11 +++---
 data/interfaces/playlist.ui |    1 +
 src/parole-player.c         |   73 ++++++++++++++++++++++++++++---------------
 3 files changed, 54 insertions(+), 31 deletions(-)

diff --git a/data/interfaces/parole.ui b/data/interfaces/parole.ui
index 2706a9f..92e3308 100644
--- a/data/interfaces/parole.ui
+++ b/data/interfaces/parole.ui
@@ -69,11 +69,10 @@
     </columns>
   </object>
   <object class="GtkWindow" id="main-window">
+    <property name="visible">True</property>
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Parole Media Player</property>
     <property name="window_position">center</property>
-    <property name="default_width">780</property>
-    <property name="default_height">480</property>
     <property name="icon_name">parole</property>
     <signal name="destroy" handler="parole_player_destroy_cb" swapped="no"/>
     <signal name="configure-event" handler="parole_player_configure_event_cb" swapped="no"/>
@@ -478,9 +477,9 @@
                         <property name="use_underline">True</property>
                         <property name="image">image_volume_up</property>
                         <property name="use_stock">False</property>
-                        <accelerator key="plus" signal="activate"/>
-                        <accelerator key="equal" signal="activate"/>
                         <accelerator key="KP_Add" signal="activate"/>
+                        <accelerator key="equal" signal="activate"/>
+                        <accelerator key="plus" signal="activate"/>
                         <signal name="activate" handler="parole_player_volume_up" swapped="no"/>
                       </object>
                     </child>
@@ -493,8 +492,8 @@
                         <property name="use_underline">True</property>
                         <property name="image">image_volume_down</property>
                         <property name="use_stock">False</property>
-                        <accelerator key="KP_Subtract" signal="activate"/>
                         <accelerator key="minus" signal="activate"/>
+                        <accelerator key="KP_Subtract" signal="activate"/>
                         <signal name="activate" handler="parole_player_volume_down" swapped="no"/>
                       </object>
                     </child>
@@ -1045,8 +1044,8 @@ audio-volume-medium</property>
                     </child>
                     <child>
                       <object class="GtkNotebook" id="notebook-playlist">
-                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
+                        <property name="no_show_all">True</property>
                         <property name="show_border">False</property>
                         <property name="scrollable">True</property>
                         <property name="enable_popup">True</property>
diff --git a/data/interfaces/playlist.ui b/data/interfaces/playlist.ui
index 1330b86..6086771 100644
--- a/data/interfaces/playlist.ui
+++ b/data/interfaces/playlist.ui
@@ -89,6 +89,7 @@
     <property name="icon_name">media-playlist-shuffle</property>
   </object>
   <object class="GtkVBox" id="playlist-box">
+    <property name="width_request">220</property>
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <child>
diff --git a/src/parole-player.c b/src/parole-player.c
index e52d5be..59088f1 100644
--- a/src/parole-player.c
+++ b/src/parole-player.c
@@ -367,6 +367,8 @@ struct ParolePlayerPrivate
     
     gboolean        wait_for_gst_disc_info;
     
+    gint            handle_width;
+    
     GtkTreeRowReference *row;
         
 };
@@ -428,25 +430,40 @@ void ratio_20_9_toggled_cb (GtkWidget *widget, ParolePlayer *player)
 
 void parole_player_set_playlist_visible (ParolePlayer *player, gboolean visibility)
 {
-	gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(player->priv->show_hide_playlist), visibility );
-	if ( visibility )
-	{
-		gtk_widget_show_all (player->priv->playlist_nt);
-		gtk_image_set_from_stock( GTK_IMAGE( player->priv->show_hide_playlist_image ), "gtk-go-forward", GTK_ICON_SIZE_LARGE_TOOLBAR );
-		gtk_widget_set_tooltip_text( GTK_WIDGET( player->priv->show_hide_playlist_button ), "Hide playlist");
-		g_object_set (G_OBJECT (player->priv->conf),	
-		  "showhide-playlist", TRUE,
-		  NULL);
-	}
-	else
-	{
-		gtk_widget_hide (player->priv->playlist_nt);
-		gtk_image_set_from_stock( GTK_IMAGE( player->priv->show_hide_playlist_image ), "gtk-go-back", GTK_ICON_SIZE_LARGE_TOOLBAR );
-		gtk_widget_set_tooltip_text( GTK_WIDGET( player->priv->show_hide_playlist_button ), "Show playlist");
-		g_object_set (G_OBJECT (player->priv->conf),	
-		  "showhide-playlist", FALSE,
-		  NULL);
-	}
+    gint window_w, window_h, playlist_w;
+
+    gtk_window_get_size (GTK_WINDOW (player->priv->window), &window_w, &window_h);
+    
+    /* Get the playlist width.  If we fail to get it, use the default 220. */
+    playlist_w = player->priv->playlist_nt->allocation.width;
+    if (playlist_w == 1)
+        playlist_w = 220;
+
+    gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(player->priv->show_hide_playlist), visibility );
+    if ( visibility )
+    {
+        if ( !player->priv->full_screen )
+            gtk_window_resize(GTK_WINDOW (player->priv->window), window_w+playlist_w+player->priv->handle_width, window_h);
+        
+        gtk_widget_show (player->priv->playlist_nt);
+        gtk_image_set_from_stock( GTK_IMAGE( player->priv->show_hide_playlist_image ), "gtk-go-forward", GTK_ICON_SIZE_LARGE_TOOLBAR );
+        gtk_widget_set_tooltip_text( GTK_WIDGET( player->priv->show_hide_playlist_button ), "Hide playlist");
+        g_object_set (G_OBJECT (player->priv->conf),	
+                    "showhide-playlist", TRUE,
+                    NULL);
+    }
+    else
+    {
+        gtk_widget_hide (player->priv->playlist_nt);
+        gtk_image_set_from_stock( GTK_IMAGE( player->priv->show_hide_playlist_image ), "gtk-go-back", GTK_ICON_SIZE_LARGE_TOOLBAR );
+        gtk_widget_set_tooltip_text( GTK_WIDGET( player->priv->show_hide_playlist_button ), "Show playlist");
+        g_object_set (G_OBJECT (player->priv->conf),	
+                    "showhide-playlist", FALSE,
+                    NULL);
+        
+        if ( !player->priv->full_screen )
+            gtk_window_resize(GTK_WINDOW (player->priv->window), window_w-playlist_w-player->priv->handle_width, window_h);
+    }
 }
 
 void parole_player_show_hide_playlist (GtkWidget *widget, ParolePlayer *player)
@@ -2768,6 +2785,7 @@ parole_player_init (ParolePlayer *player)
     gint volume;
     
     GtkWidget *hbox_audiobox;
+    GtkWidget *hpaned;
     
     GtkWidget *recent_menu;
     GtkRecentFilter *recent_filter;
@@ -2936,6 +2954,9 @@ parole_player_init (ParolePlayer *player)
     player->priv->main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main-box"));
     player->priv->eventbox_output = GTK_WIDGET (gtk_builder_get_object (builder, "eventbox_output"));
     
+    hpaned = GTK_WIDGET (gtk_builder_get_object (builder, "hpaned"));
+    gtk_widget_style_get (hpaned, "handle-size", &player->priv->handle_width, NULL);
+    
     /* Audio box */
     hbox_audiobox = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_audiobox"));
     g_signal_connect(hbox_audiobox, "expose-event",
@@ -3002,21 +3023,23 @@ parole_player_init (ParolePlayer *player)
     gtk_notebook_append_page (GTK_NOTEBOOK (player->priv->playlist_nt), 
 			      GTK_WIDGET (player->priv->list),
 			      gtk_label_new (_("Playlist")));
-
+			      
+    g_object_get (G_OBJECT (player->priv->conf),
+		  "showhide-playlist", &showhide,
+		  NULL);
+		  
     g_object_get (G_OBJECT (player->priv->conf),
 		  "window-width", &w,
 		  "window-height", &h,
 		  NULL);
+		  
+    parole_player_set_playlist_visible(player, showhide);
     
     gtk_window_set_default_size (GTK_WINDOW (player->priv->window), w, h);
+    gtk_window_resize (GTK_WINDOW (player->priv->window), w, h);
     
     gtk_widget_show_all (player->priv->window);
 
-    g_object_get (G_OBJECT (player->priv->conf),
-		  "showhide-playlist", &showhide,
-		  NULL);
-    parole_player_set_playlist_visible(player, showhide);
-    
     parole_player_set_wm_opacity_hint (player->priv->window);
     
     gtk_box_pack_start (GTK_BOX (output), 


More information about the Xfce4-commits mailing list