1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
6
* Copyright (C) 2009 Free Software Foundation, Inc.
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
24
#include "gth-file-tool.h"
34
static gpointer parent_class = NULL;
35
static guint gth_file_tool_signals[LAST_SIGNAL] = { 0 };
38
struct _GthFileToolPrivate {
40
const char *icon_name;
41
const char *button_text;
42
const char *options_title;
48
gth_file_tool_base_update_sensitivity (GthFileTool *self)
55
gth_file_tool_base_activate (GthFileTool *self)
62
gth_file_tool_base_get_options (GthFileTool *self)
69
gth_file_tool_base_destroy_options (GthFileTool *self)
76
gth_file_tool_finalize (GObject *object)
80
g_return_if_fail (object != NULL);
81
g_return_if_fail (GTH_IS_FILE_TOOL (object));
83
self = (GthFileTool *) object;
86
G_OBJECT_CLASS (parent_class)->finalize (object);
91
gth_file_tool_class_init (GthFileToolClass *klass)
93
GObjectClass *gobject_class;
95
parent_class = g_type_class_peek_parent (klass);
96
g_type_class_add_private (klass, sizeof (GthFileToolPrivate));
98
gobject_class = (GObjectClass*) klass;
99
gobject_class->finalize = gth_file_tool_finalize;
101
klass->update_sensitivity = gth_file_tool_base_update_sensitivity;
102
klass->activate = gth_file_tool_base_activate;
103
klass->get_options = gth_file_tool_base_get_options;
104
klass->destroy_options = gth_file_tool_base_destroy_options;
106
gth_file_tool_signals[SHOW_OPTIONS] =
107
g_signal_new ("show-options",
108
G_TYPE_FROM_CLASS (klass),
110
G_STRUCT_OFFSET (GthFileToolClass, show_options),
112
g_cclosure_marshal_VOID__VOID,
115
gth_file_tool_signals[HIDE_OPTIONS] =
116
g_signal_new ("hide-options",
117
G_TYPE_FROM_CLASS (klass),
119
G_STRUCT_OFFSET (GthFileToolClass, hide_options),
121
g_cclosure_marshal_VOID__VOID,
128
gth_file_tool_instance_init (GthFileTool *self)
130
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_FILE_TOOL, GthFileToolPrivate);
131
self->priv->icon_name = NULL;
132
self->priv->button_text = NULL;
133
self->priv->options_title = NULL;
135
gtk_button_set_relief (GTK_BUTTON (self), GTK_RELIEF_NONE);
140
gth_file_tool_get_type (void) {
141
static GType type_id = 0;
143
static const GTypeInfo g_define_type_info = {
144
sizeof (GthFileToolClass),
145
(GBaseInitFunc) NULL,
146
(GBaseFinalizeFunc) NULL,
147
(GClassInitFunc) gth_file_tool_class_init,
148
(GClassFinalizeFunc) NULL,
150
sizeof (GthFileTool),
152
(GInstanceInitFunc) gth_file_tool_instance_init,
155
type_id = g_type_register_static (GTK_TYPE_BUTTON, "GthFileTool", &g_define_type_info, 0);
162
gth_file_tool_construct (GthFileTool *self,
163
const char *icon_name,
164
const char *button_text,
165
const char *options_title,
172
self->priv->icon_name = icon_name;
173
self->priv->button_text = button_text;
174
self->priv->options_title = options_title;
175
self->priv->separator = separator;
177
hbox = gtk_hbox_new (FALSE, 6);
179
icon = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
180
gtk_widget_show (icon);
181
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
183
label = gtk_label_new (button_text);
184
gtk_widget_show (label);
185
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
187
gtk_widget_show (hbox);
188
gtk_container_add (GTK_CONTAINER (self), hbox);
193
gth_file_tool_get_window (GthFileTool *self)
195
if (self->priv->window == NULL) {
196
self->priv->window = gtk_widget_get_toplevel (GTK_WIDGET (self));
197
if (! GTK_WIDGET_TOPLEVEL (self->priv->window))
198
self->priv->window = NULL;
200
return self->priv->window;
205
gth_file_tool_get_icon_name (GthFileTool *self)
207
return self->priv->icon_name;
212
gth_file_tool_activate (GthFileTool *self)
214
GTH_FILE_TOOL_GET_CLASS (self)->activate (self);
219
gth_file_tool_update_sensitivity (GthFileTool *self)
221
GTH_FILE_TOOL_GET_CLASS (self)->update_sensitivity (self);
226
gth_file_tool_show_options (GthFileTool *self)
228
g_signal_emit (self, gth_file_tool_signals[SHOW_OPTIONS], 0, NULL);
233
gth_file_tool_hide_options (GthFileTool *self)
235
g_signal_emit (self, gth_file_tool_signals[HIDE_OPTIONS], 0, NULL);
240
gth_file_tool_get_options (GthFileTool *self)
242
return GTH_FILE_TOOL_GET_CLASS (self)->get_options (self);
247
gth_file_tool_get_options_title (GthFileTool *self)
249
return self->priv->options_title;
254
gth_file_tool_has_separator (GthFileTool *self)
256
return self->priv->separator;
261
gth_file_tool_destroy_options (GthFileTool *self)
263
GTH_FILE_TOOL_GET_CLASS (self)->destroy_options (self);