[gnome-builder: 87/139] glade: port to libide-editor
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder: 87/139] glade: port to libide-editor
- Date: Thu, 10 Jan 2019 04:24:38 +0000 (UTC)
commit d6fcf1433a59548749e90f4b2285bbe43ce8080c
Author: Christian Hergert <chergert redhat com>
Date: Wed Jan 9 17:24:01 2019 -0800
glade: port to libide-editor
Mostly just a rename of components to their new naming schemes.
src/plugins/glade/gbp-glade-editor-addin.c | 138 +++++++------
src/plugins/glade/gbp-glade-editor-addin.h | 2 +-
...ayout-stack-addin.c => gbp-glade-frame-addin.c} | 155 ++++++++-------
...ayout-stack-addin.h => gbp-glade-frame-addin.h} | 8 +-
...ade-view-actions.c => gbp-glade-page-actions.c} | 70 +++----
...view-shortcuts.c => gbp-glade-page-shortcuts.c} | 8 +-
.../glade/{gbp-glade-view.c => gbp-glade-page.c} | 215 ++++++++++-----------
.../glade/{gbp-glade-view.h => gbp-glade-page.h} | 18 +-
src/plugins/glade/gbp-glade-private.h | 18 +-
src/plugins/glade/gbp-glade-properties.c | 2 +-
src/plugins/glade/gbp-glade-properties.h | 2 +-
src/plugins/glade/gbp-glade-workbench-addin.c | 161 +++++++++------
src/plugins/glade/gbp-glade-workbench-addin.h | 2 +-
.../glade/{gbp-glade-plugin.c => glade-plugin.c} | 17 +-
src/plugins/glade/glade.gresource.xml | 10 +-
src/plugins/glade/glade.plugin | 10 +-
src/plugins/glade/meson.build | 31 ++-
src/plugins/glade/themes/Adwaita-dark.css | 10 +-
src/plugins/glade/themes/Adwaita-shared.css | 6 +-
src/plugins/glade/themes/Adwaita.css | 2 +-
20 files changed, 476 insertions(+), 409 deletions(-)
---
diff --git a/src/plugins/glade/gbp-glade-editor-addin.c b/src/plugins/glade/gbp-glade-editor-addin.c
index 86a7d4825..dfbeaade7 100644
--- a/src/plugins/glade/gbp-glade-editor-addin.c
+++ b/src/plugins/glade/gbp-glade-editor-addin.c
@@ -23,18 +23,19 @@
#include "config.h"
#include <glib/gi18n.h>
+#include <libide-editor.h>
#include "gbp-glade-editor-addin.h"
#include "gbp-glade-private.h"
#include "gbp-glade-properties.h"
-#include "gbp-glade-view.h"
+#include "gbp-glade-page.h"
struct _GbpGladeEditorAddin
{
GObject parent_instance;
/* Widgets */
- IdeEditorPerspective *editor;
+ IdeEditorSurface *editor;
GbpGladeProperties *properties;
GladeSignalEditor *signals;
DzlDockWidget *signals_dock;
@@ -50,6 +51,46 @@ static void editor_addin_iface_init (IdeEditorAddinInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GbpGladeEditorAddin, gbp_glade_editor_addin, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (IDE_TYPE_EDITOR_ADDIN, editor_addin_iface_init))
+static void
+gbp_glade_editor_addin_ensure_properties (GbpGladeEditorAddin *self)
+{
+ IdeTransientSidebar *transient;
+ GtkWidget *utils;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_GLADE_EDITOR_ADDIN (self));
+
+ if (self->properties)
+ return;
+
+ transient = ide_editor_surface_get_transient_sidebar (self->editor);
+ utils = ide_editor_surface_get_utilities (self->editor);
+
+ self->properties = g_object_new (GBP_TYPE_GLADE_PROPERTIES,
+ "visible", TRUE,
+ NULL);
+ g_signal_connect (self->properties,
+ "destroy",
+ G_CALLBACK (gtk_widget_destroyed),
+ &self->properties);
+ gtk_container_add (GTK_CONTAINER (transient), GTK_WIDGET (self->properties));
+
+ self->signals_dock = g_object_new (DZL_TYPE_DOCK_WIDGET,
+ "title", _("Signals"),
+ "icon-name", "glade-symbolic",
+ "visible", TRUE,
+ NULL);
+ gtk_container_add (GTK_CONTAINER (utils), GTK_WIDGET (self->signals_dock));
+
+ self->signals = g_object_new (GLADE_TYPE_SIGNAL_EDITOR,
+ "visible", TRUE,
+ NULL);
+ gtk_container_add (GTK_CONTAINER (self->signals_dock), GTK_WIDGET (self->signals));
+
+ /* Wire up the shortcuts to the panel too */
+ _gbp_glade_page_init_shortcuts (GTK_WIDGET (self->properties));
+}
+
static void
gbp_glade_editor_addin_dispose (GObject *object)
{
@@ -86,15 +127,21 @@ gbp_glade_editor_addin_selection_changed_cb (GbpGladeEditorAddin *self,
GtkWidget *widget = selection->data;
GladeWidget *glade = glade_widget_get_from_gobject (widget);
+ gbp_glade_editor_addin_ensure_properties (self);
+
gbp_glade_properties_set_widget (self->properties, glade);
glade_signal_editor_load_widget (self->signals, glade);
gtk_widget_show (GTK_WIDGET (self->signals_dock));
}
else
{
- gbp_glade_properties_set_widget (self->properties, NULL);
+ if (self->properties)
+ gbp_glade_properties_set_widget (self->properties, NULL);
+
glade_signal_editor_load_widget (self->signals, NULL);
- gtk_widget_hide (GTK_WIDGET (self->signals_dock));
+
+ if (self->signals_dock)
+ gtk_widget_hide (GTK_WIDGET (self->signals_dock));
}
}
@@ -139,104 +186,87 @@ gbp_glade_editor_addin_set_project (GbpGladeEditorAddin *self,
}
static void
-gbp_glade_editor_addin_view_set (IdeEditorAddin *addin,
- IdeLayoutView *view)
+gbp_glade_editor_addin_page_set (IdeEditorAddin *addin,
+ IdePage *view)
{
GbpGladeEditorAddin *self = (GbpGladeEditorAddin *)addin;
- IdeLayoutTransientSidebar *transient;
+ IdeTransientSidebar *transient;
GladeProject *project = NULL;
g_assert (GBP_IS_GLADE_EDITOR_ADDIN (self));
- g_assert (!view || IDE_IS_LAYOUT_VIEW (view));
+ g_assert (!view || IDE_IS_PAGE (view));
- transient = ide_editor_perspective_get_transient_sidebar (self->editor);
+ transient = ide_editor_surface_get_transient_sidebar (self->editor);
if (self->has_hold)
{
- ide_layout_transient_sidebar_unlock (transient);
+ ide_transient_sidebar_unlock (transient);
self->has_hold = FALSE;
}
- if (GBP_IS_GLADE_VIEW (view))
+ if (GBP_IS_GLADE_PAGE (view))
{
- project = gbp_glade_view_get_project (GBP_GLADE_VIEW (view));
- ide_layout_transient_sidebar_set_view (transient, view);
- ide_layout_transient_sidebar_lock (transient);
+ gbp_glade_editor_addin_ensure_properties (self);
+
+ project = gbp_glade_page_get_project (GBP_GLADE_PAGE (view));
+ ide_transient_sidebar_set_page (transient, view);
+ ide_transient_sidebar_lock (transient);
gtk_widget_show (GTK_WIDGET (transient));
dzl_dock_item_present (DZL_DOCK_ITEM (self->properties));
self->has_hold = TRUE;
dzl_gtk_widget_mux_action_groups (GTK_WIDGET (self->properties),
GTK_WIDGET (view),
- "GBP_GLADE_VIEW");
+ "GBP_GLADE_PAGE");
}
else
{
- gtk_widget_hide (GTK_WIDGET (self->signals_dock));
- dzl_gtk_widget_mux_action_groups (GTK_WIDGET (self->properties),
- NULL,
- "GBP_GLADE_VIEW");
+ if (self->signals_dock)
+ gtk_widget_hide (GTK_WIDGET (self->signals_dock));
+
+ if (self->properties)
+ dzl_gtk_widget_mux_action_groups (GTK_WIDGET (self->properties),
+ NULL,
+ "GBP_GLADE_PAGE");
}
gbp_glade_editor_addin_set_project (self, project);
}
static void
-gbp_glade_editor_addin_load (IdeEditorAddin *addin,
- IdeEditorPerspective *editor)
+gbp_glade_editor_addin_load (IdeEditorAddin *addin,
+ IdeEditorSurface *editor)
{
GbpGladeEditorAddin *self = (GbpGladeEditorAddin *)addin;
- IdeLayoutTransientSidebar *transient;
- GtkWidget *utils;
+ g_assert (IDE_IS_MAIN_THREAD ());
g_assert (GBP_IS_GLADE_EDITOR_ADDIN (self));
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (editor));
+ g_assert (IDE_IS_EDITOR_SURFACE (editor));
self->editor = editor;
-
- transient = ide_editor_perspective_get_transient_sidebar (self->editor);
- utils = ide_editor_perspective_get_utilities (self->editor);
-
- self->properties = g_object_new (GBP_TYPE_GLADE_PROPERTIES,
- "visible", TRUE,
- NULL);
- gtk_container_add (GTK_CONTAINER (transient), GTK_WIDGET (self->properties));
-
- self->signals_dock = g_object_new (DZL_TYPE_DOCK_WIDGET,
- "title", _("Signals"),
- "icon-name", "glade-symbolic",
- "visible", TRUE,
- NULL);
- gtk_container_add (GTK_CONTAINER (utils), GTK_WIDGET (self->signals_dock));
-
- self->signals = g_object_new (GLADE_TYPE_SIGNAL_EDITOR,
- "visible", TRUE,
- NULL);
- gtk_container_add (GTK_CONTAINER (self->signals_dock), GTK_WIDGET (self->signals));
-
- /* Wire up the shortcuts to the panel too */
- _gbp_glade_view_init_shortcuts (GTK_WIDGET (self->properties));
}
static void
gbp_glade_editor_addin_unload (IdeEditorAddin *addin,
- IdeEditorPerspective *editor)
+ IdeEditorSurface *editor)
{
GbpGladeEditorAddin *self = (GbpGladeEditorAddin *)addin;
- IdeLayoutTransientSidebar *transient;
+ IdeTransientSidebar *transient;
g_assert (GBP_IS_GLADE_EDITOR_ADDIN (self));
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (editor));
+ g_assert (IDE_IS_EDITOR_SURFACE (editor));
- transient = ide_editor_perspective_get_transient_sidebar (self->editor);
+ transient = ide_editor_surface_get_transient_sidebar (self->editor);
if (self->has_hold)
{
- ide_layout_transient_sidebar_unlock (transient);
+ ide_transient_sidebar_unlock (transient);
self->has_hold = FALSE;
}
gtk_widget_insert_action_group (GTK_WIDGET (editor), "glade", NULL);
- gtk_widget_destroy (GTK_WIDGET (self->properties));
+
+ if (self->properties)
+ gtk_widget_destroy (GTK_WIDGET (self->properties));
self->editor = NULL;
}
@@ -246,5 +276,5 @@ editor_addin_iface_init (IdeEditorAddinInterface *iface)
{
iface->load = gbp_glade_editor_addin_load;
iface->unload = gbp_glade_editor_addin_unload;
- iface->view_set = gbp_glade_editor_addin_view_set;
+ iface->page_set = gbp_glade_editor_addin_page_set;
}
diff --git a/src/plugins/glade/gbp-glade-editor-addin.h b/src/plugins/glade/gbp-glade-editor-addin.h
index b370c34e2..df0765642 100644
--- a/src/plugins/glade/gbp-glade-editor-addin.h
+++ b/src/plugins/glade/gbp-glade-editor-addin.h
@@ -22,7 +22,7 @@
#pragma once
#include <gladeui/glade.h>
-#include <ide.h>
+#include <libide-gui.h>
G_BEGIN_DECLS
diff --git a/src/plugins/glade/gbp-glade-layout-stack-addin.c b/src/plugins/glade/gbp-glade-frame-addin.c
similarity index 67%
rename from src/plugins/glade/gbp-glade-layout-stack-addin.c
rename to src/plugins/glade/gbp-glade-frame-addin.c
index d349b8cb9..e7349399f 100644
--- a/src/plugins/glade/gbp-glade-layout-stack-addin.c
+++ b/src/plugins/glade/gbp-glade-frame-addin.c
@@ -1,4 +1,4 @@
-/* gbp-glade-layout-stack-addin.c
+/* gbp-glade-frame-addin.c
*
* Copyright 2018-2019 Christian Hergert <chergert redhat com>
*
@@ -18,17 +18,18 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
-#define G_LOG_DOMAIN "gbp-glade-layout-stack-addin"
+#define G_LOG_DOMAIN "gbp-glade-frame-addin"
#include "config.h"
#include <glib/gi18n.h>
#include <gladeui/glade.h>
+#include <libide-editor.h>
-#include "gbp-glade-layout-stack-addin.h"
-#include "gbp-glade-view.h"
+#include "gbp-glade-frame-addin.h"
+#include "gbp-glade-page.h"
-struct _GbpGladeLayoutStackAddin
+struct _GbpGladeFrameAddin
{
GObject parent_instance;
GtkMenuButton *button;
@@ -37,22 +38,22 @@ struct _GbpGladeLayoutStackAddin
GtkButton *toggle_source;
GladeInspector *inspector;
DzlSignalGroup *project_signals;
- IdeLayoutView *view;
+ IdePage *view;
};
-static void layout_stack_addin_iface_init (IdeLayoutStackAddinInterface *iface);
+static void frame_addin_iface_init (IdeFrameAddinInterface *iface);
-G_DEFINE_TYPE_WITH_CODE (GbpGladeLayoutStackAddin, gbp_glade_layout_stack_addin, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (IDE_TYPE_LAYOUT_STACK_ADDIN,
- layout_stack_addin_iface_init))
+G_DEFINE_TYPE_WITH_CODE (GbpGladeFrameAddin, gbp_glade_frame_addin, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_FRAME_ADDIN,
+ frame_addin_iface_init))
static void
-gbp_glade_layout_stack_addin_selection_changed_cb (GbpGladeLayoutStackAddin *self,
+gbp_glade_frame_addin_selection_changed_cb (GbpGladeFrameAddin *self,
GladeProject *project)
{
GList *selection = NULL;
- g_assert (GBP_IS_GLADE_LAYOUT_STACK_ADDIN (self));
+ g_assert (GBP_IS_GLADE_FRAME_ADDIN (self));
g_assert (!project || GLADE_IS_PROJECT (project));
if (project != NULL)
@@ -92,9 +93,9 @@ gbp_glade_layout_stack_addin_selection_changed_cb (GbpGladeLayoutStackAddin *sel
}
static void
-gbp_glade_layout_stack_addin_dispose (GObject *object)
+gbp_glade_frame_addin_dispose (GObject *object)
{
- GbpGladeLayoutStackAddin *self = (GbpGladeLayoutStackAddin *)object;
+ GbpGladeFrameAddin *self = (GbpGladeFrameAddin *)object;
if (self->project_signals != NULL)
{
@@ -102,25 +103,25 @@ gbp_glade_layout_stack_addin_dispose (GObject *object)
g_clear_object (&self->project_signals);
}
- G_OBJECT_CLASS (gbp_glade_layout_stack_addin_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gbp_glade_frame_addin_parent_class)->dispose (object);
}
static void
-gbp_glade_layout_stack_addin_class_init (GbpGladeLayoutStackAddinClass *klass)
+gbp_glade_frame_addin_class_init (GbpGladeFrameAddinClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = gbp_glade_layout_stack_addin_dispose;
+ object_class->dispose = gbp_glade_frame_addin_dispose;
}
static void
-gbp_glade_layout_stack_addin_init (GbpGladeLayoutStackAddin *self)
+gbp_glade_frame_addin_init (GbpGladeFrameAddin *self)
{
self->project_signals = dzl_signal_group_new (GLADE_TYPE_PROJECT);
dzl_signal_group_connect_object (self->project_signals,
"selection-changed",
- G_CALLBACK (gbp_glade_layout_stack_addin_selection_changed_cb),
+ G_CALLBACK (gbp_glade_frame_addin_selection_changed_cb),
self,
G_CONNECT_SWAPPED);
}
@@ -144,7 +145,7 @@ find_view_cb (GtkWidget *widget,
struct {
GFile *file;
GType type;
- IdeLayoutView *view;
+ IdePage *view;
} *lookup = user_data;
GFile *file;
@@ -153,14 +154,14 @@ find_view_cb (GtkWidget *widget,
if (g_type_is_a (G_OBJECT_TYPE (widget), lookup->type))
{
- if (IDE_IS_EDITOR_VIEW (widget))
+ if (IDE_IS_EDITOR_PAGE (widget))
{
- IdeBuffer *buffer = ide_editor_view_get_buffer (IDE_EDITOR_VIEW (widget));
- file = ide_file_get_file (ide_buffer_get_file (buffer));
+ IdeBuffer *buffer = ide_editor_page_get_buffer (IDE_EDITOR_PAGE (widget));
+ file = ide_buffer_get_file (buffer);
}
- else if (GBP_IS_GLADE_VIEW (widget))
+ else if (GBP_IS_GLADE_PAGE (widget))
{
- file = gbp_glade_view_get_file (GBP_GLADE_VIEW (widget));
+ file = gbp_glade_page_get_file (GBP_GLADE_PAGE (widget));
}
else
{
@@ -168,11 +169,11 @@ find_view_cb (GtkWidget *widget,
}
if (g_file_equal (lookup->file, file))
- lookup->view = IDE_LAYOUT_VIEW (widget);
+ lookup->view = IDE_PAGE (widget);
}
}
-static IdeLayoutView *
+static IdePage *
find_view_by_file_and_type (IdeWorkbench *workbench,
GFile *file,
GType type)
@@ -180,46 +181,45 @@ find_view_by_file_and_type (IdeWorkbench *workbench,
struct {
GFile *file;
GType type;
- IdeLayoutView *view;
+ IdePage *view;
} lookup = { file, type, NULL };
g_assert (IDE_IS_WORKBENCH (workbench));
g_assert (G_IS_FILE (file));
- g_assert (type == IDE_TYPE_EDITOR_VIEW || type == GBP_TYPE_GLADE_VIEW);
+ g_assert (type == IDE_TYPE_EDITOR_PAGE || type == GBP_TYPE_GLADE_PAGE);
- ide_workbench_views_foreach (workbench, find_view_cb, &lookup);
+ ide_workbench_foreach_page (workbench, find_view_cb, &lookup);
return lookup.view;
}
static void
-on_toggle_source_clicked_cb (GbpGladeLayoutStackAddin *self,
+on_toggle_source_clicked_cb (GbpGladeFrameAddin *self,
GtkButton *toggle_source)
{
IdeWorkbench *workbench;
- IdeLayoutView *other;
+ IdePage *other;
const gchar *hint;
GFile *gfile;
GType type;
- g_assert (GBP_IS_GLADE_LAYOUT_STACK_ADDIN (self));
+ g_assert (GBP_IS_GLADE_FRAME_ADDIN (self));
g_assert (GTK_IS_BUTTON (toggle_source));
workbench = ide_widget_get_workbench (GTK_WIDGET (toggle_source));
- if (IDE_IS_EDITOR_VIEW (self->view))
+ if (IDE_IS_EDITOR_PAGE (self->view))
{
- IdeBuffer *buffer = ide_editor_view_get_buffer (IDE_EDITOR_VIEW (self->view));
- IdeFile *file = ide_buffer_get_file (buffer);
+ IdeBuffer *buffer = ide_editor_page_get_buffer (IDE_EDITOR_PAGE (self->view));
- gfile = ide_file_get_file (file);
- type = GBP_TYPE_GLADE_VIEW;
+ gfile = ide_buffer_get_file (buffer);
+ type = GBP_TYPE_GLADE_PAGE;
hint = "glade";
}
- else if (GBP_IS_GLADE_VIEW (self->view))
+ else if (GBP_IS_GLADE_PAGE (self->view))
{
- gfile = gbp_glade_view_get_file (GBP_GLADE_VIEW (self->view));
- type = IDE_TYPE_EDITOR_VIEW;
+ gfile = gbp_glade_page_get_file (GBP_GLADE_PAGE (self->view));
+ type = IDE_TYPE_EDITOR_PAGE;
hint = "editor";
}
else
@@ -229,33 +229,31 @@ on_toggle_source_clicked_cb (GbpGladeLayoutStackAddin *self,
if (!(other = find_view_by_file_and_type (workbench, gfile, type)))
{
- g_autoptr(IdeUri) uri = ide_uri_new_from_file (gfile);
-
- ide_workbench_open_uri_async (workbench,
- uri,
- hint,
- IDE_WORKBENCH_OPEN_FLAGS_NONE,
- NULL, NULL, NULL);
+ ide_workbench_open_async (workbench,
+ gfile,
+ hint,
+ IDE_BUFFER_OPEN_FLAGS_NONE,
+ NULL, NULL, NULL);
}
else
{
- ide_workbench_focus (workbench, GTK_WIDGET (other));
+ gtk_widget_grab_focus (GTK_WIDGET (other));
}
}
static void
-gbp_glade_layout_stack_addin_load (IdeLayoutStackAddin *addin,
- IdeLayoutStack *stack)
+gbp_glade_frame_addin_load (IdeFrameAddin *addin,
+ IdeFrame *stack)
{
- GbpGladeLayoutStackAddin *self = (GbpGladeLayoutStackAddin *)addin;
+ GbpGladeFrameAddin *self = (GbpGladeFrameAddin *)addin;
GtkPopover *popover;
GtkWidget *header;
GtkBox *box;
- g_assert (GBP_IS_GLADE_LAYOUT_STACK_ADDIN (self));
- g_assert (IDE_IS_LAYOUT_STACK (stack));
+ g_assert (GBP_IS_GLADE_FRAME_ADDIN (self));
+ g_assert (IDE_IS_FRAME (stack));
- header = ide_layout_stack_get_titlebar (stack);
+ header = ide_frame_get_titlebar (stack);
popover = g_object_new (GTK_TYPE_POPOVER,
"width-request", 400,
@@ -276,7 +274,7 @@ gbp_glade_layout_stack_addin_load (IdeLayoutStackAddin *addin,
"destroy",
G_CALLBACK (gtk_widget_destroyed),
&self->button);
- ide_layout_stack_header_add_custom_title (IDE_LAYOUT_STACK_HEADER (header),
+ ide_frame_header_add_custom_title (IDE_FRAME_HEADER (header),
GTK_WIDGET (self->button),
200);
@@ -330,13 +328,13 @@ gbp_glade_layout_stack_addin_load (IdeLayoutStackAddin *addin,
}
static void
-gbp_glade_layout_stack_addin_unload (IdeLayoutStackAddin *addin,
- IdeLayoutStack *stack)
+gbp_glade_frame_addin_unload (IdeFrameAddin *addin,
+ IdeFrame *stack)
{
- GbpGladeLayoutStackAddin *self = (GbpGladeLayoutStackAddin *)addin;
+ GbpGladeFrameAddin *self = (GbpGladeFrameAddin *)addin;
- g_assert (GBP_IS_GLADE_LAYOUT_STACK_ADDIN (self));
- g_assert (IDE_IS_LAYOUT_STACK (stack));
+ g_assert (GBP_IS_GLADE_FRAME_ADDIN (self));
+ g_assert (IDE_IS_FRAME (stack));
self->view = NULL;
@@ -348,14 +346,14 @@ gbp_glade_layout_stack_addin_unload (IdeLayoutStackAddin *addin,
}
static void
-gbp_glade_layout_stack_addin_set_view (IdeLayoutStackAddin *addin,
- IdeLayoutView *view)
+gbp_glade_frame_addin_set_view (IdeFrameAddin *addin,
+ IdePage *view)
{
- GbpGladeLayoutStackAddin *self = (GbpGladeLayoutStackAddin *)addin;
+ GbpGladeFrameAddin *self = (GbpGladeFrameAddin *)addin;
GladeProject *project = NULL;
- g_assert (GBP_IS_GLADE_LAYOUT_STACK_ADDIN (self));
- g_assert (!view || IDE_IS_LAYOUT_VIEW (view));
+ g_assert (GBP_IS_GLADE_FRAME_ADDIN (self));
+ g_assert (!view || IDE_IS_PAGE (view));
self->view = view;
@@ -363,14 +361,14 @@ gbp_glade_layout_stack_addin_set_view (IdeLayoutStackAddin *addin,
* Update related widgetry from view change.
*/
- if (GBP_IS_GLADE_VIEW (view))
- project = gbp_glade_view_get_project (GBP_GLADE_VIEW (view));
+ if (GBP_IS_GLADE_PAGE (view))
+ project = gbp_glade_page_get_project (GBP_GLADE_PAGE (view));
glade_inspector_set_project (self->inspector, project);
gtk_widget_set_visible (GTK_WIDGET (self->button), project != NULL);
dzl_signal_group_set_target (self->project_signals, project);
- gbp_glade_layout_stack_addin_selection_changed_cb (self, project);
+ gbp_glade_frame_addin_selection_changed_cb (self, project);
/*
* If this is an editor view and a UI file, we can allow the user
@@ -379,12 +377,11 @@ gbp_glade_layout_stack_addin_set_view (IdeLayoutStackAddin *addin,
gtk_widget_hide (GTK_WIDGET (self->toggle_source));
- if (IDE_IS_EDITOR_VIEW (view))
+ if (IDE_IS_EDITOR_PAGE (view))
{
- IdeBuffer *buffer = ide_editor_view_get_buffer (IDE_EDITOR_VIEW (view));
- IdeFile *file = ide_buffer_get_file (buffer);
- GFile *gfile = ide_file_get_file (file);
- g_autofree gchar *name = g_file_get_basename (gfile);
+ IdeBuffer *buffer = ide_editor_page_get_buffer (IDE_EDITOR_PAGE (view));
+ GFile *file = ide_buffer_get_file (buffer);
+ g_autofree gchar *name = g_file_get_basename (file);
if (g_str_has_suffix (name, ".ui"))
{
@@ -394,7 +391,7 @@ gbp_glade_layout_stack_addin_set_view (IdeLayoutStackAddin *addin,
gtk_widget_show (GTK_WIDGET (self->toggle_source));
}
}
- else if (GBP_IS_GLADE_VIEW (view))
+ else if (GBP_IS_GLADE_PAGE (view))
{
gtk_button_set_label (self->toggle_source, _("View Source"));
gtk_widget_set_tooltip_text (GTK_WIDGET (self->toggle_source),
@@ -404,9 +401,9 @@ gbp_glade_layout_stack_addin_set_view (IdeLayoutStackAddin *addin,
}
static void
-layout_stack_addin_iface_init (IdeLayoutStackAddinInterface *iface)
+frame_addin_iface_init (IdeFrameAddinInterface *iface)
{
- iface->load = gbp_glade_layout_stack_addin_load;
- iface->unload = gbp_glade_layout_stack_addin_unload;
- iface->set_view = gbp_glade_layout_stack_addin_set_view;
+ iface->load = gbp_glade_frame_addin_load;
+ iface->unload = gbp_glade_frame_addin_unload;
+ iface->set_page = gbp_glade_frame_addin_set_view;
}
diff --git a/src/plugins/glade/gbp-glade-layout-stack-addin.h b/src/plugins/glade/gbp-glade-frame-addin.h
similarity index 76%
rename from src/plugins/glade/gbp-glade-layout-stack-addin.h
rename to src/plugins/glade/gbp-glade-frame-addin.h
index 361bffeaf..a2c7aaba2 100644
--- a/src/plugins/glade/gbp-glade-layout-stack-addin.h
+++ b/src/plugins/glade/gbp-glade-frame-addin.h
@@ -1,4 +1,4 @@
-/* gbp-glade-layout-stack-addin.h
+/* gbp-glade-frame-addin.h
*
* Copyright 2018-2019 Christian Hergert <chergert redhat com>
*
@@ -20,12 +20,12 @@
#pragma once
-#include <ide.h>
+#include <libide-gui.h>
G_BEGIN_DECLS
-#define GBP_TYPE_GLADE_LAYOUT_STACK_ADDIN (gbp_glade_layout_stack_addin_get_type())
+#define GBP_TYPE_GLADE_FRAME_ADDIN (gbp_glade_frame_addin_get_type())
-G_DECLARE_FINAL_TYPE (GbpGladeLayoutStackAddin, gbp_glade_layout_stack_addin, GBP, GLADE_LAYOUT_STACK_ADDIN,
GObject)
+G_DECLARE_FINAL_TYPE (GbpGladeFrameAddin, gbp_glade_frame_addin, GBP, GLADE_FRAME_ADDIN, GObject)
G_END_DECLS
diff --git a/src/plugins/glade/gbp-glade-view-actions.c b/src/plugins/glade/gbp-glade-page-actions.c
similarity index 74%
rename from src/plugins/glade/gbp-glade-view-actions.c
rename to src/plugins/glade/gbp-glade-page-actions.c
index 3a6ab47ba..f82d6d828 100644
--- a/src/plugins/glade/gbp-glade-view-actions.c
+++ b/src/plugins/glade/gbp-glade-page-actions.c
@@ -1,4 +1,4 @@
-/* gbp-glade-view-actions.c
+/* gbp-glade-page-actions.c
*
* Copyright 2018-2019 Christian Hergert <chergert redhat com>
*
@@ -18,7 +18,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
-#define G_LOG_DOMAIN "gbp-glade-view-actions"
+#define G_LOG_DOMAIN "gbp-glade-page-actions"
#include "config.h"
@@ -27,34 +27,34 @@
#include "gbp-glade-private.h"
static void
-gbp_glade_view_action_save (GSimpleAction *action,
+gbp_glade_page_action_save (GSimpleAction *action,
GVariant *param,
gpointer user_data)
{
- GbpGladeView *self = user_data;
+ GbpGladePage *self = user_data;
g_autoptr(GError) error = NULL;
g_assert (G_IS_SIMPLE_ACTION (action));
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
- if (!_gbp_glade_view_save (self, &error))
+ if (!_gbp_glade_page_save (self, &error))
/* translators: %s is replaced with the specific error message */
- ide_widget_warning (self, _("Failed to save glade document: %s"), error->message);
+ g_warning (_("Failed to save glade document: %s"), error->message);
}
static void
-gbp_glade_view_action_preview (GSimpleAction *action,
+gbp_glade_page_action_preview (GSimpleAction *action,
GVariant *param,
gpointer user_data)
{
- GbpGladeView *self = user_data;
+ GbpGladePage *self = user_data;
GladeProject *project;
GList *toplevels;
g_assert (G_IS_SIMPLE_ACTION (action));
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
- project = gbp_glade_view_get_project (self);
+ project = gbp_glade_page_get_project (self);
toplevels = glade_project_toplevels (project);
/* Just preview the first toplevel. To preview others, they need to
@@ -74,11 +74,11 @@ gbp_glade_view_action_preview (GSimpleAction *action,
}
static void
-gbp_glade_view_action_pointer_mode (GSimpleAction *action,
+gbp_glade_page_action_pointer_mode (GSimpleAction *action,
GVariant *param,
gpointer user_data)
{
- GbpGladeView *self = user_data;
+ GbpGladePage *self = user_data;
g_autoptr(GEnumClass) klass = NULL;
GladeProject *project;
const gchar *nick;
@@ -88,9 +88,9 @@ gbp_glade_view_action_pointer_mode (GSimpleAction *action,
g_assert (G_IS_SIMPLE_ACTION (action));
g_assert (param != NULL);
g_assert (g_variant_is_of_type (param, G_VARIANT_TYPE_STRING));
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
- project = gbp_glade_view_get_project (self);
+ project = gbp_glade_page_get_project (self);
nick = g_variant_get_string (param, NULL);
/* No GType to lookup from public API yet */
@@ -103,15 +103,15 @@ gbp_glade_view_action_pointer_mode (GSimpleAction *action,
}
static void
-gbp_glade_view_action_paste (GSimpleAction *action,
+gbp_glade_page_action_paste (GSimpleAction *action,
GVariant *param,
gpointer user_data)
{
- GbpGladeView *self = user_data;
+ GbpGladePage *self = user_data;
GtkWidget *placeholder;
g_assert (G_IS_SIMPLE_ACTION (action));
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
placeholder = glade_util_get_placeholder_from_pointer (GTK_CONTAINER (self));
glade_project_command_paste (self->project, placeholder ? GLADE_PLACEHOLDER (placeholder) : NULL);
@@ -119,14 +119,14 @@ gbp_glade_view_action_paste (GSimpleAction *action,
#define WRAP_PROJECT_ACTION(name, func) \
static void \
-gbp_glade_view_action_##name (GSimpleAction *action, \
+gbp_glade_page_action_##name (GSimpleAction *action, \
GVariant *param, \
gpointer user_data) \
{ \
- GbpGladeView *self = user_data; \
+ GbpGladePage *self = user_data; \
\
g_assert (G_IS_SIMPLE_ACTION (action)); \
- g_assert (GBP_IS_GLADE_VIEW (self)); \
+ g_assert (GBP_IS_GLADE_PAGE (self)); \
\
glade_project_##func (self->project); \
}
@@ -138,24 +138,24 @@ WRAP_PROJECT_ACTION (redo, redo)
WRAP_PROJECT_ACTION (undo, undo)
static GActionEntry actions[] = {
- { "cut", gbp_glade_view_action_cut },
- { "copy", gbp_glade_view_action_copy },
- { "paste", gbp_glade_view_action_paste },
- { "delete", gbp_glade_view_action_delete },
- { "redo", gbp_glade_view_action_redo },
- { "undo", gbp_glade_view_action_undo },
- { "save", gbp_glade_view_action_save },
- { "preview", gbp_glade_view_action_preview },
- { "pointer-mode", gbp_glade_view_action_pointer_mode, "s" },
+ { "cut", gbp_glade_page_action_cut },
+ { "copy", gbp_glade_page_action_copy },
+ { "paste", gbp_glade_page_action_paste },
+ { "delete", gbp_glade_page_action_delete },
+ { "redo", gbp_glade_page_action_redo },
+ { "undo", gbp_glade_page_action_undo },
+ { "save", gbp_glade_page_action_save },
+ { "preview", gbp_glade_page_action_preview },
+ { "pointer-mode", gbp_glade_page_action_pointer_mode, "s" },
};
void
-_gbp_glade_view_update_actions (GbpGladeView *self)
+_gbp_glade_page_update_actions (GbpGladePage *self)
{
GladeCommand *redo;
GladeCommand *undo;
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
g_assert (GLADE_IS_PROJECT (self->project));
redo = glade_project_next_redo_item (self->project);
@@ -170,11 +170,11 @@ _gbp_glade_view_update_actions (GbpGladeView *self)
}
void
-_gbp_glade_view_init_actions (GbpGladeView *self)
+_gbp_glade_page_init_actions (GbpGladePage *self)
{
g_autoptr(GSimpleActionGroup) group = NULL;
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
group = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (group),
@@ -185,5 +185,5 @@ _gbp_glade_view_init_actions (GbpGladeView *self)
"glade-view",
G_ACTION_GROUP (group));
- _gbp_glade_view_update_actions (self);
+ _gbp_glade_page_update_actions (self);
}
diff --git a/src/plugins/glade/gbp-glade-view-shortcuts.c b/src/plugins/glade/gbp-glade-page-shortcuts.c
similarity index 96%
rename from src/plugins/glade/gbp-glade-view-shortcuts.c
rename to src/plugins/glade/gbp-glade-page-shortcuts.c
index 947c97ad0..9f4eaf6dc 100644
--- a/src/plugins/glade/gbp-glade-view-shortcuts.c
+++ b/src/plugins/glade/gbp-glade-page-shortcuts.c
@@ -1,4 +1,4 @@
-/* gbp-glade-view-shortcuts.c
+/* gbp-glade-page-shortcuts.c
*
* Copyright 2018-2019 Christian Hergert <chergert redhat com>
*
@@ -18,7 +18,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
-#define G_LOG_DOMAIN "gbp-glade-view-shortcuts"
+#define G_LOG_DOMAIN "gbp-glade-page-shortcuts"
#include "config.h"
@@ -26,7 +26,7 @@
#include <glib/gi18n.h>
#include "gbp-glade-private.h"
-#include "gbp-glade-view.h"
+#include "gbp-glade-page.h"
#define I_(s) (g_intern_static_string(s))
@@ -57,7 +57,7 @@ static DzlShortcutEntry glade_view_shortcuts[] = {
};
void
-_gbp_glade_view_init_shortcuts (GtkWidget *widget)
+_gbp_glade_page_init_shortcuts (GtkWidget *widget)
{
DzlShortcutController *controller;
diff --git a/src/plugins/glade/gbp-glade-view.c b/src/plugins/glade/gbp-glade-page.c
similarity index 77%
rename from src/plugins/glade/gbp-glade-view.c
rename to src/plugins/glade/gbp-glade-page.c
index 1f9f871dd..73a8c21f6 100644
--- a/src/plugins/glade/gbp-glade-view.c
+++ b/src/plugins/glade/gbp-glade-page.c
@@ -1,4 +1,4 @@
-/* gbp-glade-view.c
+/* gbp-glade-page.c
*
* Copyright 2018-2019 Christian Hergert <chergert redhat com>
*
@@ -18,16 +18,16 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
-#define G_LOG_DOMAIN "gbp-glade-view"
+#define G_LOG_DOMAIN "gbp-glade-page"
#include "config.h"
#include <glib/gi18n.h>
-#include "gbp-glade-view.h"
+#include "gbp-glade-page.h"
#include "gbp-glade-private.h"
-G_DEFINE_TYPE (GbpGladeView, gbp_glade_view, IDE_TYPE_LAYOUT_VIEW)
+G_DEFINE_TYPE (GbpGladePage, gbp_glade_page, IDE_TYPE_PAGE)
enum {
PROP_0,
@@ -38,55 +38,53 @@ enum {
static GParamSpec *properties [N_PROPS];
/**
- * gbp_glade_view_new:
+ * gbp_glade_page_new:
*
- * Create a new #GbpGladeView.
+ * Create a new #GbpGladePage.
*
- * Returns: (transfer full): a newly created #GbpGladeView
- *
- * Since: 3.32
+ * Returns: (transfer full): a newly created #GbpGladePage
*/
-GbpGladeView *
-gbp_glade_view_new (void)
+GbpGladePage *
+gbp_glade_page_new (void)
{
- return g_object_new (GBP_TYPE_GLADE_VIEW, NULL);
+ return g_object_new (GBP_TYPE_GLADE_PAGE, NULL);
}
static void
-gbp_glade_view_notify_modified_cb (GbpGladeView *self,
+gbp_glade_page_notify_modified_cb (GbpGladePage *self,
GParamSpec *pspec,
GladeProject *project)
{
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
g_assert (GLADE_IS_PROJECT (project));
- ide_layout_view_set_modified (IDE_LAYOUT_VIEW (self),
+ ide_page_set_modified (IDE_PAGE (self),
glade_project_get_modified (project));
}
static void
-gbp_glade_view_changed_cb (GbpGladeView *self,
+gbp_glade_page_changed_cb (GbpGladePage *self,
GladeCommand *command,
gboolean execute,
GladeProject *project)
{
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
g_assert (!command || GLADE_IS_COMMAND (command));
g_assert (GLADE_IS_PROJECT (project));
if (project != self->project)
return;
- _gbp_glade_view_update_actions (self);
+ _gbp_glade_page_update_actions (self);
}
static void
-gbp_glade_view_set_project (GbpGladeView *self,
+gbp_glade_page_set_project (GbpGladePage *self,
GladeProject *project)
{
GladeProject *old_project = NULL;
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
g_assert (GLADE_IS_PROJECT (project));
if (project == self->project)
@@ -137,7 +135,7 @@ gbp_glade_view_set_project (GbpGladeView *self,
if (self->chooser != NULL)
glade_adaptor_chooser_set_project (self->chooser, self->project);
- ide_layout_view_set_modified (IDE_LAYOUT_VIEW (self),
+ ide_page_set_modified (IDE_PAGE (self),
self->project != NULL && glade_project_get_modified (self->project));
g_clear_object (&old_project);
@@ -146,11 +144,11 @@ gbp_glade_view_set_project (GbpGladeView *self,
}
gboolean
-_gbp_glade_view_reload (GbpGladeView *self)
+_gbp_glade_page_reload (GbpGladePage *self)
{
GladeProject *project;
- g_return_val_if_fail (GBP_IS_GLADE_VIEW (self), FALSE);
+ g_return_val_if_fail (GBP_IS_GLADE_PAGE (self), FALSE);
g_return_val_if_fail (GLADE_IS_PROJECT (self->project), FALSE);
/*
@@ -159,8 +157,8 @@ _gbp_glade_view_reload (GbpGladeView *self)
* Sadly we can't reuse existing GladeProject objects.
*/
project = glade_project_new ();
- gbp_glade_view_set_project (self, project);
- gbp_glade_view_load_file_async (self, self->file, NULL, NULL, NULL);
+ gbp_glade_page_set_project (self, project);
+ gbp_glade_page_load_file_async (self, self->file, NULL, NULL, NULL);
g_clear_object (&project);
/*
@@ -181,12 +179,12 @@ _gbp_glade_view_reload (GbpGladeView *self)
}
gboolean
-_gbp_glade_view_save (GbpGladeView *self,
+_gbp_glade_page_save (GbpGladePage *self,
GError **error)
{
const gchar *path;
- g_return_val_if_fail (GBP_IS_GLADE_VIEW (self), FALSE);
+ g_return_val_if_fail (GBP_IS_GLADE_PAGE (self), FALSE);
g_return_val_if_fail (GLADE_IS_PROJECT (self->project), FALSE);
if (self->file == NULL || !(path = g_file_peek_path (self->file)))
@@ -206,7 +204,7 @@ _gbp_glade_view_save (GbpGladeView *self,
IdeBuffer *buffer;
context = ide_widget_get_context (GTK_WIDGET (self));
- bufmgr = ide_context_get_buffer_manager (context);
+ bufmgr = ide_buffer_manager_from_context (context);
/* We successfully wrote the file, so trigger a full reload of the
* IdeBuffer if there is one already currently open.
@@ -216,8 +214,7 @@ _gbp_glade_view_save (GbpGladeView *self,
{
ide_buffer_manager_load_file_async (bufmgr,
ide_buffer_get_file (buffer),
- TRUE,
- IDE_WORKBENCH_OPEN_FLAGS_NO_VIEW,
+ IDE_BUFFER_OPEN_FLAGS_NO_VIEW |
IDE_BUFFER_OPEN_FLAGS_FORCE_RELOAD,
NULL, NULL, NULL, NULL);
}
@@ -228,24 +225,24 @@ _gbp_glade_view_save (GbpGladeView *self,
}
static void
-gbp_glade_view_agree_to_close_async (IdeLayoutView *view,
+gbp_glade_page_agree_to_close_async (IdePage *view,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GbpGladeView *self = (GbpGladeView *)view;
+ GbpGladePage *self = (GbpGladePage *)view;
g_autoptr(IdeTask) task = NULL;
g_autoptr(GError) error = NULL;
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
task = ide_task_new (self, cancellable, callback, user_data);
- ide_task_set_source_tag (task, gbp_glade_view_agree_to_close_async);
+ ide_task_set_source_tag (task, gbp_glade_page_agree_to_close_async);
- if (ide_layout_view_get_modified (view))
+ if (ide_page_get_modified (view))
{
- if (!_gbp_glade_view_save (self, &error))
+ if (!_gbp_glade_page_save (self, &error))
{
ide_task_return_error (task, g_steal_pointer (&error));
return;
@@ -256,23 +253,23 @@ gbp_glade_view_agree_to_close_async (IdeLayoutView *view,
}
static gboolean
-gbp_glade_view_agree_to_close_finish (IdeLayoutView *view,
+gbp_glade_page_agree_to_close_finish (IdePage *view,
GAsyncResult *result,
GError **error)
{
- g_assert (GBP_IS_GLADE_VIEW (view));
+ g_assert (GBP_IS_GLADE_PAGE (view));
g_assert (IDE_IS_TASK (result));
return ide_task_propagate_boolean (IDE_TASK (result), error);
}
static void
-viewport_style_changed_cb (GbpGladeView *self,
+viewport_style_changed_cb (GbpGladePage *self,
GtkStyleContext *style_context)
{
GdkRGBA bg, fg;
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
g_assert (GTK_IS_STYLE_CONTEXT (style_context));
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
@@ -280,19 +277,18 @@ viewport_style_changed_cb (GbpGladeView *self,
gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_NORMAL, &bg);
G_GNUC_END_IGNORE_DEPRECATIONS;
- ide_layout_view_set_primary_color_bg (IDE_LAYOUT_VIEW (self), &bg);
- ide_layout_view_set_primary_color_fg (IDE_LAYOUT_VIEW (self), &fg);
+ ide_page_set_primary_color_bg (IDE_PAGE (self), &bg);
+ ide_page_set_primary_color_fg (IDE_PAGE (self), &fg);
}
static void
-gbp_glade_view_buffer_saved_cb (GbpGladeView *self,
+gbp_glade_page_buffer_saved_cb (GbpGladePage *self,
IdeBuffer *buffer,
IdeBufferManager *bufmgr)
{
- IdeFile *file;
- GFile *gfile;
+ GFile *file;
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
g_assert (IDE_IS_BUFFER (buffer));
g_assert (IDE_IS_BUFFER_MANAGER (bufmgr));
@@ -300,43 +296,42 @@ gbp_glade_view_buffer_saved_cb (GbpGladeView *self,
return;
file = ide_buffer_get_file (buffer);
- gfile = ide_file_get_file (file);
- if (g_file_equal (gfile, self->file))
- _gbp_glade_view_reload (self);
+ if (g_file_equal (file, self->file))
+ _gbp_glade_page_reload (self);
}
static void
-gbp_glade_view_context_set (GtkWidget *widget,
+gbp_glade_page_context_set (GtkWidget *widget,
IdeContext *context)
{
- GbpGladeView *self = (GbpGladeView *)widget;
+ GbpGladePage *self = (GbpGladePage *)widget;
IdeBufferManager *bufmgr;
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
g_assert (!context || IDE_IS_CONTEXT (context));
if (context == NULL)
return;
/* Track when buffers are saved so that we can reload the view */
- bufmgr = ide_context_get_buffer_manager (context);
+ bufmgr = ide_buffer_manager_from_context (context);
g_signal_connect_object (bufmgr,
"buffer-saved",
- G_CALLBACK (gbp_glade_view_buffer_saved_cb),
+ G_CALLBACK (gbp_glade_page_buffer_saved_cb),
self,
G_CONNECT_SWAPPED);
}
static void
-gbp_glade_view_add_signal_handler_cb (GbpGladeView *self,
+gbp_glade_page_add_signal_handler_cb (GbpGladePage *self,
GladeWidget *widget,
const GladeSignal *gsignal,
GladeProject *project)
{
IDE_ENTRY;
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
g_assert (GLADE_IS_WIDGET (widget));
g_assert (GLADE_IS_SIGNAL (gsignal));
g_assert (GLADE_IS_PROJECT (project));
@@ -348,14 +343,14 @@ gbp_glade_view_add_signal_handler_cb (GbpGladeView *self,
}
static void
-gbp_glade_view_remove_signal_handler_cb (GbpGladeView *self,
+gbp_glade_page_remove_signal_handler_cb (GbpGladePage *self,
GladeWidget *widget,
const GladeSignal *gsignal,
GladeProject *project)
{
IDE_ENTRY;
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
g_assert (GLADE_IS_WIDGET (widget));
g_assert (GLADE_IS_SIGNAL (gsignal));
g_assert (GLADE_IS_PROJECT (project));
@@ -367,7 +362,7 @@ gbp_glade_view_remove_signal_handler_cb (GbpGladeView *self,
}
static void
-gbp_glade_view_change_signal_handler_cb (GbpGladeView *self,
+gbp_glade_page_change_signal_handler_cb (GbpGladePage *self,
GladeWidget *widget,
const GladeSignal *old_gsignal,
const GladeSignal *new_gsignal,
@@ -375,7 +370,7 @@ gbp_glade_view_change_signal_handler_cb (GbpGladeView *self,
{
IDE_ENTRY;
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
g_assert (GLADE_IS_WIDGET (widget));
g_assert (GLADE_IS_SIGNAL (old_gsignal));
g_assert (GLADE_IS_SIGNAL (new_gsignal));
@@ -389,14 +384,14 @@ gbp_glade_view_change_signal_handler_cb (GbpGladeView *self,
}
static void
-gbp_glade_view_activate_signal_handler_cb (GbpGladeView *self,
+gbp_glade_page_activate_signal_handler_cb (GbpGladePage *self,
GladeWidget *widget,
const GladeSignal *gsignal,
GladeProject *project)
{
IDE_ENTRY;
- g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (GBP_IS_GLADE_PAGE (self));
g_assert (GLADE_IS_WIDGET (widget));
g_assert (GLADE_IS_SIGNAL (gsignal));
g_assert (GLADE_IS_PROJECT (project));
@@ -408,9 +403,9 @@ gbp_glade_view_activate_signal_handler_cb (GbpGladeView *self,
}
static void
-gbp_glade_view_dispose (GObject *object)
+gbp_glade_page_dispose (GObject *object)
{
- GbpGladeView *self = (GbpGladeView *)object;
+ GbpGladePage *self = (GbpGladePage *)object;
g_clear_object (&self->file);
g_clear_object (&self->project);
@@ -421,21 +416,21 @@ gbp_glade_view_dispose (GObject *object)
g_clear_object (&self->project_signals);
}
- G_OBJECT_CLASS (gbp_glade_view_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gbp_glade_page_parent_class)->dispose (object);
}
static void
-gbp_glade_view_get_property (GObject *object,
+gbp_glade_page_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
- GbpGladeView *self = GBP_GLADE_VIEW (object);
+ GbpGladePage *self = GBP_GLADE_PAGE (object);
switch (prop_id)
{
case PROP_PROJECT:
- g_value_set_object (value, gbp_glade_view_get_project (self));
+ g_value_set_object (value, gbp_glade_page_get_project (self));
break;
default:
@@ -444,17 +439,17 @@ gbp_glade_view_get_property (GObject *object,
}
static void
-gbp_glade_view_class_init (GbpGladeViewClass *klass)
+gbp_glade_page_class_init (GbpGladePageClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- IdeLayoutViewClass *view_class = IDE_LAYOUT_VIEW_CLASS (klass);
+ IdePageClass *view_class = IDE_PAGE_CLASS (klass);
- object_class->dispose = gbp_glade_view_dispose;
- object_class->get_property = gbp_glade_view_get_property;
+ object_class->dispose = gbp_glade_page_dispose;
+ object_class->get_property = gbp_glade_page_get_property;
- view_class->agree_to_close_async = gbp_glade_view_agree_to_close_async;
- view_class->agree_to_close_finish = gbp_glade_view_agree_to_close_finish;
+ view_class->agree_to_close_async = gbp_glade_page_agree_to_close_async;
+ view_class->agree_to_close_finish = gbp_glade_page_agree_to_close_finish;
properties [PROP_PROJECT] =
g_param_spec_object ("project",
@@ -469,7 +464,7 @@ gbp_glade_view_class_init (GbpGladeViewClass *klass)
}
static void
-gbp_glade_view_init (GbpGladeView *self)
+gbp_glade_page_init (GbpGladePage *self)
{
GtkBox *box;
GtkViewport *viewport;
@@ -486,54 +481,54 @@ gbp_glade_view_init (GbpGladeView *self)
{ "align-edit", "pointer-mode-pin-symbolic", N_("Switch to alignment editor") },
};
- ide_layout_view_set_can_split (IDE_LAYOUT_VIEW (self), FALSE);
- ide_layout_view_set_menu_id (IDE_LAYOUT_VIEW (self), "gbp-glade-view-menu");
- ide_layout_view_set_title (IDE_LAYOUT_VIEW (self), _("Unnamed Glade project"));
- ide_layout_view_set_icon_name (IDE_LAYOUT_VIEW (self), "glade-symbolic");
- ide_layout_view_set_menu_id (IDE_LAYOUT_VIEW (self), "gbp-glade-view-document-menu");
+ ide_page_set_can_split (IDE_PAGE (self), FALSE);
+ ide_page_set_menu_id (IDE_PAGE (self), "gbp-glade-page-menu");
+ ide_page_set_title (IDE_PAGE (self), _("Unnamed Glade project"));
+ ide_page_set_icon_name (IDE_PAGE (self), "glade-symbolic");
+ ide_page_set_menu_id (IDE_PAGE (self), "gbp-glade-page-document-menu");
self->project_signals = dzl_signal_group_new (GLADE_TYPE_PROJECT);
dzl_signal_group_connect_object (self->project_signals,
"notify::modified",
- G_CALLBACK (gbp_glade_view_notify_modified_cb),
+ G_CALLBACK (gbp_glade_page_notify_modified_cb),
self,
G_CONNECT_SWAPPED);
dzl_signal_group_connect_object (self->project_signals,
"changed",
- G_CALLBACK (gbp_glade_view_changed_cb),
+ G_CALLBACK (gbp_glade_page_changed_cb),
self,
G_CONNECT_SWAPPED);
dzl_signal_group_connect_object (self->project_signals,
"add-signal-handler",
- G_CALLBACK (gbp_glade_view_add_signal_handler_cb),
+ G_CALLBACK (gbp_glade_page_add_signal_handler_cb),
self,
G_CONNECT_SWAPPED);
dzl_signal_group_connect_object (self->project_signals,
"remove-signal-handler",
- G_CALLBACK (gbp_glade_view_remove_signal_handler_cb),
+ G_CALLBACK (gbp_glade_page_remove_signal_handler_cb),
self,
G_CONNECT_SWAPPED);
dzl_signal_group_connect_object (self->project_signals,
"change-signal-handler",
- G_CALLBACK (gbp_glade_view_change_signal_handler_cb),
+ G_CALLBACK (gbp_glade_page_change_signal_handler_cb),
self,
G_CONNECT_SWAPPED);
dzl_signal_group_connect_object (self->project_signals,
"activate-signal-handler",
- G_CALLBACK (gbp_glade_view_activate_signal_handler_cb),
+ G_CALLBACK (gbp_glade_page_activate_signal_handler_cb),
self,
G_CONNECT_SWAPPED);
- ide_widget_set_context_handler (self, gbp_glade_view_context_set);
+ ide_widget_set_context_handler (self, gbp_glade_page_context_set);
project = glade_project_new ();
- gbp_glade_view_set_project (self, project);
+ gbp_glade_page_set_project (self, project);
g_clear_object (&project);
self->main_box = g_object_new (GTK_TYPE_BOX,
@@ -614,21 +609,19 @@ gbp_glade_view_init (GbpGladeView *self)
/* Setup action state and shortcuts */
- _gbp_glade_view_init_actions (self);
- _gbp_glade_view_init_shortcuts (GTK_WIDGET (self));
+ _gbp_glade_page_init_actions (self);
+ _gbp_glade_page_init_shortcuts (GTK_WIDGET (self));
}
/**
- * gbp_glade_view_get_project:
+ * gbp_glade_page_get_project:
*
* Returns: (transfer none): A #GladeProject or %NULL
- *
- * Since: 3.32
*/
GladeProject *
-gbp_glade_view_get_project (GbpGladeView *self)
+gbp_glade_page_get_project (GbpGladePage *self)
{
- g_return_val_if_fail (GBP_IS_GLADE_VIEW (self), NULL);
+ g_return_val_if_fail (GBP_IS_GLADE_PAGE (self), NULL);
return self->project;
}
@@ -650,11 +643,11 @@ file_missing_or_empty (GFile *file)
}
static void
-gbp_glade_view_load_file_map_cb (GladeDesignView *designer,
+gbp_glade_page_load_file_map_cb (GladeDesignView *designer,
IdeTask *task)
{
g_autofree gchar *name = NULL;
- GbpGladeView *self;
+ GbpGladePage *self;
const gchar *path;
GFile *file;
@@ -666,7 +659,7 @@ gbp_glade_view_load_file_map_cb (GladeDesignView *designer,
file = ide_task_get_task_data (task);
g_signal_handlers_disconnect_by_func (self->designer,
- G_CALLBACK (gbp_glade_view_load_file_map_cb),
+ G_CALLBACK (gbp_glade_page_load_file_map_cb),
task);
if (!g_file_is_native (file))
@@ -685,7 +678,7 @@ gbp_glade_view_load_file_map_cb (GladeDesignView *designer,
if (file_missing_or_empty (file))
{
name = g_file_get_basename (file);
- ide_layout_view_set_title (IDE_LAYOUT_VIEW (self), name);
+ ide_page_set_title (IDE_PAGE (self), name);
ide_task_return_boolean (task, TRUE);
return;
}
@@ -701,11 +694,11 @@ gbp_glade_view_load_file_map_cb (GladeDesignView *designer,
ide_task_return_boolean (task, TRUE);
name = glade_project_get_name (self->project);
- ide_layout_view_set_title (IDE_LAYOUT_VIEW (self), name);
+ ide_page_set_title (IDE_PAGE (self), name);
}
void
-gbp_glade_view_load_file_async (GbpGladeView *self,
+gbp_glade_page_load_file_async (GbpGladePage *self,
GFile *file,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -713,12 +706,12 @@ gbp_glade_view_load_file_async (GbpGladeView *self,
{
g_autoptr(IdeTask) task = NULL;
- g_return_if_fail (GBP_IS_GLADE_VIEW (self));
+ g_return_if_fail (GBP_IS_GLADE_PAGE (self));
g_return_if_fail (G_IS_FILE (file));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
task = ide_task_new (self, cancellable, callback, user_data);
- ide_task_set_source_tag (task, gbp_glade_view_load_file_async);
+ ide_task_set_source_tag (task, gbp_glade_page_load_file_async);
ide_task_set_task_data (task, g_object_ref (file), g_object_unref);
g_set_object (&self->file, file);
@@ -730,36 +723,34 @@ gbp_glade_view_load_file_async (GbpGladeView *self,
if (!gtk_widget_get_mapped (GTK_WIDGET (self->designer)))
g_signal_connect_data (self->designer,
"map",
- G_CALLBACK (gbp_glade_view_load_file_map_cb),
+ G_CALLBACK (gbp_glade_page_load_file_map_cb),
g_steal_pointer (&task),
(GClosureNotify)g_object_unref,
0);
else
- gbp_glade_view_load_file_map_cb (self->designer, task);
+ gbp_glade_page_load_file_map_cb (self->designer, task);
}
gboolean
-gbp_glade_view_load_file_finish (GbpGladeView *self,
+gbp_glade_page_load_file_finish (GbpGladePage *self,
GAsyncResult *result,
GError **error)
{
- g_return_val_if_fail (GBP_IS_GLADE_VIEW (self), FALSE);
+ g_return_val_if_fail (GBP_IS_GLADE_PAGE (self), FALSE);
g_return_val_if_fail (IDE_IS_TASK (result), FALSE);
return ide_task_propagate_boolean (IDE_TASK (result), error);
}
/**
- * gbp_glade_view_get_file:
+ * gbp_glade_page_get_file:
*
* Returns: (nullable) (transfer none): a #GFile or %NULL
- *
- * Since: 3.32
*/
GFile *
-gbp_glade_view_get_file (GbpGladeView *self)
+gbp_glade_page_get_file (GbpGladePage *self)
{
- g_return_val_if_fail (GBP_IS_GLADE_VIEW (self), NULL);
+ g_return_val_if_fail (GBP_IS_GLADE_PAGE (self), NULL);
return self->file;
}
diff --git a/src/plugins/glade/gbp-glade-view.h b/src/plugins/glade/gbp-glade-page.h
similarity index 73%
rename from src/plugins/glade/gbp-glade-view.h
rename to src/plugins/glade/gbp-glade-page.h
index b5f6105f5..7bfb1f14e 100644
--- a/src/plugins/glade/gbp-glade-view.h
+++ b/src/plugins/glade/gbp-glade-page.h
@@ -1,4 +1,4 @@
-/* gbp-glade-view.h
+/* gbp-glade-page.h
*
* Copyright 2018-2019 Christian Hergert <chergert redhat com>
*
@@ -21,24 +21,24 @@
#pragma once
#include <gladeui/glade.h>
-#include <ide.h>
+#include <libide-gui.h>
G_BEGIN_DECLS
-#define GBP_TYPE_GLADE_VIEW (gbp_glade_view_get_type())
+#define GBP_TYPE_GLADE_PAGE (gbp_glade_page_get_type())
-G_DECLARE_FINAL_TYPE (GbpGladeView, gbp_glade_view, GBP, GLADE_VIEW, IdeLayoutView)
+G_DECLARE_FINAL_TYPE (GbpGladePage, gbp_glade_page, GBP, GLADE_PAGE, IdePage)
-GbpGladeView *gbp_glade_view_new (void);
-GFile *gbp_glade_view_get_file (GbpGladeView *self);
-void gbp_glade_view_load_file_async (GbpGladeView *self,
+GbpGladePage *gbp_glade_page_new (void);
+GFile *gbp_glade_page_get_file (GbpGladePage *self);
+void gbp_glade_page_load_file_async (GbpGladePage *self,
GFile *file,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
-gboolean gbp_glade_view_load_file_finish (GbpGladeView *self,
+gboolean gbp_glade_page_load_file_finish (GbpGladePage *self,
GAsyncResult *result,
GError **error);
-GladeProject *gbp_glade_view_get_project (GbpGladeView *self);
+GladeProject *gbp_glade_page_get_project (GbpGladePage *self);
G_END_DECLS
diff --git a/src/plugins/glade/gbp-glade-private.h b/src/plugins/glade/gbp-glade-private.h
index 76b4483bf..87169fec4 100644
--- a/src/plugins/glade/gbp-glade-private.h
+++ b/src/plugins/glade/gbp-glade-private.h
@@ -20,17 +20,17 @@
#pragma once
-#include <ide.h>
+#include <libide-gui.h>
#include <gladeui/glade.h>
#include <gladeui/glade-adaptor-chooser.h>
-#include "gbp-glade-view.h"
+#include "gbp-glade-page.h"
G_BEGIN_DECLS
-struct _GbpGladeView
+struct _GbpGladePage
{
- IdeLayoutView parent_instance;
+ IdePage parent_instance;
GFile *file;
GladeProject *project;
@@ -41,11 +41,11 @@ struct _GbpGladeView
GtkBox *main_box;
};
-void _gbp_glade_view_init_actions (GbpGladeView *self);
-void _gbp_glade_view_init_shortcuts (GtkWidget *widget);
-void _gbp_glade_view_update_actions (GbpGladeView *self);
-gboolean _gbp_glade_view_reload (GbpGladeView *self);
-gboolean _gbp_glade_view_save (GbpGladeView *self,
+void _gbp_glade_page_init_actions (GbpGladePage *self);
+void _gbp_glade_page_init_shortcuts (GtkWidget *widget);
+void _gbp_glade_page_update_actions (GbpGladePage *self);
+gboolean _gbp_glade_page_reload (GbpGladePage *self);
+gboolean _gbp_glade_page_save (GbpGladePage *self,
GError **error);
G_END_DECLS
diff --git a/src/plugins/glade/gbp-glade-properties.c b/src/plugins/glade/gbp-glade-properties.c
index 972951810..2c6ba142e 100644
--- a/src/plugins/glade/gbp-glade-properties.c
+++ b/src/plugins/glade/gbp-glade-properties.c
@@ -51,7 +51,7 @@ gbp_glade_properties_class_init (GbpGladePropertiesClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/plugins/glade-plugin/gbp-glade-properties.ui");
+ gtk_widget_class_set_template_from_resource (widget_class, "/plugins/glade/gbp-glade-properties.ui");
gtk_widget_class_set_css_name (widget_class, "gbpgladeproperties");
gtk_widget_class_bind_template_child (widget_class, GbpGladeProperties, stack);
gtk_widget_class_bind_template_child (widget_class, GbpGladeProperties, stack_switcher);
diff --git a/src/plugins/glade/gbp-glade-properties.h b/src/plugins/glade/gbp-glade-properties.h
index bf61e02bb..aff86e58d 100644
--- a/src/plugins/glade/gbp-glade-properties.h
+++ b/src/plugins/glade/gbp-glade-properties.h
@@ -21,7 +21,7 @@
#pragma once
#include <gladeui/glade.h>
-#include <ide.h>
+#include <libide-gui.h>
G_BEGIN_DECLS
diff --git a/src/plugins/glade/gbp-glade-workbench-addin.c b/src/plugins/glade/gbp-glade-workbench-addin.c
index 3e60ae239..0d499e837 100644
--- a/src/plugins/glade/gbp-glade-workbench-addin.c
+++ b/src/plugins/glade/gbp-glade-workbench-addin.c
@@ -22,40 +22,72 @@
#include "config.h"
-#include "gbp-glade-view.h"
+#include <libide-gui.h>
+
+#include "gbp-glade-page.h"
#include "gbp-glade-workbench-addin.h"
struct _GbpGladeWorkbenchAddin
{
- GObject parent_instance;
- IdeWorkbench *workbench;
- GHashTable *catalog_paths;
+ GObject parent_instance;
+ IdeWorkbench *workbench;
+ IdeBuildManager *build_manager;
+ GHashTable *catalog_paths;
};
typedef struct
{
GFile *file;
- GbpGladeView *view;
-} LocateView;
+ GbpGladePage *view;
+} LocatePage;
-static gchar *
-gbp_glade_workbench_addin_get_id (IdeWorkbenchAddin *addin)
+static void
+find_most_recent_editor_cb (GtkWidget *widget,
+ gpointer user_data)
{
- return g_strdup ("glade");
+ IdeSurface **surface = user_data;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (IDE_IS_WORKSPACE (widget));
+
+ if (*surface == NULL)
+ *surface = ide_workspace_get_surface_by_name (IDE_WORKSPACE (widget), "editor");
+}
+
+static IdeSurface *
+find_most_recent_editor (GbpGladeWorkbenchAddin *self)
+{
+ IdeSurface *surface = NULL;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (IDE_IS_WORKBENCH (self->workbench));
+
+ ide_workbench_foreach_workspace (self->workbench,
+ find_most_recent_editor_cb,
+ &surface);
+
+ return surface;
}
static gboolean
gbp_glade_workbench_addin_can_open (IdeWorkbenchAddin *addin,
- IdeUri *uri,
+ GFile *file,
const gchar *content_type,
gint *priority)
{
+ GbpGladeWorkbenchAddin *self = (GbpGladeWorkbenchAddin *)addin;
const gchar *path;
- g_assert (GBP_IS_GLADE_WORKBENCH_ADDIN (addin));
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (G_IS_FILE (file));
+ g_assert (GBP_IS_GLADE_WORKBENCH_ADDIN (self));
g_assert (priority != NULL);
- path = ide_uri_get_path (uri);
+ /* Ignore all open requests unless we have a surface */
+ if (!find_most_recent_editor (self))
+ return FALSE;
+
+ path = g_file_peek_path (file);
if (g_strcmp0 (content_type, "application/x-gtk-builder") == 0 ||
g_strcmp0 (content_type, "application/x-designer") == 0 ||
@@ -73,23 +105,23 @@ gbp_glade_workbench_addin_open_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
- GbpGladeView *view = (GbpGladeView *)object;
+ GbpGladePage *view = (GbpGladePage *)object;
g_autoptr(GError) error = NULL;
g_autoptr(IdeTask) task = user_data;
GladeProject *project;
GList *toplevels;
- g_assert (GBP_IS_GLADE_VIEW (view));
+ g_assert (GBP_IS_GLADE_PAGE (view));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (IDE_IS_TASK (task));
- if (!gbp_glade_view_load_file_finish (view, result, &error))
+ if (!gbp_glade_page_load_file_finish (view, result, &error))
{
ide_task_return_error (task, g_steal_pointer (&error));
return;
}
- project = gbp_glade_view_get_project (view);
+ project = gbp_glade_page_get_project (view);
toplevels = glade_project_toplevels (project);
/* Select the first toplevel so that we don't start with a non-existant
@@ -102,74 +134,81 @@ gbp_glade_workbench_addin_open_cb (GObject *object,
}
static void
-locate_view (GtkWidget *view,
+locate_page (GtkWidget *view,
gpointer user_data)
{
- LocateView *locate = user_data;
+ LocatePage *locate = user_data;
GFile *file;
- g_assert (IDE_IS_LAYOUT_VIEW (view));
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (IDE_IS_PAGE (view));
g_assert (locate != NULL);
if (locate->view != NULL)
return;
- if (!GBP_IS_GLADE_VIEW (view))
+ if (!GBP_IS_GLADE_PAGE (view))
return;
- file = gbp_glade_view_get_file (GBP_GLADE_VIEW (view));
+ file = gbp_glade_page_get_file (GBP_GLADE_PAGE (view));
if (g_file_equal (file, locate->file))
- locate->view = GBP_GLADE_VIEW (view);
+ locate->view = GBP_GLADE_PAGE (view);
}
static void
-gbp_glade_workbench_addin_open_async (IdeWorkbenchAddin *addin,
- IdeUri *uri,
- const gchar *content_type,
- IdeWorkbenchOpenFlags flags,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+gbp_glade_workbench_addin_open_async (IdeWorkbenchAddin *addin,
+ GFile *file,
+ const gchar *content_type,
+ IdeBufferOpenFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GbpGladeWorkbenchAddin *self = (GbpGladeWorkbenchAddin *)addin;
g_autoptr(IdeTask) task = NULL;
- g_autoptr(GFile) file = NULL;
- IdePerspective *editor;
- GbpGladeView *view;
- LocateView locate = { 0 };
+ GbpGladePage *view;
+ IdeSurface *editor;
+ LocatePage locate = { 0 };
+ g_assert (IDE_IS_MAIN_THREAD ());
g_assert (GBP_IS_GLADE_WORKBENCH_ADDIN (self));
g_assert (IDE_IS_WORKBENCH (self->workbench));
- g_assert (uri != NULL);
+ g_assert (G_IS_FILE (file));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, gbp_glade_workbench_addin_open_async);
- editor = ide_workbench_get_perspective_by_name (self->workbench, "editor");
- file = ide_uri_to_file (uri);
+ if (!(editor = find_most_recent_editor (self)))
+ {
+ ide_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ "Cannot open, not in project mode");
+ return;
+ }
/* First try to find an existing view for the file */
locate.file = file;
- ide_workbench_views_foreach (self->workbench, locate_view, &locate);
+ ide_workbench_foreach_page (self->workbench, locate_page, &locate);
if (locate.view != NULL)
{
- ide_workbench_focus (self->workbench, GTK_WIDGET (locate.view));
+ ide_widget_reveal_and_grab (GTK_WIDGET (locate.view));
ide_task_return_boolean (task, TRUE);
return;
}
- view = gbp_glade_view_new ();
+ view = gbp_glade_page_new ();
gtk_container_add (GTK_CONTAINER (editor), GTK_WIDGET (view));
gtk_widget_show (GTK_WIDGET (view));
- gbp_glade_view_load_file_async (view,
+ gbp_glade_page_load_file_async (view,
file,
cancellable,
gbp_glade_workbench_addin_open_cb,
g_steal_pointer (&task));
- ide_workbench_focus (self->workbench, GTK_WIDGET (view));
+ ide_widget_reveal_and_grab (GTK_WIDGET (view));
}
static gboolean
@@ -257,14 +296,26 @@ gbp_glade_workbench_addin_load (IdeWorkbenchAddin *addin,
IdeWorkbench *workbench)
{
GbpGladeWorkbenchAddin *self = (GbpGladeWorkbenchAddin *)addin;
- IdeBuildManager *build_manager;
- IdeContext *context;
+ g_assert (IDE_IS_MAIN_THREAD ());
g_assert (GBP_IS_GLADE_WORKBENCH_ADDIN (self));
g_assert (IDE_IS_WORKBENCH (workbench));
self->workbench = workbench;
self->catalog_paths = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+}
+
+static void
+gbp_glade_workbench_addin_project_loaded (IdeWorkbenchAddin *addin,
+ IdeProjectInfo *project_info)
+{
+ GbpGladeWorkbenchAddin *self = (GbpGladeWorkbenchAddin *)addin;
+ IdeBuildManager *build_manager;
+ IdeContext *context;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_GLADE_WORKBENCH_ADDIN (self));
+ g_assert (IDE_IS_PROJECT_INFO (project_info));
/*
* We want to watch the build pipeline for changes to the current
@@ -278,10 +329,11 @@ gbp_glade_workbench_addin_load (IdeWorkbenchAddin *addin,
* the runtime is a foreign mount.
*/
- context = ide_workbench_get_context (workbench);
- build_manager = ide_context_get_build_manager (context);
+ context = ide_workbench_get_context (self->workbench);
+ build_manager = ide_build_manager_from_context (context);
- g_signal_connect_object (build_manager,
+ self->build_manager = g_object_ref (build_manager);
+ g_signal_connect_object (self->build_manager,
"notify::pipeline",
G_CALLBACK (on_build_pipeline_changed_cb),
self,
@@ -296,20 +348,19 @@ gbp_glade_workbench_addin_unload (IdeWorkbenchAddin *addin,
IdeWorkbench *workbench)
{
GbpGladeWorkbenchAddin *self = (GbpGladeWorkbenchAddin *)addin;
- IdeBuildManager *build_manager;
- IdeContext *context;
const gchar *path;
GHashTableIter iter;
g_assert (GBP_IS_GLADE_WORKBENCH_ADDIN (self));
g_assert (IDE_IS_WORKBENCH (workbench));
- context = ide_workbench_get_context (workbench);
- build_manager = ide_context_get_build_manager (context);
-
- g_signal_handlers_disconnect_by_func (build_manager,
- G_CALLBACK (on_build_pipeline_changed_cb),
- self);
+ if (self->build_manager != NULL)
+ {
+ g_signal_handlers_disconnect_by_func (self->build_manager,
+ G_CALLBACK (on_build_pipeline_changed_cb),
+ self);
+ g_clear_object (&self->build_manager);
+ }
g_hash_table_iter_init (&iter, self->catalog_paths);
while (g_hash_table_iter_next (&iter, (gpointer *)&path, NULL))
@@ -327,7 +378,7 @@ gbp_glade_workbench_addin_unload (IdeWorkbenchAddin *addin,
static void
workbench_addin_iface_init (IdeWorkbenchAddinInterface *iface)
{
- iface->get_id = gbp_glade_workbench_addin_get_id;
+ iface->project_loaded = gbp_glade_workbench_addin_project_loaded;
iface->load = gbp_glade_workbench_addin_load;
iface->unload = gbp_glade_workbench_addin_unload;
iface->can_open = gbp_glade_workbench_addin_can_open;
diff --git a/src/plugins/glade/gbp-glade-workbench-addin.h b/src/plugins/glade/gbp-glade-workbench-addin.h
index a8dfe1c59..b2a9be9c1 100644
--- a/src/plugins/glade/gbp-glade-workbench-addin.h
+++ b/src/plugins/glade/gbp-glade-workbench-addin.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-gui.h>
G_BEGIN_DECLS
diff --git a/src/plugins/glade/gbp-glade-plugin.c b/src/plugins/glade/glade-plugin.c
similarity index 80%
rename from src/plugins/glade/gbp-glade-plugin.c
rename to src/plugins/glade/glade-plugin.c
index d4e12a360..da384cc96 100644
--- a/src/plugins/glade/gbp-glade-plugin.c
+++ b/src/plugins/glade/glade-plugin.c
@@ -1,4 +1,4 @@
-/* gbp-glade-plugin.c
+/* glade-plugin.c
*
* Copyright 2018-2019 Christian Hergert <chergert redhat com>
*
@@ -20,16 +20,19 @@
#define G_LOG_DOMAIN "gbp-glade-plugin"
+#include "config.h"
+
#include <gladeui/glade.h>
-#include <ide.h>
+#include <libide-editor.h>
+#include <libide-gui.h>
#include <libpeas/peas.h>
#include "gbp-glade-editor-addin.h"
-#include "gbp-glade-layout-stack-addin.h"
+#include "gbp-glade-frame-addin.h"
#include "gbp-glade-workbench-addin.h"
-void
-gbp_glade_register_types (PeasObjectModule *module)
+_IDE_EXTERN void
+_gbp_glade_register_types (PeasObjectModule *module)
{
glade_init ();
@@ -37,8 +40,8 @@ gbp_glade_register_types (PeasObjectModule *module)
IDE_TYPE_EDITOR_ADDIN,
GBP_TYPE_GLADE_EDITOR_ADDIN);
peas_object_module_register_extension_type (module,
- IDE_TYPE_LAYOUT_STACK_ADDIN,
- GBP_TYPE_GLADE_LAYOUT_STACK_ADDIN);
+ IDE_TYPE_FRAME_ADDIN,
+ GBP_TYPE_GLADE_FRAME_ADDIN);
peas_object_module_register_extension_type (module,
IDE_TYPE_WORKBENCH_ADDIN,
GBP_TYPE_GLADE_WORKBENCH_ADDIN);
diff --git a/src/plugins/glade/glade.gresource.xml b/src/plugins/glade/glade.gresource.xml
index fc9b5e994..50caa9678 100644
--- a/src/plugins/glade/glade.gresource.xml
+++ b/src/plugins/glade/glade.gresource.xml
@@ -1,13 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
- <gresource prefix="/org/gnome/builder/plugins">
+ <gresource prefix="/plugins/glade">
<file>glade.plugin</file>
- </gresource>
- <gresource prefix="/org/gnome/builder/plugins/glade-plugin">
- <file>gtk/menus.ui</file>
-
- <file>gbp-glade-properties.ui</file>
-
+ <file preprocess="xml-stripblanks">gtk/menus.ui</file>
+ <file preprocess="xml-stripblanks">gbp-glade-properties.ui</file>
<file>themes/shared.css</file>
<file>themes/Adwaita.css</file>
<file>themes/Adwaita-dark.css</file>
diff --git a/src/plugins/glade/glade.plugin b/src/plugins/glade/glade.plugin
index d818163e1..05e5074bd 100644
--- a/src/plugins/glade/glade.plugin
+++ b/src/plugins/glade/glade.plugin
@@ -1,9 +1,9 @@
[Plugin]
-Module=glade-plugin
-Name=Glade
-Description=Integration with Glade UI designer for Gtk
Authors=Christian Hergert <christian hergert me>
+Builtin=true
Copyright=Copyright © 2018 Christian Hergert
Depends=editor;
-Builtin=true
-Embedded=gbp_glade_register_types
+Description=Integration with Glade UI designer for Gtk
+Embedded=_gbp_glade_register_types
+Module=glade
+Name=Glade
diff --git a/src/plugins/glade/meson.build b/src/plugins/glade/meson.build
index 7b26ce989..c57630612 100644
--- a/src/plugins/glade/meson.build
+++ b/src/plugins/glade/meson.build
@@ -1,27 +1,26 @@
-if get_option('with_glade')
+if get_option('plugin_glade')
-glade_resources = gnome.compile_resources(
+plugins_sources += files([
+ 'gbp-glade-editor-addin.c',
+ 'gbp-glade-frame-addin.c',
+ 'gbp-glade-properties.c',
+ 'gbp-glade-page.c',
+ 'gbp-glade-page-actions.c',
+ 'gbp-glade-page-shortcuts.c',
+ 'glade-plugin.c',
+ 'gbp-glade-workbench-addin.c',
+])
+
+plugin_glade_resources = gnome.compile_resources(
'glade-resources',
'glade.gresource.xml',
c_name: 'gbp_glade',
)
-glade_sources = [
- 'gbp-glade-editor-addin.c',
- 'gbp-glade-layout-stack-addin.c',
- 'gbp-glade-plugin.c',
- 'gbp-glade-properties.c',
- 'gbp-glade-view.c',
- 'gbp-glade-view-actions.c',
- 'gbp-glade-view-shortcuts.c',
- 'gbp-glade-workbench-addin.c',
-]
-
-gnome_builder_plugins_deps += [
+plugins_deps += [
dependency('gladeui-2.0', version: '>=3.22.0'),
]
-gnome_builder_plugins_sources += files(glade_sources)
-gnome_builder_plugins_sources += glade_resources[0]
+plugins_sources += plugin_glade_resources[0]
endif
diff --git a/src/plugins/glade/themes/Adwaita-dark.css b/src/plugins/glade/themes/Adwaita-dark.css
index 87f288f85..434ad6dd5 100644
--- a/src/plugins/glade/themes/Adwaita-dark.css
+++ b/src/plugins/glade/themes/Adwaita-dark.css
@@ -1,12 +1,12 @@
-@import url("resource:///org/gnome/builder/plugins/glade-plugin/themes/Adwaita-shared.css");
+@import url("resource:///plugins/glade/themes/Adwaita-shared.css");
/* Draw our grid over the glade background pattern */
gbpgladeview viewport {
- background-color: #1c1f20;
+ background-color: #201f21;
background-size: 8px 8px;
- background-image: repeating-linear-gradient(0deg, #212527, #212527 1px, transparent 1px, transparent 8px),
- repeating-linear-gradient(-90deg, #212527, #212527 1px, transparent 1px, transparent
8px);
+ background-image: repeating-linear-gradient(0deg, #232224, #232224 1px, transparent 1px, transparent 8px),
+ repeating-linear-gradient(-90deg, #232224, #232224 1px, transparent 1px, transparent
8px);
}
.glade-chooser {
- background-color: #1c1f20;
+ background-color: #201f21;
}
diff --git a/src/plugins/glade/themes/Adwaita-shared.css b/src/plugins/glade/themes/Adwaita-shared.css
index 0b07468ee..2b73fb3bb 100644
--- a/src/plugins/glade/themes/Adwaita-shared.css
+++ b/src/plugins/glade/themes/Adwaita-shared.css
@@ -1,4 +1,4 @@
-@import url("resource:///org/gnome/builder/plugins/glade-plugin/themes/shared.css");
+@import url("resource:///plugins/glade/themes/shared.css");
gbpgladeproperties {
font-size: 0.83333em;
@@ -27,8 +27,8 @@ gbpgladeproperties spinbutton entry {
}
gbpgladeproperties switch slider {
- min-height: 18px;
- min-width: 32px;
+ min-height: 16px;
+ min-width: 18px;
}
gbpgladeproperties button.combo {
diff --git a/src/plugins/glade/themes/Adwaita.css b/src/plugins/glade/themes/Adwaita.css
index c34e9a5df..eed31ba86 100644
--- a/src/plugins/glade/themes/Adwaita.css
+++ b/src/plugins/glade/themes/Adwaita.css
@@ -1,4 +1,4 @@
-@import url("resource:///org/gnome/builder/plugins/glade-plugin/themes/Adwaita-shared.css");
+@import url("resource:///plugins/glade/themes/Adwaita-shared.css");
/* Draw our grid over the glade background pattern */
gbpgladeview viewport {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]