[Xfce4-commits] <parole:bluesabre/gtk3> Fix parole background image

Sean Davis noreply at xfce.org
Wed Aug 21 02:30:01 CEST 2013


Updating branch refs/heads/bluesabre/gtk3
         to 6728aaa9202732026dfd5ccf586fa354619a2476 (commit)
       from e00256f810a195e6ce79dcce4e7a4c26d2083fa9 (commit)

commit 6728aaa9202732026dfd5ccf586fa354619a2476
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Tue Aug 20 20:29:16 2013 -0400

    Fix parole background image

 data/interfaces/parole.ui |   29 +++++++++-
 src/gst/parole-gst.c      |  132 +++------------------------------------------
 src/parole-player.c       |  113 ++++++++++----------------------------
 3 files changed, 62 insertions(+), 212 deletions(-)

diff --git a/data/interfaces/parole.ui b/data/interfaces/parole.ui
index 9b3c389..c9c97ef 100644
--- a/data/interfaces/parole.ui
+++ b/data/interfaces/parole.ui
@@ -456,8 +456,8 @@
                         <property name="use_underline">True</property>
                         <property name="image">image3</property>
                         <property name="use_stock">False</property>
-                        <accelerator key="plus" signal="activate"/>
                         <accelerator key="equal" signal="activate"/>
+                        <accelerator key="plus" signal="activate"/>
                         <signal name="activate" handler="parole_player_volume_up" swapped="no"/>
                       </object>
                     </child>
@@ -555,8 +555,8 @@
                         <property name="can_focus">False</property>
                         <child>
                           <object class="GtkBox" id="video_output">
-                            <property name="visible">True</property>
                             <property name="can_focus">False</property>
+                            <property name="no_show_all">True</property>
                             <property name="orientation">vertical</property>
                             <child>
                               <placeholder/>
@@ -655,6 +655,31 @@
                             <property name="position">1</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkScrolledWindow" id="logo_window">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkViewport" id="viewport1">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="shadow_type">none</property>
+                                <child>
+                                  <object class="GtkImage" id="logo">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="stock">gtk-missing-image</property>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
                       </object>
                     </child>
                   </object>
diff --git a/src/gst/parole-gst.c b/src/gst/parole-gst.c
index ad63ac3..5b1baa6 100644
--- a/src/gst/parole-gst.c
+++ b/src/gst/parole-gst.c
@@ -450,105 +450,6 @@ parole_gst_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
 }
 
 static void
-parole_gst_draw_logo (ParoleGst *gst)
-{
-    static GdkPixbuf *pix = NULL;
-#if GTK_CHECK_VERSION(3, 0, 0)
-    cairo_region_t *region;
-    GdkRGBA *color;
-    cairo_t *cr;
-#else
-    GdkRegion *region;
-#endif
-    GdkRectangle rect;
-    GtkWidget *widget;
-    GtkAllocation *allocation = g_new0 (GtkAllocation, 1);
-
-    widget = GTK_WIDGET (gst);
-
-    if ( !gtk_widget_get_window(widget) )
-	return;
-
-    rect.x = 0;
-    rect.y = 0;
-    
-    gtk_widget_get_allocation(widget, allocation);
-    rect.width = allocation->width;
-    rect.height = allocation->height;
-
-#if GTK_CHECK_VERSION(3, 0, 0)
-    region = cairo_region_create_rectangle(&rect);
-#else
-    region = gdk_region_rectangle (&rect);
-#endif
-    
-    gdk_window_begin_paint_region (gtk_widget_get_window(widget),
-				   region);
-
-#if GTK_CHECK_VERSION(3, 0, 0)
-    cairo_region_destroy (region);
-
-    GdkWindow *window;
-    cairo_surface_t *target;
-
-    window = gtk_widget_get_window (widget);
-    target = cairo_get_group_target (cr);
-
-    /* Clear to parent-relative pixmap
-    * We need to use direct X access here because GDK doesn't know about
-    * the parent relative pixmap. */
-    cairo_surface_flush (target);
-
-    XClearArea (GDK_WINDOW_XDISPLAY (window),
-                GDK_WINDOW_XID (window),
-                0, 0,
-                allocation->width, allocation->height,
-                False);
-    cairo_surface_mark_dirty_rectangle (target,
-                                        0, 0,
-                                        allocation->width, allocation->height);
-#else
-    gdk_region_destroy (region);
-    
-    gdk_window_clear_area (gtk_widget_get_window(widget),
-			   0, 0,
-			   allocation->width,
-			   allocation->height);
-#endif
-
-    if (gst->priv->scale_logo)
-    {
-	if (pix)
-	    g_object_unref (pix);
-	pix = gdk_pixbuf_scale_simple (gst->priv->logo,
-				       allocation->width,
-				       allocation->height,
-				       GDK_INTERP_BILINEAR);
-	gst->priv->scale_logo = FALSE;
-    }
-
-#if GTK_CHECK_VERSION(3, 0, 0)
-    cr = gdk_cairo_create (gtk_widget_get_window(widget));
-    gdk_cairo_set_source_pixbuf (cr, pix, 0, 0);
-    cairo_paint (cr);
-    cairo_destroy (cr);
-#else
-    gdk_draw_pixbuf (GDK_DRAWABLE (gtk_widget_get_window(widget)),
-		     gtk_widget_get_style(widget)->fg_gc[0],
-		     pix,
-		     0, 0, 0, 0,
-		     allocation->width,
-		     allocation->height,
-		     GDK_RGB_DITHER_NONE,
-		     0, 0);
-#endif
-
-    gdk_window_end_paint (gtk_widget_get_window(GTK_WIDGET (gst)));
-    
-    g_free(allocation);
-}
-
-static void
 parole_gst_set_video_color_balance (ParoleGst *gst)
 {
     GstElement *video_sink;
@@ -613,14 +514,18 @@ parole_gst_set_video_overlay (ParoleGst *gst)
 }
 
 static gboolean
+#if GTK_CHECK_VERSION(3, 0, 0)
+parole_gst_expose_event (GtkWidget *widget, cairo_t *cr)
+#else
 parole_gst_expose_event (GtkWidget *widget, GdkEventExpose *ev)
+#endif
 {
     ParoleGst *gst;
     
     gboolean playing_video;
 
-    if ( ev && ev->count > 0 )
-	return TRUE;
+    //if ( ev && ev->count > 0 )
+	//return TRUE;
 
     gst = PAROLE_GST (widget);
 
@@ -643,8 +548,6 @@ parole_gst_expose_event (GtkWidget *widget, GdkEventExpose *ev)
         gst_x_overlay_expose (GST_X_OVERLAY (gst->priv->video_sink));
 #endif
 	    }
-	    else
-		parole_gst_draw_logo (gst);
 	    break;
 	case GST_STATE_PAUSED:
 	    if ( playing_video || gst->priv->vis_loaded || gst->priv->target == GST_STATE_PLAYING )
@@ -653,13 +556,9 @@ parole_gst_expose_event (GtkWidget *widget, GdkEventExpose *ev)
 #else
         gst_x_overlay_expose (GST_X_OVERLAY (gst->priv->video_sink));
 #endif
-	    else
-		parole_gst_draw_logo (gst);
 	    break;
 	case GST_STATE_READY:
-	    if (gst->priv->target != GST_STATE_PLAYING)
-		parole_gst_draw_logo (gst);
-	    else
+	    if (!(gst->priv->target != GST_STATE_PLAYING))
 #if GST_CHECK_VERSION(1, 0, 0)
 		gst_video_overlay_expose (GST_VIDEO_OVERLAY (gst->priv->video_sink));
 #else
@@ -668,24 +567,12 @@ parole_gst_expose_event (GtkWidget *widget, GdkEventExpose *ev)
 	    break;
 	case GST_STATE_NULL:
 	case GST_STATE_VOID_PENDING:
-	    parole_gst_draw_logo (gst);
 	    break;
     }
     return TRUE;
 }
 
 static void
-parole_gst_load_logo (ParoleGst *gst)
-{
-    gchar *path;
-
-    path = g_strdup_printf ("%s/parole.png", PIXMAPS_DIR);
-    
-    gst->priv->logo = gdk_pixbuf_new_from_file (path, NULL);
-    g_free (path);
-}
-
-static void
 parole_gst_query_capabilities (ParoleGst *gst)
 {
     GstQuery *query;
@@ -1126,7 +1013,6 @@ parole_gst_evaluate_state (ParoleGst *gst, GstState old, GstState new, GstState
 	    gtk_widget_get_allocation( GTK_WIDGET (gst), allocation );
 		parole_gst_size_allocate (GTK_WIDGET (gst), allocation);
 		g_free(allocation);
-		parole_gst_draw_logo (gst);
 	    }
 	    break;
 	}
@@ -2390,7 +2276,6 @@ parole_gst_constructed (GObject *object)
 
     
     parole_gst_update_vis (gst);
-    parole_gst_load_logo (gst);
     parole_gst_set_subtitle_encoding (gst);
     parole_gst_set_subtitle_font (gst);
     
@@ -2407,7 +2292,6 @@ parole_gst_style_set (GtkWidget *widget, GtkStyle *prev_style)
     if ( gst->priv->logo )
 	g_object_unref (gst->priv->logo);
 	
-    parole_gst_load_logo (gst);
     gtk_widget_queue_draw (widget);
 }
 
@@ -2427,7 +2311,7 @@ parole_gst_class_init (ParoleGstClass *klass)
     widget_class->size_allocate = parole_gst_size_allocate;
 #if GTK_CHECK_VERSION(3, 0, 0)
     // FIXME: parole-gst.c:2429:24: warning: assignment from incompatible pointer type [enabled by default]
-    widget_class->draw = parole_gst_expose_event;
+    //widget_class->draw = parole_gst_expose_event;
 #else
     widget_class->expose_event = parole_gst_expose_event;
 #endif
diff --git a/src/parole-player.c b/src/parole-player.c
index c3c2d4f..5201203 100644
--- a/src/parole-player.c
+++ b/src/parole-player.c
@@ -333,6 +333,8 @@ struct ParolePlayerPrivate
     GtkWidget		*fullscreen_button;
     GtkWidget		*fullscreen_image;
     GdkPixbuf       *logo;
+    GtkWidget       *logo_image;
+    GtkWidget       *logo_window;
     gboolean        scale_logo;
     
     GtkWidget		*hbox_infobar;
@@ -895,6 +897,7 @@ parole_player_show_audiobox (ParolePlayer *player)
 {
     /* Only show the audiobox if we're sure there's no video playing and 
        visualizations are disabled. */
+    gtk_widget_hide(player->priv->logo_window);
     if (!gst_get_has_video ( PAROLE_GST(player->priv->gst) ) &&
         !gst_get_has_vis   ( PAROLE_GST(player->priv->gst) ) )
     {
@@ -904,7 +907,7 @@ parole_player_show_audiobox (ParolePlayer *player)
     else
     {
 	gtk_widget_hide(player->priv->audiobox);
-	gtk_widget_show_all(player->priv->videobox);
+	gtk_widget_show(player->priv->videobox);
     }
 }
 
@@ -1446,6 +1449,16 @@ parole_player_stopped (ParolePlayer *player)
     gtk_widget_set_sensitive (player->priv->play_pause, 
 			      parole_media_list_is_selected_row (player->priv->list) || 
 			      !parole_media_list_is_empty (player->priv->list));
+			      
+    gtk_window_set_title (GTK_WINDOW (player->priv->window), "Parole Media Player");
+
+	gtk_widget_hide(player->priv->videobox);
+	gtk_widget_hide(player->priv->audiobox);
+	gtk_widget_show_all(player->priv->logo_window);
+	
+	gchar dur_text[128];
+    get_time_string (dur_text, 0);
+    gtk_label_set_text (GTK_LABEL (player->priv->label_duration), dur_text);
 
     parole_player_change_range_value (player, 0);
     gtk_widget_set_sensitive (player->priv->range, FALSE);
@@ -2758,7 +2771,6 @@ parole_audiobox_expose_event (GtkWidget *w, GdkEventExpose *ev, ParolePlayer *pl
 void
 on_content_area_size_allocate (GtkWidget *widget, GtkAllocation *allocation, ParolePlayer *player)
 {
-    g_print("size allocate\n");
     g_return_if_fail (allocation != NULL);
     
     gtk_widget_set_allocation(widget, allocation);
@@ -2771,74 +2783,15 @@ on_content_area_size_allocate (GtkWidget *widget, GtkAllocation *allocation, Par
 	}
 }
 
-static void
-parole_draw_logo (ParolePlayer *player)
-{
-    static GdkPixbuf *pix = NULL;
-#if GTK_CHECK_VERSION(3, 0, 0)
-    cairo_region_t *region;
-    GdkRGBA *color;
-    cairo_t *cr;
-#else
-    GdkRegion *region;
-#endif
-    GdkRectangle rect;
-    GtkWidget *widget;
+static gboolean
+on_logo_draw (GtkWidget *widget, GdkEventExpose *ev, ParolePlayer *player) {
+    GtkWidget *parent;
     GtkAllocation *allocation = g_new0 (GtkAllocation, 1);
-
-    widget = GTK_WIDGET (player->priv->eventbox_output);
-
-    if ( !gtk_widget_get_window(widget) )
-	return;
-
-    rect.x = 0;
-    rect.y = 0;
-    
-    gtk_widget_get_allocation(widget, allocation);
-    rect.width = allocation->width;
-    rect.height = allocation->height;
-
-#if GTK_CHECK_VERSION(3, 0, 0)
-    region = cairo_region_create_rectangle(&rect);
-#else
-    region = gdk_region_rectangle (&rect);
-#endif
-    
-    gdk_window_begin_paint_region (gtk_widget_get_window(widget),
-				   region);
-
-#if GTK_CHECK_VERSION(3, 0, 0)
-    cairo_region_destroy (region);
-
-    GdkWindow *window;
-    cairo_surface_t *target;
-
-    window = gtk_widget_get_window (widget);
-
-    //target = cairo_get_group_target (cr);
+    static GdkPixbuf *pix = NULL;
     
-    /* Clear to parent-relative pixmap
-    * We need to use direct X access here because GDK doesn't know about
-    * the parent relative pixmap. */
-    //cairo_surface_flush (target);
-
-    XClearArea (GDK_WINDOW_XDISPLAY (window),
-                GDK_WINDOW_XID (window),
-                0, 0,
-                allocation->width, allocation->height,
-                False);/*
-    cairo_surface_mark_dirty_rectangle (target,
-                                        0, 0,
-                                        allocation->width, allocation->height);*/
-#else
-    gdk_region_destroy (region);
+    parent = gtk_widget_get_parent(widget);
+    gtk_widget_get_allocation(parent, allocation);
     
-    gdk_window_clear_area (gtk_widget_get_window(widget),
-			   0, 0,
-			   allocation->width,
-			   allocation->height);
-#endif
-
     if (player->priv->scale_logo)
     {
 	if (pix)
@@ -2847,28 +2800,13 @@ parole_draw_logo (ParolePlayer *player)
 				       allocation->width,
 				       allocation->height,
 				       GDK_INTERP_BILINEAR);
+    gtk_image_set_from_pixbuf(GTK_IMAGE(player->priv->logo_image), pix);
 	player->priv->scale_logo = FALSE;
     }
 
-#if GTK_CHECK_VERSION(3, 0, 0)
-    cr = gdk_cairo_create (gtk_widget_get_window(widget));
-    gdk_cairo_set_source_pixbuf (cr, pix, 0, 0);
-    cairo_paint (cr);
-    cairo_destroy (cr);
-#else
-    gdk_draw_pixbuf (GDK_DRAWABLE (gtk_widget_get_window(widget)),
-		     gtk_widget_get_style(widget)->fg_gc[0],
-		     pix,
-		     0, 0, 0, 0,
-		     allocation->width,
-		     allocation->height,
-		     GDK_RGB_DITHER_NONE,
-		     0, 0);
-#endif
-
-    gdk_window_end_paint (gtk_widget_get_window(GTK_WIDGET (player->priv->eventbox_output)));
-    
     g_free(allocation);
+    
+    return FALSE;
 }
 
 gboolean
@@ -2885,7 +2823,7 @@ parole_player_configure_event_cb (GtkWidget *widget, GdkEventConfigure *ev, Paro
 		      NULL);
     }
     
-    parole_draw_logo(player);
+    player->priv->scale_logo = TRUE;
     
     return FALSE;
 }
@@ -3191,6 +3129,9 @@ parole_player_init (ParolePlayer *player)
     player->priv->fullscreen_image = GTK_WIDGET (gtk_builder_get_object (builder, "image_media_fullscreen"));
     player->priv->eventbox_output = GTK_WIDGET (gtk_builder_get_object (builder, "content_area"));
     player->priv->logo = gdk_pixbuf_new_from_file (g_strdup_printf ("%s/parole.png", PIXMAPS_DIR), NULL);
+    player->priv->logo_image = GTK_WIDGET (gtk_builder_get_object (builder, "logo"));
+    g_signal_connect(player->priv->logo_image, "draw", G_CALLBACK(on_logo_draw), player);
+    player->priv->logo_window = GTK_WIDGET (gtk_builder_get_object (builder, "logo_window"));
     
     hpaned = GTK_WIDGET (gtk_builder_get_object (builder, "hpaned"));
     gtk_widget_style_get (hpaned, "handle-size", &player->priv->handle_width, NULL);


More information about the Xfce4-commits mailing list