[anjuta] git: Use models from GtkBuilder for the branch combo boxes.
- From: James Liggett <jrliggett src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjuta] git: Use models from GtkBuilder for the branch combo boxes.
- Date: Thu, 21 May 2009 18:30:15 -0400 (EDT)
commit 5943c5362f7fab0136db936040f9e50e1b77fb88
Author: James Liggett <jrliggett cox net>
Date: Thu May 21 15:29:10 2009 -0700
git: Use models from GtkBuilder for the branch combo boxes.
Setting up branch combo boxes is now done completely with builder.
Branch models can be shared across dialogs. I also added in some other things for
being able to select multiple branches, and another model for getting the log of different
branches, but those things aren't fully implemented yet.
---
plugins/git/Makefile.am | 2 -
plugins/git/anjuta-git.ui | 64 ++++++++++++++
plugins/git/git-branch-combo-model.c | 115 --------------------------
plugins/git/git-branch-combo-model.h | 54 ------------
plugins/git/git-create-patch-series-dialog.c | 34 ++++----
plugins/git/git-create-patch-series-dialog.h | 1 -
plugins/git/git-delete-branch-dialog.c | 36 ++++----
plugins/git/git-delete-branch-dialog.h | 1 -
plugins/git/git-delete-remote-dialog.c | 48 ++++++-----
plugins/git/git-delete-remote-dialog.h | 1 -
plugins/git/git-merge-dialog.c | 35 ++++----
plugins/git/git-merge-dialog.h | 1 -
plugins/git/git-rebase-dialog.c | 34 ++++----
plugins/git/git-rebase-dialog.h | 1 -
plugins/git/git-switch-dialog.c | 37 ++++----
plugins/git/git-switch-dialog.h | 1 -
plugins/git/git-ui-utils.c | 23 ++++--
plugins/git/git-ui-utils.h | 11 +--
18 files changed, 196 insertions(+), 303 deletions(-)
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index f58bbfc..5951850 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -76,8 +76,6 @@ libanjuta_git_la_SOURCES = \
git-branch-list-command.c \
git-merge-command.h \
git-merge-command.c \
- git-branch-combo-model.c \
- git-branch-combo-model.h \
git-merge-dialog.h \
git-merge-dialog.c \
git-branch-checkout-command.h \
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index 4cfe743..2124c4b 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -3,6 +3,28 @@
<requires lib="gtk+" version="2.16"/>
<requires lib="anjuta" version="2366.5320"/>
<!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkListStore" id="log_branch_combo_model">
+ <columns>
+ <!-- column-name active_icon -->
+ <column type="gchararray"/>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkListStore" id="branch_list_model">
+ <columns>
+ <!-- column-name selected -->
+ <column type="gboolean"/>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkListStore" id="branch_combo_model">
+ <columns>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="commit_dialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
@@ -846,6 +868,13 @@
<object class="GtkComboBox" id="merge_branch_combo">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="model">branch_combo_model</property>
+ <child>
+ <object class="GtkCellRendererText" id="merge_branch_combo_name"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
</object>
</child>
</object>
@@ -1075,6 +1104,13 @@
<child>
<object class="GtkComboBox" id="switch_branch_combo">
<property name="visible">True</property>
+ <property name="model">branch_combo_model</property>
+ <child>
+ <object class="GtkCellRendererText" id="switch_branch_combo_name"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
</object>
</child>
</object>
@@ -1360,6 +1396,13 @@
<child>
<object class="GtkComboBox" id="delete_branch_combo">
<property name="visible">True</property>
+ <property name="model">branch_combo_model</property>
+ <child>
+ <object class="GtkCellRendererText" id="delete_branch_combo_name"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
</object>
</child>
</object>
@@ -2917,6 +2960,13 @@
<object class="GtkComboBox" id="rebase_branch_combo">
<property name="visible">True</property>
<property name="sensitive">False</property>
+ <property name="model">branch_combo_model</property>
+ <child>
+ <object class="GtkCellRendererText" id="rebase_branch_combo_name"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
</object>
<packing>
<property name="position">0</property>
@@ -3511,6 +3561,13 @@
<child>
<object class="GtkComboBox" id="delete_remote_combo">
<property name="visible">True</property>
+ <property name="model">branch_combo_model</property>
+ <child>
+ <object class="GtkCellRendererText" id="delete_remote_combo_name"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
</object>
</child>
</object>
@@ -3609,6 +3666,13 @@
<object class="GtkComboBox" id="patch_series_branch_combo">
<property name="visible">True</property>
<property name="sensitive">False</property>
+ <property name="model">branch_combo_model</property>
+ <child>
+ <object class="GtkCellRendererText" id="patch_series_branch_combo_name"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
</object>
<packing>
<property name="position">0</property>
diff --git a/plugins/git/git-branch-combo-model.c b/plugins/git/git-branch-combo-model.c
deleted file mode 100644
index d7c2565..0000000
--- a/plugins/git/git-branch-combo-model.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
-/*
- * anjuta
- * Copyright (C) James Liggett 2008 <jrliggett cox net>
- *
- * anjuta is free software.
- *
- * You may redistribute it and/or modify it under the terms of the
- * GNU General Public License, as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * anjuta 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 anjuta. If not, write to:
- * The Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301, USA.
- */
-
-#include "git-branch-combo-model.h"
-
-enum
-{
- COL_ACTIVE,
- COL_NAME,
-
- NUM_COLS
-};
-
-GitBranchComboData *
-git_branch_combo_data_new (GtkListStore *model, GtkComboBox *combo_box,
- GtkBuilder *bxml, Git *plugin)
-{
- GitBranchComboData *data;
-
- data = g_new0 (GitBranchComboData, 1);
- data->model = model;
- data->combo_box = combo_box;
- data->bxml = bxml;
- data->plugin = plugin;
-
- return data;
-}
-
-void
-git_branch_combo_data_free (GitBranchComboData *data)
-{
- g_object_unref (data->bxml);
- g_free (data);
-}
-
-GtkListStore *
-git_branch_combo_model_new (void)
-{
- return gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_STRING);
-}
-
-void
-git_branch_combo_model_setup_widget (GtkWidget *widget)
-{
- GtkCellRenderer *renderer;
-
- /* Active column */
- renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget), renderer, FALSE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (widget), renderer,
- "stock-id", COL_ACTIVE);
-
- /* Name column */
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget), renderer, FALSE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (widget), renderer,
- "text", COL_NAME);
-}
-
-void
-git_branch_combo_model_append (GtkListStore *model, GitBranch *branch)
-{
- gchar *name;
- GtkTreeIter iter;
-
- name = git_branch_get_name (branch);
-
- gtk_list_store_append (model, &iter);
- gtk_list_store_set (model, &iter, COL_NAME, name, -1);
-
- if (git_branch_is_active (branch))
- gtk_list_store_set (model, &iter, COL_ACTIVE, GTK_STOCK_YES, -1);
-
- g_free (name);
-}
-
-void
-git_branch_combo_model_append_remote (GtkListStore *model, const gchar *name)
-{
- GtkTreeIter iter;
-
- gtk_list_store_append (model, &iter);
- gtk_list_store_set (model, &iter, COL_NAME, name, -1);
-}
-
-gchar *
-git_branch_combo_model_get_branch (GtkListStore *model, GtkTreeIter *iter)
-{
- gchar *branch;
-
- gtk_tree_model_get (GTK_TREE_MODEL (model), iter, COL_NAME, &branch, -1);
-
- return branch;
-}
diff --git a/plugins/git/git-branch-combo-model.h b/plugins/git/git-branch-combo-model.h
deleted file mode 100644
index 2261d0b..0000000
--- a/plugins/git/git-branch-combo-model.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
-/*
- * anjuta
- * Copyright (C) James Liggett 2008 <jrliggett cox net>
- *
- * anjuta is free software.
- *
- * You may redistribute it and/or modify it under the terms of the
- * GNU General Public License, as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * anjuta 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 anjuta. If not, write to:
- * The Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GIT_BRANCH_COMBO_MODEL_H
-#define _GIT_BRANCH_COMBO_MODEL_H
-
-#include <gtk/gtk.h>
-#include <glade/glade.h>
-#include "git-branch.h"
-#include "plugin.h"
-
-typedef struct
-{
- GtkListStore *model;
- GtkComboBox *combo_box;
- GtkBuilder *bxml; /* Seems redundant, but we don't know what the combo box
- * is called in the glade file. */
- Git *plugin;
-} GitBranchComboData;
-
-GitBranchComboData *git_branch_combo_data_new (GtkListStore *model,
- GtkComboBox *combo_box,
- GtkBuilder *bxml, Git *plugin);
-void git_branch_combo_data_free (GitBranchComboData *data);
-GtkListStore *git_branch_combo_model_new (void);
-void git_branch_combo_model_setup_widget (GtkWidget *widget);
-void git_branch_combo_model_append (GtkListStore *model, GitBranch *branch);
-void git_branch_combo_model_append_remote (GtkListStore *model,
- const gchar *name);
-gchar *git_branch_combo_model_get_branch (GtkListStore *model,
- GtkTreeIter *iter);
-
-#endif
diff --git a/plugins/git/git-create-patch-series-dialog.c b/plugins/git/git-create-patch-series-dialog.c
index a1deb20..f296bfd 100644
--- a/plugins/git/git-create-patch-series-dialog.c
+++ b/plugins/git/git-create-patch-series-dialog.c
@@ -26,12 +26,13 @@
static void
on_create_patch_series_dialog_response (GtkDialog *dialog, gint response_id,
- GitBranchComboData *data)
+ GitUIData *data)
{
GtkWidget *patch_series_origin_check;
GtkWidget *patch_series_branch_combo;
GtkWidget *patch_series_file_chooser_button;
GtkWidget *patch_series_signoff_check;
+ GtkTreeModel *branch_combo_model;
gchar *branch;
gchar *output_directory;
GtkTreeIter iter;
@@ -47,6 +48,8 @@ on_create_patch_series_dialog_response (GtkDialog *dialog, gint response_id,
"patch_series_file_chooser_button"));
patch_series_signoff_check = GTK_WIDGET (gtk_builder_get_object (data->bxml,
"patch_series_signoff_check"));
+ branch_combo_model = GTK_TREE_MODEL (gtk_builder_get_object (data->bxml,
+ "branch_combo_model"));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (patch_series_origin_check)))
branch = g_strdup ("origin");
@@ -54,7 +57,7 @@ on_create_patch_series_dialog_response (GtkDialog *dialog, gint response_id,
{
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (patch_series_branch_combo),
&iter);
- branch = git_branch_combo_model_get_branch (data->model, &iter);
+ gtk_tree_model_get (branch_combo_model, &iter, 0, &branch, -1);
}
output_directory = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (patch_series_file_chooser_button));
@@ -81,20 +84,20 @@ on_create_patch_series_dialog_response (GtkDialog *dialog, gint response_id,
}
gtk_widget_destroy (GTK_WIDGET (dialog));
- git_branch_combo_data_free (data);
+ git_ui_data_free (data);
}
static void
create_patch_series_dialog (Git *plugin)
{
GtkBuilder *bxml;
- gchar *objects[] = {"patch_series_dialog", NULL};
+ gchar *objects[] = {"patch_series_dialog", "branch_combo_model", NULL};
GError *error;
GtkWidget *dialog;
GtkWidget *patch_series_origin_check;
GtkWidget *patch_series_branch_combo;
- GtkListStore *branch_list_store;
- GitBranchComboData *data;
+ GtkListStore *branch_combo_model;
+ GitUIData *data;
GitBranchListCommand *list_command;
bxml = gtk_builder_new ();
@@ -112,26 +115,21 @@ create_patch_series_dialog (Git *plugin)
"patch_series_origin_check"));
patch_series_branch_combo = GTK_WIDGET (gtk_builder_get_object (bxml,
"patch_series_branch_combo"));
- branch_list_store = git_branch_combo_model_new ();
+ branch_combo_model = GTK_LIST_STORE (gtk_builder_get_object (bxml,
+ "branch_combo_model"));
- gtk_combo_box_set_model (GTK_COMBO_BOX (patch_series_branch_combo),
- GTK_TREE_MODEL (branch_list_store));
- git_branch_combo_model_setup_widget (patch_series_branch_combo);
-
- data = git_branch_combo_data_new (branch_list_store,
- GTK_COMBO_BOX (patch_series_branch_combo),
- bxml, plugin);
+ data = git_ui_data_new (plugin, bxml);
list_command = git_branch_list_command_new (plugin->project_root_directory,
GIT_BRANCH_TYPE_ALL);
g_signal_connect (G_OBJECT (list_command), "data-arrived",
- G_CALLBACK (on_git_list_branch_command_data_arrived),
- data);
+ G_CALLBACK (on_git_list_branch_combo_command_data_arrived),
+ branch_combo_model);
g_signal_connect (G_OBJECT (list_command), "command-finished",
- G_CALLBACK (on_git_list_branch_command_finished),
- data);
+ G_CALLBACK (on_git_list_branch_combo_command_finished),
+ patch_series_branch_combo);
anjuta_command_start (ANJUTA_COMMAND (list_command));
diff --git a/plugins/git/git-create-patch-series-dialog.h b/plugins/git/git-create-patch-series-dialog.h
index 34df671..36d0a81 100644
--- a/plugins/git/git-create-patch-series-dialog.h
+++ b/plugins/git/git-create-patch-series-dialog.h
@@ -28,7 +28,6 @@
#include "git-branch-list-command.h"
#include "git-format-patch-command.h"
#include "git-ui-utils.h"
-#include "git-branch-combo-model.h"
void on_menu_git_create_patch_series (GtkAction *action, Git *plugin);
diff --git a/plugins/git/git-delete-branch-dialog.c b/plugins/git/git-delete-branch-dialog.c
index a25bd05..f877569 100644
--- a/plugins/git/git-delete-branch-dialog.c
+++ b/plugins/git/git-delete-branch-dialog.c
@@ -54,10 +54,11 @@ on_delete_command_finished (AnjutaCommand *command, guint return_code,
static void
on_delete_branch_dialog_response (GtkDialog *dialog, gint response_id,
- GitBranchComboData *data)
+ GitUIData *data)
{
GtkWidget *delete_branch_combo;
GtkWidget *require_merged_check;
+ GtkTreeModel *branch_combo_model;
gchar *branch;
GtkTreeIter iter;
GitBranchDeleteCommand *delete_command;
@@ -68,9 +69,11 @@ on_delete_branch_dialog_response (GtkDialog *dialog, gint response_id,
"delete_branch_combo"));
require_merged_check = GTK_WIDGET (gtk_builder_get_object (data->bxml,
"require_merged_check"));
+ branch_combo_model = GTK_TREE_MODEL (gtk_builder_get_object (data->bxml,
+ "branch_combo_model"));
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (delete_branch_combo), &iter);
- branch = git_branch_combo_model_get_branch (data->model, &iter);
+ gtk_tree_model_get (branch_combo_model, &iter, 0, &branch, -1);
delete_command = git_branch_delete_command_new (data->plugin->project_root_directory,
branch,
@@ -92,19 +95,19 @@ on_delete_branch_dialog_response (GtkDialog *dialog, gint response_id,
}
gtk_widget_destroy (GTK_WIDGET (dialog));
- git_branch_combo_data_free (data);
+ git_ui_data_free (data);
}
static void
delete_branch_dialog (Git *plugin)
{
GtkBuilder *bxml;
- gchar *objects[] = {"delete_branch_dialog", NULL};
+ gchar *objects[] = {"delete_branch_dialog", "branch_combo_model", NULL};
GError *error;
GtkWidget *dialog;
GtkWidget *delete_branch_combo;
- GtkListStore *branch_list_store;
- GitBranchComboData *data;
+ GtkListStore *branch_combo_model;
+ GitUIData *data;
GitBranchListCommand *list_command;
bxml = gtk_builder_new ();
@@ -119,26 +122,21 @@ delete_branch_dialog (Git *plugin)
dialog = GTK_WIDGET (gtk_builder_get_object (bxml, "delete_branch_dialog"));
delete_branch_combo = GTK_WIDGET (gtk_builder_get_object (bxml, "delete_branch_combo"));
- branch_list_store = git_branch_combo_model_new ();
-
- gtk_combo_box_set_model (GTK_COMBO_BOX (delete_branch_combo),
- GTK_TREE_MODEL (branch_list_store));
- git_branch_combo_model_setup_widget (delete_branch_combo);
-
- data = git_branch_combo_data_new (branch_list_store,
- GTK_COMBO_BOX (delete_branch_combo), bxml,
- plugin);
+ branch_combo_model = GTK_LIST_STORE (gtk_builder_get_object (bxml,
+ "branch_combo_model"));
+ data = git_ui_data_new (plugin, bxml);
+
list_command = git_branch_list_command_new (plugin->project_root_directory,
GIT_BRANCH_TYPE_LOCAL);
g_signal_connect (G_OBJECT (list_command), "data-arrived",
- G_CALLBACK (on_git_list_branch_command_data_arrived),
- data);
+ G_CALLBACK (on_git_list_branch_combo_command_data_arrived),
+ branch_combo_model);
g_signal_connect (G_OBJECT (list_command), "command-finished",
- G_CALLBACK (on_git_list_branch_command_finished),
- data);
+ G_CALLBACK (on_git_list_branch_combo_command_finished),
+ delete_branch_combo);
anjuta_command_start (ANJUTA_COMMAND (list_command));
diff --git a/plugins/git/git-delete-branch-dialog.h b/plugins/git/git-delete-branch-dialog.h
index f3f5154..8a17126 100644
--- a/plugins/git/git-delete-branch-dialog.h
+++ b/plugins/git/git-delete-branch-dialog.h
@@ -28,7 +28,6 @@
#include "git-branch-list-command.h"
#include "git-branch-delete-command.h"
#include "git-ui-utils.h"
-#include "git-branch-combo-model.h"
void on_menu_git_delete_branch (GtkAction *action, Git *plugin);
diff --git a/plugins/git/git-delete-remote-dialog.c b/plugins/git/git-delete-remote-dialog.c
index 38f7bdf..723ce1b 100644
--- a/plugins/git/git-delete-remote-dialog.c
+++ b/plugins/git/git-delete-remote-dialog.c
@@ -26,9 +26,10 @@
static void
on_delete_remote_dialog_response (GtkDialog *dialog, gint response_id,
- GitBranchComboData *data)
+ GitUIData *data)
{
GtkWidget *delete_remote_branch_combo;
+ GtkTreeModel *branch_combo_model;
gchar *branch;
GtkTreeIter iter;
GitRemoteDeleteCommand *delete_command;
@@ -37,10 +38,12 @@ on_delete_remote_dialog_response (GtkDialog *dialog, gint response_id,
{
delete_remote_branch_combo = GTK_WIDGET (gtk_builder_get_object (data->bxml,
"delete_remote_combo"));
+ branch_combo_model = GTK_TREE_MODEL (gtk_builder_get_object (data->bxml,
+ "branch_combo_model"));
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (delete_remote_branch_combo),
&iter);
- branch = git_branch_combo_model_get_branch (data->model, &iter);
+ gtk_tree_model_get (branch_combo_model, &iter, 0, &branch, -1);
delete_command = git_remote_delete_command_new (data->plugin->project_root_directory,
branch);
@@ -61,7 +64,7 @@ on_delete_remote_dialog_response (GtkDialog *dialog, gint response_id,
}
gtk_widget_destroy (GTK_WIDGET (dialog));
- git_branch_combo_data_free (data);
+ git_ui_data_free (data);
}
static void
@@ -70,32 +73,38 @@ on_remote_list_command_data_arrived (AnjutaCommand *command,
{
GQueue *output_queue;
gchar *remote_name;
+ GtkTreeIter iter;
output_queue = git_raw_output_command_get_output (GIT_RAW_OUTPUT_COMMAND (command));
while (g_queue_peek_head (output_queue))
{
remote_name = g_queue_pop_head (output_queue);
- git_branch_combo_model_append_remote (model, remote_name);
+
+ gtk_list_store_append (model, &iter);
+ gtk_list_store_set (model, &iter, 0, remote_name, -1);
+
g_free (remote_name);
}
}
static void
on_remote_list_command_finished (AnjutaCommand *command, guint return_code,
- GitBranchComboData *data)
+ GtkBuilder *bxml)
{
GtkWidget *delete_remote_ok_button;
GtkWidget *delete_remote_combo;
+ GtkTreeModel *branch_combo_model;
GtkTreeIter iter;
- delete_remote_ok_button = GTK_WIDGET (gtk_builder_get_object (data->bxml,
+ delete_remote_ok_button = GTK_WIDGET (gtk_builder_get_object (bxml,
"delete_remote_ok_button"));
- delete_remote_combo = GTK_WIDGET (gtk_builder_get_object (data->bxml,
+ delete_remote_combo = GTK_WIDGET (gtk_builder_get_object (bxml,
"delete_remote_combo"));
+ branch_combo_model = GTK_TREE_MODEL (gtk_builder_get_object (bxml,
+ "branch_combo_model"));
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (data->model),
- &iter))
+ if (gtk_tree_model_get_iter_first (branch_combo_model, &iter))
{
gtk_widget_set_sensitive (delete_remote_ok_button, TRUE);
gtk_combo_box_set_active (GTK_COMBO_BOX (delete_remote_combo), 0);
@@ -106,12 +115,12 @@ static void
delete_remote_dialog (Git *plugin)
{
GtkBuilder *bxml;
- gchar *objects[] = {"delete_remote_dialog", NULL};
+ gchar *objects[] = {"delete_remote_dialog", "branch_combo_model", NULL};
GError *error;
GtkWidget *dialog;
GtkWidget *delete_remote_combo;
- GtkListStore *branch_list_store;
- GitBranchComboData *data;
+ GtkListStore *branch_combo_model;
+ GitUIData *data;
GitRemoteListCommand *list_command;
bxml = gtk_builder_new ();
@@ -127,25 +136,20 @@ delete_remote_dialog (Git *plugin)
dialog = GTK_WIDGET (gtk_builder_get_object (bxml, "delete_remote_dialog"));
delete_remote_combo = GTK_WIDGET (gtk_builder_get_object (bxml,
"delete_remote_combo"));
- branch_list_store = git_branch_combo_model_new ();
+ branch_combo_model = GTK_LIST_STORE (gtk_builder_get_object (bxml,
+ "branch_combo_model"));
- gtk_combo_box_set_model (GTK_COMBO_BOX (delete_remote_combo),
- GTK_TREE_MODEL (branch_list_store));
- git_branch_combo_model_setup_widget (delete_remote_combo);
-
- data = git_branch_combo_data_new (branch_list_store,
- GTK_COMBO_BOX (delete_remote_combo), bxml,
- plugin);
+ data = git_ui_data_new (plugin, bxml);
list_command = git_remote_list_command_new (plugin->project_root_directory);
g_signal_connect (G_OBJECT (list_command), "data-arrived",
G_CALLBACK (on_remote_list_command_data_arrived),
- data->model);
+ branch_combo_model);
g_signal_connect (G_OBJECT (list_command), "command-finished",
G_CALLBACK (on_remote_list_command_finished),
- data);
+ bxml);
anjuta_command_start (ANJUTA_COMMAND (list_command));
diff --git a/plugins/git/git-delete-remote-dialog.h b/plugins/git/git-delete-remote-dialog.h
index c485e2f..4d67110 100644
--- a/plugins/git/git-delete-remote-dialog.h
+++ b/plugins/git/git-delete-remote-dialog.h
@@ -28,7 +28,6 @@
#include "git-remote-list-command.h"
#include "git-remote-delete-command.h"
#include "git-ui-utils.h"
-#include "git-branch-combo-model.h"
void on_menu_git_delete_remote (GtkAction *action, Git *plugin);
diff --git a/plugins/git/git-merge-dialog.c b/plugins/git/git-merge-dialog.c
index 350d231..fff0cf4 100644
--- a/plugins/git/git-merge-dialog.c
+++ b/plugins/git/git-merge-dialog.c
@@ -43,13 +43,14 @@ on_merge_command_finished (AnjutaCommand *command, guint return_code,
static void
on_merge_dialog_response (GtkDialog *dialog, gint response_id,
- GitBranchComboData *data)
+ GitUIData *data)
{
GtkWidget *merge_branch_combo;
GtkWidget *no_commit_check;
GtkWidget *squash_check;
GtkWidget *use_custom_log_check;
GtkWidget *merge_log_view;
+ GtkTreeModel *branch_combo_model;
gchar *log;
GtkWidget *log_prompt_dialog;
gint prompt_response;
@@ -69,6 +70,8 @@ on_merge_dialog_response (GtkDialog *dialog, gint response_id,
"use_custom_log_check"));
merge_log_view = GTK_WIDGET (gtk_builder_get_object (data->bxml,
"merge_log_view"));
+ branch_combo_model = GTK_TREE_MODEL (gtk_builder_get_object (data->bxml,
+ "branch_combo_model"));
log = NULL;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (use_custom_log_check)))
@@ -92,9 +95,9 @@ on_merge_dialog_response (GtkDialog *dialog, gint response_id,
g_free (log);
}
-
+
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (merge_branch_combo), &iter);
- branch = git_branch_combo_model_get_branch (data->model, &iter);
+ gtk_tree_model_get (branch_combo_model, &iter, 0, &branch, -1);
merge_command = git_merge_command_new (data->plugin->project_root_directory,
branch, log,
@@ -117,7 +120,7 @@ on_merge_dialog_response (GtkDialog *dialog, gint response_id,
}
gtk_widget_destroy (GTK_WIDGET (dialog));
- git_branch_combo_data_free (data);
+ git_ui_data_free (data);
}
static void
@@ -131,14 +134,14 @@ static void
merge_dialog (Git *plugin)
{
GtkBuilder *bxml;
- gchar *objects[] = {"merge_dialog", NULL};
+ gchar *objects[] = {"merge_dialog", "branch_combo_model", NULL};
GError *error;
GtkWidget *dialog;
GtkWidget *merge_branch_combo;
GtkWidget *use_custom_log_check;
GtkWidget *merge_log_view;
- GtkListStore *branch_list_store;
- GitBranchComboData *data;
+ GtkListStore *branch_combo_model;
+ GitUIData *data;
GitBranchListCommand *list_command;
bxml = gtk_builder_new ();
@@ -156,26 +159,20 @@ merge_dialog (Git *plugin)
use_custom_log_check = GTK_WIDGET (gtk_builder_get_object (bxml,
"use_custom_log_check"));
merge_log_view = GTK_WIDGET (gtk_builder_get_object (bxml, "merge_log_view"));
- branch_list_store = git_branch_combo_model_new ();
-
- gtk_combo_box_set_model (GTK_COMBO_BOX (merge_branch_combo),
- GTK_TREE_MODEL (branch_list_store));
- git_branch_combo_model_setup_widget (merge_branch_combo);
+ branch_combo_model = GTK_LIST_STORE (gtk_builder_get_object (bxml, "branch_combo_model"));
- data = git_branch_combo_data_new (branch_list_store,
- GTK_COMBO_BOX (merge_branch_combo), bxml,
- plugin);
+ data = git_ui_data_new (plugin, bxml);
list_command = git_branch_list_command_new (plugin->project_root_directory,
GIT_BRANCH_TYPE_ALL);
g_signal_connect (G_OBJECT (list_command), "data-arrived",
- G_CALLBACK (on_git_list_branch_command_data_arrived),
- data);
+ G_CALLBACK (on_git_list_branch_combo_command_data_arrived),
+ branch_combo_model);
g_signal_connect (G_OBJECT (list_command), "command-finished",
- G_CALLBACK (on_git_list_branch_command_finished),
- data);
+ G_CALLBACK (on_git_list_branch_combo_command_finished),
+ merge_branch_combo);
anjuta_command_start (ANJUTA_COMMAND (list_command));
diff --git a/plugins/git/git-merge-dialog.h b/plugins/git/git-merge-dialog.h
index eec714d..e6c9b5b 100644
--- a/plugins/git/git-merge-dialog.h
+++ b/plugins/git/git-merge-dialog.h
@@ -27,7 +27,6 @@
#include "git-merge-command.h"
#include "git-ui-utils.h"
-#include "git-branch-combo-model.h"
#include "git-branch-list-command.h"
void on_menu_git_merge (GtkAction *action, Git *plugin);
diff --git a/plugins/git/git-rebase-dialog.c b/plugins/git/git-rebase-dialog.c
index abab746..e93d38a 100644
--- a/plugins/git/git-rebase-dialog.c
+++ b/plugins/git/git-rebase-dialog.c
@@ -26,10 +26,11 @@
static void
on_rebase_dialog_response (GtkDialog *dialog, gint response_id,
- GitBranchComboData *data)
+ GitUIData *data)
{
GtkWidget *rebase_branch_combo;
GtkWidget *rebase_origin_check;
+ GtkTreeModel *branch_combo_model;
gchar *branch;
GtkTreeIter iter;
GitRebaseStartCommand *rebase_command;
@@ -41,6 +42,8 @@ on_rebase_dialog_response (GtkDialog *dialog, gint response_id,
"rebase_branch_combo"));
rebase_origin_check = GTK_WIDGET (gtk_builder_get_object (data->bxml,
"rebase_origin_check"));
+ branch_combo_model = GTK_TREE_MODEL (gtk_builder_get_object (data->bxml,
+ "branch_combo_model"));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rebase_origin_check)))
branch = g_strdup ("origin");
@@ -48,7 +51,7 @@ on_rebase_dialog_response (GtkDialog *dialog, gint response_id,
{
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (rebase_branch_combo),
&iter);
- branch = git_branch_combo_model_get_branch (data->model, &iter);
+ gtk_tree_model_get (branch_combo_model, &iter, 0, &branch, -1);
}
rebase_command = git_rebase_start_command_new (data->plugin->project_root_directory,
@@ -81,20 +84,20 @@ on_rebase_dialog_response (GtkDialog *dialog, gint response_id,
}
gtk_widget_destroy (GTK_WIDGET (dialog));
- git_branch_combo_data_free (data);
+ git_ui_data_free (data);
}
static void
rebase_dialog (Git *plugin)
{
GtkBuilder *bxml;
- gchar *objects[] = {"rebase_dialog", NULL};
+ gchar *objects[] = {"rebase_dialog", "branch_combo_model", NULL};
GError *error;
GtkWidget *dialog;
GtkWidget *rebase_branch_combo;
GtkWidget *rebase_origin_check;
- GtkListStore *branch_list_store;
- GitBranchComboData *data;
+ GtkListStore *branch_combo_model;
+ GitUIData *data;
GitBranchListCommand *list_command;
bxml = gtk_builder_new ();
@@ -112,26 +115,21 @@ rebase_dialog (Git *plugin)
"rebase_branch_combo"));
rebase_origin_check = GTK_WIDGET (gtk_builder_get_object (bxml,
"rebase_origin_check"));
- branch_list_store = git_branch_combo_model_new ();
+ branch_combo_model = GTK_LIST_STORE (gtk_builder_get_object (bxml,
+ "branch_combo_model"));
- gtk_combo_box_set_model (GTK_COMBO_BOX (rebase_branch_combo),
- GTK_TREE_MODEL (branch_list_store));
- git_branch_combo_model_setup_widget (rebase_branch_combo);
-
- data = git_branch_combo_data_new (branch_list_store,
- GTK_COMBO_BOX (rebase_branch_combo), bxml,
- plugin);
+ data = git_ui_data_new (plugin, bxml);
list_command = git_branch_list_command_new (plugin->project_root_directory,
GIT_BRANCH_TYPE_REMOTE);
g_signal_connect (G_OBJECT (list_command), "data-arrived",
- G_CALLBACK (on_git_list_branch_command_data_arrived),
- data);
+ G_CALLBACK (on_git_list_branch_combo_command_data_arrived),
+ branch_combo_model);
g_signal_connect (G_OBJECT (list_command), "command-finished",
- G_CALLBACK (on_git_list_branch_command_finished),
- data);
+ G_CALLBACK (on_git_list_branch_combo_command_finished),
+ rebase_branch_combo);
anjuta_command_start (ANJUTA_COMMAND (list_command));
diff --git a/plugins/git/git-rebase-dialog.h b/plugins/git/git-rebase-dialog.h
index ae00683..ceab587 100644
--- a/plugins/git/git-rebase-dialog.h
+++ b/plugins/git/git-rebase-dialog.h
@@ -28,7 +28,6 @@
#include "git-rebase-start-command.h"
#include "git-rebase-continue-command.h"
#include "git-ui-utils.h"
-#include "git-branch-combo-model.h"
void on_menu_git_rebase_start (GtkAction *action, Git *plugin);
void on_menu_git_rebase_continue (GtkAction *action, Git *plugin);
diff --git a/plugins/git/git-switch-dialog.c b/plugins/git/git-switch-dialog.c
index 70d00cf..d1fdb30 100644
--- a/plugins/git/git-switch-dialog.c
+++ b/plugins/git/git-switch-dialog.c
@@ -43,9 +43,10 @@ on_checkout_command_finished (AnjutaCommand *command, guint return_code,
static void
on_switch_dialog_response (GtkDialog *dialog, gint response_id,
- GitBranchComboData *data)
+ GitUIData *data)
{
GtkWidget *switch_branch_combo;
+ GtkTreeModel *branch_combo_model;
gchar *branch;
GtkTreeIter iter;
GitBranchCheckoutCommand *checkout_command;
@@ -54,13 +55,18 @@ on_switch_dialog_response (GtkDialog *dialog, gint response_id,
{
switch_branch_combo = GTK_WIDGET (gtk_builder_get_object (data->bxml,
"switch_branch_combo"));
+ branch_combo_model = GTK_TREE_MODEL (gtk_builder_get_object (data->bxml,
+ "branch_combo_model"));
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (switch_branch_combo), &iter);
- branch = git_branch_combo_model_get_branch (data->model, &iter);
+ gtk_tree_model_get (branch_combo_model, &iter, 0, &branch, -1);
+
checkout_command = git_branch_checkout_command_new (data->plugin->project_root_directory,
branch);
+
+
g_free (branch);
git_create_message_view (data->plugin);
@@ -77,19 +83,19 @@ on_switch_dialog_response (GtkDialog *dialog, gint response_id,
}
gtk_widget_destroy (GTK_WIDGET (dialog));
- git_branch_combo_data_free (data);
+ git_ui_data_free (data);
}
static void
switch_dialog (Git *plugin)
{
GtkBuilder *bxml;
- gchar *objects[] = {"switch_dialog", NULL};
+ gchar *objects[] = {"switch_dialog", "branch_combo_model", NULL};
GError *error;
GtkWidget *dialog;
GtkWidget *switch_branch_combo;
- GtkListStore *branch_list_store;
- GitBranchComboData *data;
+ GtkListStore *branch_combo_model;
+ GitUIData *data;
GitBranchListCommand *list_command;
bxml = gtk_builder_new ();
@@ -105,26 +111,21 @@ switch_dialog (Git *plugin)
dialog = GTK_WIDGET (gtk_builder_get_object (bxml, "switch_dialog"));
switch_branch_combo = GTK_WIDGET (gtk_builder_get_object (bxml,
"switch_branch_combo"));
- branch_list_store = git_branch_combo_model_new ();
+ branch_combo_model = GTK_LIST_STORE (gtk_builder_get_object (bxml,
+ "branch_combo_model"));
- gtk_combo_box_set_model (GTK_COMBO_BOX (switch_branch_combo),
- GTK_TREE_MODEL (branch_list_store));
- git_branch_combo_model_setup_widget (switch_branch_combo);
-
- data = git_branch_combo_data_new (branch_list_store,
- GTK_COMBO_BOX (switch_branch_combo), bxml,
- plugin);
+ data = git_ui_data_new (plugin, bxml);
list_command = git_branch_list_command_new (plugin->project_root_directory,
GIT_BRANCH_TYPE_LOCAL);
g_signal_connect (G_OBJECT (list_command), "data-arrived",
- G_CALLBACK (on_git_list_branch_command_data_arrived),
- data);
+ G_CALLBACK (on_git_list_branch_combo_command_data_arrived),
+ branch_combo_model);
g_signal_connect (G_OBJECT (list_command), "command-finished",
- G_CALLBACK (on_git_list_branch_command_finished),
- data);
+ G_CALLBACK (on_git_list_branch_combo_command_finished),
+ switch_branch_combo);
anjuta_command_start (ANJUTA_COMMAND (list_command));
diff --git a/plugins/git/git-switch-dialog.h b/plugins/git/git-switch-dialog.h
index b1101f4..a9c83e1 100644
--- a/plugins/git/git-switch-dialog.h
+++ b/plugins/git/git-switch-dialog.h
@@ -28,7 +28,6 @@
#include "git-branch-list-command.h"
#include "git-branch-checkout-command.h"
#include "git-ui-utils.h"
-#include "git-branch-combo-model.h"
void on_menu_git_switch (GtkAction *action, Git *plugin);
diff --git a/plugins/git/git-ui-utils.c b/plugins/git/git-ui-utils.c
index f7c47c7..837f890 100644
--- a/plugins/git/git-ui-utils.c
+++ b/plugins/git/git-ui-utils.c
@@ -345,27 +345,38 @@ on_git_command_progress (AnjutaCommand *command, gfloat progress,
}
void
-on_git_list_branch_command_data_arrived (AnjutaCommand *command,
- GitBranchComboData *data)
+on_git_list_branch_combo_command_data_arrived (AnjutaCommand *command,
+ GtkListStore *branch_combo_model)
{
GQueue *output_queue;
GitBranch *branch;
+ GtkTreeIter iter;
+ gchar *name;
output_queue = git_branch_list_command_get_output (GIT_BRANCH_LIST_COMMAND (command));
while (g_queue_peek_head (output_queue))
{
branch = g_queue_pop_head (output_queue);
- git_branch_combo_model_append (data->model, branch);
+ name = git_branch_get_name (branch);
+
+ if (!git_branch_is_active (branch))
+ {
+ gtk_list_store_append (branch_combo_model, &iter);
+ gtk_list_store_set (branch_combo_model, &iter, 0, name, -1);
+ }
+
g_object_unref (branch);
+ g_free (name);
}
}
void
-on_git_list_branch_command_finished (AnjutaCommand *command, guint return_code,
- GitBranchComboData *data)
+on_git_list_branch_combo_command_finished (AnjutaCommand *command,
+ guint return_code,
+ GtkComboBox *combo_box)
{
- gtk_combo_box_set_active (data->combo_box, 0);
+ gtk_combo_box_set_active (combo_box, 0);
git_report_errors (command, return_code);
g_object_unref (command);
diff --git a/plugins/git/git-ui-utils.h b/plugins/git/git-ui-utils.h
index ad28488..11a8357 100644
--- a/plugins/git/git-ui-utils.h
+++ b/plugins/git/git-ui-utils.h
@@ -33,7 +33,6 @@
#include "git-status-command.h"
#include "git-diff-command.h"
#include "git-branch-list-command.h"
-#include "git-branch-combo-model.h"
typedef struct
{
@@ -72,11 +71,11 @@ void on_git_status_command_data_arrived (AnjutaCommand *command,
void on_git_command_info_arrived (AnjutaCommand *command, Git *plugin);
void on_git_command_progress (AnjutaCommand *command, gfloat progress,
GitProgressData *data);
-void on_git_list_branch_command_data_arrived (AnjutaCommand *command,
- GitBranchComboData *data);
-void on_git_list_branch_command_finished (AnjutaCommand *command,
- guint return_code,
- GitBranchComboData *data);
+void on_git_list_branch_combo_command_data_arrived (AnjutaCommand *command,
+ GtkListStore *branch_combo_model);
+void on_git_list_branch_combo_command_finished (AnjutaCommand *command,
+ guint return_code,
+ GtkComboBox *combo_box);
void git_select_all_status_items (GtkButton *select_all_button,
AnjutaVcsStatusTreeView *tree_view);
void git_clear_all_status_selections (GtkButton *clear_button,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]