コード例 #1
0
static gboolean webViewLeavingFullScreen(WebKitWebView *webView, GObject *element, GtkWidget* vbox)
{
    GtkWidget *window = gtk_widget_get_toplevel(GTK_WIDGET(webView));
    if (gtk_widget_is_toplevel(window) && GTK_IS_WINDOW(window) && !GTK_IS_OFFSCREEN_WINDOW(window))
        g_signal_handlers_disconnect_by_func(window, G_CALLBACK(webViewWindowStateEvent), webView);
    gtk_container_foreach(GTK_CONTAINER(vbox), (GtkCallback) showWidget, NULL);
    return FALSE;
}
コード例 #2
0
static gboolean webViewWindowStateEvent(GtkWidget *widget, GdkEventWindowState *event, WebKitWebView *webView)
{
    if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) {
        WebKitWebFrame *frame = webkit_web_view_get_main_frame(webView);
        const gchar *uri = webkit_web_frame_get_uri(frame);
        GtkWidget *window = gtk_widget_get_toplevel(GTK_WIDGET(webView));
        if (!gtk_widget_is_toplevel(window) || !GTK_IS_WINDOW(window) || GTK_IS_OFFSCREEN_WINDOW(window))
            window = 0;

        GtkWidget *dialog = gtk_message_dialog_new(window ? GTK_WINDOW(window) : 0,
                                                    GTK_DIALOG_MODAL,
                                                    GTK_MESSAGE_INFO,
                                                    GTK_BUTTONS_CLOSE,
                                                    "%s is now full screen. Press ESC or f to exit.", uri);
        g_signal_connect_swapped(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog);
        g_timeout_add(1500, (GSourceFunc) webViewFullscreenMessageWindowClose, dialog);
        gtk_dialog_run(GTK_DIALOG(dialog));
    }
    return TRUE;
}
コード例 #3
0
static gboolean webViewEnteringFullScreen(WebKitWebView *webView, GObject *element, GtkWidget* vbox)
{
    WebKitWebFrame *frame = webkit_web_view_get_main_frame(webView);
    const gchar *uri = webkit_web_frame_get_uri(frame);
    GtkWidget *window = gtk_widget_get_toplevel(GTK_WIDGET(webView));
    if (!gtk_widget_is_toplevel(window) || !GTK_IS_WINDOW(window) || GTK_IS_OFFSCREEN_WINDOW(window))
        window = 0;

    GtkWidget *dialog = gtk_message_dialog_new(window ? GTK_WINDOW(window) : 0,
                                               GTK_DIALOG_MODAL,
                                               GTK_MESSAGE_INFO,
                                               GTK_BUTTONS_YES_NO,
                                               "Allow full screen display of %s ?", uri);
    gint result = gtk_dialog_run(GTK_DIALOG(dialog));
    if (result == GTK_RESPONSE_YES) {
        gtk_container_foreach(GTK_CONTAINER(vbox), (GtkCallback) hideWidget, NULL);
        gtk_widget_destroy(GTK_WIDGET(dialog));
        return FALSE;
    }
    gtk_widget_destroy(GTK_WIDGET(dialog));
    return TRUE;
}
コード例 #4
0
bool widgetIsOnscreenToplevelWindow(GtkWidget* widget)
{
    return widget && gtk_widget_is_toplevel(widget) && GTK_IS_WINDOW(widget) && !GTK_IS_OFFSCREEN_WINDOW(widget);
}