2
* This file is part of libtile.
4
* Copyright (c) 2006 Novell, Inc.
6
* Libtile is free software; you can redistribute it and/or modify it under the
7
* terms of the GNU Lesser General Public License as published by the Free
8
* Software Foundation; either version 2 of the License, or (at your option)
11
* Libtile is distributed in the hope that it will be useful, but WITHOUT ANY
12
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with libslab; if not, write to the Free Software Foundation, Inc., 51
18
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
G_DEFINE_TYPE (TileAction, tile_action, G_TYPE_OBJECT)
25
static void tile_action_finalize (GObject *);
26
static void tile_action_menu_item_activate_cb (GtkMenuItem *, gpointer);
28
static void tile_action_class_init (TileActionClass * this_class)
30
GObjectClass *g_obj_class = G_OBJECT_CLASS (this_class);
32
g_obj_class->finalize = tile_action_finalize;
36
tile_action_init (TileAction * this)
40
this->menu_item = NULL;
45
tile_action_finalize (GObject * g_object)
47
TileAction *action = TILE_ACTION (g_object);
48
if (action->menu_item)
49
gtk_widget_destroy (GTK_WIDGET (action->menu_item));
51
(*G_OBJECT_CLASS (tile_action_parent_class)->finalize) (g_object);
55
tile_action_new (Tile * tile, TileActionFunc func, const gchar * menu_item_markup, guint32 flags)
57
TileAction *this = g_object_new (TILE_ACTION_TYPE, NULL);
63
tile_action_set_menu_item_label (this, menu_item_markup);
65
this->menu_item = NULL;
73
tile_action_set_menu_item_label (TileAction * this, const gchar * markup)
79
label = gtk_bin_get_child (GTK_BIN (this->menu_item));
80
gtk_label_set_markup (GTK_LABEL (label), markup);
84
label = gtk_label_new (markup);
85
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
86
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
88
this->menu_item = GTK_MENU_ITEM (gtk_menu_item_new ());
89
gtk_container_add (GTK_CONTAINER (this->menu_item), label);
91
g_signal_connect (G_OBJECT (this->menu_item), "activate",
92
G_CALLBACK (tile_action_menu_item_activate_cb), this);
97
tile_action_get_menu_item (TileAction * this)
99
return this->menu_item;
103
tile_action_menu_item_activate_cb (GtkMenuItem * menu_item, gpointer user_data)
105
TileAction *this = TILE_ACTION (user_data);
107
tile_trigger_action (this->tile, this);