~kroq-gar78/ubuntu/precise/gnome-control-center/fix-885947

« back to all changes in this revision

Viewing changes to libslab/tile-action.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya
  • Date: 2011-05-17 10:47:27 UTC
  • mfrom: (0.1.11 experimental) (1.1.45 upstream)
  • Revision ID: james.westby@ubuntu.com-20110517104727-lqel6m8vhfw5jby1
Tags: 1:3.0.1.1-1ubuntu1
* Rebase on Debian, remaining Ubuntu changes:
* debian/control:
  - Build-Depend on hardening-wrapper, dpkg-dev and dh-autoreconf
  - Add dependency on ubuntu-system-service
  - Remove dependency on gnome-icon-theme-symbolic
  - Move dependency on apg, gnome-icon-theme-symbolic and accountsservice to
    be a Recommends: until we get them in main
* debian/rules:
  - Use autoreconf
  - Add binary-post-install rule for gnome-control-center-data
  - Run dh-autoreconf
* debian/gnome-control-center.dirs:
* debian/gnome-control-center.links:
  - Add a link to the control center shell for indicators
* debian/patches/00_disable-nm.patch:
  - Temporary patch to disable building with NetworkManager until we get
    the new one in the archive
* debian/patches/01_git_remove_gettext_calls.patch:
  - Remove calls to AM_GNU_GETTEXT, IT_PROG_INTLTOOL should be enough
* debian/patches/01_git_kill_warning.patch:
  - Kill warning
* debian/patches/50_ubuntu_systemwide_prefs.patch:
  - Ubuntu specific proxy preferences
* debian/patches/51_ubuntu_system_keyboard.patch:
  - Implement the global keyboard spec at https://wiki.ubuntu.com/DefaultKeyboardSettings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * This file is part of libtile.
3
 
 *
4
 
 * Copyright (c) 2006 Novell, Inc.
5
 
 *
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)
9
 
 * any later version.
10
 
 *
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
14
 
 * more details.
15
 
 *
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
19
 
 */
20
 
 
21
 
#include "tile.h"
22
 
 
23
 
G_DEFINE_TYPE (TileAction, tile_action, G_TYPE_OBJECT)
24
 
 
25
 
static void tile_action_finalize (GObject *);
26
 
static void tile_action_menu_item_activate_cb (GtkMenuItem *, gpointer);
27
 
 
28
 
static void tile_action_class_init (TileActionClass * this_class)
29
 
{
30
 
        GObjectClass *g_obj_class = G_OBJECT_CLASS (this_class);
31
 
 
32
 
        g_obj_class->finalize = tile_action_finalize;
33
 
}
34
 
 
35
 
static void
36
 
tile_action_init (TileAction * this)
37
 
{
38
 
        this->tile = NULL;
39
 
        this->func = 0;
40
 
        this->menu_item = NULL;
41
 
        this->flags = 0;
42
 
}
43
 
 
44
 
static void
45
 
tile_action_finalize (GObject * g_object)
46
 
{
47
 
        TileAction *action = TILE_ACTION (g_object);
48
 
        if (action->menu_item)
49
 
                gtk_widget_destroy (GTK_WIDGET (action->menu_item));
50
 
 
51
 
        (*G_OBJECT_CLASS (tile_action_parent_class)->finalize) (g_object);
52
 
}
53
 
 
54
 
TileAction *
55
 
tile_action_new (Tile * tile, TileActionFunc func, const gchar * menu_item_markup, guint32 flags)
56
 
{
57
 
        TileAction *this = g_object_new (TILE_ACTION_TYPE, NULL);
58
 
 
59
 
        this->tile = tile;
60
 
        this->func = func;
61
 
 
62
 
        if (menu_item_markup)
63
 
                tile_action_set_menu_item_label (this, menu_item_markup);
64
 
        else
65
 
                this->menu_item = NULL;
66
 
 
67
 
        this->flags = flags;
68
 
 
69
 
        return this;
70
 
}
71
 
 
72
 
void
73
 
tile_action_set_menu_item_label (TileAction * this, const gchar * markup)
74
 
{
75
 
        GtkWidget *label;
76
 
 
77
 
        if (this->menu_item)
78
 
        {
79
 
                label = gtk_bin_get_child (GTK_BIN (this->menu_item));
80
 
                gtk_label_set_markup (GTK_LABEL (label), markup);
81
 
        }
82
 
        else
83
 
        {
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);
87
 
 
88
 
                this->menu_item = GTK_MENU_ITEM (gtk_menu_item_new ());
89
 
                gtk_container_add (GTK_CONTAINER (this->menu_item), label);
90
 
 
91
 
                g_signal_connect (G_OBJECT (this->menu_item), "activate",
92
 
                        G_CALLBACK (tile_action_menu_item_activate_cb), this);
93
 
        }
94
 
}
95
 
 
96
 
GtkMenuItem *
97
 
tile_action_get_menu_item (TileAction * this)
98
 
{
99
 
        return this->menu_item;
100
 
}
101
 
 
102
 
static void
103
 
tile_action_menu_item_activate_cb (GtkMenuItem * menu_item, gpointer user_data)
104
 
{
105
 
        TileAction *this = TILE_ACTION (user_data);
106
 
 
107
 
        tile_trigger_action (this->tile, this);
108
 
}