void _ide_tree_builder_set_tree (IdeTreeBuilder *builder, IdeTree *tree) { IdeTreeBuilderPrivate *priv = ide_tree_builder_get_instance_private (builder); g_return_if_fail (IDE_IS_TREE_BUILDER (builder)); g_return_if_fail (priv->tree == NULL || IDE_IS_TREE (priv->tree)); g_return_if_fail (IDE_IS_TREE (tree)); if (priv->tree != tree) { if (priv->tree != NULL) { g_object_remove_weak_pointer (G_OBJECT (priv->tree), (gpointer *)&priv->tree); priv->tree = NULL; } if (tree != NULL) { priv->tree = tree; g_object_add_weak_pointer (G_OBJECT (priv->tree), (gpointer *)&priv->tree); } g_object_notify_by_pspec (G_OBJECT (builder), properties [PROP_TREE]); } }
static gboolean find_child_node (IdeTree *tree, IdeTreeNode *node, IdeTreeNode *child, gpointer user_data) { const gchar *name = user_data; GObject *item; g_assert (IDE_IS_TREE (tree)); g_assert (IDE_IS_TREE_NODE (node)); g_assert (IDE_IS_TREE_NODE (child)); item = ide_tree_node_get_item (child); if (GB_IS_PROJECT_FILE (item)) { const gchar *item_name; item_name = gb_project_file_get_display_name (GB_PROJECT_FILE (item)); return ide_str_equal0 (item_name, name); } return FALSE; }
static void find_in_files_action (GSimpleAction *action, GVariant *param, gpointer user_data) { GbpGrepTreeAddin *self = user_data; g_autoptr(GFile) file = NULL; IdeProjectFile *project_file; IdeTreeNode *node; g_assert (G_IS_SIMPLE_ACTION (action)); g_assert (GBP_IS_GREP_TREE_ADDIN (self)); g_assert (self->tree != NULL); g_assert (IDE_IS_TREE (self->tree)); if ((node = ide_tree_get_selected_node (self->tree)) && ide_tree_node_holds (node, IDE_TYPE_PROJECT_FILE) && (project_file = ide_tree_node_get_item (node)) && (file = ide_project_file_ref_file (project_file))) { gboolean is_dir = ide_project_file_is_directory (project_file); GtkPopover *popover; popover = g_object_new (GBP_TYPE_GREP_POPOVER, "file", file, "is-directory", is_dir, "position", GTK_POS_RIGHT, NULL); g_signal_connect_after (popover, "closed", G_CALLBACK (popover_closed_cb), NULL); ide_tree_show_popover_at_node (self->tree, node, popover); } }
void _ide_tree_builder_removed (IdeTreeBuilder *builder, IdeTree *tree) { g_return_if_fail (IDE_IS_TREE_BUILDER (builder)); g_return_if_fail (IDE_IS_TREE (tree)); g_signal_emit (builder, signals [REMOVED], 0, tree); }
static gboolean find_files_node (IdeTree *tree, IdeTreeNode *node, IdeTreeNode *child, gpointer user_data) { GObject *item; g_assert (IDE_IS_TREE (tree)); g_assert (IDE_IS_TREE_NODE (node)); g_assert (IDE_IS_TREE_NODE (child)); item = ide_tree_node_get_item (child); return GB_IS_PROJECT_FILE (item); }
static void gbp_grep_tree_addin_unload (IdeTreeAddin *addin, IdeTree *tree, IdeTreeModel *model) { GbpGrepTreeAddin *self = (GbpGrepTreeAddin *)addin; g_assert (IDE_IS_MAIN_THREAD ()); g_assert (GBP_IS_GREP_TREE_ADDIN (self)); g_assert (IDE_IS_TREE (tree)); g_assert (IDE_IS_TREE_MODEL (model)); gtk_widget_insert_action_group (GTK_WIDGET (tree), "grep", NULL); self->tree = NULL; }
static void gbp_grep_tree_addin_load (IdeTreeAddin *addin, IdeTree *tree, IdeTreeModel *model) { GbpGrepTreeAddin *self = (GbpGrepTreeAddin *)addin; g_autoptr(GActionMap) group = NULL; static const GActionEntry actions[] = { { "find-in-files", find_in_files_action }, }; g_assert (IDE_IS_MAIN_THREAD ()); g_assert (GBP_IS_GREP_TREE_ADDIN (self)); g_assert (IDE_IS_TREE (tree)); g_assert (IDE_IS_TREE_MODEL (model)); self->tree = tree; group = G_ACTION_MAP (g_simple_action_group_new ()); g_action_map_add_action_entries (group, actions, G_N_ELEMENTS (actions), self); gtk_widget_insert_action_group (GTK_WIDGET (tree), "grep", G_ACTION_GROUP (group)); }