[gnome-builder/wip/chergert/perspective] project-tree: port new project-tree plugin to IdeWorkbench
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/perspective] project-tree: port new project-tree plugin to IdeWorkbench
- Date: Thu, 19 Nov 2015 00:49:56 +0000 (UTC)
commit 6cb26f20e7034ad911b9c92e543fc1c32f75ab53
Author: Christian Hergert <christian hergert me>
Date: Wed Nov 18 16:49:10 2015 -0800
project-tree: port new project-tree plugin to IdeWorkbench
libide/Makefile.am | 2 +
libide/ide.h | 2 +
libide/util/ide-file-manager.c | 191 ++++++++++++++++
libide/util/ide-file-manager.h | 31 +++
plugins/project-tree/Makefile.am | 25 ++-
plugins/project-tree/gb-new-file-popover.c | 2 +-
.../project-tree}/gb-new-file-popover.ui | 0
plugins/project-tree/gb-project-tree-actions.c | 235 ++++++++++----------
plugins/project-tree/gb-project-tree-addin.c | 61 +++++-
plugins/project-tree/gb-project-tree-builder.c | 101 ++++-----
plugins/project-tree/gb-project-tree-builder.h | 7 +-
plugins/project-tree/gb-project-tree-private.h | 4 +-
plugins/project-tree/gb-project-tree.c | 28 ++-
plugins/project-tree/gb-project-tree.gresource.xml | 6 +
plugins/project-tree/gb-project-tree.h | 4 +-
15 files changed, 485 insertions(+), 214 deletions(-)
---
diff --git a/libide/Makefile.am b/libide/Makefile.am
index a25f297..ff3bc62 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -230,6 +230,8 @@ libide_1_0_la_public_sources = \
ide.h \
local/ide-local-device.c \
local/ide-local-device.h \
+ util/ide-file-manager.c \
+ util/ide-file-manager.h \
$(NULL)
libide_1_0_la_SOURCES = \
diff --git a/libide/ide.h b/libide/ide.h
index 19444e8..f27f34f 100644
--- a/libide/ide.h
+++ b/libide/ide.h
@@ -121,6 +121,8 @@ G_BEGIN_DECLS
#include "git/ide-git-remote-callbacks.h"
#include "git/ide-git-vcs.h"
#include "local/ide-local-device.h"
+#include "util/ide-file-manager.h"
+#include "util/ide-gtk.h"
#include "util/ide-line-reader.h"
#include "util/ide-list-inline.h"
diff --git a/libide/util/ide-file-manager.c b/libide/util/ide-file-manager.c
new file mode 100644
index 0000000..f782857
--- /dev/null
+++ b/libide/util/ide-file-manager.c
@@ -0,0 +1,191 @@
+/* ide-file-manager.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ide-file-manager.h"
+
+#include <glib/gi18n.h>
+
+#if defined(G_OS_WIN32)
+/* This is a hack for Windows known directory support.
+ * DATADIR (autotools-generated constant) is a type defined in objidl.h
+ * so we must #undef it before including shlobj.h in order to avoid a
+ * name clash. */
+#undef DATADIR
+#include <windows.h>
+#include <shlobj.h>
+#endif
+
+#ifdef PLATFORM_OSX
+#include <AppKit/AppKit.h>
+#endif
+
+/* Copied from the GIMP */
+gboolean
+ide_file_manager_show (GFile *file,
+ GError **error)
+{
+ g_return_val_if_fail (G_IS_FILE (file), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+#if defined(G_OS_WIN32)
+
+ {
+ gboolean ret;
+ char *filename;
+ int n;
+ LPWSTR w_filename = NULL;
+ ITEMIDLIST *pidl = NULL;
+
+ ret = FALSE;
+
+ /* Calling this function mutiple times should do no harm, but it is
+ easier to put this here as it needs linking against ole32. */
+ CoInitialize (NULL);
+
+ filename = g_file_get_path (file);
+ if (!filename)
+ {
+ g_set_error_literal (error, G_FILE_ERROR, 0,
+ _("File path is NULL"));
+ goto out;
+ }
+
+ n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ filename, -1, NULL, 0);
+ if (n == 0)
+ {
+ g_set_error_literal (error, G_FILE_ERROR, 0,
+ _("Error converting UTF-8 filename to wide char"));
+ goto out;
+ }
+
+ w_filename = g_malloc_n (n + 1, sizeof (wchar_t));
+ n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ filename, -1,
+ w_filename, (n + 1) * sizeof (wchar_t));
+ if (n == 0)
+ {
+ g_set_error_literal (error, G_FILE_ERROR, 0,
+ _("Error converting UTF-8 filename to wide char"));
+ goto out;
+ }
+
+ pidl = ILCreateFromPathW (w_filename);
+ if (!pidl)
+ {
+ g_set_error_literal (error, G_FILE_ERROR, 0,
+ _("ILCreateFromPath() failed"));
+ goto out;
+ }
+
+ SHOpenFolderAndSelectItems (pidl, 0, NULL, 0);
+ ret = TRUE;
+
+ out:
+ if (pidl)
+ ILFree (pidl);
+ g_free (w_filename);
+ g_free (filename);
+
+ return ret;
+ }
+
+#elif defined(PLATFORM_OSX)
+
+ {
+ gchar *uri;
+ NSString *filename;
+ NSURL *url;
+ gboolean retval = TRUE;
+
+ uri = g_file_get_uri (file);
+ filename = [NSString stringWithUTF8String:uri];
+
+ url = [NSURL URLWithString:filename];
+ if (url)
+ {
+ NSArray *url_array = [NSArray arrayWithObject:url];
+
+ [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:url_array];
+ }
+ else
+ {
+ g_set_error (error, G_FILE_ERROR, 0,
+ _("Cannot convert '%s' into a valid NSURL."), uri);
+ retval = FALSE;
+ }
+
+ g_free (uri);
+
+ return retval;
+ }
+
+#else /* UNIX */
+
+ {
+ GDBusProxy *proxy;
+ GVariant *retval;
+ GVariantBuilder *builder;
+ gchar *uri;
+
+ proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ "org.freedesktop.FileManager1",
+ "/org/freedesktop/FileManager1",
+ "org.freedesktop.FileManager1",
+ NULL, error);
+
+ if (!proxy)
+ {
+ g_prefix_error (error,
+ _("Connecting to org.freedesktop.FileManager1 failed: "));
+ return FALSE;
+ }
+
+ uri = g_file_get_uri (file);
+
+ builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
+ g_variant_builder_add (builder, "s", uri);
+
+ g_free (uri);
+
+ retval = g_dbus_proxy_call_sync (proxy,
+ "ShowItems",
+ g_variant_new ("(ass)",
+ builder,
+ ""),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, error);
+
+ g_variant_builder_unref (builder);
+ g_object_unref (proxy);
+
+ if (!retval)
+ {
+ g_prefix_error (error, _("Calling ShowItems failed: "));
+ return FALSE;
+ }
+
+ g_variant_unref (retval);
+
+ return TRUE;
+ }
+
+#endif
+}
diff --git a/libide/util/ide-file-manager.h b/libide/util/ide-file-manager.h
new file mode 100644
index 0000000..287a076
--- /dev/null
+++ b/libide/util/ide-file-manager.h
@@ -0,0 +1,31 @@
+/* ide-file-manager.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDE_FILE_MANAGER_H
+#define IDE_FILE_MANAGER_H
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+gboolean ide_file_manager_show (GFile *file,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* IDE_FILE_MANAGER_H */
diff --git a/plugins/project-tree/Makefile.am b/plugins/project-tree/Makefile.am
index f1ec14f..f407e49 100644
--- a/plugins/project-tree/Makefile.am
+++ b/plugins/project-tree/Makefile.am
@@ -28,31 +28,38 @@ libproject_tree_plugin_la_SOURCES = \
project-tree-plugin.c \
$(NULL)
+nodist_libproject_tree_plugin_la_SOURCES = \
+ gb-project-tree-resources.c \
+ gb-project-tree-resources.h
+
libproject_tree_plugin_la_CFLAGS = \
$(LIBIDE_CFLAGS) \
$(OPTIMIZE_CFLAGS) \
$(DEBUG_CFLAGS) \
- $(TERMINAL_CFLAGS) \
-I$(top_srcdir)/libide \
- -I$(top_srcdir)/src/tree \
- -I$(top_srcdir)/src/util \
$(NULL)
+libproject_tree_plugin_la_LIBADD =
+
if ENABLE_TERMINAL_PLUGIN
-libproject_tree_plugin_la_CFLAGS += -DHAVE_VTE
+libproject_tree_plugin_la_LIBADD += $(TERMINAL_LIBS)
+libproject_tree_plugin_la_CFLAGS += \
+ $(TERMINAL_CFLAGS) \
+ -DHAVE_VTE
endif
-libproject_tree_plugin_la_LIBADD = \
- $(LIBIDE_LIBS) \
- $(top_builddir)/libide/libide-1.0.la \
- $(NULL)
-
libproject_tree_plugin_la_LDFLAGS = \
$(OPTIMIZE_LDFLAGS) \
-avoid-version \
-module \
$(NULL)
+glib_resources_c = gb-project-tree-resources.c
+glib_resources_h = gb-project-tree-resources.h
+glib_resources_xml = gb-project-tree.gresource.xml
+glib_resources_namespace = gb_project_tree
+include $(top_srcdir)/build/autotools/Makefile.am.gresources
+
include $(top_srcdir)/plugins/Makefile.plugin
endif
diff --git a/plugins/project-tree/gb-new-file-popover.c b/plugins/project-tree/gb-new-file-popover.c
index 25ece48..423a731 100644
--- a/plugins/project-tree/gb-new-file-popover.c
+++ b/plugins/project-tree/gb-new-file-popover.c
@@ -291,7 +291,7 @@ gb_new_file_popover_class_init (GbNewFilePopoverClass *klass)
G_TYPE_FILE,
G_TYPE_FILE_TYPE);
- gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/builder/ui/gb-new-file-popover.ui");
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/plugins/project-tree/gb-new-file-popover.ui");
gtk_widget_class_bind_template_child (widget_class, GbNewFilePopover, button);
gtk_widget_class_bind_template_child (widget_class, GbNewFilePopover, entry);
gtk_widget_class_bind_template_child (widget_class, GbNewFilePopover, message);
diff --git a/data/ui/gb-new-file-popover.ui b/plugins/project-tree/gb-new-file-popover.ui
similarity index 100%
rename from data/ui/gb-new-file-popover.ui
rename to plugins/project-tree/gb-new-file-popover.ui
diff --git a/plugins/project-tree/gb-project-tree-actions.c b/plugins/project-tree/gb-project-tree-actions.c
index aa62505..c1bd333 100644
--- a/plugins/project-tree/gb-project-tree-actions.c
+++ b/plugins/project-tree/gb-project-tree-actions.c
@@ -26,7 +26,6 @@
# include <vte/vte.h>
#endif
-#include "gb-file-manager.h"
#include "gb-new-file-popover.h"
#include "gb-project-file.h"
#include "gb-project-tree.h"
@@ -34,11 +33,6 @@
#include "gb-project-tree-private.h"
#include "gb-rename-file-popover.h"
-#if 0
-#include "gb-view-stack.h"
-#endif
-
-#if 0
static void
action_set (GActionGroup *group,
const gchar *action_name,
@@ -74,28 +68,28 @@ gb_project_tree_actions_refresh (GSimpleAction *action,
gpointer user_data)
{
GbProjectTree *self = user_data;
- GbTreeNode *selected;
+ IdeTreeNode *selected;
GObject *item = NULL;
g_assert (GB_IS_PROJECT_TREE (self));
- if ((selected = gb_tree_get_selected (GB_TREE (self))))
+ if ((selected = ide_tree_get_selected (IDE_TREE (self))))
{
- item = gb_tree_node_get_item (selected);
+ item = ide_tree_node_get_item (selected);
if (item != NULL)
g_object_ref (item);
}
- gb_tree_rebuild (GB_TREE (self));
+ ide_tree_rebuild (IDE_TREE (self));
if (item != NULL)
{
- selected = gb_tree_find_item (GB_TREE (self), item);
+ selected = ide_tree_find_item (IDE_TREE (self), item);
if (selected != NULL)
{
- gb_tree_node_expand (selected, TRUE);
- gb_tree_node_select (selected);
- gb_tree_scroll_to_node (GB_TREE (self), selected);
+ ide_tree_node_expand (selected, TRUE);
+ ide_tree_node_select (selected);
+ ide_tree_scroll_to_node (IDE_TREE (self), selected);
}
g_object_unref (item);
}
@@ -118,22 +112,21 @@ gb_project_tree_actions_open (GSimpleAction *action,
GVariant *variant,
gpointer user_data)
{
-#if 0
GbProjectTree *self = user_data;
IdeWorkbench *workbench;
- GbTreeNode *selected;
+ IdeTreeNode *selected;
GObject *item;
g_assert (GB_IS_PROJECT_TREE (self));
- workbench = gb_widget_get_workbench (GTK_WIDGET (self));
- g_assert (GB_IS_WORKBENCH (workbench));
+ workbench = ide_widget_get_workbench (GTK_WIDGET (self));
+ g_assert (IDE_IS_WORKBENCH (workbench));
- if (!(selected = gb_tree_get_selected (GB_TREE (self))) ||
- !(item = gb_tree_node_get_item (selected)))
+ if (!(selected = ide_tree_get_selected (IDE_TREE (self))) ||
+ !(item = ide_tree_node_get_item (selected)))
return;
- item = gb_tree_node_get_item (selected);
+ item = ide_tree_node_get_item (selected);
if (GB_IS_PROJECT_FILE (item))
{
@@ -151,9 +144,8 @@ gb_project_tree_actions_open (GSimpleAction *action,
if (!file)
return;
- ide_workbench_open (workbench, file);
+ ide_workbench_open_files_async (workbench, &file, 1, NULL, NULL, NULL);
}
-#endif
}
static void
@@ -161,11 +153,10 @@ gb_project_tree_actions_open_with (GSimpleAction *action,
GVariant *variant,
gpointer user_data)
{
-#if 0
g_autoptr(GDesktopAppInfo) app_info = NULL;
g_autoptr(GdkAppLaunchContext) launch_context = NULL;
GbProjectTree *self = user_data;
- GbTreeNode *selected;
+ IdeTreeNode *selected;
IdeWorkbench *workbench;
GdkDisplay *display;
GFileInfo *file_info;
@@ -177,9 +168,9 @@ gb_project_tree_actions_open_with (GSimpleAction *action,
g_assert (GB_IS_PROJECT_TREE (self));
g_assert (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING));
- if (!(workbench = gb_widget_get_workbench (GTK_WIDGET (self))) ||
- !(selected = gb_tree_get_selected (GB_TREE (self))) ||
- !(item = gb_tree_node_get_item (selected)) ||
+ if (!(workbench = ide_widget_get_workbench (GTK_WIDGET (self))) ||
+ !(selected = ide_tree_get_selected (IDE_TREE (self))) ||
+ !(item = ide_tree_node_get_item (selected)) ||
!GB_IS_PROJECT_FILE (item) ||
!(app_id = g_variant_get_string (variant, NULL)) ||
!(file_info = gb_project_file_get_file_info (GB_PROJECT_FILE (item))) ||
@@ -193,7 +184,6 @@ gb_project_tree_actions_open_with (GSimpleAction *action,
files = g_list_append (NULL, file);
g_app_info_launch (G_APP_INFO (app_info), files, G_APP_LAUNCH_CONTEXT (launch_context), NULL);
g_list_free (files);
-#endif
}
static void
@@ -206,18 +196,18 @@ gb_project_tree_actions_open_with_editor (GSimpleAction *action,
GbProjectTree *self = user_data;
GFileInfo *file_info;
GFile *file;
- GbTreeNode *selected;
+ IdeTreeNode *selected;
GObject *item;
g_assert (GB_IS_PROJECT_TREE (self));
- if (!(selected = gb_tree_get_selected (GB_TREE (self))) ||
- !(item = gb_tree_node_get_item (selected)) ||
+ if (!(selected = ide_tree_get_selected (IDE_TREE (self))) ||
+ !(item = ide_tree_node_get_item (selected)) ||
!GB_IS_PROJECT_FILE (item) ||
!(file_info = gb_project_file_get_file_info (GB_PROJECT_FILE (item))) ||
(g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY) ||
!(file = gb_project_file_get_file (GB_PROJECT_FILE (item))) ||
- !(workbench = gb_widget_get_workbench (GTK_WIDGET (self))))
+ !(workbench = ide_widget_get_workbench (GTK_WIDGET (self))))
return;
ide_workbench_open_with_editor (workbench, file);
@@ -230,20 +220,20 @@ gb_project_tree_actions_open_containing_folder (GSimpleAction *action,
gpointer user_data)
{
GbProjectTree *self = user_data;
- GbTreeNode *selected;
+ IdeTreeNode *selected;
GObject *item;
GFile *file;
g_assert (GB_IS_PROJECT_TREE (self));
- if (!(selected = gb_tree_get_selected (GB_TREE (self))) ||
- !(item = gb_tree_node_get_item (selected)) ||
+ if (!(selected = ide_tree_get_selected (IDE_TREE (self))) ||
+ !(item = ide_tree_node_get_item (selected)) ||
!GB_IS_PROJECT_FILE (item))
return;
file = gb_project_file_get_file (GB_PROJECT_FILE (item));
- gb_file_manager_show (file, NULL);
+ ide_file_manager_show (file, NULL);
}
/* Based on gdesktopappinfo.c in GIO */
@@ -290,7 +280,7 @@ gb_project_tree_actions_open_in_terminal (GSimpleAction *action,
gpointer user_data)
{
GbProjectTree *self = user_data;
- GbTreeNode *selected;
+ IdeTreeNode *selected;
GObject *item;
GFile *file;
g_autofree gchar *workdir = NULL;
@@ -301,8 +291,8 @@ gb_project_tree_actions_open_in_terminal (GSimpleAction *action,
g_assert (GB_IS_PROJECT_TREE (self));
- if (!(selected = gb_tree_get_selected (GB_TREE (self))) ||
- !(item = gb_tree_node_get_item (selected)) ||
+ if (!(selected = ide_tree_get_selected (IDE_TREE (self))) ||
+ !(item = ide_tree_node_get_item (selected)) ||
!GB_IS_PROJECT_FILE (item))
return;
@@ -365,11 +355,11 @@ gb_project_tree_actions__make_directory_cb (GObject *object,
gpointer user_data)
{
GFile *file = (GFile *)object;
- g_autoptr(GbTreeNode) node = user_data;
+ g_autoptr(IdeTreeNode) node = user_data;
g_autoptr(GError) error = NULL;
g_assert (G_IS_FILE (file));
- g_assert (GB_IS_TREE_NODE (node));
+ g_assert (IDE_IS_TREE_NODE (node));
if (!g_file_make_directory_finish (file, result, &error))
{
@@ -377,9 +367,9 @@ gb_project_tree_actions__make_directory_cb (GObject *object,
return;
}
- gb_tree_node_invalidate (node);
- gb_tree_node_expand (node, FALSE);
- gb_tree_node_select (node);
+ ide_tree_node_invalidate (node);
+ ide_tree_node_expand (node, FALSE);
+ ide_tree_node_select (node);
}
static void
@@ -388,13 +378,13 @@ gb_project_tree_actions__create_cb (GObject *object,
gpointer user_data)
{
GFile *file = (GFile *)object;
- g_autoptr(GbTreeNode) node = user_data;
+ g_autoptr(IdeTreeNode) node = user_data;
g_autoptr(GError) error = NULL;
GbProjectTree *self;
IdeWorkbench *workbench;
g_assert (G_IS_FILE (file));
- g_assert (GB_IS_TREE_NODE (node));
+ g_assert (IDE_IS_TREE_NODE (node));
if (!g_file_create_finish (file, result, &error))
{
@@ -402,19 +392,19 @@ gb_project_tree_actions__create_cb (GObject *object,
return;
}
- self = GB_PROJECT_TREE (gb_tree_node_get_tree (node));
+ self = GB_PROJECT_TREE (ide_tree_node_get_tree (node));
if (self == NULL)
return;
- workbench = gb_widget_get_workbench (GTK_WIDGET (self));
+ workbench = ide_widget_get_workbench (GTK_WIDGET (self));
if (workbench == NULL)
return;
- ide_workbench_open (workbench, file);
+ ide_workbench_open_files_async (workbench, &file, 1, NULL, NULL, NULL);
- gb_tree_node_invalidate (node);
- gb_tree_node_expand (node, FALSE);
- gb_tree_node_select (node);
+ ide_tree_node_invalidate (node);
+ ide_tree_node_expand (node, FALSE);
+ ide_tree_node_select (node);
}
static void
@@ -423,7 +413,7 @@ gb_project_tree_actions__popover_create_file_cb (GbProjectTree *self,
GFileType file_type,
GbNewFilePopover *popover)
{
- GbTreeNode *selected;
+ IdeTreeNode *selected;
g_assert (GB_IS_PROJECT_TREE (self));
g_assert (G_IS_FILE (file));
@@ -431,10 +421,10 @@ gb_project_tree_actions__popover_create_file_cb (GbProjectTree *self,
(file_type == G_FILE_TYPE_REGULAR));
g_assert (GB_IS_NEW_FILE_POPOVER (popover));
- selected = gb_tree_get_selected (GB_TREE (self));
+ selected = ide_tree_get_selected (IDE_TREE (self));
g_assert (selected != NULL);
- g_assert (GB_IS_TREE_NODE (selected));
+ g_assert (IDE_IS_TREE_NODE (selected));
if (file_type == G_FILE_TYPE_DIRECTORY)
{
@@ -468,22 +458,22 @@ static void
gb_project_tree_actions__popover_closed_cb (GbProjectTree *self,
GtkPopover *popover)
{
- GbTreeNode *selected;
+ IdeTreeNode *selected;
g_assert (GB_IS_PROJECT_TREE (self));
g_assert (GTK_IS_POPOVER (popover));
- if (!(selected = gb_tree_get_selected (GB_TREE (self))) || !self->expanded_in_new)
+ if (!(selected = ide_tree_get_selected (IDE_TREE (self))) || !self->expanded_in_new)
return;
- gb_tree_node_collapse (selected);
+ ide_tree_node_collapse (selected);
}
static void
gb_project_tree_actions_new (GbProjectTree *self,
GFileType file_type)
{
- GbTreeNode *selected;
+ IdeTreeNode *selected;
GObject *item;
GtkPopover *popover;
GbProjectFile *project_file;
@@ -495,8 +485,8 @@ gb_project_tree_actions_new (GbProjectTree *self,
(file_type == G_FILE_TYPE_REGULAR));
again:
- if (!(selected = gb_tree_get_selected (GB_TREE (self))) ||
- !(item = gb_tree_node_get_item (selected)) ||
+ if (!(selected = ide_tree_get_selected (IDE_TREE (self))) ||
+ !(item = ide_tree_node_get_item (selected)) ||
!GB_IS_PROJECT_FILE (item))
return;
@@ -516,17 +506,17 @@ again:
{
GtkTreePath *path;
- selected = gb_tree_node_get_parent (selected);
- gb_tree_node_select (selected);
- path = gb_tree_node_get_path (selected);
+ selected = ide_tree_node_get_parent (selected);
+ ide_tree_node_select (selected);
+ path = ide_tree_node_get_path (selected);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (self), path, NULL, FALSE, 0, 0);
gtk_tree_path_free (path);
goto again;
}
- if ((self->expanded_in_new = !gb_tree_node_get_expanded (selected)))
- gb_tree_node_expand (selected, FALSE);
+ if ((self->expanded_in_new = !ide_tree_node_get_expanded (selected)))
+ ide_tree_node_expand (selected, FALSE);
popover = g_object_new (GB_TYPE_NEW_FILE_POPOVER,
"directory", file,
@@ -544,7 +534,7 @@ again:
self,
G_CONNECT_SWAPPED);
- gb_tree_node_show_popover (selected, popover);
+ ide_tree_node_show_popover (selected, popover);
}
static void
@@ -572,12 +562,12 @@ gb_project_tree_actions_new_file (GSimpleAction *action,
}
static gboolean
-find_child_node (GbTree *tree,
- GbTreeNode *parent,
- GbTreeNode *child,
+find_child_node (IdeTree *tree,
+ IdeTreeNode *parent,
+ IdeTreeNode *child,
gpointer user_data)
{
- GObject *item = gb_tree_node_get_item (child);
+ GObject *item = ide_tree_node_get_item (child);
GFile *target = user_data;
GFile *child_file;
@@ -597,10 +587,10 @@ gb_project_tree_actions__project_rename_file_cb (GObject *object,
IdeProject *project = (IdeProject *)object;
g_autoptr(GbRenameFilePopover) popover = user_data;
g_autoptr(GError) error = NULL;
- GbTreeNode *node;
- GbTreeNode *parent;
+ IdeTreeNode *node;
+ IdeTreeNode *parent;
GFile *file;
- GbTree *tree;
+ IdeTree *tree;
g_assert (IDE_IS_PROJECT (project));
g_assert (GB_IS_RENAME_FILE_POPOVER (popover));
@@ -613,26 +603,26 @@ gb_project_tree_actions__project_rename_file_cb (GObject *object,
}
file = g_object_get_data (G_OBJECT (popover), "G_FILE");
- tree = GB_TREE (gtk_popover_get_relative_to (GTK_POPOVER (popover)));
+ tree = IDE_TREE (gtk_popover_get_relative_to (GTK_POPOVER (popover)));
g_assert (G_IS_FILE (file));
- g_assert (GB_IS_TREE (tree));
+ g_assert (IDE_IS_TREE (tree));
- node = gb_tree_get_selected (tree);
+ node = ide_tree_get_selected (tree);
if (node == NULL)
goto cleanup;
- parent = gb_tree_node_get_parent (node);
+ parent = ide_tree_node_get_parent (node);
- gb_tree_node_invalidate (parent);
- gb_tree_node_expand (parent, FALSE);
+ ide_tree_node_invalidate (parent);
+ ide_tree_node_expand (parent, FALSE);
- node = gb_tree_find_child_node (tree, parent, find_child_node, file);
+ node = ide_tree_find_child_node (tree, parent, find_child_node, file);
if (node != NULL)
- gb_tree_node_select (node);
+ ide_tree_node_select (node);
else
- gb_tree_node_select (parent);
+ ide_tree_node_select (parent);
cleanup:
gtk_widget_hide (GTK_WIDGET (popover));
@@ -654,7 +644,7 @@ gb_project_tree_actions__rename_file_cb (GbProjectTree *self,
g_assert (G_IS_FILE (new_file));
g_assert (GTK_IS_POPOVER (popover));
- workbench = gb_widget_get_workbench (GTK_WIDGET (self));
+ workbench = ide_widget_get_workbench (GTK_WIDGET (self));
context = ide_workbench_get_context (workbench);
project = ide_context_get_project (context);
@@ -676,7 +666,7 @@ gb_project_tree_actions_rename_file (GSimpleAction *action,
gpointer user_data)
{
GbProjectTree *self = user_data;
- GbTreeNode *selected;
+ IdeTreeNode *selected;
GtkPopover *popover;
GObject *item;
GFile *file;
@@ -685,8 +675,8 @@ gb_project_tree_actions_rename_file (GSimpleAction *action,
g_assert (GB_IS_PROJECT_TREE (self));
- if (!(selected = gb_tree_get_selected (GB_TREE (self))) ||
- !(item = gb_tree_node_get_item (selected)) ||
+ if (!(selected = ide_tree_get_selected (IDE_TREE (self))) ||
+ !(item = ide_tree_node_get_item (selected)) ||
!GB_IS_PROJECT_FILE (item) ||
!(file = gb_project_file_get_file (GB_PROJECT_FILE (item))) ||
!(file_info = gb_project_file_get_file_info (GB_PROJECT_FILE (item))))
@@ -704,7 +694,7 @@ gb_project_tree_actions_rename_file (GSimpleAction *action,
G_CALLBACK (gb_project_tree_actions__rename_file_cb),
self,
G_CONNECT_SWAPPED);
- gb_tree_node_show_popover (selected, popover);
+ ide_tree_node_show_popover (selected, popover);
}
static void
@@ -713,12 +703,12 @@ gb_project_tree_actions__trash_file_cb (GObject *object,
gpointer user_data)
{
IdeProject *project = (IdeProject *)object;
- g_autoptr(GbTreeNode) node = user_data;
+ g_autoptr(IdeTreeNode) node = user_data;
g_autoptr(GError) error = NULL;
- GbTreeNode *parent;
+ IdeTreeNode *parent;
g_assert (IDE_IS_PROJECT (project));
- g_assert (GB_IS_TREE_NODE (node));
+ g_assert (IDE_IS_TREE_NODE (node));
if (!ide_project_trash_file_finish (project, result, &error))
{
@@ -727,36 +717,40 @@ gb_project_tree_actions__trash_file_cb (GObject *object,
return;
}
- if ((parent = gb_tree_node_get_parent (node)))
+ if ((parent = ide_tree_node_get_parent (node)))
{
- gb_tree_node_invalidate (parent);
- gb_tree_node_expand (parent, FALSE);
- gb_tree_node_select (parent);
+ ide_tree_node_invalidate (parent);
+ ide_tree_node_expand (parent, FALSE);
+ ide_tree_node_select (parent);
}
}
typedef struct
{
- GbDocument *document;
- GList *views;
+ IdeBuffer *document;
+ GList *views;
} ViewsRemoval;
static void
gb_project_tree_actions_close_views_cb (GtkWidget *widget,
gpointer user_data)
{
- GbDocument *document;
ViewsRemoval *removal = user_data;
- IdeView *view = (IdeView *)widget;
+ IdeLayoutView *view = (IdeLayoutView *)widget;
- g_assert (GB_IS_VIEW (view));
+ g_assert (IDE_IS_LAYOUT_VIEW (view));
g_assert (removal != NULL);
- g_assert (GB_IS_DOCUMENT (removal->document));
+ g_assert (IDE_IS_BUFFER (removal->document));
- document = gb_view_get_document (view);
+ if (IDE_IS_EDITOR_VIEW (view))
+ {
+ IdeBuffer *buffer;
+
+ buffer = ide_editor_view_get_document (IDE_EDITOR_VIEW (view));
- if (document == removal->document)
- removal->views = g_list_prepend (removal->views, g_object_ref (view));
+ if (buffer == removal->document)
+ removal->views = g_list_prepend (removal->views, g_object_ref (view));
+ }
}
static void
@@ -771,7 +765,7 @@ gb_project_tree_actions_move_to_trash (GSimpleAction *action,
ViewsRemoval removal = { 0 };
IdeBuffer *buffer;
IdeProject *project;
- GbTreeNode *node;
+ IdeTreeNode *node;
GFile *file;
GObject *item;
GList *iter;
@@ -779,13 +773,13 @@ gb_project_tree_actions_move_to_trash (GSimpleAction *action,
g_assert (G_IS_SIMPLE_ACTION (action));
g_assert (GB_IS_PROJECT_TREE (self));
- workbench = gb_widget_get_workbench (GTK_WIDGET (self));
+ workbench = ide_widget_get_workbench (GTK_WIDGET (self));
context = ide_workbench_get_context (workbench);
project = ide_context_get_project (context);
buffer_manager = ide_context_get_buffer_manager (context);
- if (!(node = gb_tree_get_selected (GB_TREE (self))) ||
- !(item = gb_tree_node_get_item (node)) ||
+ if (!(node = ide_tree_get_selected (IDE_TREE (self))) ||
+ !(item = ide_tree_node_get_item (node)) ||
!GB_IS_PROJECT_FILE (item) ||
!(file = gb_project_file_get_file (GB_PROJECT_FILE (item))))
return;
@@ -810,9 +804,9 @@ gb_project_tree_actions_move_to_trash (GSimpleAction *action,
{
GtkWidget *stack;
- stack = gtk_widget_get_ancestor (iter->data, GB_TYPE_VIEW_STACK);
+ stack = gtk_widget_get_ancestor (iter->data, IDE_TYPE_LAYOUT_STACK);
if (stack != NULL)
- gb_view_stack_remove (GB_VIEW_STACK (stack), iter->data);
+ ide_layout_stack_remove (IDE_LAYOUT_STACK (stack), iter->data);
}
g_list_free_full (removal.views, g_object_unref);
@@ -828,13 +822,13 @@ gb_project_tree_actions_move_to_trash (GSimpleAction *action,
}
static gboolean
-is_files_node (GbTreeNode *node)
+is_files_node (IdeTreeNode *node)
{
if (node != NULL)
{
- GObject *item = gb_tree_node_get_item (node);
- GbTreeNode *parent = gb_tree_node_get_parent (node);
- GObject *parent_item = gb_tree_node_get_item (parent);
+ GObject *item = ide_tree_node_get_item (node);
+ IdeTreeNode *parent = ide_tree_node_get_parent (node);
+ GObject *parent_item = ide_tree_node_get_item (parent);
return (GB_IS_PROJECT_FILE (item) && !GB_IS_PROJECT_FILE (parent_item));
}
@@ -855,12 +849,10 @@ static GActionEntry GbProjectTreeActions[] = {
{ "refresh", gb_project_tree_actions_refresh },
{ "rename-file", gb_project_tree_actions_rename_file },
};
-#endif
void
gb_project_tree_actions_init (GbProjectTree *self)
{
-#if 0
g_autoptr(GSettings) settings = NULL;
g_autoptr(GSettings) tree_settings = NULL;
g_autoptr(GSimpleActionGroup) actions = NULL;
@@ -892,15 +884,13 @@ gb_project_tree_actions_init (GbProjectTree *self)
g_clear_object (&action);
gb_project_tree_actions_update (self);
-#endif
}
void
gb_project_tree_actions_update (GbProjectTree *self)
{
-#if 0
GActionGroup *group;
- GbTreeNode *selection;
+ IdeTreeNode *selection;
GObject *item = NULL;
IDE_ENTRY;
@@ -910,9 +900,9 @@ gb_project_tree_actions_update (GbProjectTree *self)
group = gtk_widget_get_action_group (GTK_WIDGET (self), "project-tree");
g_assert (G_IS_SIMPLE_ACTION_GROUP (group));
- selection = gb_tree_get_selected (GB_TREE (self));
+ selection = ide_tree_get_selected (IDE_TREE (self));
if (selection != NULL)
- item = gb_tree_node_get_item (selection);
+ item = ide_tree_node_get_item (selection);
action_set (group, "new-file",
"enabled", GB_IS_PROJECT_FILE (item),
@@ -940,5 +930,4 @@ gb_project_tree_actions_update (GbProjectTree *self)
NULL);
IDE_EXIT;
-#endif
}
diff --git a/plugins/project-tree/gb-project-tree-addin.c b/plugins/project-tree/gb-project-tree-addin.c
index c4d5c1d..236791a 100644
--- a/plugins/project-tree/gb-project-tree-addin.c
+++ b/plugins/project-tree/gb-project-tree-addin.c
@@ -21,46 +21,93 @@
#include "gb-project-tree.h"
#include "gb-project-tree-addin.h"
+#include "gb-project-tree-resources.h"
static void workbench_addin_iface_init (IdeWorkbenchAddinInterface *iface);
struct _GbProjectTreeAddin
{
- GObject parent_instance;
+ GObject jparent_instance;
+ IdeTree *tree;
};
G_DEFINE_TYPE_EXTENDED (GbProjectTreeAddin, gb_project_tree_addin, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (IDE_TYPE_WORKBENCH_ADDIN, workbench_addin_iface_init))
static void
+gb_project_tree_addin_context_set (GtkWidget *widget,
+ IdeContext *context)
+{
+ GbProjectTree *project_tree = (GbProjectTree *)widget;
+
+ g_assert (GB_IS_PROJECT_TREE (project_tree));
+ g_assert (!context || IDE_IS_CONTEXT (context));
+
+ gb_project_tree_set_context (project_tree, context);
+}
+
+static void
gb_project_tree_addin_load (IdeWorkbenchAddin *addin,
IdeWorkbench *workbench)
{
+ GbProjectTreeAddin *self = (GbProjectTreeAddin *)addin;
+ IdePerspective *editor;
+ GtkWidget *pane;
+ GtkWidget *scroller;
+
+ g_assert (IDE_IS_WORKBENCH_ADDIN (self));
+ g_assert (IDE_IS_WORKBENCH (workbench));
+
+ editor = ide_workbench_get_perspective_by_name (workbench, "editor");
+ g_assert (editor != NULL);
+
+ pane = ide_layout_get_left_pane (IDE_LAYOUT (editor));
+ g_assert (pane != NULL);
+
+ scroller = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
+ "visible", TRUE,
+ NULL);
+ self->tree = g_object_new (GB_TYPE_PROJECT_TREE,
+ "headers-visible", FALSE,
+ "visible", TRUE,
+ NULL);
+ gtk_container_add (GTK_CONTAINER (scroller), GTK_WIDGET (self->tree));
+
+ ide_layout_pane_add_page (IDE_LAYOUT_PANE (pane), scroller,
+ _("Project Tree"), "folder-symbolic");
+
+ ide_widget_set_context_handler (self->tree, gb_project_tree_addin_context_set);
+}
+
+static void
+gb_project_tree_addin_unload (IdeWorkbenchAddin *addin,
+ IdeWorkbench *workbench)
+{
IdePerspective *editor;
GtkWidget *pane;
- GtkWidget *tree;
g_assert (IDE_IS_WORKBENCH_ADDIN (addin));
g_assert (IDE_IS_WORKBENCH (workbench));
editor = ide_workbench_get_perspective_by_name (workbench, "editor");
+ g_assert (editor != NULL);
+
pane = ide_layout_get_left_pane (IDE_LAYOUT (editor));
- tree = g_object_new (GB_TYPE_PROJECT_TREE,
- "headers-visible", FALSE,
- "visible", TRUE,
- NULL);
- ide_layout_pane_add_page (IDE_LAYOUT_PANE (pane), tree, _("Project Tree"), "folder-symbolic");
+ g_assert (pane != NULL);
+
}
static void
workbench_addin_iface_init (IdeWorkbenchAddinInterface *iface)
{
iface->load = gb_project_tree_addin_load;
+ iface->unload = gb_project_tree_addin_unload;
}
static void
gb_project_tree_addin_class_init (GbProjectTreeAddinClass *klass)
{
+ g_resources_register (gb_project_tree_get_resource ());
}
static void
diff --git a/plugins/project-tree/gb-project-tree-builder.c b/plugins/project-tree/gb-project-tree-builder.c
index 4e9304b..fec6a5a 100644
--- a/plugins/project-tree/gb-project-tree-builder.c
+++ b/plugins/project-tree/gb-project-tree-builder.c
@@ -22,20 +22,19 @@
#include "gb-project-file.h"
#include "gb-project-tree.h"
#include "gb-project-tree-builder.h"
-#include "gb-tree.h"
struct _GbProjectTreeBuilder
{
- GbTreeBuilder parent_instance;
+ IdeTreeBuilder parent_instance;
- GSettings *file_chooser_settings;
+ GSettings *file_chooser_settings;
- guint sort_directories_first : 1;
+ guint sort_directories_first : 1;
};
-G_DEFINE_TYPE (GbProjectTreeBuilder, gb_project_tree_builder, GB_TYPE_TREE_BUILDER)
+G_DEFINE_TYPE (GbProjectTreeBuilder, gb_project_tree_builder, IDE_TYPE_TREE_BUILDER)
-GbTreeBuilder *
+IdeTreeBuilder *
gb_project_tree_builder_new (void)
{
return g_object_new (GB_TYPE_PROJECT_TREE_BUILDER, NULL);
@@ -43,20 +42,20 @@ gb_project_tree_builder_new (void)
static void
build_context (GbProjectTreeBuilder *self,
- GbTreeNode *node)
+ IdeTreeNode *node)
{
g_autoptr(GbProjectFile) item = NULL;
g_autoptr(GFileInfo) file_info = NULL;
g_autofree gchar *name = NULL;
- GbTreeNode *child;
+ IdeTreeNode *child;
IdeContext *context;
IdeVcs *vcs;
GFile *workdir;
g_return_if_fail (GB_IS_PROJECT_TREE_BUILDER (self));
- g_return_if_fail (GB_IS_TREE_NODE (node));
+ g_return_if_fail (IDE_IS_TREE_NODE (node));
- context = IDE_CONTEXT (gb_tree_node_get_item (node));
+ context = IDE_CONTEXT (ide_tree_node_get_item (node));
vcs = ide_context_get_vcs (context);
workdir = ide_vcs_get_working_directory (vcs);
@@ -73,37 +72,37 @@ build_context (GbProjectTreeBuilder *self,
"file-info", file_info,
NULL);
- child = g_object_new (GB_TYPE_TREE_NODE,
+ child = g_object_new (IDE_TYPE_TREE_NODE,
"item", item,
"text", _("Files"),
"icon-name", "folder-symbolic",
NULL);
- gb_tree_node_append (node, child);
+ ide_tree_node_append (node, child);
}
static IdeVcs *
-get_vcs (GbTreeNode *node)
+get_vcs (IdeTreeNode *node)
{
- GbTree *tree;
- GbTreeNode *root;
+ IdeTree *tree;
+ IdeTreeNode *root;
IdeContext *context;
- g_assert (GB_IS_TREE_NODE (node));
+ g_assert (IDE_IS_TREE_NODE (node));
- tree = gb_tree_node_get_tree (node);
- root = gb_tree_get_root (tree);
- context = IDE_CONTEXT (gb_tree_node_get_item (root));
+ tree = ide_tree_node_get_tree (node);
+ root = ide_tree_get_root (tree);
+ context = IDE_CONTEXT (ide_tree_node_get_item (root));
return ide_context_get_vcs (context);
}
static gint
-compare_nodes_func (GbTreeNode *a,
- GbTreeNode *b,
- gpointer user_data)
+compare_nodes_func (IdeTreeNode *a,
+ IdeTreeNode *b,
+ gpointer user_data)
{
- GbProjectFile *file_a = GB_PROJECT_FILE (gb_tree_node_get_item (a));
- GbProjectFile *file_b = GB_PROJECT_FILE (gb_tree_node_get_item (b));
+ GbProjectFile *file_a = GB_PROJECT_FILE (ide_tree_node_get_item (a));
+ GbProjectFile *file_b = GB_PROJECT_FILE (ide_tree_node_get_item (b));
GbProjectTreeBuilder *self = user_data;
if (self->sort_directories_first)
@@ -114,22 +113,22 @@ compare_nodes_func (GbTreeNode *a,
static void
build_file (GbProjectTreeBuilder *self,
- GbTreeNode *node)
+ IdeTreeNode *node)
{
g_autoptr(GFileEnumerator) enumerator = NULL;
GbProjectFile *project_file;
gpointer file_info_ptr;
IdeVcs *vcs;
GFile *file;
- GbTree *tree;
+ IdeTree *tree;
gboolean show_ignored_files;
g_return_if_fail (GB_IS_PROJECT_TREE_BUILDER (self));
- g_return_if_fail (GB_IS_TREE_NODE (node));
+ g_return_if_fail (IDE_IS_TREE_NODE (node));
- project_file = GB_PROJECT_FILE (gb_tree_node_get_item (node));
+ project_file = GB_PROJECT_FILE (ide_tree_node_get_item (node));
- tree = gb_tree_builder_get_tree (GB_TREE_BUILDER (self));
+ tree = ide_tree_builder_get_tree (IDE_TREE_BUILDER (self));
show_ignored_files = gb_project_tree_get_show_ignored_files (GB_PROJECT_TREE (tree));
vcs = get_vcs (node);
@@ -159,7 +158,7 @@ build_file (GbProjectTreeBuilder *self,
g_autoptr(GFileInfo) item_file_info = file_info_ptr;
g_autoptr(GFile) item_file = NULL;
g_autoptr(GbProjectFile) item = NULL;
- GbTreeNode *child;
+ IdeTreeNode *child;
const gchar *name;
const gchar *display_name;
const gchar *icon_name;
@@ -177,30 +176,30 @@ build_file (GbProjectTreeBuilder *self,
display_name = gb_project_file_get_display_name (item);
icon_name = gb_project_file_get_icon_name (item);
- child = g_object_new (GB_TYPE_TREE_NODE,
+ child = g_object_new (IDE_TYPE_TREE_NODE,
"icon-name", icon_name,
"text", display_name,
"item", item,
"use-dim-label", ignored,
NULL);
- gb_tree_node_insert_sorted (node, child, compare_nodes_func, self);
+ ide_tree_node_insert_sorted (node, child, compare_nodes_func, self);
if (g_file_info_get_file_type (item_file_info) == G_FILE_TYPE_DIRECTORY)
- gb_tree_node_set_children_possible (child, TRUE);
+ ide_tree_node_set_children_possible (child, TRUE);
}
}
static void
-gb_project_tree_builder_build_node (GbTreeBuilder *builder,
- GbTreeNode *node)
+gb_project_tree_builder_build_node (IdeTreeBuilder *builder,
+ IdeTreeNode *node)
{
GbProjectTreeBuilder *self = (GbProjectTreeBuilder *)builder;
GObject *item;
g_return_if_fail (GB_IS_PROJECT_TREE_BUILDER (self));
- item = gb_tree_node_get_item (node);
+ item = ide_tree_node_get_item (node);
if (IDE_IS_CONTEXT (item))
build_context (self, node);
@@ -265,9 +264,9 @@ populate_mime_handlers (GMenu *menu,
}
static void
-gb_project_tree_builder_node_popup (GbTreeBuilder *builder,
- GbTreeNode *node,
- GMenu *menu)
+gb_project_tree_builder_node_popup (IdeTreeBuilder *builder,
+ IdeTreeNode *node,
+ GMenu *menu)
{
GtkApplication *app;
GObject *item;
@@ -277,11 +276,11 @@ gb_project_tree_builder_node_popup (GbTreeBuilder *builder,
GFile *file;
g_assert (GB_IS_PROJECT_TREE_BUILDER (builder));
- g_assert (GB_IS_TREE_NODE (node));
+ g_assert (IDE_IS_TREE_NODE (node));
g_assert (G_IS_MENU (menu));
app = GTK_APPLICATION (g_application_get_default ());
- item = gb_tree_node_get_item (node);
+ item = ide_tree_node_get_item (node);
if (GB_IS_PROJECT_FILE (item))
{
@@ -328,19 +327,19 @@ gb_project_tree_builder_node_popup (GbTreeBuilder *builder,
}
static gboolean
-gb_project_tree_builder_node_activated (GbTreeBuilder *builder,
- GbTreeNode *node)
+gb_project_tree_builder_node_activated (IdeTreeBuilder *builder,
+ IdeTreeNode *node)
{
GObject *item;
g_assert (GB_IS_PROJECT_TREE_BUILDER (builder));
- item = gb_tree_node_get_item (node);
+ item = ide_tree_node_get_item (node);
if (GB_IS_PROJECT_FILE (item))
{
GtkWidget *workbench;
- GbTree *tree;
+ IdeTree *tree;
GFile *file;
if (gb_project_file_get_is_directory (GB_PROJECT_FILE (item)))
@@ -350,12 +349,12 @@ gb_project_tree_builder_node_activated (GbTreeBuilder *builder,
if (!file)
goto failure;
- tree = gb_tree_node_get_tree (node);
+ tree = ide_tree_node_get_tree (node);
if (!tree)
goto failure;
workbench = gtk_widget_get_ancestor (GTK_WIDGET (tree), IDE_TYPE_WORKBENCH);
- ide_workbench_open_async (IDE_WORKBENCH (workbench), &file, 1, NULL, NULL, NULL);
+ ide_workbench_open_files_async (IDE_WORKBENCH (workbench), &file, 1, NULL, NULL, NULL);
return TRUE;
}
@@ -369,7 +368,7 @@ gb_project_tree_builder_rebuild (GSettings *settings,
const gchar *key,
GbProjectTreeBuilder *self)
{
- GbTree *tree;
+ IdeTree *tree;
gboolean sort_directories_first;
g_assert (G_IS_SETTINGS (settings));
@@ -380,8 +379,8 @@ gb_project_tree_builder_rebuild (GSettings *settings,
if (sort_directories_first != self->sort_directories_first)
{
self->sort_directories_first = sort_directories_first;
- if ((tree = gb_tree_builder_get_tree (GB_TREE_BUILDER (self))))
- gb_tree_rebuild (tree);
+ if ((tree = ide_tree_builder_get_tree (IDE_TREE_BUILDER (self))))
+ ide_tree_rebuild (tree);
}
}
@@ -399,7 +398,7 @@ static void
gb_project_tree_builder_class_init (GbProjectTreeBuilderClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GbTreeBuilderClass *tree_builder_class = GB_TREE_BUILDER_CLASS (klass);
+ IdeTreeBuilderClass *tree_builder_class = IDE_TREE_BUILDER_CLASS (klass);
object_class->finalize = gb_project_tree_builder_finalize;
diff --git a/plugins/project-tree/gb-project-tree-builder.h b/plugins/project-tree/gb-project-tree-builder.h
index 2924185..ad63441 100644
--- a/plugins/project-tree/gb-project-tree-builder.h
+++ b/plugins/project-tree/gb-project-tree-builder.h
@@ -21,16 +21,13 @@
#include <ide.h>
-#include "gb-tree-builder.h"
-
G_BEGIN_DECLS
#define GB_TYPE_PROJECT_TREE_BUILDER (gb_project_tree_builder_get_type())
-G_DECLARE_FINAL_TYPE (GbProjectTreeBuilder, gb_project_tree_builder,
- GB, PROJECT_TREE_BUILDER, GbTreeBuilder)
+G_DECLARE_FINAL_TYPE (GbProjectTreeBuilder, gb_project_tree_builder, GB, PROJECT_TREE_BUILDER,
IdeTreeBuilder)
-GbTreeBuilder *gb_project_tree_builder_new (void);
+IdeTreeBuilder *gb_project_tree_builder_new (void);
G_END_DECLS
diff --git a/plugins/project-tree/gb-project-tree-private.h b/plugins/project-tree/gb-project-tree-private.h
index d63b95f..c78ac8c 100644
--- a/plugins/project-tree/gb-project-tree-private.h
+++ b/plugins/project-tree/gb-project-tree-private.h
@@ -19,13 +19,13 @@
#ifndef GB_PROJECT_TREE_PRIVATE_H
#define GB_PROJECT_TREE_PRIVATE_H
-#include "gb-tree.h"
+#include <ide.h>
G_BEGIN_DECLS
struct _GbProjectTree
{
- GbTree parent_instance;
+ IdeTree parent_instance;
GSettings *settings;
diff --git a/plugins/project-tree/gb-project-tree.c b/plugins/project-tree/gb-project-tree.c
index b6b8545..2338f99 100644
--- a/plugins/project-tree/gb-project-tree.c
+++ b/plugins/project-tree/gb-project-tree.c
@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#define G_LOG_DOMAIN "project-tree"
+
#include <glib/gi18n.h>
#include "gb-project-tree.h"
@@ -23,7 +25,7 @@
#include "gb-project-tree-builder.h"
#include "gb-project-tree-private.h"
-G_DEFINE_TYPE (GbProjectTree, gb_project_tree, GB_TYPE_TREE)
+G_DEFINE_TYPE (GbProjectTree, gb_project_tree, IDE_TYPE_TREE)
enum {
PROP_0,
@@ -42,13 +44,13 @@ gb_project_tree_new (void)
IdeContext *
gb_project_tree_get_context (GbProjectTree *self)
{
- GbTreeNode *root;
+ IdeTreeNode *root;
GObject *item;
g_return_val_if_fail (GB_IS_PROJECT_TREE (self), NULL);
- if ((root = gb_tree_get_root (GB_TREE (self))) &&
- (item = gb_tree_node_get_item (root)) &&
+ if ((root = ide_tree_get_root (IDE_TREE (self))) &&
+ (item = ide_tree_node_get_item (root)) &&
IDE_IS_OBJECT (item))
return ide_object_get_context (IDE_OBJECT (item));
@@ -61,16 +63,16 @@ gb_project_tree_set_context (GbProjectTree *self,
{
GtkTreeModel *model;
GtkTreeIter iter;
- GbTreeNode *root;
+ IdeTreeNode *root;
g_return_if_fail (GB_IS_PROJECT_TREE (self));
g_return_if_fail (!context || IDE_IS_CONTEXT (context));
model = gtk_tree_view_get_model (GTK_TREE_VIEW (self));
- root = gb_tree_node_new ();
- gb_tree_node_set_item (root, G_OBJECT (context));
- gb_tree_set_root (GB_TREE (self), root);
+ root = ide_tree_node_new ();
+ ide_tree_node_set_item (root, G_OBJECT (context));
+ ide_tree_set_root (IDE_TREE (self), root);
/*
* If we only have one toplevel item (underneath root), expand it.
@@ -78,11 +80,11 @@ gb_project_tree_set_context (GbProjectTree *self,
if ((gtk_tree_model_iter_n_children (model, NULL) == 1) &&
gtk_tree_model_get_iter_first (model, &iter))
{
- g_autoptr(GbTreeNode) node = NULL;
+ g_autoptr(IdeTreeNode) node = NULL;
gtk_tree_model_get (model, &iter, 0, &node, -1);
if (node != NULL)
- gb_tree_node_expand (node, FALSE);
+ ide_tree_node_expand (node, FALSE);
}
}
@@ -165,7 +167,7 @@ gb_project_tree_class_init (GbProjectTreeClass *klass)
static void
gb_project_tree_init (GbProjectTree *self)
{
- GbTreeBuilder *builder;
+ IdeTreeBuilder *builder;
self->settings = g_settings_new ("org.gnome.builder.project-tree");
@@ -177,7 +179,7 @@ gb_project_tree_init (GbProjectTree *self)
G_SETTINGS_BIND_DEFAULT);
builder = gb_project_tree_builder_new ();
- gb_tree_add_builder (GB_TREE (self), builder);
+ ide_tree_add_builder (IDE_TREE (self), builder);
g_signal_connect (self,
"notify::selection",
@@ -207,6 +209,6 @@ gb_project_tree_set_show_ignored_files (GbProjectTree *self,
{
self->show_ignored_files = show_ignored_files;
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_SHOW_IGNORED_FILES]);
- gb_tree_rebuild (GB_TREE (self));
+ ide_tree_rebuild (IDE_TREE (self));
}
}
diff --git a/plugins/project-tree/gb-project-tree.gresource.xml
b/plugins/project-tree/gb-project-tree.gresource.xml
new file mode 100644
index 0000000..0f689a7
--- /dev/null
+++ b/plugins/project-tree/gb-project-tree.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/builder/plugins/project-tree">
+ <file>gb-new-file-popover.ui</file>
+ </gresource>
+</gresources>
diff --git a/plugins/project-tree/gb-project-tree.h b/plugins/project-tree/gb-project-tree.h
index 9e7358e..ad492ba 100644
--- a/plugins/project-tree/gb-project-tree.h
+++ b/plugins/project-tree/gb-project-tree.h
@@ -21,13 +21,11 @@
#include <ide.h>
-#include "gb-tree.h"
-
G_BEGIN_DECLS
#define GB_TYPE_PROJECT_TREE (gb_project_tree_get_type())
-G_DECLARE_FINAL_TYPE (GbProjectTree, gb_project_tree, GB, PROJECT_TREE, GbTree)
+G_DECLARE_FINAL_TYPE (GbProjectTree, gb_project_tree, GB, PROJECT_TREE, IdeTree)
GtkWidget *gb_project_tree_new (void);
void gb_project_tree_set_context (GbProjectTree *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]