1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2010 <jrliggett@cox.net>
6 * anjuta is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * anjuta is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "git-remotes-pane.h"
22 struct _GitRemotesPanePriv
25 gchar
*selected_remote
;
26 GtkWidget
* remotes_combo
;
29 G_DEFINE_TYPE (GitRemotesPane
, git_remotes_pane
, GIT_TYPE_PANE
);
32 git_remotes_pane_init (GitRemotesPane
*self
)
34 gchar
*objects
[] = {"remotes_pane",
39 self
->priv
= g_new0 (GitRemotesPanePriv
, 1);
40 self
->priv
->builder
= gtk_builder_new ();
42 if (!gtk_builder_add_objects_from_file (self
->priv
->builder
, BUILDER_FILE
,
46 g_warning ("Couldn't load builder file: %s", error
->message
);
50 self
->priv
->remotes_combo
= GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
55 git_remotes_pane_finalize (GObject
*object
)
59 self
= GIT_REMOTES_PANE (object
);
61 g_object_unref (self
->priv
->builder
);
62 g_free (self
->priv
->selected_remote
);
65 G_OBJECT_CLASS (git_remotes_pane_parent_class
)->finalize (object
);
69 git_remotes_pane_get_widget (AnjutaDockPane
*pane
)
73 self
= GIT_REMOTES_PANE (pane
);
75 return GTK_WIDGET (gtk_builder_get_object (self
->priv
->builder
,
80 git_remotes_pane_class_init (GitRemotesPaneClass
*klass
)
82 GObjectClass
* object_class
= G_OBJECT_CLASS (klass
);
83 AnjutaDockPaneClass
* pane_class
= ANJUTA_DOCK_PANE_CLASS (klass
);
85 object_class
->finalize
= git_remotes_pane_finalize
;
86 pane_class
->get_widget
= git_remotes_pane_get_widget
;
87 pane_class
->refresh
= NULL
;
91 on_remote_list_command_data_arrived (AnjutaCommand
*command
,
97 output
= git_raw_output_command_get_output (GIT_RAW_OUTPUT_COMMAND (command
));
99 while (g_queue_peek_head (output
))
101 remote
= g_queue_pop_head (output
);
103 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(self
->priv
->remotes_combo
),
105 if (gtk_combo_box_get_active (GTK_COMBO_BOX (self
->priv
->remotes_combo
))
108 gtk_combo_box_set_active (GTK_COMBO_BOX (self
->priv
->remotes_combo
), 0);
116 git_remotes_pane_new (Git
*plugin
)
118 GitRemotesPane
*self
;
119 GtkListStore
*remotes_list_model
;
121 self
= g_object_new (GIT_TYPE_REMOTES_PANE
, "plugin", plugin
, NULL
);
122 remotes_list_model
= GTK_LIST_STORE (gtk_builder_get_object (self
->priv
->builder
,
123 "remotes_list_model"));
125 g_signal_connect_swapped (G_OBJECT (plugin
->remote_list_command
),
127 G_CALLBACK (gtk_list_store_clear
),
130 g_signal_connect (G_OBJECT (plugin
->remote_list_command
), "data-arrived",
131 G_CALLBACK (on_remote_list_command_data_arrived
),
134 return ANJUTA_DOCK_PANE (self
);
138 git_remotes_pane_get_selected_remote (GitRemotesPane
*self
)
140 return gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (self
->priv
->remotes_combo
));