~ubuntu-branches/ubuntu/lucid/giggle/lucid

« back to all changes in this revision

Viewing changes to src/giggle-tree-view-helpers.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrea Corradi
  • Date: 2009-03-30 19:41:43 UTC
  • mfrom: (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090330194143-nyr9ze1xola1shm5
Tags: 0.4.91-1
* New upstream release (Closes:  #519014)
* Use Standards-Version 3.8.1
* Add new Build-Depends
* Update Homepage and watch file
* Update debian/copyright
* Remove patch
* Update path in debian/rules
* Remove defs option from LDFLAGS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
 
/*
3
 
 * Copyright (C) 2007 Imendio AB
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or
6
 
 * modify it under the terms of the GNU General Public License as
7
 
 * published by the Free Software Foundation; either version 2 of the
8
 
 * License, or (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 
 * General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public
16
 
 * License along with this program; if not, write to the
17
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
 
 * Boston, MA 02111-1307, USA.
19
 
 */
20
 
 
21
 
#include <config.h>
22
 
 
23
 
#include "giggle-tree-view-helpers.h"
24
 
 
25
 
#include <gdk/gdkkeysyms.h>
26
 
#include <gtk/gtktreeselection.h>
27
 
 
28
 
static void
29
 
remote_editor_tree_selection_get_branches (GtkTreeModel *model,
30
 
                                           GtkTreePath  *path,
31
 
                                           GtkTreeIter  *iter,
32
 
                                           GList       **branches)
33
 
{
34
 
        *branches = g_list_prepend (*branches, gtk_tree_row_reference_new (model, path));
35
 
}
36
 
 
37
 
static void
38
 
remote_editor_remove_branch (GtkTreeRowReference *ref)
39
 
{
40
 
        GtkTreeModel *model;
41
 
        GtkTreeIter   iter;
42
 
 
43
 
        model = gtk_tree_row_reference_get_model (ref);
44
 
        gtk_tree_model_get_iter (model, &iter,
45
 
                                 gtk_tree_row_reference_get_path (ref));
46
 
        gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
47
 
 
48
 
        gtk_tree_row_reference_free (ref);
49
 
}
50
 
 
51
 
gboolean
52
 
tree_view_delete_selection_on_list_store (GtkWidget   *treeview,
53
 
                                          GdkEventKey *event)
54
 
{
55
 
        if (event->keyval == GDK_Delete) {
56
 
                GtkTreeSelection* sel;
57
 
                sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
58
 
 
59
 
                if (gtk_tree_selection_count_selected_rows (sel) > 0) {
60
 
                        GList* branches = NULL;
61
 
                        gtk_tree_selection_selected_foreach (sel,
62
 
                                                             (GtkTreeSelectionForeachFunc)
63
 
                                                                remote_editor_tree_selection_get_branches,
64
 
                                                             &branches);
65
 
                        g_list_foreach (branches, (GFunc)remote_editor_remove_branch, NULL);
66
 
                        g_list_free (branches);
67
 
                        return TRUE;
68
 
                }
69
 
        }
70
 
        return FALSE;
71
 
}
72