==11430== 48 (24 direct, 24 indirect) bytes in 1 blocks are definitely lost in loss record 10,663 of 18,7 ==11430== at 0x4A06C50: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==11430== by 0x7F260AC: g_malloc (gmem.c:97) ==11430== by 0x7F3F0F7: g_slice_alloc (gslice.c:1007) ==11430== by 0x7F19BE5: g_list_prepend (glist.c:311) ==11430== by 0x684843B: accum_cells (gtkcellarea.c:1563) ==11430== by 0x6850989: gtk_cell_area_box_foreach (gtkcellareabox.c:1145) ==11430== by 0x6848AAA: gtk_cell_area_foreach (gtkcellarea.c:1730) ==11430== by 0x6848490: gtk_cell_area_get_cells (gtkcellarea.c:1573) ==11430== by 0x6857339: gtk_cell_layout_get_cells (gtkcelllayout.c:592) ==11430== by 0x685668F: gtk_cell_layout_default_get_cells (gtkcelllayout.c:342) ==11430== by 0x6857339: gtk_cell_layout_get_cells (gtkcelllayout.c:592) ==11430== by 0x45242B: cc_shell_item_view_update_cells (cc-shell-item-view.c:116) ==11430== by 0x451DDD: cc_shell_category_view_constructed (cc-shell-category-view.c:141) ==11430== by 0x7C8DC10: g_object_new_internal (gobject.c:1814) ==11430== by 0x7C8E71A: g_object_new_valist (gobject.c:2033) ==11430== by 0x7C8D6C5: g_object_new (gobject.c:1617) ==11430== by 0x4520AB: cc_shell_category_view_new (cc-shell-category-view.c:213) ==11430== by 0x44F5D2: add_category_view (cc-window.c:852) ==11430== by 0x44F78B: setup_model (cc-window.c:880) ==11430== by 0x450EBC: create_main_page (cc-window.c:1460) ==11430== by 0x4514F1: create_window (cc-window.c:1553) ==11430== by 0x45170A: cc_window_init (cc-window.c:1587) ==11430== by 0x7CA6E7D: g_type_create_instance (gtype.c:1870) ==11430== by 0x7C8DAC5: g_object_new_internal (gobject.c:1774) ==11430== by 0x7C8E71A: g_object_new_valist (gobject.c:2033) ==11430== by 0x7C8D6C5: g_object_new (gobject.c:1617) ==11430== by 0x451847: cc_window_new (cc-window.c:1602) ==11430== by 0x44D409: cc_application_startup (cc-application.c:262) ==11430== by 0x7C8827D: g_cclosure_marshal_VOID__VOIDv (gmarshal.c:905) ==11430== by 0x7C8590F: g_type_class_meta_marshalv (gclosure.c:1021) ==11430== by 0x7C854D1: _g_closure_invoke_va (gclosure.c:864) ==11430== by 0x7CA0771: g_signal_emit_valist (gsignal.c:3246) ==11430== by 0x7CA18E9: g_signal_emit (gsignal.c:3393) ==11430== by 0x7982671: g_application_register (gapplication.c:2015) ==11430== by 0x79808D2: g_application_real_local_command_line (gapplication.c:983) ==11430== by 0x68143D6: gtk_application_local_command_line (gtkapplication.c:638) ==11430== by 0x7982D4D: g_application_run (gapplication.c:2280) ==11430== by 0x44C96B: main (main.c:57) https://bugzilla.gnome.org/show_bug.cgi?id=756762
173 lines
4.8 KiB
C
173 lines
4.8 KiB
C
/*
|
|
* Copyright (c) 2010 Intel, Inc.
|
|
*
|
|
* The Control Center is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by the
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
* option) any later version.
|
|
*
|
|
* The Control Center is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
* for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with the Control Center; if not, write to the Free Software Foundation,
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*
|
|
* Author: Thomas Wood <thos@gnome.org>
|
|
*/
|
|
|
|
#include "cc-shell-item-view.h"
|
|
#include "cc-shell-model.h"
|
|
|
|
G_DEFINE_TYPE (CcShellItemView, cc_shell_item_view, GTK_TYPE_ICON_VIEW)
|
|
|
|
#define SHELL_ITEM_VIEW_PRIVATE(o) \
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_SHELL_ITEM_VIEW, CcShellItemViewPrivate))
|
|
|
|
struct _CcShellItemViewPrivate
|
|
{
|
|
gpointer padding;
|
|
};
|
|
|
|
|
|
enum
|
|
{
|
|
DESKTOP_ITEM_ACTIVATED,
|
|
|
|
LAST_SIGNAL
|
|
};
|
|
|
|
static guint signals[LAST_SIGNAL] = {0,};
|
|
|
|
static void
|
|
cc_shell_item_view_get_property (GObject *object,
|
|
guint property_id,
|
|
GValue *value,
|
|
GParamSpec *pspec)
|
|
{
|
|
switch (property_id)
|
|
{
|
|
default:
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
}
|
|
}
|
|
|
|
static void
|
|
cc_shell_item_view_set_property (GObject *object,
|
|
guint property_id,
|
|
const GValue *value,
|
|
GParamSpec *pspec)
|
|
{
|
|
switch (property_id)
|
|
{
|
|
default:
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
}
|
|
}
|
|
|
|
static void
|
|
cc_shell_item_view_dispose (GObject *object)
|
|
{
|
|
G_OBJECT_CLASS (cc_shell_item_view_parent_class)->dispose (object);
|
|
}
|
|
|
|
static void
|
|
cc_shell_item_view_finalize (GObject *object)
|
|
{
|
|
G_OBJECT_CLASS (cc_shell_item_view_parent_class)->finalize (object);
|
|
}
|
|
|
|
static void
|
|
iconview_item_activated_cb (GtkIconView *icon_view,
|
|
GtkTreePath *path,
|
|
CcShellItemView *cc_view)
|
|
{
|
|
GtkTreeModel *model;
|
|
GtkTreeIter iter;
|
|
gchar *name, *id;
|
|
|
|
model = gtk_icon_view_get_model (icon_view);
|
|
|
|
gtk_icon_view_unselect_all (icon_view);
|
|
|
|
/* get the iter and ensure it is valid */
|
|
if (!gtk_tree_model_get_iter (model, &iter, path))
|
|
return;
|
|
|
|
gtk_tree_model_get (model, &iter,
|
|
COL_NAME, &name,
|
|
COL_ID, &id,
|
|
-1);
|
|
|
|
g_signal_emit (cc_view, signals[DESKTOP_ITEM_ACTIVATED], 0,
|
|
name, id);
|
|
|
|
g_free (name);
|
|
g_free (id);
|
|
}
|
|
|
|
void
|
|
cc_shell_item_view_update_cells (CcShellItemView *view)
|
|
{
|
|
GList *cells, *l;
|
|
|
|
cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (view));
|
|
for (l = cells ; l != NULL; l = l->next)
|
|
{
|
|
GtkCellRenderer *cell = l->data;
|
|
|
|
if (GTK_IS_CELL_RENDERER_TEXT (cell)) {
|
|
g_object_set (G_OBJECT (cell),
|
|
"wrap-mode", PANGO_WRAP_WORD,
|
|
NULL);
|
|
/* We only have one text cell */
|
|
break;
|
|
}
|
|
}
|
|
g_list_free (cells);
|
|
}
|
|
|
|
static void
|
|
cc_shell_item_view_class_init (CcShellItemViewClass *klass)
|
|
{
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
g_type_class_add_private (klass, sizeof (CcShellItemViewPrivate));
|
|
|
|
object_class->get_property = cc_shell_item_view_get_property;
|
|
object_class->set_property = cc_shell_item_view_set_property;
|
|
object_class->dispose = cc_shell_item_view_dispose;
|
|
object_class->finalize = cc_shell_item_view_finalize;
|
|
|
|
signals[DESKTOP_ITEM_ACTIVATED] = g_signal_new ("desktop-item-activated",
|
|
CC_TYPE_SHELL_ITEM_VIEW,
|
|
G_SIGNAL_RUN_FIRST,
|
|
0,
|
|
NULL,
|
|
NULL,
|
|
g_cclosure_marshal_generic,
|
|
G_TYPE_NONE,
|
|
2,
|
|
G_TYPE_STRING,
|
|
G_TYPE_STRING);
|
|
}
|
|
|
|
static void
|
|
cc_shell_item_view_init (CcShellItemView *self)
|
|
{
|
|
self->priv = SHELL_ITEM_VIEW_PRIVATE (self);
|
|
|
|
g_object_set (self, "margin", 0, NULL);
|
|
g_signal_connect (self, "item-activated",
|
|
G_CALLBACK (iconview_item_activated_cb), self);
|
|
}
|
|
|
|
GtkWidget *
|
|
cc_shell_item_view_new (void)
|
|
{
|
|
return g_object_new (CC_TYPE_SHELL_ITEM_VIEW,
|
|
"activate-on-single-click", TRUE,
|
|
NULL);
|
|
}
|