[totem] backend: Cleanup auto-resize code
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] backend: Cleanup auto-resize code
- Date: Fri, 3 Dec 2010 01:07:52 +0000 (UTC)
commit ac16366ad0fa981311a707d56f0c85ab33b55acd
Author: Bastien Nocera <hadess hadess net>
Date: Fri Dec 3 01:06:50 2010 +0000
backend: Cleanup auto-resize code
Thanks to Owen Taylor for the nice tricks!
src/backend/bacon-video-widget-gst-0.10.c | 28 +++++++-----------
src/backend/video-utils.c | 44 -----------------------------
src/backend/video-utils.h | 3 --
3 files changed, 11 insertions(+), 64 deletions(-)
---
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index d15b3da..0d19ac4 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -576,11 +576,12 @@ bacon_video_widget_realize (GtkWidget * widget)
{
BaconVideoWidget *bvw = BACON_VIDEO_WIDGET (widget);
GdkWindowAttr attributes;
- gint attributes_mask, w, h;
+ gint attributes_mask;
GdkColor colour;
GdkWindow *window;
GdkEventMask event_mask;
GtkAllocation allocation;
+ GtkWidget *toplevel;
event_mask = gtk_widget_get_events (widget)
| GDK_POINTER_MOTION_MASK
@@ -628,9 +629,10 @@ bacon_video_widget_realize (GtkWidget * widget)
g_signal_connect (G_OBJECT (gtk_widget_get_screen (widget)),
"size-changed", G_CALLBACK (size_changed_cb), bvw);
- /* nice hack to show the logo fullsize, while still being resizable */
- get_media_size (BACON_VIDEO_WIDGET (widget), &w, &h);
- totem_widget_set_preferred_size (widget, w, h);
+ /* setup the toplevel, ready to be resized */
+ toplevel = gtk_widget_get_toplevel (widget);
+ if (gtk_widget_is_toplevel (toplevel))
+ gtk_window_set_geometry_hints (GTK_WINDOW (toplevel), widget, NULL, 0);
bacon_video_widget_gst_missing_plugins_setup (bvw);
@@ -1382,16 +1384,6 @@ bacon_video_widget_init (BaconVideoWidget * bvw)
bacon_video_widget_gst_missing_plugins_blacklist ();
}
-static void
-shrink_toplevel (BaconVideoWidget * bvw)
-{
- GtkWidget *toplevel, *widget;
- widget = GTK_WIDGET (bvw);
- toplevel = gtk_widget_get_toplevel (widget);
- if (toplevel != widget && GTK_IS_WINDOW (toplevel) != FALSE)
- gtk_window_resize (GTK_WINDOW (toplevel), 1, 1);
-}
-
static gboolean bvw_query_timeout (BaconVideoWidget *bvw);
static gboolean bvw_query_buffering_timeout (BaconVideoWidget *bvw);
static void parse_stream_info (BaconVideoWidget *bvw);
@@ -5211,6 +5203,7 @@ bacon_video_widget_get_aspect_ratio (BaconVideoWidget *bvw)
void
bacon_video_widget_set_scale_ratio (BaconVideoWidget * bvw, gfloat ratio)
{
+ GtkWidget *toplevel;
gint w, h;
g_return_if_fail (bvw != NULL);
@@ -5246,10 +5239,11 @@ bacon_video_widget_set_scale_ratio (BaconVideoWidget * bvw, gfloat ratio)
w = (gfloat) w * ratio;
h = (gfloat) h * ratio;
- shrink_toplevel (bvw);
-
GST_DEBUG ("setting preferred size %dx%d", w, h);
- totem_widget_set_preferred_size (GTK_WIDGET (bvw), w, h);
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (bvw));
+ if (gtk_widget_is_toplevel (toplevel))
+ gtk_window_resize_to_geometry (GTK_WINDOW (toplevel), w, h);
}
/**
diff --git a/src/backend/video-utils.c b/src/backend/video-utils.c
index e235ab7..0116f82 100644
--- a/src/backend/video-utils.c
+++ b/src/backend/video-utils.c
@@ -165,50 +165,6 @@ totem_time_to_string_text (gint64 msecs)
return string;
}
-typedef struct _TotemPrefSize {
- gint width, height;
- gulong sig_id;
-} TotemPrefSize;
-
-static gboolean
-cb_unset_size (gpointer data)
-{
- GtkWidget *widget = data;
-
- gtk_widget_queue_resize_no_redraw (widget);
-
- return FALSE;
-}
-
-static void
-cb_set_preferred_size (GtkWidget *widget, GtkRequisition *req,
- gpointer data)
-{
- TotemPrefSize *size = data;
-
- req->width = size->width;
- req->height = size->height;
-
- g_signal_handler_disconnect (widget, size->sig_id);
- g_free (size);
- g_idle_add (cb_unset_size, widget);
-}
-
-void
-totem_widget_set_preferred_size (GtkWidget *widget, gint width,
- gint height)
-{
- TotemPrefSize *size = g_new (TotemPrefSize, 1);
-
- size->width = width;
- size->height = height;
- size->sig_id = g_signal_connect (widget, "size-request",
- G_CALLBACK (cb_set_preferred_size),
- size);
-
- gtk_widget_queue_resize (widget);
-}
-
gboolean
totem_ratio_fits_screen (GtkWidget *video_widget, int video_width,
int video_height, gfloat ratio)
diff --git a/src/backend/video-utils.h b/src/backend/video-utils.h
index d1f1f6a..5d6708d 100644
--- a/src/backend/video-utils.h
+++ b/src/backend/video-utils.h
@@ -13,9 +13,6 @@ char *totem_time_to_string (gint64 msecs);
gint64 totem_string_to_time (const char *time_string);
char *totem_time_to_string_text (gint64 msecs);
-void totem_widget_set_preferred_size (GtkWidget *widget,
- gint width,
- gint height);
gboolean totem_ratio_fits_screen (GtkWidget *widget,
int video_width,
int video_height,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]