3
* Copyright (C) 2014 Christian Hergert <christian@hergert.me>
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#include <glib/gi18n.h>
21
#include "gb-workspace.h"
36
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GbWorkspace, gb_workspace, GTK_TYPE_BIN)
38
static GParamSpec *gParamSpecs[LAST_PROP];
41
gb_workspace_get_icon_name (GbWorkspace *self)
43
GbWorkspacePrivate *priv = gb_workspace_get_instance_private (self);
45
g_return_val_if_fail (GB_IS_WORKSPACE (self), NULL);
47
return priv->icon_name;
51
gb_workspace_set_icon_name (GbWorkspace *self,
52
const gchar *icon_name)
54
GbWorkspacePrivate *priv = gb_workspace_get_instance_private (self);
56
g_return_if_fail (GB_IS_WORKSPACE (self));
58
if (priv->icon_name != icon_name)
60
g_free (priv->icon_name);
61
priv->icon_name = g_strdup (icon_name);
62
g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs[PROP_ICON_NAME]);
67
gb_workspace_get_title (GbWorkspace *self)
69
GbWorkspacePrivate *priv = gb_workspace_get_instance_private (self);
71
g_return_val_if_fail (GB_IS_WORKSPACE (self), NULL);
77
gb_workspace_set_title (GbWorkspace *self,
80
GbWorkspacePrivate *priv = gb_workspace_get_instance_private (self);
82
g_return_if_fail (GB_IS_WORKSPACE (self));
84
if (priv->title != title)
87
priv->title = g_strdup (title);
88
g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_TITLE]);
93
gb_workspace_finalize (GObject *object)
95
GbWorkspace *self = (GbWorkspace *)object;
96
GbWorkspacePrivate *priv = gb_workspace_get_instance_private (self);
98
g_clear_pointer (&priv->icon_name, g_free);
99
g_clear_pointer (&priv->title, g_free);
101
G_OBJECT_CLASS (gb_workspace_parent_class)->finalize (object);
105
gb_workspace_get_property (GObject *object,
110
GbWorkspace *self = GB_WORKSPACE (object);
115
g_value_set_string (value, gb_workspace_get_icon_name (self));
119
g_value_set_string (value, gb_workspace_get_title (self));
123
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
128
gb_workspace_set_property (GObject *object,
133
GbWorkspace *self = GB_WORKSPACE (object);
138
gb_workspace_set_icon_name (self, g_value_get_string (value));
142
gb_workspace_set_title (self, g_value_get_string (value));
146
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
151
gb_workspace_class_init (GbWorkspaceClass *klass)
153
GObjectClass *object_class;
155
object_class = G_OBJECT_CLASS (klass);
156
object_class->finalize = gb_workspace_finalize;
157
object_class->get_property = gb_workspace_get_property;
158
object_class->set_property = gb_workspace_set_property;
160
gParamSpecs[PROP_TITLE] =
161
g_param_spec_string ("title",
163
_("The title of the workspace."),
166
G_PARAM_STATIC_STRINGS));
168
gParamSpecs[PROP_ICON_NAME] =
169
g_param_spec_string ("icon-name",
171
_("The name of the icon to use."),
174
G_PARAM_STATIC_STRINGS));
176
g_object_class_install_properties (object_class, LAST_PROP, gParamSpecs);
180
gb_workspace_init (GbWorkspace *workspace)
185
gb_workspace_views_foreach (GbWorkspace *self,
186
GtkCallback callback,
187
gpointer callback_data)
189
g_return_if_fail (GB_IS_WORKSPACE (self));
190
g_return_if_fail (callback != NULL);
192
if (GB_WORKSPACE_GET_CLASS (self)->views_foreach)
193
GB_WORKSPACE_GET_CLASS (self)->views_foreach (self, callback, callback_data);