[gnome-builder/wip/chergert/layout] workbench: use DzlApplicationWindow
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/layout] workbench: use DzlApplicationWindow
- Date: Sat, 8 Jul 2017 08:44:51 +0000 (UTC)
commit 55a8b0661dd64fa93b21c7fc812d6201967b1d10
Author: Christian Hergert <chergert redhat com>
Date: Sat Jul 8 01:43:39 2017 -0700
workbench: use DzlApplicationWindow
DzlApplicationWindow supports fullscreen management now so we
can use that instead of implementing focus-mode inside of
Builder.
It also now handles various corner cases that we were not
handling.
libide/workbench/ide-workbench-actions.c | 18 ---
libide/workbench/ide-workbench-private.h | 5 +-
libide/workbench/ide-workbench.c | 176 +++++-------------------------
libide/workbench/ide-workbench.h | 7 +-
libide/workbench/ide-workbench.ui | 77 +++++--------
5 files changed, 59 insertions(+), 224 deletions(-)
---
diff --git a/libide/workbench/ide-workbench-actions.c b/libide/workbench/ide-workbench-actions.c
index 3ea45d9..b10e3cb 100644
--- a/libide/workbench/ide-workbench-actions.c
+++ b/libide/workbench/ide-workbench-actions.c
@@ -196,9 +196,6 @@ ide_workbench_actions_global_search (GSimpleAction *action,
g_assert (IDE_IS_WORKBENCH (self));
ide_workbench_header_bar_focus_search (self->header_bar);
-
- if (self->focus_mode)
- gtk_revealer_set_reveal_child (self->header_revealer, TRUE);
}
static void
@@ -227,20 +224,6 @@ ide_workbench_actions_counters (GSimpleAction *action,
dzl_counter_arena_unref (arena);
}
-static void
-ide_workbench_actions_fullscreen (GSimpleAction *action,
- GVariant *state,
- gpointer user_data)
-{
- IdeWorkbench *self = user_data;
-
- g_assert (IDE_IS_WORKBENCH (self));
- g_assert (g_variant_is_of_type (state, G_VARIANT_TYPE_BOOLEAN));
-
- ide_workbench_set_focus_mode (self, g_variant_get_boolean (state));
- g_simple_action_set_state (action, state);
-}
-
void
ide_workbench_actions_init (IdeWorkbench *self)
{
@@ -252,7 +235,6 @@ ide_workbench_actions_init (IdeWorkbench *self)
{ "save-all", ide_workbench_actions_save_all },
{ "save-all-quit", ide_workbench_actions_save_all_quit },
{ "counters", ide_workbench_actions_counters },
- { "fullscreen", NULL, NULL, "false", ide_workbench_actions_fullscreen },
};
g_action_map_add_action_entries (G_ACTION_MAP (self), actions, G_N_ELEMENTS (actions), self);
diff --git a/libide/workbench/ide-workbench-private.h b/libide/workbench/ide-workbench-private.h
index 36d38ee..c9557c8 100644
--- a/libide/workbench/ide-workbench-private.h
+++ b/libide/workbench/ide-workbench-private.h
@@ -30,7 +30,7 @@ G_BEGIN_DECLS
struct _IdeWorkbench
{
- GtkApplicationWindow parent;
+ DzlApplicationWindow parent;
guint unloading : 1;
guint focus_mode : 1;
@@ -47,15 +47,12 @@ struct _IdeWorkbench
*/
GListStore *perspectives;
- GtkContainer *header_container;
- GtkRevealer *header_revealer;
GtkStack *header_stack;
IdeWorkbenchHeaderBar *header_bar;
IdePerspectiveMenuButton *perspective_menu_button;
GtkStack *perspectives_stack;
GtkSizeGroup *header_size_group;
GtkBox *message_box;
- GtkEventBox *fullscreen_eventbox;
GObject *selection_owner;
};
diff --git a/libide/workbench/ide-workbench.c b/libide/workbench/ide-workbench.c
index d0f2afc..d586818 100644
--- a/libide/workbench/ide-workbench.c
+++ b/libide/workbench/ide-workbench.c
@@ -42,13 +42,12 @@
#define STABLIZE_DELAY_MSEC 50
#define SHOW_HEADER_OFFSET 5
-G_DEFINE_TYPE (IdeWorkbench, ide_workbench, GTK_TYPE_APPLICATION_WINDOW)
+G_DEFINE_TYPE (IdeWorkbench, ide_workbench, DZL_TYPE_APPLICATION_WINDOW)
enum {
PROP_0,
PROP_CONTEXT,
PROP_DISABLE_GREETER,
- PROP_FOCUS_MODE,
PROP_VISIBLE_PERSPECTIVE,
PROP_VISIBLE_PERSPECTIVE_NAME,
LAST_PROP
@@ -65,61 +64,6 @@ static GParamSpec *properties [LAST_PROP];
static guint signals [LAST_SIGNAL];
static void
-ide_workbench_event_box_notify (GtkWidget *revealer,
- GParamSpec *pspec,
- IdeWorkbench *self)
-{
- gboolean visible;
-
- /* Hack to show and hide the revealer when its child is not visible */
- visible = gtk_revealer_get_reveal_child (GTK_REVEALER (revealer)) ||
- gtk_revealer_get_child_revealed (GTK_REVEALER (revealer));
-
- gtk_widget_set_visible (revealer, visible);
-}
-
-static gboolean
-ide_workbench_event_box_motion_notify_event (GtkEventBox *event_box,
- GdkEventMotion *event,
- IdeWorkbench *self)
-{
- GtkWidget *focus_widget;
- GdkWindow *window;
- gdouble x, y;
-
- x = event->x;
- y = event->y;
-
- /* Find the (x, y) values relative to the workbench */
- window = event->window;
- while (window != NULL && window != gtk_widget_get_window (GTK_WIDGET (event_box)))
- {
- gdk_window_coords_to_parent (window, x, y, &x, &y);
- window = gdk_window_get_parent (window);
- }
-
- if (window == NULL)
- return GDK_EVENT_PROPAGATE;
-
- /* If any widget in the header is focused, don't hide it */
- focus_widget = gtk_window_get_focus (GTK_WINDOW (self));
-
- if (focus_widget &&
- gtk_widget_get_ancestor (focus_widget, IDE_TYPE_WORKBENCH_HEADER_BAR) != NULL)
- {
- return GDK_EVENT_PROPAGATE;
- }
-
- /* Show the header with a small offset below */
- if (y < SHOW_HEADER_OFFSET)
- gtk_widget_show (GTK_WIDGET (self->header_revealer));
-
- gtk_revealer_set_reveal_child (self->header_revealer, y < SHOW_HEADER_OFFSET);
-
- return GDK_EVENT_PROPAGATE;
-}
-
-static void
ide_workbench_notify_visible_child (IdeWorkbench *self,
GParamSpec *pspec,
GtkStack *stack)
@@ -260,6 +204,29 @@ ide_workbench_grab_focus (GtkWidget *widget)
}
static void
+ide_workbench_notify_fullscreen (GtkWidget *widget,
+ gpointer user_data)
+{
+ if (IDE_IS_PERSPECTIVE (widget))
+ ide_perspective_set_fullscreen (IDE_PERSPECTIVE (widget), !!user_data);
+}
+
+static void
+ide_workbench_set_fullscreen (DzlApplicationWindow *window,
+ gboolean fullscreen)
+{
+ IdeWorkbench *self = (IdeWorkbench *)window;
+
+ g_assert (IDE_IS_WORKBENCH (self));
+
+ DZL_APPLICATION_WINDOW_CLASS (ide_workbench_parent_class)->set_fullscreen (window, fullscreen);
+
+ gtk_container_foreach (GTK_CONTAINER (self->perspectives_stack),
+ ide_workbench_notify_fullscreen,
+ GINT_TO_POINTER (fullscreen));
+}
+
+static void
ide_workbench_constructed (GObject *object)
{
IdeWorkbench *self = (IdeWorkbench *)object;
@@ -316,10 +283,6 @@ ide_workbench_get_property (GObject *object,
g_value_set_boolean (value, self->disable_greeter);
break;
- case PROP_FOCUS_MODE:
- g_value_set_boolean (value, self->focus_mode);
- break;
-
case PROP_VISIBLE_PERSPECTIVE:
g_value_set_object (value, ide_workbench_get_visible_perspective (self));
break;
@@ -347,10 +310,6 @@ ide_workbench_set_property (GObject *object,
self->disable_greeter = g_value_get_boolean (value);
break;
- case PROP_FOCUS_MODE:
- ide_workbench_set_focus_mode (self, g_value_get_boolean (value));
- break;
-
case PROP_VISIBLE_PERSPECTIVE:
ide_workbench_set_visible_perspective (self, g_value_get_object (value));
break;
@@ -369,6 +328,7 @@ ide_workbench_class_init (IdeWorkbenchClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ DzlApplicationWindowClass *app_win_class = DZL_APPLICATION_WINDOW_CLASS (klass);
object_class->constructed = ide_workbench_constructed;
object_class->finalize = ide_workbench_finalize;
@@ -378,6 +338,8 @@ ide_workbench_class_init (IdeWorkbenchClass *klass)
widget_class->grab_focus = ide_workbench_grab_focus;
widget_class->delete_event = ide_workbench_delete_event;
+ app_win_class->set_fullscreen = ide_workbench_set_fullscreen;
+
/**
* IdeWorkbench:context:
*
@@ -431,19 +393,6 @@ ide_workbench_class_init (IdeWorkbenchClass *klass)
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
/**
- * IdeWorkbench:focus-mode:
- *
- * Whether this workbench is in focus mode. Focus mode turns the workbench
- * into a fullscreen window with a floating headerbar.
- */
- properties [PROP_FOCUS_MODE] =
- g_param_spec_boolean ("focus-mode",
- "Focus mode",
- "If the workbench is in focus mode",
- FALSE,
- (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
-
- /**
* IdeWorkbench:visible-perspective-name:
*
* This property is just like #IdeWorkbench:visible-perspective except that
@@ -496,17 +445,12 @@ ide_workbench_class_init (IdeWorkbenchClass *klass)
1, IDE_TYPE_CONTEXT);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/builder/ui/ide-workbench.ui");
- gtk_widget_class_bind_template_child (widget_class, IdeWorkbench, fullscreen_eventbox);
gtk_widget_class_bind_template_child (widget_class, IdeWorkbench, header_bar);
- gtk_widget_class_bind_template_child (widget_class, IdeWorkbench, header_container);
- gtk_widget_class_bind_template_child (widget_class, IdeWorkbench, header_revealer);
gtk_widget_class_bind_template_child (widget_class, IdeWorkbench, header_size_group);
gtk_widget_class_bind_template_child (widget_class, IdeWorkbench, header_stack);
gtk_widget_class_bind_template_child (widget_class, IdeWorkbench, message_box);
gtk_widget_class_bind_template_child (widget_class, IdeWorkbench, perspective_menu_button);
gtk_widget_class_bind_template_child (widget_class, IdeWorkbench, perspectives_stack);
-
- gtk_widget_class_bind_template_callback (widget_class, ide_workbench_event_box_notify);
}
static void
@@ -1166,69 +1110,3 @@ ide_workbench_pop_message (IdeWorkbench *self,
return FALSE;
}
-
-gboolean
-ide_workbench_get_focus_mode (IdeWorkbench *self)
-{
- g_return_val_if_fail (IDE_IS_WORKBENCH (self), FALSE);
-
- return self->focus_mode;
-}
-
-static void
-ide_workbench_notify_addins_fullscreen (GtkWidget *perspective,
- gpointer user_data)
-{
- IdeWorkbench *self = user_data;
-
- g_assert (IDE_IS_WORKBENCH (self));
- g_assert (IDE_IS_PERSPECTIVE (perspective));
-
- ide_perspective_set_fullscreen (IDE_PERSPECTIVE (perspective),self->focus_mode);
-}
-
-void
-ide_workbench_set_focus_mode (IdeWorkbench *self,
- gboolean focus_mode)
-{
- focus_mode = !!focus_mode;
-
- g_return_if_fail (IDE_IS_WORKBENCH (self));
-
- if (focus_mode == self->focus_mode)
- return;
-
- self->focus_mode = focus_mode;
-
- g_object_ref (self->header_stack);
-
- if (focus_mode)
- {
- gtk_container_remove (self->header_container, GTK_WIDGET (self->header_stack));
- gtk_container_add (GTK_CONTAINER (self->header_revealer), GTK_WIDGET (self->header_stack));
- gtk_window_fullscreen (GTK_WINDOW (self));
-
- g_signal_connect (self->fullscreen_eventbox,
- "motion-notify-event",
- G_CALLBACK (ide_workbench_event_box_motion_notify_event),
- self);
- }
- else
- {
- g_signal_handlers_disconnect_by_func (self->fullscreen_eventbox,
- ide_workbench_event_box_motion_notify_event,
- self);
- gtk_container_remove (GTK_CONTAINER (self->header_revealer), GTK_WIDGET (self->header_stack));
- gtk_container_add (self->header_container, GTK_WIDGET (self->header_stack));
- gtk_revealer_set_reveal_child (self->header_revealer, FALSE);
- gtk_window_unfullscreen (GTK_WINDOW (self));
- }
-
- g_object_unref (self->header_stack);
-
- gtk_container_foreach (GTK_CONTAINER (self->perspectives_stack),
- ide_workbench_notify_addins_fullscreen,
- self);
-
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FOCUS_MODE]);
-}
diff --git a/libide/workbench/ide-workbench.h b/libide/workbench/ide-workbench.h
index 5643147..d2a90fa 100644
--- a/libide/workbench/ide-workbench.h
+++ b/libide/workbench/ide-workbench.h
@@ -19,7 +19,7 @@
#ifndef IDE_WORKBENCH_H
#define IDE_WORKBENCH_H
-#include <gtk/gtk.h>
+#include <dazzle.h>
#include "ide-context.h"
@@ -38,7 +38,7 @@ typedef enum
#define IDE_TYPE_WORKBENCH (ide_workbench_get_type())
-G_DECLARE_FINAL_TYPE (IdeWorkbench, ide_workbench, IDE, WORKBENCH, GtkApplicationWindow)
+G_DECLARE_FINAL_TYPE (IdeWorkbench, ide_workbench, IDE, WORKBENCH, DzlApplicationWindow)
void ide_workbench_open_project_async (IdeWorkbench *self,
GFile *file_or_directory,
@@ -92,9 +92,6 @@ void ide_workbench_set_visible_perspective (IdeWorkbench
const gchar *ide_workbench_get_visible_perspective_name (IdeWorkbench *self);
void ide_workbench_set_visible_perspective_name (IdeWorkbench *self,
const gchar *name);
-gboolean ide_workbench_get_fullscreen (IdeWorkbench *self);
-void ide_workbench_set_fullscreen (IdeWorkbench *self,
- gboolean fullscreen);
void ide_workbench_views_foreach (IdeWorkbench *self,
GtkCallback callback,
gpointer user_data);
diff --git a/libide/workbench/ide-workbench.ui b/libide/workbench/ide-workbench.ui
index df19635..e8c9e69 100644
--- a/libide/workbench/ide-workbench.ui
+++ b/libide/workbench/ide-workbench.ui
@@ -1,32 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.22 -->
- <template class="IdeWorkbench" parent="GtkApplicationWindow">
+ <template class="IdeWorkbench" parent="DzlApplicationWindow">
<style>
<class name="workbench"/>
</style>
<child type="titlebar">
- <object class="GtkBox" id="header_container">
+ <object class="GtkStack" id="header_stack">
<property name="visible">true</property>
<child>
- <object class="GtkStack" id="header_stack">
+ <object class="IdeWorkbenchHeaderBar" id="header_bar">
<property name="visible">true</property>
- <child>
- <object class="IdeWorkbenchHeaderBar" id="header_bar">
- <property name="visible">true</property>
- <child internal-child="left">
- <object class="DzlPriorityBox">
- <child>
- <object class="IdePerspectiveMenuButton" id="perspective_menu_button">
- <property name="focus-on-click">false</property>
- <property name="stack">perspectives_stack</property>
- <property name="visible">false</property>
- </object>
- <packing>
- <property name="priority">-100000</property>
- </packing>
- </child>
+ <child internal-child="left">
+ <object class="DzlPriorityBox">
+ <child>
+ <object class="IdePerspectiveMenuButton" id="perspective_menu_button">
+ <property name="focus-on-click">false</property>
+ <property name="stack">perspectives_stack</property>
+ <property name="visible">false</property>
</object>
+ <packing>
+ <property name="priority">-100000</property>
+ </packing>
</child>
</object>
</child>
@@ -37,41 +32,27 @@
<child>
<object class="GtkOverlay">
<property name="visible">true</property>
- <child type="overlay">
- <object class="GtkRevealer" id="header_revealer">
- <property name="valign">start</property>
- <property name="reveal-child">false</property>
- <property name="transition-type">slide-down</property>
- <signal name="notify::reveal-child" handler="ide_workbench_event_box_notify"
object="IdeWorkbench" swapped="no" />
- <signal name="notify::child-revealed" handler="ide_workbench_event_box_notify"
object="IdeWorkbench" swapped="no" />
- </object>
- </child>
<child>
- <object class="GtkEventBox" id="fullscreen_eventbox">
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
<property name="visible">true</property>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="message_box">
<property name="orientation">vertical</property>
+ <property name="hexpand">false</property>
+ <property name="visible">true</property>
+ <style>
+ <class name="message-box"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStack" id="perspectives_stack">
+ <property name="hexpand">true</property>
+ <property name="homogeneous">false</property>
+ <property name="transition-type">crossfade</property>
+ <property name="transition-duration">333</property>
<property name="visible">true</property>
- <child>
- <object class="GtkBox" id="message_box">
- <property name="orientation">vertical</property>
- <property name="hexpand">false</property>
- <property name="visible">true</property>
- <style>
- <class name="message-box"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkStack" id="perspectives_stack">
- <property name="hexpand">true</property>
- <property name="homogeneous">false</property>
- <property name="transition-type">crossfade</property>
- <property name="transition-duration">333</property>
- <property name="visible">true</property>
- </object>
- </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]