[anjuta] git: Use combo box instead of tree view for remotes
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] git: Use combo box instead of tree view for remotes
- Date: Sun, 11 Dec 2011 11:12:14 +0000 (UTC)
commit 9f5989682f9fc356c940e99601089f0225286ede
Author: Johannes Schmid <jhs gnome org>
Date: Sun Dec 11 12:01:54 2011 +0100
git: Use combo box instead of tree view for remotes
plugins/git/anjuta-git.ui | 30 ++++--------------------
plugins/git/git-remotes-pane.c | 48 +++++++++------------------------------
2 files changed, 16 insertions(+), 62 deletions(-)
---
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index 70e6385..c8e94fb 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -2813,30 +2813,10 @@
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <object class="GtkComboBoxText" id="remotes_combo">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTreeView" id="remotes_view">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="model">remotes_list_model</property>
- <property name="headers_visible">False</property>
- <property name="headers_clickable">False</property>
- <child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn1">
- <property name="title">column</property>
- <child>
- <object class="GtkCellRendererText" id="name_renderer"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- </child>
- </object>
- </child>
+ <property name="can_focus">False</property>
+ <property name="entry-text-column">0</property>
</object>
</child>
</object>
@@ -2853,8 +2833,8 @@
</child>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
diff --git a/plugins/git/git-remotes-pane.c b/plugins/git/git-remotes-pane.c
index 7cfae46..a75dd92 100644
--- a/plugins/git/git-remotes-pane.c
+++ b/plugins/git/git-remotes-pane.c
@@ -23,30 +23,11 @@ struct _GitRemotesPanePriv
{
GtkBuilder *builder;
gchar *selected_remote;
+ GtkWidget* remotes_combo;
};
G_DEFINE_TYPE (GitRemotesPane, git_remotes_pane, GIT_TYPE_PANE);
-static gboolean
-on_remote_selected (GtkTreeSelection *selection, GtkTreeModel *model,
- GtkTreePath *path, gboolean path_currently_selected,
- GitRemotesPane *self)
-{
- GtkTreeIter iter;
-
- if (!path_currently_selected)
- {
- gtk_tree_model_get_iter (model, &iter, path);
-
- g_free (self->priv->selected_remote);
- gtk_tree_model_get (model, &iter, 0, &(self->priv->selected_remote), -1);
-
- anjuta_dock_pane_notify_single_selection_changed (ANJUTA_DOCK_PANE (self));
- }
-
- return TRUE;
-}
-
static void
git_remotes_pane_init (GitRemotesPane *self)
{
@@ -54,8 +35,6 @@ git_remotes_pane_init (GitRemotesPane *self)
"remotes_list_model",
NULL};
GError *error = NULL;
- GtkTreeView *remotes_view;
- GtkTreeSelection *selection;
self->priv = g_new0 (GitRemotesPanePriv, 1);
self->priv->builder = gtk_builder_new ();
@@ -68,14 +47,8 @@ git_remotes_pane_init (GitRemotesPane *self)
g_error_free (error);
}
- remotes_view = GTK_TREE_VIEW (gtk_builder_get_object (self->priv->builder,
- "remotes_view"));
- selection = gtk_tree_view_get_selection (remotes_view);
-
-
- gtk_tree_selection_set_select_function (selection,
- (GtkTreeSelectionFunc) on_remote_selected,
- self, NULL);
+ self->priv->remotes_combo = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+ "remotes_combo"));
}
static void
@@ -118,21 +91,22 @@ static void
on_remote_list_command_data_arrived (AnjutaCommand *command,
GitRemotesPane *self)
{
- GtkListStore *remotes_list_model;
GQueue *output;
gchar *remote;
- GtkTreeIter iter;
- remotes_list_model = GTK_LIST_STORE (gtk_builder_get_object (self->priv->builder,
- "remotes_list_model"));
output = git_raw_output_command_get_output (GIT_RAW_OUTPUT_COMMAND (command));
while (g_queue_peek_head (output))
{
remote = g_queue_pop_head (output);
- gtk_list_store_append (remotes_list_model, &iter);
- gtk_list_store_set (remotes_list_model, &iter, 0, remote, -1);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(self->priv->remotes_combo),
+ remote);
+ if (gtk_combo_box_get_active (GTK_COMBO_BOX (self->priv->remotes_combo))
+ == -1)
+ {
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->remotes_combo), 0);
+ }
g_free (remote);
}
@@ -163,5 +137,5 @@ git_remotes_pane_new (Git *plugin)
gchar *
git_remotes_pane_get_selected_remote (GitRemotesPane *self)
{
- return g_strdup (self->priv->selected_remote);
+ return gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (self->priv->remotes_combo));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]