2005-07-12 05:09:13 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
|
|
|
* gtkfilechooserembed.h: Abstract sizing interface for file selector implementations
|
|
|
|
* Copyright (C) 2004, Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2004-03-06 03:38:59 +00:00
|
|
|
#include <config.h>
|
2004-02-27 23:51:16 +00:00
|
|
|
#include "gtkfilechooserembed.h"
|
|
|
|
#include "gtkmarshalers.h"
|
2005-09-01 05:11:46 +00:00
|
|
|
#include "gtkintl.h"
|
2005-03-20 07:01:23 +00:00
|
|
|
#include "gtkalias.h"
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
|
|
static void gtk_file_chooser_embed_class_init (gpointer g_iface);
|
|
|
|
static void delegate_get_default_size (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
gint *default_width,
|
|
|
|
gint *default_height);
|
|
|
|
static void delegate_get_resizable_hints (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
gboolean *resize_horizontally,
|
|
|
|
gboolean *resize_vertically);
|
2004-03-05 00:10:59 +00:00
|
|
|
static gboolean delegate_should_respond (GtkFileChooserEmbed *chooser_embed);
|
2004-03-08 22:21:47 +00:00
|
|
|
static void delegate_initial_focus (GtkFileChooserEmbed *chooser_embed);
|
2004-02-27 23:51:16 +00:00
|
|
|
static void delegate_default_size_changed (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
gpointer data);
|
2006-05-01 21:41:12 +00:00
|
|
|
static void delegate_response_requested (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
gpointer data);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
|
|
static GtkFileChooserEmbed *
|
|
|
|
get_delegate (GtkFileChooserEmbed *receiver)
|
|
|
|
{
|
|
|
|
return g_object_get_data (G_OBJECT (receiver), "gtk-file-chooser-embed-delegate");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _gtk_file_chooser_embed_delegate_iface_init:
|
|
|
|
* @iface: a #GtkFileChoserEmbedIface structure
|
|
|
|
*
|
|
|
|
* An interface-initialization function for use in cases where an object is
|
|
|
|
* simply delegating the methods, signals of the #GtkFileChooserEmbed interface
|
|
|
|
* to another object. _gtk_file_chooser_embed_set_delegate() must be called on
|
|
|
|
* each instance of the object so that the delegate object can be found.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
_gtk_file_chooser_embed_delegate_iface_init (GtkFileChooserEmbedIface *iface)
|
|
|
|
{
|
|
|
|
iface->get_default_size = delegate_get_default_size;
|
|
|
|
iface->get_resizable_hints = delegate_get_resizable_hints;
|
2004-03-05 00:10:59 +00:00
|
|
|
iface->should_respond = delegate_should_respond;
|
2004-03-08 22:21:47 +00:00
|
|
|
iface->initial_focus = delegate_initial_focus;
|
2004-02-27 23:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _gtk_file_chooser_embed_set_delegate:
|
|
|
|
* @receiver: a GOobject implementing #GtkFileChooserEmbed
|
|
|
|
* @delegate: another GObject implementing #GtkFileChooserEmbed
|
|
|
|
*
|
|
|
|
* Establishes that calls on @receiver for #GtkFileChooser methods should be
|
|
|
|
* delegated to @delegate, and that #GtkFileChooser signals emitted on @delegate
|
|
|
|
* should be forwarded to @receiver. Must be used in confunction with
|
|
|
|
* _gtk_file_chooser_delegate_iface_init().
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
_gtk_file_chooser_embed_set_delegate (GtkFileChooserEmbed *receiver,
|
|
|
|
GtkFileChooserEmbed *delegate)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_FILE_CHOOSER_EMBED (receiver));
|
|
|
|
g_return_if_fail (GTK_IS_FILE_CHOOSER_EMBED (delegate));
|
|
|
|
|
2005-09-01 05:11:46 +00:00
|
|
|
g_object_set_data (G_OBJECT (receiver), I_("gtk-file-chooser-embed-delegate"), delegate);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
|
|
g_signal_connect (delegate, "default_size_changed",
|
|
|
|
G_CALLBACK (delegate_default_size_changed), receiver);
|
2006-05-01 21:41:12 +00:00
|
|
|
g_signal_connect (delegate, "response_requested",
|
|
|
|
G_CALLBACK (delegate_response_requested), receiver);
|
2004-02-27 23:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
delegate_get_default_size (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
gint *default_width,
|
|
|
|
gint *default_height)
|
|
|
|
{
|
|
|
|
_gtk_file_chooser_embed_get_default_size (get_delegate (chooser_embed), default_width, default_height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
delegate_get_resizable_hints (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
gboolean *resize_horizontally,
|
|
|
|
gboolean *resize_vertically)
|
|
|
|
{
|
|
|
|
_gtk_file_chooser_embed_get_resizable_hints (get_delegate (chooser_embed), resize_horizontally, resize_vertically);
|
|
|
|
}
|
|
|
|
|
2004-03-05 00:10:59 +00:00
|
|
|
static gboolean
|
|
|
|
delegate_should_respond (GtkFileChooserEmbed *chooser_embed)
|
|
|
|
{
|
|
|
|
return _gtk_file_chooser_embed_should_respond (get_delegate (chooser_embed));
|
|
|
|
}
|
|
|
|
|
2004-03-08 22:21:47 +00:00
|
|
|
static void
|
|
|
|
delegate_initial_focus (GtkFileChooserEmbed *chooser_embed)
|
|
|
|
{
|
2004-03-11 15:32:01 +00:00
|
|
|
_gtk_file_chooser_embed_initial_focus (get_delegate (chooser_embed));
|
2004-03-08 22:21:47 +00:00
|
|
|
}
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
static void
|
|
|
|
delegate_default_size_changed (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
g_signal_emit_by_name (data, "default-size-changed");
|
|
|
|
}
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
static void
|
|
|
|
delegate_response_requested (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
g_signal_emit_by_name (data, "response-requested");
|
|
|
|
}
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
|
|
/* publicly callable functions */
|
|
|
|
|
|
|
|
GType
|
|
|
|
_gtk_file_chooser_embed_get_type (void)
|
|
|
|
{
|
|
|
|
static GType file_chooser_embed_type = 0;
|
|
|
|
|
|
|
|
if (!file_chooser_embed_type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo file_chooser_embed_info =
|
|
|
|
{
|
|
|
|
sizeof (GtkFileChooserEmbedIface), /* class_size */
|
|
|
|
NULL, /* base_init */
|
|
|
|
NULL, /* base_finalize */
|
|
|
|
(GClassInitFunc)gtk_file_chooser_embed_class_init, /* class_init */
|
|
|
|
};
|
|
|
|
|
|
|
|
file_chooser_embed_type = g_type_register_static (G_TYPE_INTERFACE,
|
2005-09-01 05:11:46 +00:00
|
|
|
I_("GtkFileChooserEmbed"),
|
2004-02-27 23:51:16 +00:00
|
|
|
&file_chooser_embed_info, 0);
|
|
|
|
|
|
|
|
g_type_interface_add_prerequisite (file_chooser_embed_type, GTK_TYPE_WIDGET);
|
|
|
|
}
|
|
|
|
|
|
|
|
return file_chooser_embed_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_file_chooser_embed_class_init (gpointer g_iface)
|
|
|
|
{
|
|
|
|
GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
|
|
|
|
|
2005-09-01 05:11:46 +00:00
|
|
|
g_signal_new (I_("default-size-changed"),
|
2004-02-27 23:51:16 +00:00
|
|
|
iface_type,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkFileChooserEmbedIface, default_size_changed),
|
|
|
|
NULL, NULL,
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2006-05-11 17:54:20 +00:00
|
|
|
g_signal_new (I_("response-requested"),
|
2006-05-01 21:41:12 +00:00
|
|
|
iface_type,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkFileChooserEmbedIface, response_requested),
|
|
|
|
NULL, NULL,
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2004-02-27 23:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_file_chooser_embed_get_default_size (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
gint *default_width,
|
|
|
|
gint *default_height)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_FILE_CHOOSER_EMBED (chooser_embed));
|
2004-02-29 07:55:24 +00:00
|
|
|
g_return_if_fail (default_width != NULL);
|
|
|
|
g_return_if_fail (default_height != NULL);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
|
|
GTK_FILE_CHOOSER_EMBED_GET_IFACE (chooser_embed)->get_default_size (chooser_embed, default_width, default_height);
|
|
|
|
}
|
|
|
|
|
2004-03-05 00:10:59 +00:00
|
|
|
gboolean
|
|
|
|
_gtk_file_chooser_embed_should_respond (GtkFileChooserEmbed *chooser_embed)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_FILE_CHOOSER_EMBED (chooser_embed), FALSE);
|
|
|
|
|
|
|
|
return GTK_FILE_CHOOSER_EMBED_GET_IFACE (chooser_embed)->should_respond (chooser_embed);
|
|
|
|
}
|
|
|
|
|
2004-03-08 22:21:47 +00:00
|
|
|
void
|
|
|
|
_gtk_file_chooser_embed_initial_focus (GtkFileChooserEmbed *chooser_embed)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_FILE_CHOOSER_EMBED (chooser_embed));
|
|
|
|
|
|
|
|
GTK_FILE_CHOOSER_EMBED_GET_IFACE (chooser_embed)->initial_focus (chooser_embed);
|
|
|
|
}
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
void
|
|
|
|
_gtk_file_chooser_embed_get_resizable_hints (GtkFileChooserEmbed *chooser_embed,
|
2004-02-29 07:55:24 +00:00
|
|
|
gboolean *resize_horizontally,
|
|
|
|
gboolean *resize_vertically)
|
2004-02-27 23:51:16 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_FILE_CHOOSER_EMBED (chooser_embed));
|
2004-02-29 07:55:24 +00:00
|
|
|
g_return_if_fail (resize_horizontally != NULL);
|
|
|
|
g_return_if_fail (resize_vertically != NULL);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
|
|
GTK_FILE_CHOOSER_EMBED_GET_IFACE (chooser_embed)->get_resizable_hints (chooser_embed, resize_horizontally, resize_vertically);
|
|
|
|
}
|
|
|
|
|
2005-03-20 07:01:23 +00:00
|
|
|
#define __GTK_FILE_CHOOSER_EMBED_C__
|
|
|
|
#include "gtkaliasdef.c"
|