[gedit/wip/redesign: 8/9] Handle fullscreen



commit 8325bae68b87d098cf2f76ba390f70811b3e32fb
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Mon May 6 12:50:02 2013 +0200

    Handle fullscreen

 gedit/gedit-commands-view.c  |   24 ++----
 gedit/gedit-commands.h       |   10 ++-
 gedit/gedit-ui.h             |   11 +--
 gedit/gedit-ui.xml           |   14 ----
 gedit/gedit-window-private.h |    1 +
 gedit/gedit-window.c         |   66 ++++-------------
 gedit/gedit-window.ui        |  167 ++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 200 insertions(+), 93 deletions(-)
---
diff --git a/gedit/gedit-commands-view.c b/gedit/gedit-commands-view.c
index 6cc41e4..af9befa 100644
--- a/gedit/gedit-commands-view.c
+++ b/gedit/gedit-commands-view.c
@@ -42,9 +42,12 @@
 #include "gedit-window-private.h"
 
 void
-_gedit_cmd_view_toggle_fullscreen_mode (GtkAction   *action,
-                                       GeditWindow *window)
+_gedit_cmd_view_toggle_fullscreen_mode (GSimpleAction *action,
+                                        GVariant      *parameter,
+                                        gpointer       user_data)
 {
+       GeditWindow *window = GEDIT_WINDOW (user_data);
+
        gedit_debug (DEBUG_COMMANDS);
 
        if (_gedit_window_is_fullscreen (window))
@@ -54,22 +57,13 @@ _gedit_cmd_view_toggle_fullscreen_mode (GtkAction   *action,
 }
 
 void
-_gedit_cmd_view_leave_fullscreen_mode (GtkAction   *action,
-                                      GeditWindow *window)
+_gedit_cmd_view_leave_fullscreen_mode (GSimpleAction *action,
+                                       GVariant      *parameter,
+                                       gpointer       user_data)
 {
-       GtkAction *view_action;
+       GeditWindow *window = GEDIT_WINDOW (user_data);
 
-       view_action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
-                                                  "ViewFullscreen");
-       g_signal_handlers_block_by_func
-               (view_action, G_CALLBACK (_gedit_cmd_view_toggle_fullscreen_mode),
-                window);
-       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (view_action),
-                                     FALSE);
        _gedit_window_unfullscreen (window);
-       g_signal_handlers_unblock_by_func (view_action,
-                                          G_CALLBACK (_gedit_cmd_view_toggle_fullscreen_mode),
-                                          window);
 }
 
 /* ex:set ts=8 noet: */
diff --git a/gedit/gedit-commands.h b/gedit/gedit-commands.h
index 07a2c15..51eb0e2 100644
--- a/gedit/gedit-commands.h
+++ b/gedit/gedit-commands.h
@@ -120,10 +120,12 @@ void              _gedit_cmd_edit_select_all              (GtkAction   *action,
 void           _gedit_cmd_edit_preferences             (GtkAction   *action,
                                                         GeditWindow *window);
 
-void           _gedit_cmd_view_toggle_fullscreen_mode  (GtkAction   *action,
-                                                        GeditWindow *window);
-void           _gedit_cmd_view_leave_fullscreen_mode   (GtkAction   *action,
-                                                        GeditWindow *window);
+void           _gedit_cmd_view_toggle_fullscreen_mode  (GSimpleAction *action,
+                                                         GVariant      *parameter,
+                                                         gpointer       user_data);
+void           _gedit_cmd_view_leave_fullscreen_mode   (GSimpleAction *action,
+                                                         GVariant      *parameter,
+                                                         gpointer       user_data);
 
 void           _gedit_cmd_search_find                  (GSimpleAction *action,
                                                          GVariant      *parameter,
diff --git a/gedit/gedit-ui.h b/gedit/gedit-ui.h
index 76942aa..b1044d8 100644
--- a/gedit/gedit-ui.h
+++ b/gedit/gedit-ui.h
@@ -101,13 +101,6 @@ static const GtkActionEntry gedit_quit_menu_entries[] =
          N_("Quit the program"), G_CALLBACK (_gedit_cmd_file_quit) }
 };
 
-static const GtkToggleActionEntry gedit_always_sensitive_toggle_menu_entries[] =
-{
-       { "ViewFullscreen", GTK_STOCK_FULLSCREEN, NULL, "F11",
-         N_("Edit text in fullscreen"),
-         G_CALLBACK (_gedit_cmd_view_toggle_fullscreen_mode), FALSE }
-};
-
 static GActionEntry win_entries[] = {
        { "open", _gedit_cmd_file_open },
        { "new_tab", _gedit_cmd_file_new },
@@ -116,6 +109,8 @@ static GActionEntry win_entries[] = {
        { "print", _gedit_cmd_file_print },
        { "revert", _gedit_cmd_file_revert },
        { "close", _gedit_cmd_file_close },
+       { "fullscreen", _gedit_cmd_view_toggle_fullscreen_mode },
+       { "leave_fullscreen", _gedit_cmd_view_leave_fullscreen_mode },
        { "find", _gedit_cmd_search_find },
        { "find_next", _gedit_cmd_search_find_next },
        { "find_prev", _gedit_cmd_search_find_prev },
@@ -126,5 +121,5 @@ static GActionEntry win_entries[] = {
 
 G_END_DECLS
 
-#endif  /* __GEDIT_UI_H__  */
+#endif  /* __GEDIT_UI_H__ */
 /* ex:set ts=8 noet: */
diff --git a/gedit/gedit-ui.xml b/gedit/gedit-ui.xml
index 16bafcf..30a97f6 100644
--- a/gedit/gedit-ui.xml
+++ b/gedit/gedit-ui.xml
@@ -64,8 +64,6 @@
     </menu>
 
     <menu name="ViewMenu" action="View">
-      <menuitem name="ViewFullscreenMenu" action="ViewFullscreen"/>
-      <separator/>
       <menu name="ViewHighlightModeMenu" action="ViewHighlightMode">
         <placeholder name="LanguagesMenuPlaceholder">
         </placeholder>
@@ -125,16 +123,4 @@
     <toolitem action="EditPaste"/>
   </toolbar>
 
-  <toolbar name="FullscreenToolBar">
-    <toolitem action="EditUndo"/>
-    <toolitem action="EditRedo"/>
-    <separator/>
-    <toolitem action="EditCut"/>
-    <toolitem action="EditCopy"/>
-    <toolitem action="EditPaste"/>
-    <separator/>
-    <separator expand="true"/>
-    <toolitem action="LeaveFullscreen"/>
-  </toolbar>
-
 </ui>
diff --git a/gedit/gedit-window-private.h b/gedit/gedit-window-private.h
index eb9481a..bf54dea 100644
--- a/gedit/gedit-window-private.h
+++ b/gedit/gedit-window-private.h
@@ -65,6 +65,7 @@ struct _GeditWindowPrivate
 
        /* Widgets for fullscreen mode */
        GtkWidget      *fullscreen_controls;
+       gboolean        fullscreen_controls_setup;
        guint           fullscreen_animation_timeout_id;
        gboolean        fullscreen_animation_enter;
 
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index bf4787a..d59993c 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -435,6 +435,7 @@ gedit_window_class_init (GeditWindowClass *klass)
        gtk_widget_class_bind_child (widget_class, GeditWindowPrivate, multi_notebook);
        gtk_widget_class_bind_child (widget_class, GeditWindowPrivate, bottom_panel);
        gtk_widget_class_bind_child (widget_class, GeditWindowPrivate, statusbar);
+       gtk_widget_class_bind_child (widget_class, GeditWindowPrivate, fullscreen_controls);
 
        g_type_class_add_private (object_class, sizeof (GeditWindowPrivate));
 }
@@ -1160,10 +1161,6 @@ create_menu_bar_and_toolbar (GeditWindow *window)
                                      gedit_always_sensitive_menu_entries,
                                      G_N_ELEMENTS (gedit_always_sensitive_menu_entries),
                                      window);
-       gtk_action_group_add_toggle_actions (action_group,
-                                            gedit_always_sensitive_toggle_menu_entries,
-                                            G_N_ELEMENTS (gedit_always_sensitive_toggle_menu_entries),
-                                            window);
 
        gtk_ui_manager_insert_action_group (manager, action_group, 0);
        g_object_unref (action_group);
@@ -2573,9 +2570,9 @@ run_fullscreen_animation (gpointer data)
 }
 
 static void
-show_hide_fullscreen_toolbar (GeditWindow *window,
-                             gboolean     show,
-                             gint         height)
+show_hide_fullscreen_controls (GeditWindow *window,
+                              gboolean     show,
+                              gint         height)
 {
        GtkSettings *settings;
        gboolean enable_animations;
@@ -2628,7 +2625,7 @@ on_fullscreen_controls_enter_notify_event (GtkWidget        *widget,
                                           GdkEventCrossing *event,
                                           GeditWindow      *window)
 {
-       show_hide_fullscreen_toolbar (window, TRUE, 0);
+       show_hide_fullscreen_controls (window, TRUE, 0);
 
        return FALSE;
 }
@@ -2652,45 +2649,23 @@ on_fullscreen_controls_leave_notify_event (GtkWidget        *widget,
         */
        if (y >= h)
        {
-               show_hide_fullscreen_toolbar (window, FALSE, h);
+               show_hide_fullscreen_controls (window, FALSE, h);
        }
 
        return FALSE;
 }
 
 static void
-fullscreen_controls_build (GeditWindow *window)
+fullscreen_controls_setup (GeditWindow *window)
 {
        GeditWindowPrivate *priv = window->priv;
-       GtkWidget *toolbar;
-       GtkAction *action;
 
-       if (priv->fullscreen_controls != NULL)
+       if (priv->fullscreen_controls_setup)
                return;
 
-       priv->fullscreen_controls = gtk_window_new (GTK_WINDOW_POPUP);
-
        gtk_window_set_transient_for (GTK_WINDOW (priv->fullscreen_controls),
                                      GTK_WINDOW (&window->window));
-
-       /* popup toolbar */
-       toolbar = gtk_ui_manager_get_widget (priv->manager, "/FullscreenToolBar");
-       gtk_container_add (GTK_CONTAINER (priv->fullscreen_controls),
-                          toolbar);
-
-       action = gtk_action_group_get_action (priv->always_sensitive_action_group,
-                                             "LeaveFullscreen");
-       g_object_set (action, "is-important", TRUE, NULL);
-
-       //setup_toolbar_open_button (window, toolbar);
-
-       gtk_container_foreach (GTK_CONTAINER (toolbar),
-                              (GtkCallback)set_non_homogeneus,
-                              NULL);
-
-       /* Set the toolbar style */
-       gtk_toolbar_set_style (GTK_TOOLBAR (toolbar),
-                              GTK_TOOLBAR_BOTH_HORIZ);
+       gtk_window_set_attached_to (GTK_WINDOW (window), priv->fullscreen_controls);
 
        g_signal_connect (priv->fullscreen_controls, "enter-notify-event",
                          G_CALLBACK (on_fullscreen_controls_enter_notify_event),
@@ -2698,6 +2673,7 @@ fullscreen_controls_build (GeditWindow *window)
        g_signal_connect (priv->fullscreen_controls, "leave-notify-event",
                          G_CALLBACK (on_fullscreen_controls_leave_notify_event),
                          window);
+       priv->fullscreen_controls_setup = TRUE;
 }
 
 static void
@@ -4270,13 +4246,9 @@ _gedit_window_fullscreen (GeditWindow *window)
                                               (GtkCallback)hide_notebook_tabs,
                                               window);
 
-       gtk_widget_hide (window->priv->menubar);
-
-       gtk_widget_hide (window->priv->toolbar);
-
        gtk_widget_hide (window->priv->statusbar);
 
-       fullscreen_controls_build (window);
+       fullscreen_controls_setup (window);
        fullscreen_controls_show (window);
 }
 
@@ -4293,9 +4265,6 @@ show_notebook_tabs (GtkNotebook *notebook,
 void
 _gedit_window_unfullscreen (GeditWindow *window)
 {
-       gboolean visible;
-       GtkAction *action;
-
        g_return_if_fail (GEDIT_IS_WINDOW (window));
 
        if (!_gedit_window_is_fullscreen (window))
@@ -4310,17 +4279,10 @@ _gedit_window_unfullscreen (GeditWindow *window)
 
        gtk_widget_show (window->priv->menubar);
 
-       action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
-                                             "ViewToolbar");
-       visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
-       if (visible)
-               gtk_widget_show (window->priv->toolbar);
-
-       action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
-                                             "ViewStatusbar");
-       visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
-       if (visible)
+       if (g_settings_get_boolean (window->priv->ui_settings, "statusbar-visible"))
+       {
                gtk_widget_show (window->priv->statusbar);
+       }
 
        gtk_widget_hide (window->priv->fullscreen_controls);
 }
diff --git a/gedit/gedit-window.ui b/gedit/gedit-window.ui
index de9c429..be9290c 100644
--- a/gedit/gedit-window.ui
+++ b/gedit/gedit-window.ui
@@ -271,4 +271,171 @@
       </object>
     </child>
   </template>
+  <object class="GtkWindow" id="fullscreen_controls">
+    <property name="type">popup</property>
+    <property name="can_focus">False</property>
+    <property name="has_focus">False</property>
+    <property name="is_focus">False</property>
+    <child>
+      <object class="GtkHeaderBar" id="fullscreen_headerbar">
+        <property name="visible">True</property>
+        <child>
+          <object class="GtkBox" id="fullscreen_open_box">
+            <property name="visible">True</property>
+            <property name="orientation">horizontal</property>
+            <property name="valign">center</property>
+            <style>
+              <class name="linked"/>
+            </style>
+            <child>
+              <object class="GtkButton" id="fullscreen_open_button">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Open</property>
+                <property name="tooltip_text" translatable="yes">Open a file</property>
+                <property name="action_name">win.open</property>
+                <style>
+                  <class name="text-button"/>
+                </style>
+              </object>
+            </child>
+            <child>
+              <object class="GeditOpenMenuButton" id="fullscreen_open_menu">
+                <property name="visible">True</property>
+                <property name="tooltip_text" translatable="yes">Open a recently used file</property>
+                <style>
+                  <class name="image-button"/>
+                </style>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="pack_type">start</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="fullscreen_new_tab_button">
+            <property name="visible">True</property>
+            <property name="valign">center</property>
+            <property name="tooltip_text" translatable="yes">Create a new document</property>
+            <property name="action_name">win.new_tab</property>
+            <style>
+              <class name="image-button"/>
+            </style>
+            <child>
+              <object class="GtkImage" id="fullscreen_new_tab_image">
+                <property name="visible">True</property>
+                <property name="icon_size">1</property>
+                <property name="icon_name">tab-new-symbolic</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="pack_type">start</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="fullscreen_save_button">
+            <property name="visible">True</property>
+            <property name="valign">center</property>
+            <property name="tooltip_text" translatable="yes">Save the current file</property>
+            <property name="action_name">win.save</property>
+            <style>
+              <class name="image-button"/>
+            </style>
+            <child>
+              <object class="GtkImage" id="fullscreen_save_image">
+                <property name="visible">True</property>
+                <property name="icon_size">1</property>
+                <property name="icon_name">document-save-symbolic</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="pack_type">start</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="fullscreen_save_box">
+            <property name="visible">True</property>
+            <property name="orientation">horizontal</property>
+            <property name="valign">center</property>
+            <style>
+              <class name="linked"/>
+            </style>
+            <child>
+              <object class="GtkButton" id="fullscreen_find_button">
+                <property name="visible">True</property>
+                <property name="valign">center</property>
+                <property name="tooltip_text" translatable="yes">Search for text</property>
+                <property name="action_name">win.find</property>
+                <style>
+                  <class name="image-button"/>
+                </style>
+                <child>
+                  <object class="GtkImage" id="fullscreen_find_image">
+                    <property name="visible">True</property>
+                    <property name="icon_size">1</property>
+                    <property name="icon_name">edit-find-symbolic</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkMenuButton" id="fullscreen_find_menu">
+                <property name="visible">True</property>
+                <property name="menu_model">search-menu</property>
+                <style>
+                  <class name="image-button"/>
+                </style>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="pack_type">end</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkMenuButton" id="fullscreen_gear_button">
+            <property name="visible">True</property>
+            <property name="valign">center</property>
+            <property name="menu_model">gear-menu</property>
+            <style>
+              <class name="image-button"/>
+            </style>
+            <child>
+              <object class="GtkImage" id="fullscreen_gear_image">
+                <property name="visible">True</property>
+                <property name="icon_size">1</property>
+                <property name="icon_name">emblem-system-symbolic</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="pack_type">end</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="leave_fullscreen_button">
+            <property name="visible">True</property>
+            <property name="valign">center</property>
+            <property name="tooltip_text" translatable="yes">Leave Fullscreen</property>
+            <property name="action_name">win.leave_fullscreen</property>
+            <style>
+              <class name="image-button"/>
+            </style>
+            <child>
+              <object class="GtkImage" id="leave_fullscreen_image">
+                <property name="visible">True</property>
+                <property name="icon_size">1</property>
+                <property name="icon_name">view-restore-symbolic</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="pack_type">end</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
 </interface>


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