[epiphany] popup windows should respect the window properties



commit d2ec9ad9588e7f720af6fa119ab63086909afc38
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Wed Jan 29 15:15:52 2014 +0100

    popup windows should respect the window properties
    
    Change the windows chrome according to the window properties used when
    creating popups.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723238

 src/ephy-toolbar.c |   29 +++++++++++++++++++++++++----
 src/ephy-window.c  |   26 +++++++++++++++++++++++---
 src/ephy-window.h  |    2 ++
 3 files changed, 50 insertions(+), 7 deletions(-)
---
diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c
index ec33025..4eefae7 100644
--- a/src/ephy-toolbar.c
+++ b/src/ephy-toolbar.c
@@ -41,6 +41,10 @@ static GParamSpec *object_properties[N_PROPERTIES] = { NULL, };
 struct _EphyToolbarPrivate {
   EphyWindow *window;
   GtkWidget *entry;
+  GtkWidget *navigation_box;
+  GtkWidget *location_box;
+  GtkWidget *page_menu_button;
+  GtkWidget *new_tab_button;
 };
 
 static void
@@ -79,6 +83,20 @@ ephy_toolbar_get_property (GObject *object,
 }
 
 static void
+sync_chromes_visibility (EphyToolbar *toolbar)
+{
+  EphyToolbarPrivate *priv = toolbar->priv;
+  EphyWindowChrome chrome;
+
+  chrome = ephy_window_get_chrome (priv->window);
+
+  gtk_widget_set_visible (priv->navigation_box, chrome & EPHY_WINDOW_CHROME_TOOLBAR);
+  gtk_widget_set_visible (priv->location_box, chrome & EPHY_WINDOW_CHROME_LOCATION);
+  gtk_widget_set_visible (priv->page_menu_button, chrome & EPHY_WINDOW_CHROME_MENU);
+  gtk_widget_set_visible (priv->new_tab_button, chrome & EPHY_WINDOW_CHROME_TABSBAR);
+}
+
+static void
 ephy_toolbar_constructed (GObject *object)
 {
   EphyToolbarPrivate *priv = EPHY_TOOLBAR (object)->priv;
@@ -95,8 +113,12 @@ ephy_toolbar_constructed (GObject *object)
 
   mode = ephy_embed_shell_get_mode (ephy_embed_shell_get_default ());
 
+  g_signal_connect_swapped (priv->window, "notify::chrome",
+                            G_CALLBACK (sync_chromes_visibility), toolbar);
+
   /* Back and Forward */
   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  priv->navigation_box = box;
 
   /* Back */
   button = ephy_middle_clickable_button_new ();
@@ -131,10 +153,10 @@ ephy_toolbar_constructed (GObject *object)
                                "linked");
 
   gtk_header_bar_pack_start (GTK_HEADER_BAR (toolbar), box);
-  gtk_widget_show_all (box);
 
   /* Location and Reload/Stop */
   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  priv->location_box = box;
   gtk_widget_set_halign (box, GTK_ALIGN_CENTER);
 
   /* Location */
@@ -178,6 +200,7 @@ ephy_toolbar_constructed (GObject *object)
 
   /* Page Menu */
   button = gtk_button_new ();
+  priv->page_menu_button = button;
   gtk_widget_set_name (button, "ephy-page-menu-button");
   /* FIXME: apparently we need an image inside the button for the action
    * icon to appear. */
@@ -187,10 +210,10 @@ ephy_toolbar_constructed (GObject *object)
   gtk_activatable_set_related_action (GTK_ACTIVATABLE (button),
                                       action);
   gtk_header_bar_pack_end (GTK_HEADER_BAR (toolbar), button);
-  gtk_widget_show_all (button);
 
   /* New Tab */
   button = gtk_button_new ();
+  priv->new_tab_button = button;
   /* FIXME: apparently we need an image inside the button for the action
    * icon to appear. */
   gtk_button_set_image (GTK_BUTTON (button), gtk_image_new ());
@@ -200,8 +223,6 @@ ephy_toolbar_constructed (GObject *object)
                                       action);
   gtk_button_set_label (GTK_BUTTON (button), NULL);
   gtk_header_bar_pack_end (GTK_HEADER_BAR (toolbar), button);
-  if (mode != EPHY_EMBED_SHELL_MODE_APPLICATION)
-    gtk_widget_show_all (button);
 
   /* Add title only in application mode. */
   if (mode == EPHY_EMBED_SHELL_MODE_APPLICATION)
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 4d4a29a..d117225 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1968,10 +1968,20 @@ ephy_window_configure_for_view (EphyWindow *window,
 {
        WebKitWindowProperties *properties;
        GdkRectangle geometry;
+       EphyWindowChrome chrome = 0;
 
        properties = webkit_web_view_get_window_properties (web_view);
 
-       gtk_widget_set_visible (window->priv->toolbar, webkit_window_properties_get_toolbar_visible 
(properties));
+       if (webkit_window_properties_get_toolbar_visible (properties))
+               chrome |= EPHY_WINDOW_CHROME_TOOLBAR;
+
+       if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_APPLICATION)
+       {
+               if (webkit_window_properties_get_menubar_visible (properties))
+                       chrome |= EPHY_WINDOW_CHROME_MENU;
+               if (webkit_window_properties_get_locationbar_visible (properties))
+                       chrome |= EPHY_WINDOW_CHROME_LOCATION;
+       }
 
        webkit_window_properties_get_geometry (properties, &geometry);
        gtk_window_set_default_size (GTK_WINDOW (window), geometry.width, geometry.height);
@@ -1980,7 +1990,7 @@ ephy_window_configure_for_view (EphyWindow *window,
                gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
 
        window->priv->is_popup = TRUE;
-       sync_chromes_visibility (window);
+       ephy_window_set_chrome (window, chrome);
        g_signal_connect (properties, "notify::geometry",
                          G_CALLBACK (window_properties_geometry_changed),
                          window);
@@ -3278,6 +3288,7 @@ ephy_window_constructor (GType type,
        GtkCssProvider *css_provider;
        int i;
        EphyEmbedShellMode mode;
+       EphyWindowChrome chrome = EPHY_WINDOW_CHROME_DEFAULT;
 
        object = G_OBJECT_CLASS (ephy_window_parent_class)->constructor
                (type, n_construct_properties, construct_params);
@@ -3413,6 +3424,7 @@ ephy_window_constructor (GType type,
                        ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME, TRUE);
                        gtk_action_set_visible (action, FALSE);
                }
+               chrome &= ~(EPHY_WINDOW_CHROME_LOCATION | EPHY_WINDOW_CHROME_MENU | 
EPHY_WINDOW_CHROME_TABSBAR);
        }
 
        /* We never want the menubar shown, we merge the app menu into
@@ -3429,7 +3441,7 @@ ephy_window_constructor (GType type,
 
        init_menu_updaters (window);
 
-       ephy_window_set_chrome (window, EPHY_WINDOW_CHROME_DEFAULT);
+       ephy_window_set_chrome (window, chrome);
 
        return object;
 }
@@ -3932,3 +3944,11 @@ ephy_window_close (EphyWindow *window)
 
        return TRUE;
 }
+
+EphyWindowChrome
+ephy_window_get_chrome (EphyWindow *window)
+{
+       g_return_val_if_fail (EPHY_IS_WINDOW (window), EPHY_WINDOW_CHROME_DEFAULT);
+
+       return window->priv->chrome;
+}
diff --git a/src/ephy-window.h b/src/ephy-window.h
index 7ca9675..4d4e3c8 100644
--- a/src/ephy-window.h
+++ b/src/ephy-window.h
@@ -87,6 +87,8 @@ gboolean          ephy_window_close               (EphyWindow *window);
 void              ephy_window_add_download        (EphyWindow *window,
                                                    EphyDownload *download);
 
+EphyWindowChrome  ephy_window_get_chrome          (EphyWindow *window);
+
 gboolean      ephy_window_is_on_current_workspace (EphyWindow *window);
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]