[epiphany/wip/exalm/fullscreen: 3/4] header-bar: Use restore button in fullscreen



commit 85f8f6b136e0b88900513f49b50fb02c16968b79
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Sep 27 19:18:51 2019 +0500

    header-bar: Use restore button in fullscreen
    
    Hide window buttons and use a restore button instead.
    
    Fixes https://gitlab.gnome.org/GNOME/epiphany/issues/938

 src/ephy-header-bar.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
---
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index 218e654b1..c01d61be6 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -61,6 +61,7 @@ struct _EphyHeaderBar {
   GtkWidget *bookmarks_button;
   GtkWidget *page_menu_button;
   GtkWidget *zoom_level_button;
+  GtkWidget *restore_button;
 };
 
 G_DEFINE_TYPE (EphyHeaderBar, ephy_header_bar, GTK_TYPE_HEADER_BAR)
@@ -114,6 +115,17 @@ sync_chromes_visibility (EphyHeaderBar *header_bar)
   gtk_widget_set_visible (header_bar->page_menu_button, chrome & EPHY_WINDOW_CHROME_MENU);
 }
 
+void
+fullscreen_changed_cb (EphyHeaderBar *header_bar)
+{
+  gboolean fullscreen;
+
+  g_object_get (header_bar->window, "fullscreen", &fullscreen, NULL);
+
+  gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (header_bar), !fullscreen);
+  gtk_widget_set_visible (header_bar->restore_button, fullscreen);
+}
+
 static void
 add_bookmark_button_clicked_cb (EphyLocationEntry *entry,
                                 gpointer          *user_data)
@@ -128,6 +140,19 @@ add_bookmark_button_clicked_cb (EphyLocationEntry *entry,
   g_action_activate (action, NULL);
 }
 
+static void
+restore_button_clicked_cb (GtkButton     *button,
+                           EphyHeaderBar *header_bar)
+{
+  GActionGroup *action_group;
+  GAction *action;
+
+  action_group = gtk_widget_get_action_group (GTK_WIDGET (header_bar->window), "win");
+  action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "fullscreen");
+
+  g_action_activate (action, NULL);
+}
+
 static void
 update_revealer_visibility (GtkRevealer *revealer)
 {
@@ -151,6 +176,9 @@ ephy_header_bar_constructed (GObject *object)
   g_signal_connect_object (header_bar->window, "notify::chrome",
                            G_CALLBACK (sync_chromes_visibility), header_bar,
                            G_CONNECT_SWAPPED);
+  g_signal_connect_object (header_bar->window, "notify::fullscreen",
+                           G_CALLBACK (fullscreen_changed_cb), header_bar,
+                           G_CONNECT_SWAPPED);
 
   /* Start action elements */
   header_bar->action_bar_start = ephy_action_bar_start_new ();
@@ -193,6 +221,16 @@ ephy_header_bar_constructed (GObject *object)
                              0);
   }
 
+  /* Fullscreen restore button */
+  header_bar->restore_button = gtk_button_new_from_icon_name ("view-restore-symbolic",
+                                                              GTK_ICON_SIZE_BUTTON);
+  gtk_widget_set_valign (header_bar->restore_button, GTK_ALIGN_CENTER);
+  g_signal_connect_object (header_bar->restore_button, "clicked",
+                           G_CALLBACK (restore_button_clicked_cb),
+                           header_bar, 0);
+  gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar),
+                           GTK_WIDGET (header_bar->restore_button));
+
   /* Page Menu */
   button = gtk_menu_button_new ();
   header_bar->page_menu_button = button;


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