summaryrefslogtreecommitdiffstats
path: root/gtk/src
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/src')
-rw-r--r--gtk/src/ghb.ui38
-rw-r--r--gtk/src/main.c70
-rw-r--r--gtk/src/preview.c79
3 files changed, 127 insertions, 60 deletions
diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui
index 94e6c53f6..7d4fc799c 100644
--- a/gtk/src/ghb.ui
+++ b/gtk/src/ghb.ui
@@ -4086,6 +4086,7 @@ location as the movie.</property>
</child>
</object>
<object class="GtkWindow" id="settings_window">
+ <property name="opacity">.85</property>
<property name="title" translatable="yes">Picture Settings</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
@@ -4860,6 +4861,12 @@ location as the movie.</property>
<signal handler="preview_configure_cb" name="configure-event"/>
<signal handler="preview_window_delete_cb" name="delete_event"/>
<child>
+ <object class="GtkTable" id="table111">
+ <property name="visible">True</property>
+ <property name="n_rows">1</property>
+ <property name="n_columns">1</property>
+
+ <child>
<object class="GtkAlignment" id="alignment111">
<property name="visible">True</property>
<property name="xalign">.5</property>
@@ -4879,14 +4886,22 @@ location as the movie.</property>
</packing>
</child>
</object>
+ <packing>
+ </packing>
</child>
- </object>
- <object class="GtkWindow" id="preview_hud">
- <property name="default_width">500</property>
- <property name="decorated">False</property>
- <property name="opacity">.50</property>
- <property name="skip_taskbar_hint">True</property>
- <property name="skip_pager_hint">True</property>
+ <child>
+ <object class="GtkAlignment" id="preview_hud">
+ <property name="visible">False</property>
+ <property name="xalign">.5</property>
+ <property name="yalign">.75</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+
+ <child>
+ <object class="GtkEventBox" id="preview_event_box">
+ <property name="visible">True</property>
+ <property name="width-request">500</property>
+ <property name="app-paintable">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
<signal name="enter-notify-event" handler="hud_enter_cb"/>
<child>
@@ -5069,6 +5084,15 @@ location as the movie.</property>
</object>
</child>
</object>
+ </child>
+
+ </object>
+ <packing>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
<object class="GtkAboutDialog" id="hb_about">
<property name="border_width">5</property>
<property name="title" translatable="yes">About HandBrake</property>
diff --git a/gtk/src/main.c b/gtk/src/main.c
index 4c7952fa3..d0d020cbb 100644
--- a/gtk/src/main.c
+++ b/gtk/src/main.c
@@ -494,11 +494,11 @@ extern int mm_flags;
int mm_support();
void x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud);
+void preview_window_expose_cb(void);
int
main (int argc, char *argv[])
{
- GtkWidget *window;
signal_user_data_t *ud;
GValue *preset;
GError *error = NULL;
@@ -540,11 +540,50 @@ main (int argc, char *argv[])
// Enable events that alert us to media change events
watch_volumes (ud);
ud->builder = create_builder_or_die (BUILDER_NAME);
+
+ GtkWidget *window, *event, *draw;
+ GdkScreen *screen;
+ GdkColormap *rgba;
+ GdkColor color;
+
+ /* Make the widgets */
+ //event = gtk_event_box_new ();
+ event = GHB_WIDGET(ud->builder, "preview_event_box");
+ draw = GHB_WIDGET(ud->builder, "preview_image");
+ window = GHB_WIDGET(ud->builder, "preview_window");
+
+ gdk_color_parse("black", &color);
+ gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &color);
+ gdk_color_parse("gray18", &color);
+ gtk_widget_modify_bg(event, GTK_STATE_NORMAL, &color);
+ /* Set the colourmap for the event box.
+ ** Must be done before the event box is realised.
+ **/
+ screen = gtk_widget_get_screen (draw);
+ rgba = gdk_screen_get_rgba_colormap (screen);
+ //gtk_widget_set_colormap (draw, rgba);
+
+ gtk_widget_set_colormap (event, rgba);
+
+ /* Set up the compositing handler.
+ ** Note that we do _after_ so that the normal (red) background is drawn
+ ** by gtk before our compositing occurs.
+ **/
+ g_signal_connect_after (window, "expose-event",
+ G_CALLBACK (preview_window_expose_cb), ud);
+ /* Set the event box GdkWindow to be composited.
+ ** Obviously must be performed after event box is realised.
+ **/
+ gtk_widget_realize(draw);
+ gtk_widget_realize(event);
+ gdk_window_set_composited (draw->window, TRUE);
+ gdk_window_set_composited (event->window, TRUE);
+
// Redirect stderr to the activity window
ghb_preview_init(ud);
IoRedirect(ud);
- ghb_log( "%s - %s - %s",
- HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE );
+ ghb_log( "%s - %s - %s",
+ HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE );
ghb_init_dep_map();
// Need to connect x264_options textview buffer to the changed signal
@@ -576,10 +615,6 @@ main (int argc, char *argv[])
ghb_presets_load();
ghb_prefs_load(ud);
- // Start the show.
- window = GHB_WIDGET (ud->builder, "hb_window");
- gtk_widget_show (window);
-
ghb_prefs_to_ui(ud);
gint logLevel;
@@ -632,27 +667,6 @@ main (int argc, char *argv[])
g_timeout_add (500, ghb_timer_cb, (gpointer)ud);
// Everything should be go-to-go. Lets rock!
- // Create floating window over preview image
- GtkWidget *widget;
- GdkWindow *parent, *win;
-
- widget = GHB_WIDGET(ud->builder, "preview_image");
- gtk_widget_realize(widget);
- //parent = gtk_widget_get_window(widget);
- parent = widget->window;
- widget = GHB_WIDGET(ud->builder, "preview_hud");
- gtk_widget_realize(widget);
- //win = gtk_widget_get_window(widget);
- win = widget->window;
- gdk_window_reparent(win, parent, 0, 0);
-
-/*
- if (ghb_settings_get_boolean(ud->settings, "preview_fullscreen"))
- {
- gtk_window_set_resizable(window, TRUE);
- gtk_window_fullscreen(window);
- }
-*/
gtk_main ();
ghb_backend_close();
if (ud->queue)
diff --git a/gtk/src/preview.c b/gtk/src/preview.c
index 61647a400..511e8f7b4 100644
--- a/gtk/src/preview.c
+++ b/gtk/src/preview.c
@@ -100,6 +100,8 @@ ghb_par_scale(signal_user_data_t *ud, gint *width, gint *height, gint par_n, gin
gint64 num, den;
ghb_screen_par(ud, &disp_par_n, &disp_par_d);
+ if (disp_par_n < 1) disp_par_n = 1;
+ if (disp_par_d < 1) disp_par_d = 1;
num = par_n * disp_par_d;
den = par_d * disp_par_n;
@@ -127,6 +129,7 @@ ghb_preview_init(signal_user_data_t *ud)
ud->preview->encode_frame = -1;
ud->preview->live_id = -1;
//xover = gst_element_factory_make("xvimagesink", "xover");
+ //xover = gst_element_factory_make("ximagesink", "xover");
xover = gst_element_factory_make("gconfvideosink", "xover");
g_object_set(G_OBJECT(ud->preview->play), "video-sink", xover, NULL);
//g_object_set(G_OBJECT(xover), "force-aspect-ratio", TRUE, NULL);
@@ -818,29 +821,6 @@ picture_settings_alt_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(toggle), !active);
}
-static void
-hud_set_position(signal_user_data_t *ud)
-{
- GtkWidget *widget;
- GdkWindow *parent, *win;
- gint pw, ph, w, h, x, y;
-
- widget = GHB_WIDGET(ud->builder, "preview_image");
- //parent = gtk_widget_get_window(widget);
- parent = widget->window;
- widget = GHB_WIDGET(ud->builder, "preview_hud");
- //win = gtk_widget_get_window(widget);
- win = widget->window;
- gdk_drawable_get_size(GDK_DRAWABLE(parent), &pw, &ph);
- gdk_drawable_get_size(GDK_DRAWABLE(win), &w, &h);
- x = pw/2 - w/2;
- if (ph/4 > h/2)
- y = ph - ph/4 - h/2;
- else
- y = ph - h;
- gdk_window_move(win, x, y);
-}
-
static gboolean
go_full(signal_user_data_t *ud)
{
@@ -1078,7 +1058,6 @@ preview_motion_cb(
widget = GHB_WIDGET(ud->builder, "preview_hud");
gtk_widget_show(widget);
- hud_set_position(ud);
}
hud_timeout_id = g_timeout_add_seconds(10, (GSourceFunc)hud_timeout, ud);
return FALSE;
@@ -1097,7 +1076,6 @@ preview_image_configure_cb(
{
w = event->width;
h = event->height;
- hud_set_position(ud);
}
return FALSE;
}
@@ -1145,3 +1123,54 @@ settings_configure_cb(
return FALSE;
}
+G_MODULE_EXPORT gboolean
+preview_window_expose_cb(
+ GtkWidget *widget,
+ GdkEventExpose *event,
+ signal_user_data_t *ud)
+{
+ GdkRegion *region;
+ GtkWidget *child;
+ cairo_t *cr;
+
+ //g_debug("preview_window_expose_cb()");
+ /* get our child (in this case, the draw area) */
+ child = GHB_WIDGET(ud->builder, "preview_image");
+ /* create a cairo context to draw to the window */
+ cr = gdk_cairo_create (widget->window);
+ /* the source data is the (composited) event box */
+ gdk_cairo_set_source_pixmap (cr, child->window,
+ child->allocation.x,
+ child->allocation.y);
+ /* draw no more than our expose event intersects our child */
+ region = gdk_region_rectangle (&child->allocation);
+ gdk_region_intersect (region, event->region);
+ gdk_cairo_region (cr, region);
+ cairo_clip (cr);
+ /* composite, with a 100% opacity */
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_paint_with_alpha (cr, 1);
+
+ cairo_reset_clip(cr);
+ /* get our child (in this case, the event box) */
+ child = GHB_WIDGET(ud->builder, "preview_event_box");
+ /* create a cairo context to draw to the window */
+ cr = gdk_cairo_create (widget->window);
+ /* the source data is the (composited) event box */
+ gdk_cairo_set_source_pixmap (cr, child->window,
+ child->allocation.x,
+ child->allocation.y);
+ /* draw no more than our expose event intersects our child */
+ region = gdk_region_rectangle (&child->allocation);
+ gdk_region_intersect (region, event->region);
+ gdk_cairo_region (cr, region);
+ cairo_clip (cr);
+ /* composite, with a 85% opacity */
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_paint_with_alpha (cr, .85);
+
+ /* we're done */
+ cairo_destroy (cr);
+ return FALSE;
+}
+