~ubuntu-branches/ubuntu/breezy/gimp/breezy

« back to all changes in this revision

Viewing changes to app/widgets/gimpdocked.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-10-04 19:04:46 UTC
  • Revision ID: james.westby@ubuntu.com-20051004190446-ukh32kwk56s4sjhu
Tags: upstream-2.2.8
ImportĀ upstreamĀ versionĀ 2.2.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* The GIMP -- an image manipulation program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
4
 * gimpdocked.c
 
5
 * Copyright (C) 2003  Michael Natterer <mitch@gimp.org>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, write to the Free Software
 
19
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
#include "config.h"
 
23
 
 
24
#include <gtk/gtk.h>
 
25
 
 
26
#include "widgets-types.h"
 
27
 
 
28
#include "core/gimpcontext.h"
 
29
#include "core/gimpmarshal.h"
 
30
 
 
31
#include "gimpdocked.h"
 
32
 
 
33
 
 
34
enum
 
35
{
 
36
  TITLE_CHANGED,
 
37
  LAST_SIGNAL
 
38
};
 
39
 
 
40
 
 
41
static void  gimp_docked_iface_base_init (GimpDockedInterface *docked_iface);
 
42
 
 
43
 
 
44
static guint docked_signals[LAST_SIGNAL] = { 0 };
 
45
 
 
46
 
 
47
GType
 
48
gimp_docked_interface_get_type (void)
 
49
{
 
50
  static GType docked_iface_type = 0;
 
51
 
 
52
  if (!docked_iface_type)
 
53
    {
 
54
      static const GTypeInfo docked_iface_info =
 
55
      {
 
56
        sizeof (GimpDockedInterface),
 
57
        (GBaseInitFunc)     gimp_docked_iface_base_init,
 
58
        (GBaseFinalizeFunc) NULL,
 
59
      };
 
60
 
 
61
      docked_iface_type = g_type_register_static (G_TYPE_INTERFACE,
 
62
                                                  "GimpDockedInterface",
 
63
                                                  &docked_iface_info,
 
64
                                                  0);
 
65
 
 
66
      g_type_interface_add_prerequisite (docked_iface_type, GTK_TYPE_WIDGET);
 
67
    }
 
68
 
 
69
  return docked_iface_type;
 
70
}
 
71
 
 
72
static void
 
73
gimp_docked_iface_base_init (GimpDockedInterface *docked_iface)
 
74
{
 
75
  static gboolean initialized = FALSE;
 
76
 
 
77
  if (! initialized)
 
78
    {
 
79
      docked_signals[TITLE_CHANGED] =
 
80
        g_signal_new ("title_changed",
 
81
                      GIMP_TYPE_DOCKED,
 
82
                      G_SIGNAL_RUN_FIRST,
 
83
                      G_STRUCT_OFFSET (GimpDockedInterface, title_changed),
 
84
                      NULL, NULL,
 
85
                      gimp_marshal_VOID__VOID,
 
86
                      G_TYPE_NONE, 0);
 
87
 
 
88
      initialized = TRUE;
 
89
    }
 
90
}
 
91
 
 
92
void
 
93
gimp_docked_title_changed (GimpDocked *docked)
 
94
{
 
95
  g_return_if_fail (GIMP_IS_DOCKED (docked));
 
96
 
 
97
  g_signal_emit (docked, docked_signals[TITLE_CHANGED], 0);
 
98
}
 
99
 
 
100
void
 
101
gimp_docked_set_aux_info (GimpDocked *docked,
 
102
                          GList      *aux_info)
 
103
{
 
104
  GimpDockedInterface *docked_iface;
 
105
 
 
106
  g_return_if_fail (GIMP_IS_DOCKED (docked));
 
107
 
 
108
  docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
 
109
 
 
110
  if (docked_iface->set_aux_info)
 
111
    docked_iface->set_aux_info (docked, aux_info);
 
112
}
 
113
 
 
114
GList *
 
115
gimp_docked_get_aux_info (GimpDocked *docked)
 
116
{
 
117
  GimpDockedInterface *docked_iface;
 
118
 
 
119
  g_return_val_if_fail (GIMP_IS_DOCKED (docked), NULL);
 
120
 
 
121
  docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
 
122
 
 
123
  if (docked_iface->get_aux_info)
 
124
    return docked_iface->get_aux_info (docked);
 
125
 
 
126
  return NULL;
 
127
}
 
128
 
 
129
GtkWidget *
 
130
gimp_docked_get_preview (GimpDocked  *docked,
 
131
                         GimpContext *context,
 
132
                         GtkIconSize  size)
 
133
{
 
134
  GimpDockedInterface *docked_iface;
 
135
 
 
136
  g_return_val_if_fail (GIMP_IS_DOCKED (docked), NULL);
 
137
 
 
138
  docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
 
139
 
 
140
  if (docked_iface->get_preview)
 
141
    return docked_iface->get_preview (docked, context, size);
 
142
 
 
143
  return NULL;
 
144
}
 
145
 
 
146
GimpUIManager *
 
147
gimp_docked_get_menu (GimpDocked     *docked,
 
148
                      const gchar   **ui_path,
 
149
                      gpointer       *popup_data)
 
150
{
 
151
  GimpDockedInterface *docked_iface;
 
152
 
 
153
  g_return_val_if_fail (GIMP_IS_DOCKED (docked), NULL);
 
154
  g_return_val_if_fail (ui_path != NULL, NULL);
 
155
  g_return_val_if_fail (popup_data != NULL, NULL);
 
156
 
 
157
  docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
 
158
 
 
159
  if (docked_iface->get_menu)
 
160
    return docked_iface->get_menu (docked, ui_path, popup_data);
 
161
 
 
162
  return NULL;
 
163
}
 
164
 
 
165
gchar *
 
166
gimp_docked_get_title (GimpDocked *docked)
 
167
{
 
168
  GimpDockedInterface *docked_iface;
 
169
 
 
170
  g_return_val_if_fail (GIMP_IS_DOCKED (docked), NULL);
 
171
 
 
172
  docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
 
173
 
 
174
  if (docked_iface->get_title)
 
175
    return docked_iface->get_title (docked);
 
176
 
 
177
  return NULL;
 
178
}
 
179
 
 
180
void
 
181
gimp_docked_set_context (GimpDocked  *docked,
 
182
                         GimpContext *context)
 
183
{
 
184
  GimpDockedInterface *docked_iface;
 
185
 
 
186
  g_return_if_fail (GIMP_IS_DOCKED (docked));
 
187
  g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));
 
188
 
 
189
  docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
 
190
 
 
191
  if (docked_iface->set_context)
 
192
    docked_iface->set_context (docked, context);
 
193
}