Example #1
0
GdkPixbuf *preview_theme(const gchar *name, const gchar *titlelayout,
                         RrFont *active_window_font,
                         RrFont *inactive_window_font,
                         RrFont *menu_title_font,
                         RrFont *menu_item_font,
                         RrFont *osd_active_font,
                         RrFont *osd_inactive_font)
{

    GdkPixbuf *preview;
    GdkPixbuf *menu;
    GdkPixbuf *window;

    gint window_w;
    gint menu_w;

    gint w, h;

    RrTheme *theme = RrThemeNew(rrinst, name, FALSE,
                                active_window_font, inactive_window_font,
                                menu_title_font, menu_item_font,
                                osd_active_font, osd_inactive_font);
    if (!theme)
        return NULL;

    menu = preview_menu(theme);
  
    window_w = theme_window_min_width(theme, titlelayout);

    menu_w = gdk_pixbuf_get_width(menu);
    h = gdk_pixbuf_get_height(menu);

    w = MAX(window_w, menu_w) + 20;
  
    /* we don't want windows disappearing on us */
    if (!window_w) window_w = menu_w;

    preview = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8,
                             w, h + 2*(theme->title_height +5) + 1);
    gdk_pixbuf_fill(preview, 0); /* clear */

    window = preview_window(theme, titlelayout, FALSE, window_w, h);
    gdk_pixbuf_copy_area(window, 0, 0, window_w, h, preview, 20, 0);
    g_object_unref(window);

    window = preview_window(theme, titlelayout, TRUE, window_w, h);
    gdk_pixbuf_copy_area(window, 0, 0, window_w, h,
                         preview, 10, theme->title_height + 5);
    g_object_unref(window);

    gdk_pixbuf_copy_area(menu, 0, 0, menu_w, h,
                         preview, 0, 2 * (theme->title_height + 5));
    g_object_unref(menu);

    RrThemeFree(theme);

    return preview;
}
Example #2
0
void
ghb_preview_init(signal_user_data_t *ud)
{
    GtkWidget *widget;

    ud->preview = g_malloc0(sizeof(preview_t));
    ud->preview->view = GHB_WIDGET(ud->builder, "preview_image");
    gtk_widget_realize(ud->preview->view);

    ud->preview->pause = TRUE;
    ud->preview->encode_frame = -1;
    ud->preview->live_id = -1;
    widget = GHB_WIDGET(ud->builder, "preview_button_image");
    gtk_widget_get_size_request(widget, &ud->preview->button_width, &ud->preview->button_height);

    widget = GHB_WIDGET(ud->builder, "preview_hud");
    gtk_widget_realize(widget);
    // Use a native window for the HUD.  Client side windows don't get
    // updated properly as video changes benieth them.
    // This also seems to be required to make the preview hud visible
    // on win32.  otherwise it is transparent for some reason.
    if (!gdk_window_ensure_native(gtk_widget_get_window(widget)))
    {
        g_message("Couldn't create native window for HUD.");
    }

#if defined(_ENABLE_GST)
    GstBus *bus;
    GstElement *xover;

    if (!gdk_window_ensure_native(preview_window(ud->preview->view)))
    {
        g_message("Couldn't create native window for GstXOverlay. Disabling live preview.");
        GtkWidget *widget = GHB_WIDGET(ud->builder, "live_preview_box");
        gtk_widget_hide (widget);
        widget = GHB_WIDGET(ud->builder, "live_preview_duration_box");
        gtk_widget_hide (widget);
        return;
    }

#if !defined(_WIN32)
    ud->preview->xid = GDK_WINDOW_XID(preview_window(ud->preview->view));
#else
    ud->preview->xid = GDK_WINDOW_HWND(preview_window(ud->preview->view));
#endif
    ud->preview->play = gst_element_factory_make("playbin", "play");
    xover = gst_element_factory_make("gconfvideosink", "xover");
    if (xover == NULL)
    {
        xover = gst_element_factory_make("xvimagesink", "xover");
    }
    if (xover == NULL)
    {
        xover = gst_element_factory_make("ximagesink", "xover");
    }
    if (xover == NULL)
    {
        xover = gst_element_factory_make("autovideosink", "xover");
    }
    if (ud->preview->play == NULL || xover == NULL)
    {
        g_message("Couldn't initialize gstreamer. Disabling live preview.");
        GtkWidget *widget = GHB_WIDGET(ud->builder, "live_preview_box");
        gtk_widget_hide (widget);
        widget = GHB_WIDGET(ud->builder, "live_preview_duration_box");
        gtk_widget_hide (widget);
        return;
    }
    else
    {

        g_object_set(G_OBJECT(ud->preview->play), "video-sink", xover, NULL);
        g_object_set(ud->preview->play, "subtitle-font-desc",
                    "sans bold 20", NULL);

        bus = gst_pipeline_get_bus(GST_PIPELINE(ud->preview->play));
        gst_bus_add_watch(bus, live_preview_cb, ud);
#if GST_CHECK_VERSION(1, 0, 0)
        gst_bus_set_sync_handler(bus, create_window, ud->preview, NULL);
#else
        gst_bus_set_sync_handler(bus, create_window, ud->preview);
#endif
        gst_object_unref(bus);
        ud->preview->live_enabled = 1;
    }
#else
    widget = GHB_WIDGET(ud->builder, "live_preview_box");
    gtk_widget_hide (widget);
    widget = GHB_WIDGET(ud->builder, "live_preview_duration_box");
    gtk_widget_hide (widget);
#endif
}