2
* Copyright (c) 2011 Red Hat, Inc.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or (at your
7
* option) any later version.
9
* This program is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12
* License for more details.
14
* You should have received a copy of the GNU Lesser General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
* Author: Cosimo Cecchi <cosimoc@redhat.com>
22
#include "gd-main-view.h"
23
#include "gd-main-view-generic.h"
25
typedef GdMainViewGenericIface GdMainViewGenericInterface;
26
G_DEFINE_INTERFACE (GdMainViewGeneric, gd_main_view_generic, GTK_TYPE_WIDGET)
33
static guint signals[LAST_SIGNAL] = { 0 };
36
gd_main_view_generic_default_init (GdMainViewGenericInterface *iface)
38
signals[DELETE_ITEM_CLICKED] =
39
g_signal_new ("delete-item-clicked",
40
GD_TYPE_MAIN_VIEW_GENERIC,
49
* gd_main_view_generic_set_model:
51
* @model: (allow-none):
55
gd_main_view_generic_set_model (GdMainViewGeneric *self,
58
GdMainViewGenericInterface *iface;
60
iface = GD_MAIN_VIEW_GENERIC_GET_IFACE (self);
62
(* iface->set_model) (self, model);
66
gd_main_view_generic_get_path_at_pos (GdMainViewGeneric *self,
70
GdMainViewGenericInterface *iface;
72
iface = GD_MAIN_VIEW_GENERIC_GET_IFACE (self);
74
return (* iface->get_path_at_pos) (self, x, y);
78
gd_main_view_generic_set_selection_mode (GdMainViewGeneric *self,
79
gboolean selection_mode)
81
GdMainViewGenericInterface *iface;
83
iface = GD_MAIN_VIEW_GENERIC_GET_IFACE (self);
85
(* iface->set_selection_mode) (self, selection_mode);
89
gd_main_view_generic_scroll_to_path (GdMainViewGeneric *self,
92
GdMainViewGenericInterface *iface;
94
iface = GD_MAIN_VIEW_GENERIC_GET_IFACE (self);
96
(* iface->scroll_to_path) (self, path);
100
build_selection_uris_foreach (GtkTreeModel *model,
105
GPtrArray *ptr_array = user_data;
107
gboolean is_selected;
109
gtk_tree_model_get (model, iter,
110
GD_MAIN_COLUMN_URI, &uri,
111
GD_MAIN_COLUMN_SELECTED, &is_selected,
115
g_ptr_array_add (ptr_array, uri);
123
model_get_selection_uris (GtkTreeModel *model)
125
GPtrArray *ptr_array = g_ptr_array_new ();
127
gtk_tree_model_foreach (model,
128
build_selection_uris_foreach,
131
g_ptr_array_add (ptr_array, NULL);
132
return (gchar **) g_ptr_array_free (ptr_array, FALSE);
136
_gd_main_view_generic_dnd_common (GtkTreeModel *model,
137
gboolean selection_mode,
139
GtkSelectionData *data)
145
uris = model_get_selection_uris (model);
155
res = gtk_tree_model_get_iter (model, &iter, path);
157
gtk_tree_model_get (model, &iter,
158
GD_MAIN_COLUMN_URI, &uri,
162
uris = g_new0 (gchar *, 2);
167
gtk_selection_data_set_uris (data, uris);
172
_gd_main_view_generic_item_delete_clicked (GdMainViewGeneric *self,
175
g_signal_emit (self, signals[DELETE_ITEM_CLICKED], 0, path);