1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2008 <jrliggett@cox.net>
6 * anjuta is free software.
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
13 * anjuta is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with anjuta. If not, write to:
20 * The Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02110-1301, USA.
25 #include "git-branch-combo-model.h"
36 git_branch_combo_data_new (GtkListStore
*model
, GtkComboBox
*combo_box
,
37 GladeXML
*gxml
, Git
*plugin
)
39 GitBranchComboData
*data
;
41 data
= g_new0 (GitBranchComboData
, 1);
43 data
->combo_box
= combo_box
;
45 data
->plugin
= plugin
;
51 git_branch_combo_data_free (GitBranchComboData
*data
)
53 g_object_unref (data
->gxml
);
58 git_branch_combo_model_new (void)
60 return gtk_list_store_new (NUM_COLS
, G_TYPE_STRING
, G_TYPE_STRING
);
64 git_branch_combo_model_setup_widget (GtkWidget
*widget
)
66 GtkCellRenderer
*renderer
;
69 renderer
= gtk_cell_renderer_pixbuf_new ();
70 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget
), renderer
, FALSE
);
71 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (widget
), renderer
,
72 "stock-id", COL_ACTIVE
);
75 renderer
= gtk_cell_renderer_text_new ();
76 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget
), renderer
, FALSE
);
77 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (widget
), renderer
,
82 git_branch_combo_model_append (GtkListStore
*model
, GitBranch
*branch
)
87 name
= git_branch_get_name (branch
);
89 gtk_list_store_append (model
, &iter
);
90 gtk_list_store_set (model
, &iter
, COL_NAME
, name
, -1);
92 if (git_branch_is_active (branch
))
93 gtk_list_store_set (model
, &iter
, COL_ACTIVE
, GTK_STOCK_YES
, -1);
99 git_branch_combo_model_get_branch (GtkListStore
*model
, GtkTreeIter
*iter
)
103 gtk_tree_model_get (GTK_TREE_MODEL (model
), iter
, COL_NAME
, &branch
, -1);