[gnome-builder/wip/gtk4-port: 796/1774] plugins/project-tree: remove macro helper
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 796/1774] plugins/project-tree: remove macro helper
- Date: Mon, 11 Jul 2022 22:31:24 +0000 (UTC)
commit 4cca530a6f4d9e8ee7154f756f2e648287ce975c
Author: Christian Hergert <chergert redhat com>
Date: Thu Apr 28 21:06:17 2022 -0700
plugins/project-tree: remove macro helper
This is honestly just annoying and not helpful like I had hoped when
originally writing it.
.../project-tree/gbp-project-tree-pane-actions.c | 100 +++++++++++++++------
1 file changed, 73 insertions(+), 27 deletions(-)
---
diff --git a/src/plugins/project-tree/gbp-project-tree-pane-actions.c
b/src/plugins/project-tree/gbp-project-tree-pane-actions.c
index efbe7de60..14257b18f 100644
--- a/src/plugins/project-tree/gbp-project-tree-pane-actions.c
+++ b/src/plugins/project-tree/gbp-project-tree-pane-actions.c
@@ -287,34 +287,46 @@ close_matching_pages (IdePage *page,
}
}
-#define DEFINE_ACTION_HANDLER(short_name, BODY) \
-static void \
-gbp_project_tree_pane_actions_##short_name (GSimpleAction *action, \
- GVariant *param, \
- gpointer user_data) \
-{ \
- GbpProjectTreePane *self = user_data; \
- \
- g_assert (G_IS_SIMPLE_ACTION (action)); \
- g_assert (GBP_IS_PROJECT_TREE_PANE (self)); \
- \
- BODY \
-}
+static void
+gbp_project_tree_pane_actions_new_file (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbpProjectTreePane *self = user_data;
+
+ g_assert (G_IS_SIMPLE_ACTION (action));
+ g_assert (GBP_IS_PROJECT_TREE_PANE (self));
-DEFINE_ACTION_HANDLER (new_file, {
gbp_project_tree_pane_actions_new (self, G_FILE_TYPE_REGULAR);
-});
+}
+
+static void
+gbp_project_tree_pane_actions_new_folder (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbpProjectTreePane *self = user_data;
+
+ g_assert (G_IS_SIMPLE_ACTION (action));
+ g_assert (GBP_IS_PROJECT_TREE_PANE (self));
-DEFINE_ACTION_HANDLER (new_folder, {
gbp_project_tree_pane_actions_new (self, G_FILE_TYPE_DIRECTORY);
-});
+}
-DEFINE_ACTION_HANDLER (open, {
+static void
+gbp_project_tree_pane_actions_open (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbpProjectTreePane *self = user_data;
IdeProjectFile *project_file;
g_autoptr(GFile) file = NULL;
IdeWorkbench *workbench;
IdeTreeNode *selected;
+ g_assert (G_IS_SIMPLE_ACTION (action));
+ g_assert (GBP_IS_PROJECT_TREE_PANE (self));
+
if (!(selected = ide_tree_get_selected_node (self->tree)) ||
!ide_tree_node_holds (selected, IDE_TYPE_PROJECT_FILE) ||
!(project_file = ide_tree_node_get_item (selected)))
@@ -331,7 +343,7 @@ DEFINE_ACTION_HANDLER (open, {
NULL,
NULL,
NULL);
-});
+}
static void
gbp_project_tree_pane_actions_rename_cb (GObject *object,
@@ -383,7 +395,12 @@ done:
gtk_popover_popdown (GTK_POPOVER (popover));
}
-DEFINE_ACTION_HANDLER (rename, {
+static void
+gbp_project_tree_pane_actions_rename (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbpProjectTreePane *self = user_data;
IdeProjectFile *project_file;
g_autoptr(GFile) file = NULL;
GbpRenameFilePopover *popover;
@@ -391,6 +408,9 @@ DEFINE_ACTION_HANDLER (rename, {
IdeTreeNode *selected;
gboolean is_dir;
+ g_assert (G_IS_SIMPLE_ACTION (action));
+ g_assert (GBP_IS_PROJECT_TREE_PANE (self));
+
if (!(selected = ide_tree_get_selected_node (self->tree)) ||
!ide_tree_node_holds (selected, IDE_TYPE_PROJECT_FILE) ||
!(project_file = ide_tree_node_get_item (selected)))
@@ -413,7 +433,7 @@ DEFINE_ACTION_HANDLER (rename, {
NULL,
gbp_project_tree_pane_actions_rename_display_cb,
g_object_ref (self));
-});
+}
static void
gbp_project_tree_pane_actions_trash_cb (GObject *object,
@@ -437,12 +457,20 @@ gbp_project_tree_pane_actions_trash_cb (GObject *object,
ide_tree_node_remove (parent, node);
}
-DEFINE_ACTION_HANDLER (trash, {
+static void
+gbp_project_tree_pane_actions_trash (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbpProjectTreePane *self = user_data;
IdeProjectFile *project_file;
g_autoptr(GFile) file = NULL;
IdeWorkbench *workbench;
IdeTreeNode *selected;
+ g_assert (G_IS_SIMPLE_ACTION (action));
+ g_assert (GBP_IS_PROJECT_TREE_PANE (self));
+
if (!(selected = ide_tree_get_selected_node (self->tree)) ||
!ide_tree_node_holds (selected, IDE_TYPE_PROJECT_FILE) ||
!(project_file = ide_tree_node_get_item (selected)))
@@ -456,13 +484,21 @@ DEFINE_ACTION_HANDLER (trash, {
NULL,
gbp_project_tree_pane_actions_trash_cb,
g_object_ref (selected));
-});
+}
-DEFINE_ACTION_HANDLER (open_containing_folder, {
+static void
+gbp_project_tree_pane_actions_open_containing_folder (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbpProjectTreePane *self = user_data;
IdeProjectFile *project_file;
g_autoptr(GFile) file = NULL;
IdeTreeNode *selected;
+ g_assert (G_IS_SIMPLE_ACTION (action));
+ g_assert (GBP_IS_PROJECT_TREE_PANE (self));
+
if (!(selected = ide_tree_get_selected_node (self->tree)) ||
!ide_tree_node_holds (selected, IDE_TYPE_PROJECT_FILE) ||
!(project_file = ide_tree_node_get_item (selected)))
@@ -470,15 +506,23 @@ DEFINE_ACTION_HANDLER (open_containing_folder, {
file = ide_project_file_ref_file (project_file);
ide_file_manager_show (file, NULL);
-});
+}
-DEFINE_ACTION_HANDLER (open_with_hint, {
+static void
+gbp_project_tree_pane_actions_open_with_hint (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbpProjectTreePane *self = user_data;
IdeProjectFile *project_file;
g_autoptr(GFile) file = NULL;
IdeWorkbench *workbench;
IdeTreeNode *selected;
const gchar *hint;
+ g_assert (G_IS_SIMPLE_ACTION (action));
+ g_assert (GBP_IS_PROJECT_TREE_PANE (self));
+
if (!(selected = ide_tree_get_selected_node (self->tree)) ||
!ide_tree_node_holds (selected, IDE_TYPE_PROJECT_FILE) ||
!(project_file = ide_tree_node_get_item (selected)) ||
@@ -496,7 +540,7 @@ DEFINE_ACTION_HANDLER (open_with_hint, {
NULL,
NULL,
NULL);
-});
+}
/* Based on gdesktopappinfo.c in GIO */
static gchar *
@@ -659,6 +703,8 @@ _gbp_project_tree_pane_update_actions (GbpProjectTreePane *self)
}
}
+ g_print ("Update actions: is_file=%d is_dir=%d\n", is_file, is_dir);
+
action_map_set (G_ACTION_MAP (self->actions), "new-file",
"enabled", is_file,
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]