Skip to content

Commit 2e33fc8

Browse files
author
Jesse van den Kieboom
committed
Added special 'All branches' item in the branches combo box
1 parent 5e38bc7 commit 2e33fc8

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

gitg/gitg-window.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,16 @@ on_branches_combo_changed(GtkComboBox *combo, GitgWindow *window)
256256

257257
gchar *name;
258258
GtkTreeIter iter;
259+
GtkTreeIter next;
259260

260261
gtk_combo_box_get_active_iter(combo, &iter);
261-
gtk_tree_model_get(gtk_combo_box_get_model(combo), &iter, 0, &name, -1);
262+
next = iter;
262263

264+
if (!gtk_tree_model_iter_next(gtk_combo_box_get_model(combo), &next))
265+
name = g_strdup("--all");
266+
else
267+
gtk_tree_model_get(gtk_combo_box_get_model(combo), &iter, 0, &name, -1);
268+
263269
gitg_repository_load(window->priv->repository, 1, (gchar const **)&name, NULL);
264270
g_free(name);
265271
}
@@ -505,6 +511,7 @@ fill_branches_combo(GitgWindow *window)
505511
refs = g_slist_sort(refs, (GCompareFunc)sort_by_ref_type);
506512
GSList *item;
507513
GitgRefType prevtype = GITG_REF_TYPE_NONE;
514+
GtkTreeIter iter;
508515

509516
for (item = refs; item; item = item->next)
510517
{
@@ -514,8 +521,6 @@ fill_branches_combo(GitgWindow *window)
514521
ref->type == GITG_REF_TYPE_BRANCH))
515522
continue;
516523

517-
GtkTreeIter iter;
518-
519524
if (ref->type != prevtype)
520525
{
521526
gtk_list_store_append(window->priv->branches_store, &iter);
@@ -531,6 +536,12 @@ fill_branches_combo(GitgWindow *window)
531536
gtk_combo_box_set_active_iter(window->priv->combo_branches, &iter);
532537
}
533538

539+
gtk_list_store_append(window->priv->branches_store, &iter);
540+
gtk_list_store_set(window->priv->branches_store, &iter, 0, NULL, -1);
541+
542+
gtk_list_store_append(window->priv->branches_store, &iter);
543+
gtk_list_store_set(window->priv->branches_store, &iter, 0, _("All branches"), -1);
544+
534545
if (!window->priv->current_branch)
535546
gtk_combo_box_set_active(window->priv->combo_branches, 0);
536547

0 commit comments

Comments
 (0)