GTK+2 panel 

GTK+2 panel Git Source Tree

Root/libgpwidgets/gpw-tasklist.c

1/* Gtk2Panel - A bleeding edge Gtk+2 panel
2 * Copyright (C) 2009 Nicola Fontana <ntd at entidi.it>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20
21/**
22 * SECTION:gpw-tasklist
23 * @title: GpwTasklist
24 * @short_description: A wrapper for #WnckTasklist
25 *
26 * The original tasklist provided by libwnck does not expose its
27 * internals as properties and this limits a lot of glade customizations.
28 * This wrapper simply implements the available features as properties.
29 **/
30
31/**
32 * GpwTasklist:
33 *
34 * All fields are private and should not be used directly.
35 * Use its public methods instead.
36 **/
37
38
39#include "gpw-wnck.h"
40#include "gpw-tasklist.h"
41#include "gpw-tasklist-private.h"
42#include "gpw-intl.h"
43
44
45enum {
46 PROP_0,
47 PROP_GROUPING_POLICY,
48 PROP_GROUPING_LIMIT,
49 PROP_RELIEF_STYLE
50};
51
52
53static void get_property (GObject *object,
54 guint prop_id,
55 GValue *value,
56 GParamSpec *pspec);
57static void set_property (GObject *object,
58 guint prop_id,
59 const GValue *value,
60 GParamSpec *pspec);
61
62
63G_DEFINE_TYPE(GpwTasklist, gpw_tasklist, WNCK_TYPE_TASKLIST);
64
65
66static void
67gpw_tasklist_class_init(GpwTasklistClass *klass)
68{
69 GObjectClass *gobject_class;
70 GParamSpec *param;
71
72 gobject_class = (GObjectClass *) klass;
73
74 g_type_class_add_private(klass, sizeof(GpwTasklistPrivate));
75
76 gobject_class->get_property = get_property;
77 gobject_class->set_property = set_property;
78
79 param = g_param_spec_enum("grouping-policy",
80 P_("Grouping Policy"),
81 P_("Type defining the policy of the WnckTasklist for grouping multiple WnckWindow of the same WnckApplication"),
82 WNCK_TYPE_TASKLIST_GROUPING_TYPE,
83 WNCK_TASKLIST_NEVER_GROUP,
84 G_PARAM_READWRITE);
85 g_object_class_install_property(gobject_class, PROP_GROUPING_POLICY, param);
86
87 param = g_param_spec_int("grouping-limit",
88 P_("Grouping Limit"),
89 P_("Maximum size of buttons before grouping when in autogroup mode"),
90 0, G_MAXINT, 150,
91 G_PARAM_READWRITE);
92 g_object_class_install_property(gobject_class, PROP_GROUPING_LIMIT, param);
93
94 param = g_param_spec_enum("button-relief",
95 P_("Button Relief"),
96 P_("Relief type of the buttons"),
97 GTK_TYPE_RELIEF_STYLE,
98 GTK_RELIEF_NORMAL,
99 G_PARAM_READWRITE);
100 g_object_class_install_property(gobject_class, PROP_RELIEF_STYLE, param);
101}
102
103static void
104gpw_tasklist_init(GpwTasklist *gpw_tasklist)
105{
106 WnckTasklist *tasklist;
107 GpwTasklistPrivate *data;
108
109 tasklist = (WnckTasklist *) gpw_tasklist;
110 data = G_TYPE_INSTANCE_GET_PRIVATE(tasklist, GPW_TYPE_TASKLIST,
111 GpwTasklistPrivate);
112
113 data->grouping_policy = WNCK_TASKLIST_NEVER_GROUP;
114 data->grouping_limit = 150;
115 data->relief_style = GTK_RELIEF_NORMAL;
116
117 /* Force the default behaviours of the tasklist,
118 * as I am not sure what is their default values */
119 wnck_tasklist_set_grouping(tasklist, data->grouping_policy);
120 wnck_tasklist_set_grouping_limit(tasklist, data->grouping_limit);
121 wnck_tasklist_set_button_relief(tasklist, data->relief_style);
122
123 gpw_tasklist->data = data;
124}
125
126static void
127get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
128{
129 GpwTasklistPrivate *data = GPW_TASKLIST_GET_DATA(object);
130
131 switch (prop_id) {
132 case PROP_GROUPING_POLICY:
133 g_value_set_enum(value, data->grouping_policy);
134 break;
135 case PROP_GROUPING_LIMIT:
136 g_value_set_int(value, data->grouping_limit);
137 break;
138 case PROP_RELIEF_STYLE:
139 g_value_set_enum(value, data->relief_style);
140 break;
141 default:
142 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
143 break;
144 }
145}
146
147static void
148set_property(GObject *object,
149 guint prop_id, const GValue *value, GParamSpec *pspec)
150{
151 GpwTasklist *tasklist;
152 GpwTasklistPrivate *data;
153
154 tasklist = (GpwTasklist *) object;
155 data = GPW_TASKLIST_GET_DATA(object);
156
157 switch (prop_id) {
158 case PROP_GROUPING_POLICY:
159 data->grouping_policy = g_value_get_enum(value);
160 wnck_tasklist_set_grouping(WNCK_TASKLIST(tasklist),
161 data->grouping_policy);
162 break;
163 case PROP_GROUPING_LIMIT:
164 data->grouping_limit = g_value_get_int(value);
165 wnck_tasklist_set_grouping_limit(WNCK_TASKLIST(tasklist),
166 data->grouping_limit);
167 break;
168 case PROP_RELIEF_STYLE:
169 data->relief_style = g_value_get_enum(value);
170 wnck_tasklist_set_button_relief(WNCK_TASKLIST(tasklist),
171 data->relief_style);
172 break;
173 default:
174 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
175 break;
176 }
177}

Archive Download this file

Branches

Tags