libgimpwidgets/gimpchainbutton.[ch] libgimpwidgets/gimpcolorarea.[ch]

2003-01-05  Sven Neumann  <sven@gimp.org>

        * libgimpwidgets/gimpchainbutton.[ch]
        * libgimpwidgets/gimpcolorarea.[ch]
        * libgimpwidgets/gimpcolorbutton.[ch]
        * libgimpwidgets/gimpdialog.c
        * libgimpwidgets/gimpfileselection.[ch]
        * libgimpwidgets/gimpoffsetarea.c
        * libgimpwidgets/gimppickbutton.c
        * libgimpwidgets/gimpquerybox.c
        * libgimpwidgets/gimpwidgets.c: added more API documentation.
        Declared gimp_scale_entry_new_internal() as static.

        * libgimpwidgets/gimpwidgets.def: changed accordingly.
This commit is contained in:
Sven Neumann 2003-01-05 15:41:23 +00:00 committed by Sven Neumann
parent d41e99de78
commit 50c8c56fe0
23 changed files with 573 additions and 435 deletions

View File

@ -1,3 +1,18 @@
2003-01-05 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpchainbutton.[ch]
* libgimpwidgets/gimpcolorarea.[ch]
* libgimpwidgets/gimpcolorbutton.[ch]
* libgimpwidgets/gimpdialog.c
* libgimpwidgets/gimpfileselection.[ch]
* libgimpwidgets/gimpoffsetarea.c
* libgimpwidgets/gimppickbutton.c
* libgimpwidgets/gimpquerybox.c
* libgimpwidgets/gimpwidgets.c: added more API documentation.
Declared gimp_scale_entry_new_internal() as static.
* libgimpwidgets/gimpwidgets.def: changed accordingly.
2003-01-05 Sven Neumann <sven@gimp.org> 2003-01-05 Sven Neumann <sven@gimp.org>
* libgimpwidgets/Makefile.am * libgimpwidgets/Makefile.am

View File

@ -1,3 +1,11 @@
2003-01-05 Sven Neumann <sven@gimp.org>
* libgimpwidgets/tmpl/gimpchainbutton.sgml
* libgimpwidgets/tmpl/gimpcolorbutton.sgml
* libgimpwidgets/tmpl/gimpfileselection.sgml
* libgimpwidgets/tmpl/gimpmemsizeentry.sgml
* libgimpwidgets/tmpl/gimpquerybox.sgml: regenerated.
2003-01-05 Sven Neumann <sven@gimp.org> 2003-01-05 Sven Neumann <sven@gimp.org>
* libgimpwidgets/libgimpwidgets-docs.sgml * libgimpwidgets/libgimpwidgets-docs.sgml

View File

@ -56,9 +56,10 @@ up two GimpSizeEntries (see #GimpSizeEntry) linked with a #GimpChainButton.
</para> </para>
@gcb: @button:
@active: @active:
<!-- # Unused Parameters # --> <!-- # Unused Parameters # -->
@gcb:
@is_active: @is_active:
@ -67,8 +68,10 @@ up two GimpSizeEntries (see #GimpSizeEntry) linked with a #GimpChainButton.
</para> </para>
@gcb: @button:
@Returns: @Returns:
<!-- # Unused Parameters # -->
@gcb:
<!-- ##### SIGNAL GimpChainButton::toggled ##### --> <!-- ##### SIGNAL GimpChainButton::toggled ##### -->

View File

@ -47,8 +47,10 @@ color, the "color_changed" signal is emitted.
</para> </para>
@gcb: @button:
@color: @color:
<!-- # Unused Parameters # -->
@gcb:
<!-- ##### FUNCTION gimp_color_button_get_color ##### --> <!-- ##### FUNCTION gimp_color_button_get_color ##### -->
@ -56,8 +58,10 @@ color, the "color_changed" signal is emitted.
</para> </para>
@gcb: @button:
@color: @color:
<!-- # Unused Parameters # -->
@gcb:
<!-- ##### FUNCTION gimp_color_button_has_alpha ##### --> <!-- ##### FUNCTION gimp_color_button_has_alpha ##### -->
@ -65,8 +69,10 @@ color, the "color_changed" signal is emitted.
</para> </para>
@gcb: @button:
@Returns: @Returns:
<!-- # Unused Parameters # -->
@gcb:
<!-- ##### FUNCTION gimp_color_button_set_type ##### --> <!-- ##### FUNCTION gimp_color_button_set_type ##### -->
@ -74,9 +80,10 @@ color, the "color_changed" signal is emitted.
</para> </para>
@gcb: @button:
@type: @type:
<!-- # Unused Parameters # --> <!-- # Unused Parameters # -->
@gcb:
@alpha: @alpha:

View File

@ -54,8 +54,10 @@ will be emitted.
</para> </para>
@gfs: @selection:
@Returns: @Returns:
<!-- # Unused Parameters # -->
@gfs:
<!-- ##### FUNCTION gimp_file_selection_set_filename ##### --> <!-- ##### FUNCTION gimp_file_selection_set_filename ##### -->
@ -63,8 +65,10 @@ will be emitted.
</para> </para>
@gfs: @selection:
@filename: @filename:
<!-- # Unused Parameters # -->
@gfs:
<!-- ##### SIGNAL GimpFileSelection::filename-changed ##### --> <!-- ##### SIGNAL GimpFileSelection::filename-changed ##### -->

View File

@ -2,11 +2,14 @@
GimpMemsizeEntry GimpMemsizeEntry
<!-- ##### SECTION Short_Description ##### --> <!-- ##### SECTION Short_Description ##### -->
A composite widget that allows to enter a memory size.
<!-- ##### SECTION Long_Description ##### --> <!-- ##### SECTION Long_Description ##### -->
<para> <para>
Similar to a #GimpSizeEntry but instead of lengths, this widget is used to let
the user enter memory sizes. An option menu allows to switch between
Kilobytes, Megabytes and Gigabytes. Used in the GIMP preferences dialog.
</para> </para>
<!-- ##### SECTION See_Also ##### --> <!-- ##### SECTION See_Also ##### -->
@ -16,7 +19,7 @@ GimpMemsizeEntry
<!-- ##### STRUCT GimpMemsizeEntry ##### --> <!-- ##### STRUCT GimpMemsizeEntry ##### -->
<para> <para>
The #GimpSizeEntry struct is considered private.
</para> </para>

View File

@ -175,13 +175,12 @@ Note that you have to g_free() the returned string.
@callback: @callback:
@data: @data:
@Returns: @Returns:
<!-- # Unused Parameters # -->
@eek:
<!-- ##### MACRO GIMP_QUERY_BOX_VBOX ##### --> <!-- ##### MACRO GIMP_QUERY_BOX_VBOX ##### -->
<para> <para>
A macro to access the #GtkVBox in a #GimpQueryBox. Useful if you want to add
more widgets.
</para> </para>
@qbox: @qbox:

View File

@ -35,14 +35,14 @@ enum
}; };
static void gimp_chain_button_class_init (GimpChainButtonClass *klass); static void gimp_chain_button_class_init (GimpChainButtonClass *klass);
static void gimp_chain_button_init (GimpChainButton *gcb); static void gimp_chain_button_init (GimpChainButton *button);
static void gimp_chain_button_clicked_callback (GtkWidget *widget, static void gimp_chain_button_clicked_callback (GtkWidget *widget,
GimpChainButton *gcb); GimpChainButton *button);
static gint gimp_chain_button_draw_lines (GtkWidget *widget, static gboolean gimp_chain_button_draw_lines (GtkWidget *widget,
GdkEventExpose *eevent, GdkEventExpose *eevent,
GimpChainButton *gcb); GimpChainButton *button);
static const gchar *gimp_chain_stock_items[] = static const gchar *gimp_chain_stock_items[] =
@ -62,11 +62,11 @@ static GtkTableClass *parent_class = NULL;
GType GType
gimp_chain_button_get_type (void) gimp_chain_button_get_type (void)
{ {
static GType gcb_type = 0; static GType button_type = 0;
if (! gcb_type) if (! button_type)
{ {
static const GTypeInfo gcb_info = static const GTypeInfo button_info =
{ {
sizeof (GimpChainButtonClass), sizeof (GimpChainButtonClass),
(GBaseInitFunc) NULL, (GBaseInitFunc) NULL,
@ -79,12 +79,11 @@ gimp_chain_button_get_type (void)
(GInstanceInitFunc) gimp_chain_button_init, (GInstanceInitFunc) gimp_chain_button_init,
}; };
gcb_type = g_type_register_static (GTK_TYPE_TABLE, button_type = g_type_register_static (GTK_TYPE_TABLE, "GimpChainButton",
"GimpChainButton", &button_info, 0);
&gcb_info, 0);
} }
return gcb_type; return button_type;
} }
static void static void
@ -105,29 +104,30 @@ gimp_chain_button_class_init (GimpChainButtonClass *klass)
} }
static void static void
gimp_chain_button_init (GimpChainButton *gcb) gimp_chain_button_init (GimpChainButton *button)
{ {
gcb->position = GIMP_CHAIN_TOP; button->position = GIMP_CHAIN_TOP;
gcb->active = FALSE; button->active = FALSE;
gcb->line1 = gtk_drawing_area_new (); button->line1 = gtk_drawing_area_new ();
gcb->line2 = gtk_drawing_area_new (); button->line2 = gtk_drawing_area_new ();
gcb->image = gtk_image_new (); button->image = gtk_image_new ();
gcb->button = gtk_button_new (); button->button = gtk_button_new ();
gtk_button_set_relief (GTK_BUTTON (gcb->button), GTK_RELIEF_NONE);
gtk_container_add (GTK_CONTAINER (gcb->button), gcb->image);
gtk_widget_show (gcb->image);
g_signal_connect (G_OBJECT (gcb->button), "clicked", gtk_button_set_relief (GTK_BUTTON (button->button), GTK_RELIEF_NONE);
gtk_container_add (GTK_CONTAINER (button->button), button->image);
gtk_widget_show (button->image);
g_signal_connect (G_OBJECT (button->button), "clicked",
G_CALLBACK (gimp_chain_button_clicked_callback), G_CALLBACK (gimp_chain_button_clicked_callback),
gcb); button);
g_signal_connect (G_OBJECT (gcb->line1), "expose_event", g_signal_connect (G_OBJECT (button->line1), "expose_event",
G_CALLBACK (gimp_chain_button_draw_lines), G_CALLBACK (gimp_chain_button_draw_lines),
gcb); button);
g_signal_connect (G_OBJECT (gcb->line2), "expose_event", g_signal_connect (G_OBJECT (button->line2), "expose_event",
G_CALLBACK (gimp_chain_button_draw_lines), G_CALLBACK (gimp_chain_button_draw_lines),
gcb); button);
} }
@ -152,97 +152,101 @@ gimp_chain_button_init (GimpChainButton *gcb)
GtkWidget * GtkWidget *
gimp_chain_button_new (GimpChainPosition position) gimp_chain_button_new (GimpChainPosition position)
{ {
GimpChainButton *gcb; GimpChainButton *button;
gcb = g_object_new (GIMP_TYPE_CHAIN_BUTTON, NULL); button = g_object_new (GIMP_TYPE_CHAIN_BUTTON, NULL);
gcb->position = position; button->position = position;
gtk_image_set_from_stock gtk_image_set_from_stock
(GTK_IMAGE (gcb->image), (GTK_IMAGE (button->image),
gimp_chain_stock_items[((position & GIMP_CHAIN_LEFT) << 1) + ! gcb->active], gimp_chain_stock_items[((position & GIMP_CHAIN_LEFT) << 1) + ! button->active],
GTK_ICON_SIZE_BUTTON); GTK_ICON_SIZE_BUTTON);
if (position & GIMP_CHAIN_LEFT) /* are we a vertical chainbutton? */ if (position & GIMP_CHAIN_LEFT) /* are we a vertical chainbutton? */
{ {
gtk_table_resize (GTK_TABLE (gcb), 3, 1); gtk_table_resize (GTK_TABLE (button), 3, 1);
gtk_table_attach (GTK_TABLE (gcb), gcb->button, 0, 1, 1, 2, gtk_table_attach (GTK_TABLE (button), button->button, 0, 1, 1, 2,
GTK_SHRINK, GTK_SHRINK, 0, 0); GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_table_attach_defaults (GTK_TABLE (gcb), gcb->line1, 0, 1, 0, 1); gtk_table_attach_defaults (GTK_TABLE (button),
gtk_table_attach_defaults (GTK_TABLE (gcb), gcb->line2, 0, 1, 2, 3); button->line1, 0, 1, 0, 1);
gtk_table_attach_defaults (GTK_TABLE (button),
button->line2, 0, 1, 2, 3);
} }
else else
{ {
gtk_table_resize (GTK_TABLE (gcb), 1, 3); gtk_table_resize (GTK_TABLE (button), 1, 3);
gtk_table_attach (GTK_TABLE (gcb), gcb->button, 1, 2, 0, 1, gtk_table_attach (GTK_TABLE (button), button->button, 1, 2, 0, 1,
GTK_SHRINK, GTK_SHRINK, 0, 0); GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_table_attach_defaults (GTK_TABLE (gcb), gcb->line1, 0, 1, 0, 1); gtk_table_attach_defaults (GTK_TABLE (button),
gtk_table_attach_defaults (GTK_TABLE (gcb), gcb->line2, 2, 3, 0, 1); button->line1, 0, 1, 0, 1);
gtk_table_attach_defaults (GTK_TABLE (button),
button->line2, 2, 3, 0, 1);
} }
gtk_widget_show (gcb->button); gtk_widget_show (button->button);
gtk_widget_show (gcb->line1); gtk_widget_show (button->line1);
gtk_widget_show (gcb->line2); gtk_widget_show (button->line2);
return GTK_WIDGET (gcb); return GTK_WIDGET (button);
} }
/** /**
* gimp_chain_button_set_active: * gimp_chain_button_set_active:
* @gcb: Pointer to a #GimpChainButton. * @button: Pointer to a #GimpChainButton.
* @active: The new state. * @active: The new state.
* *
* Sets the state of the #GimpChainButton to be either locked (#TRUE) or * Sets the state of the #GimpChainButton to be either locked (#TRUE) or
* unlocked (#FALSE) and changes the showed pixmap to reflect the new state. * unlocked (#FALSE) and changes the showed pixmap to reflect the new state.
*/ */
void void
gimp_chain_button_set_active (GimpChainButton *gcb, gimp_chain_button_set_active (GimpChainButton *button,
gboolean active) gboolean active)
{ {
g_return_if_fail (GIMP_IS_CHAIN_BUTTON (gcb)); g_return_if_fail (GIMP_IS_CHAIN_BUTTON (button));
if (gcb->active != active) if (button->active != active)
{ {
gcb->active = active ? TRUE : FALSE; button->active = active ? TRUE : FALSE;
gtk_image_set_from_stock gtk_image_set_from_stock
(GTK_IMAGE (gcb->image), (GTK_IMAGE (button->image),
gimp_chain_stock_items[((gcb->position & GIMP_CHAIN_LEFT) << 1) + ! gcb->active], gimp_chain_stock_items[((button->position & GIMP_CHAIN_LEFT) << 1) + ! button->active],
GTK_ICON_SIZE_BUTTON); GTK_ICON_SIZE_BUTTON);
} }
} }
/** /**
* gimp_chain_button_get_active * gimp_chain_button_get_active
* @gcb: Pointer to a #GimpChainButton. * @button: Pointer to a #GimpChainButton.
* *
* Checks the state of the #GimpChainButton. * Checks the state of the #GimpChainButton.
* *
* Returns: TRUE if the #GimpChainButton is active (locked). * Returns: TRUE if the #GimpChainButton is active (locked).
*/ */
gboolean gboolean
gimp_chain_button_get_active (GimpChainButton *gcb) gimp_chain_button_get_active (GimpChainButton *button)
{ {
g_return_val_if_fail (GIMP_IS_CHAIN_BUTTON (gcb), FALSE); g_return_val_if_fail (GIMP_IS_CHAIN_BUTTON (button), FALSE);
return gcb->active; return button->active;
} }
static void static void
gimp_chain_button_clicked_callback (GtkWidget *widget, gimp_chain_button_clicked_callback (GtkWidget *widget,
GimpChainButton *gcb) GimpChainButton *button)
{ {
g_return_if_fail (GIMP_IS_CHAIN_BUTTON (gcb)); g_return_if_fail (GIMP_IS_CHAIN_BUTTON (button));
gimp_chain_button_set_active (gcb, ! gcb->active); gimp_chain_button_set_active (button, ! button->active);
g_signal_emit (G_OBJECT (gcb), gimp_chain_button_signals[TOGGLED], 0); g_signal_emit (G_OBJECT (button), gimp_chain_button_signals[TOGGLED], 0);
} }
static gint static gboolean
gimp_chain_button_draw_lines (GtkWidget *widget, gimp_chain_button_draw_lines (GtkWidget *widget,
GdkEventExpose *eevent, GdkEventExpose *eevent,
GimpChainButton *gcb) GimpChainButton *button)
{ {
GdkPoint points[3]; GdkPoint points[3];
GdkPoint buf; GdkPoint buf;
@ -253,14 +257,14 @@ gimp_chain_button_draw_lines (GtkWidget *widget,
/* don't set this too high, there's no check against drawing outside /* don't set this too high, there's no check against drawing outside
the widgets bounds yet (and probably never will be) */ the widgets bounds yet (and probably never will be) */
g_return_val_if_fail (GIMP_IS_CHAIN_BUTTON (gcb), FALSE); g_return_val_if_fail (GIMP_IS_CHAIN_BUTTON (button), FALSE);
points[0].x = widget->allocation.width / 2; points[0].x = widget->allocation.width / 2;
points[0].y = widget->allocation.height / 2; points[0].y = widget->allocation.height / 2;
which_line = (widget == gcb->line1) ? 1 : -1; which_line = (widget == button->line1) ? 1 : -1;
switch (gcb->position) switch (button->position)
{ {
case GIMP_CHAIN_LEFT: case GIMP_CHAIN_LEFT:
points[0].x += SHORT_LINE; points[0].x += SHORT_LINE;

View File

@ -72,7 +72,7 @@ struct _GimpChainButtonClass
{ {
GtkTableClass parent_class; GtkTableClass parent_class;
void (* toggled) (GimpChainButton *gcb); void (* toggled) (GimpChainButton *button);
}; };
@ -80,9 +80,9 @@ GType gimp_chain_button_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_chain_button_new (GimpChainPosition position); GtkWidget * gimp_chain_button_new (GimpChainPosition position);
void gimp_chain_button_set_active (GimpChainButton *gcb, void gimp_chain_button_set_active (GimpChainButton *button,
gboolean active); gboolean active);
gboolean gimp_chain_button_get_active (GimpChainButton *gcb); gboolean gimp_chain_button_get_active (GimpChainButton *button);
G_END_DECLS G_END_DECLS

View File

@ -278,8 +278,9 @@ gimp_color_area_new (const GimpRGB *color,
/** /**
* gimp_color_area_set_color: * gimp_color_area_set_color:
* @area: Pointer to a #GimpColorArea. * @area: Pointer to a #GimpColorArea.
* @color: * @color: Pointer to a #GimpRGB struct that defines the new color.
* *
* Sets @area to a different @color.
**/ **/
void void
gimp_color_area_set_color (GimpColorArea *area, gimp_color_area_set_color (GimpColorArea *area,
@ -300,6 +301,13 @@ gimp_color_area_set_color (GimpColorArea *area,
} }
} }
/**
* gimp_color_area_get_color:
* @area: Pointer to a #GimpColorArea.
* @color: Pointer to a #GimpRGB struct that is used to return the color.
*
* Retrieves the current color of the @area.
**/
void void
gimp_color_area_get_color (GimpColorArea *area, gimp_color_area_get_color (GimpColorArea *area,
GimpRGB *color) GimpRGB *color)
@ -310,6 +318,15 @@ gimp_color_area_get_color (GimpColorArea *area,
*color = area->color; *color = area->color;
} }
/**
* gimp_color_area_has_alpha:
* @area: Pointer to a #GimpColorArea.
*
* Checks whether the @area shows transparency information. This is determined
* via the @area's #GimpColorAreaType.
*
* Returns: %TRUE if @area shows transparency information, %FALSE otherwise.
**/
gboolean gboolean
gimp_color_area_has_alpha (GimpColorArea *area) gimp_color_area_has_alpha (GimpColorArea *area)
{ {
@ -318,6 +335,15 @@ gimp_color_area_has_alpha (GimpColorArea *area)
return area->type != GIMP_COLOR_AREA_FLAT; return area->type != GIMP_COLOR_AREA_FLAT;
} }
/**
* gimp_color_area_set_type:
* @area: Pointer to a #GimpColorArea.
* @type: A #GimpColorAreaType.
*
* Allows to change the type of @area. The #GimpColorAreaType determines
* whether the widget shows transparency information and chooses the size of
* the checkerboard used to do that.
**/
void void
gimp_color_area_set_type (GimpColorArea *area, gimp_color_area_set_type (GimpColorArea *area,
GimpColorAreaType type) GimpColorAreaType type)

View File

@ -63,7 +63,7 @@ struct _GimpColorAreaClass
{ {
GtkDrawingAreaClass parent_class; GtkDrawingAreaClass parent_class;
void (* color_changed) (GimpColorArea *gca); void (* color_changed) (GimpColorArea *area);
}; };

View File

@ -56,8 +56,8 @@ enum
static void gimp_color_button_class_init (GimpColorButtonClass *klass); static void gimp_color_button_class_init (GimpColorButtonClass *klass);
static void gimp_color_button_init (GimpColorButton *gcb); static void gimp_color_button_init (GimpColorButton *button);
static void gimp_color_button_destroy (GtkObject *object); static void gimp_color_button_destroy (GtkObject *object);
static gboolean gimp_color_button_button_press (GtkWidget *widget, static gboolean gimp_color_button_button_press (GtkWidget *widget,
GdkEventButton *bevent); GdkEventButton *bevent);
@ -101,11 +101,11 @@ static GimpButtonClass * parent_class = NULL;
GType GType
gimp_color_button_get_type (void) gimp_color_button_get_type (void)
{ {
static GType gcb_type = 0; static GType button_type = 0;
if (!gcb_type) if (!button_type)
{ {
static const GTypeInfo gcb_info = static const GTypeInfo button_info =
{ {
sizeof (GimpColorButtonClass), sizeof (GimpColorButtonClass),
(GBaseInitFunc) NULL, (GBaseInitFunc) NULL,
@ -118,12 +118,12 @@ gimp_color_button_get_type (void)
(GInstanceInitFunc) gimp_color_button_init, (GInstanceInitFunc) gimp_color_button_init,
}; };
gcb_type = g_type_register_static (GIMP_TYPE_BUTTON, button_type = g_type_register_static (GIMP_TYPE_BUTTON,
"GimpColorButton", "GimpColorButton",
&gcb_info, 0); &button_info, 0);
} }
return gcb_type; return button_type;
} }
static void static void
@ -159,54 +159,54 @@ gimp_color_button_class_init (GimpColorButtonClass *klass)
} }
static void static void
gimp_color_button_init (GimpColorButton *gcb) gimp_color_button_init (GimpColorButton *button)
{ {
GimpRGB color; GimpRGB color;
gcb->title = NULL; button->title = NULL;
gcb->dialog = NULL; button->dialog = NULL;
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0); gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
gcb->color_area = gimp_color_area_new (&color, FALSE, GDK_BUTTON2_MASK); button->color_area = gimp_color_area_new (&color, FALSE, GDK_BUTTON2_MASK);
g_signal_connect (G_OBJECT (gcb->color_area), "color_changed", g_signal_connect (G_OBJECT (button->color_area), "color_changed",
G_CALLBACK (gimp_color_button_color_changed), G_CALLBACK (gimp_color_button_color_changed),
gcb); button);
gtk_container_add (GTK_CONTAINER (gcb), gcb->color_area); gtk_container_add (GTK_CONTAINER (button), button->color_area);
gtk_widget_show (gcb->color_area); gtk_widget_show (button->color_area);
/* right-click opens a popup */ /* right-click opens a popup */
gcb->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL); button->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);
gtk_item_factory_set_translate_func (gcb->item_factory, gtk_item_factory_set_translate_func (button->item_factory,
gimp_color_button_menu_translate, gimp_color_button_menu_translate,
NULL, NULL); NULL, NULL);
gtk_item_factory_create_items (gcb->item_factory, gtk_item_factory_create_items (button->item_factory,
G_N_ELEMENTS (menu_items), menu_items, gcb); G_N_ELEMENTS (menu_items), menu_items, button);
} }
static void static void
gimp_color_button_destroy (GtkObject *object) gimp_color_button_destroy (GtkObject *object)
{ {
GimpColorButton *gcb; GimpColorButton *button;
gcb = GIMP_COLOR_BUTTON (object); button = GIMP_COLOR_BUTTON (object);
if (gcb->title) if (button->title)
{ {
g_free (gcb->title); g_free (button->title);
gcb->title = NULL; button->title = NULL;
} }
if (gcb->dialog) if (button->dialog)
{ {
gtk_widget_destroy (gcb->dialog); gtk_widget_destroy (button->dialog);
gcb->dialog = NULL; button->dialog = NULL;
} }
if (gcb->color_area) if (button->color_area)
{ {
gtk_widget_destroy (gcb->color_area); gtk_widget_destroy (button->color_area);
gcb->color_area = NULL; button->color_area = NULL;
} }
if (GTK_OBJECT_CLASS (parent_class)->destroy) if (GTK_OBJECT_CLASS (parent_class)->destroy)
@ -217,11 +217,11 @@ static gboolean
gimp_color_button_button_press (GtkWidget *widget, gimp_color_button_button_press (GtkWidget *widget,
GdkEventButton *bevent) GdkEventButton *bevent)
{ {
GimpColorButton *gcb; GimpColorButton *button;
gint x; gint x;
gint y; gint y;
gcb = GIMP_COLOR_BUTTON (widget); button = GIMP_COLOR_BUTTON (widget);
if (bevent->button == 3) if (bevent->button == 3)
{ {
@ -229,7 +229,7 @@ gimp_color_button_button_press (GtkWidget *widget,
x += widget->allocation.x; x += widget->allocation.x;
y += widget->allocation.y; y += widget->allocation.y;
gtk_item_factory_popup (gcb->item_factory, gtk_item_factory_popup (button->item_factory,
x + bevent->x, y + bevent->y, x + bevent->x, y + bevent->y,
bevent->button, bevent->time); bevent->button, bevent->time);
} }
@ -278,150 +278,166 @@ gimp_color_button_new (const gchar *title,
const GimpRGB *color, const GimpRGB *color,
GimpColorAreaType type) GimpColorAreaType type)
{ {
GimpColorButton *gcb; GimpColorButton *button;
g_return_val_if_fail (color != NULL, NULL); g_return_val_if_fail (color != NULL, NULL);
gcb = g_object_new (GIMP_TYPE_COLOR_BUTTON, NULL); button = g_object_new (GIMP_TYPE_COLOR_BUTTON, NULL);
gcb->title = g_strdup (title); button->title = g_strdup (title);
gtk_widget_set_size_request (GTK_WIDGET (gcb->color_area), width, height); gtk_widget_set_size_request (GTK_WIDGET (button->color_area), width, height);
gimp_color_area_set_color (GIMP_COLOR_AREA (gcb->color_area), color); gimp_color_area_set_color (GIMP_COLOR_AREA (button->color_area), color);
gimp_color_area_set_type (GIMP_COLOR_AREA (gcb->color_area), type); gimp_color_area_set_type (GIMP_COLOR_AREA (button->color_area), type);
return GTK_WIDGET (gcb); return GTK_WIDGET (button);
} }
/** /**
* gimp_color_button_set_color: * gimp_color_button_set_color:
* @gcb: Pointer to a #GimpColorButton. * @button: Pointer to a #GimpColorButton.
* @color: Pointer to the new #GimpRGB color. * @color: Pointer to the new #GimpRGB color.
* *
* Sets the @button to the given @color.
**/ **/
void void
gimp_color_button_set_color (GimpColorButton *gcb, gimp_color_button_set_color (GimpColorButton *button,
const GimpRGB *color) const GimpRGB *color)
{ {
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb)); g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
g_return_if_fail (color != NULL); g_return_if_fail (color != NULL);
gimp_color_area_set_color (GIMP_COLOR_AREA (gcb->color_area), color); gimp_color_area_set_color (GIMP_COLOR_AREA (button->color_area), color);
} }
/** /**
* gimp_color_button_get_color: * gimp_color_button_get_color:
* @gcb: Pointer to a #GimpColorButton. * @button: Pointer to a #GimpColorButton.
* @color: * @color: Pointer to a #GimpRGB struct used to return the color.
* *
* Retrieves the currently set color from the @button.
**/ **/
void void
gimp_color_button_get_color (GimpColorButton *gcb, gimp_color_button_get_color (GimpColorButton *button,
GimpRGB *color) GimpRGB *color)
{ {
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb)); g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
g_return_if_fail (color != NULL); g_return_if_fail (color != NULL);
gimp_color_area_get_color (GIMP_COLOR_AREA (gcb->color_area), color); gimp_color_area_get_color (GIMP_COLOR_AREA (button->color_area), color);
} }
/** /**
* gimp_color_button_has_alpha: * gimp_color_button_has_alpha:
* @gcb: Pointer to a #GimpColorButton. * @button: Pointer to a #GimpColorButton.
* *
* Checks whether the @buttons shows transparency information.
* *
* Returns: * Returns: %TRUE if the @button shows transparency information, %FALSE
* otherwise.
**/ **/
gboolean gboolean
gimp_color_button_has_alpha (GimpColorButton *gcb) gimp_color_button_has_alpha (GimpColorButton *button)
{ {
g_return_val_if_fail (GIMP_IS_COLOR_BUTTON (gcb), FALSE); g_return_val_if_fail (GIMP_IS_COLOR_BUTTON (button), FALSE);
return gimp_color_area_has_alpha (GIMP_COLOR_AREA (gcb->color_area)); return gimp_color_area_has_alpha (GIMP_COLOR_AREA (button->color_area));
} }
/**
* gimp_color_button_set_type:
* @button: Pointer to a #GimpColorButton.
* @type: the new #GimpColorAreaType
*
* Sets the @button to the given @type. See also gimp_color_area_set_type().
**/
void void
gimp_color_button_set_type (GimpColorButton *gcb, gimp_color_button_set_type (GimpColorButton *button,
GimpColorAreaType type) GimpColorAreaType type)
{ {
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb)); g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
gimp_color_area_set_type (GIMP_COLOR_AREA (gcb->color_area), type); gimp_color_area_set_type (GIMP_COLOR_AREA (button->color_area), type);
} }
static void static void
gimp_color_button_clicked (GtkButton *button) gimp_color_button_clicked (GtkButton *button)
{ {
GimpColorButton *gcb; GimpColorButton *color_button;
GtkWidget *dialog;
GimpRGB color; GimpRGB color;
GdkColor gdk_color; GdkColor gdk_color;
guint16 alpha; guint16 alpha;
g_return_if_fail (GIMP_IS_COLOR_BUTTON (button)); g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
gcb = GIMP_COLOR_BUTTON (button); color_button = GIMP_COLOR_BUTTON (button);
gimp_color_button_get_color (gcb, &color); gimp_color_button_get_color (color_button, &color);
gdk_color.red = TOUINT16 (color.r); gdk_color.red = TOUINT16 (color.r);
gdk_color.green = TOUINT16 (color.g); gdk_color.green = TOUINT16 (color.g);
gdk_color.blue = TOUINT16 (color.b); gdk_color.blue = TOUINT16 (color.b);
alpha = TOUINT16 (color.a); alpha = TOUINT16 (color.a);
if (!gcb->dialog) dialog = color_button->dialog;
if (!dialog)
{ {
gcb->dialog = gtk_color_selection_dialog_new (gcb->title); dialog = gtk_color_selection_dialog_new (color_button->title);
gtk_color_selection_set_has_opacity_control (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), TRUE); gtk_color_selection_set_has_opacity_control (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel), TRUE);
gtk_widget_destroy (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->help_button); gtk_widget_destroy (GTK_COLOR_SELECTION_DIALOG (dialog)->help_button);
gtk_container_set_border_width (GTK_CONTAINER (gcb->dialog), 2); gtk_container_set_border_width (GTK_CONTAINER (dialog), 2);
g_signal_connect (G_OBJECT (gcb->dialog), "destroy", g_signal_connect (G_OBJECT (dialog), "destroy",
G_CALLBACK (gtk_widget_destroyed), G_CALLBACK (gtk_widget_destroyed),
&gcb->dialog); &color_button->dialog);
g_signal_connect (G_OBJECT (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->ok_button), g_signal_connect (G_OBJECT (GTK_COLOR_SELECTION_DIALOG (dialog)->ok_button),
"clicked", "clicked",
G_CALLBACK (gimp_color_button_dialog_ok), G_CALLBACK (gimp_color_button_dialog_ok),
gcb); color_button);
g_signal_connect (G_OBJECT (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->cancel_button), g_signal_connect (G_OBJECT (GTK_COLOR_SELECTION_DIALOG (dialog)->cancel_button),
"clicked", "clicked",
G_CALLBACK (gimp_color_button_dialog_cancel), G_CALLBACK (gimp_color_button_dialog_cancel),
gcb); color_button);
gtk_window_set_position (GTK_WINDOW (gcb->dialog), GTK_WIN_POS_MOUSE); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
color_button->dialog = dialog;
} }
gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), &gdk_color); gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel), &gdk_color);
gtk_color_selection_set_current_alpha (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), alpha); gtk_color_selection_set_current_alpha (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel), alpha);
gtk_widget_show (gcb->dialog); gtk_widget_show (dialog);
} }
static void static void
gimp_color_button_dialog_ok (GtkWidget *widget, gimp_color_button_dialog_ok (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpColorButton *gcb; GimpColorButton *button;
GimpRGB color; GimpRGB color;
GdkColor gdk_color; GdkColor gdk_color;
guint16 alpha; guint16 alpha;
g_return_if_fail (GIMP_IS_COLOR_BUTTON (data)); g_return_if_fail (GIMP_IS_COLOR_BUTTON (data));
gcb = GIMP_COLOR_BUTTON (data); button = GIMP_COLOR_BUTTON (data);
gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), &gdk_color); gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (button->dialog)->colorsel), &gdk_color);
alpha = gtk_color_selection_get_current_alpha (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel)); alpha = gtk_color_selection_get_current_alpha (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (button->dialog)->colorsel));
color.r = TODOUBLE (gdk_color.red); color.r = TODOUBLE (gdk_color.red);
color.g = TODOUBLE (gdk_color.green); color.g = TODOUBLE (gdk_color.green);
color.b = TODOUBLE (gdk_color.blue); color.b = TODOUBLE (gdk_color.blue);
color.a = TODOUBLE (alpha); color.a = TODOUBLE (alpha);
gimp_color_button_set_color (gcb, &color); gimp_color_button_set_color (button, &color);
gtk_widget_hide (gcb->dialog); gtk_widget_hide (button->dialog);
} }
static void static void
@ -469,9 +485,9 @@ static void
gimp_color_button_color_changed (GtkObject *object, gimp_color_button_color_changed (GtkObject *object,
gpointer data) gpointer data)
{ {
GimpColorButton *gcb = GIMP_COLOR_BUTTON (data); GimpColorButton *button = GIMP_COLOR_BUTTON (data);
if (gcb->dialog) if (button->dialog)
{ {
GimpRGB color; GimpRGB color;
GdkColor gdk_color; GdkColor gdk_color;
@ -484,11 +500,11 @@ gimp_color_button_color_changed (GtkObject *object,
gdk_color.blue = TOUINT16 (color.b); gdk_color.blue = TOUINT16 (color.b);
alpha = TOUINT16 (color.a); alpha = TOUINT16 (color.a);
gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), &gdk_color); gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (button->dialog)->colorsel), &gdk_color);
gtk_color_selection_set_current_alpha (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), alpha); gtk_color_selection_set_current_alpha (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (button->dialog)->colorsel), alpha);
} }
g_signal_emit (G_OBJECT (gcb), g_signal_emit (G_OBJECT (button),
gimp_color_button_signals[COLOR_CHANGED], 0); gimp_color_button_signals[COLOR_CHANGED], 0);
} }

View File

@ -59,7 +59,7 @@ struct _GimpColorButtonClass
{ {
GimpButtonClass parent_class; GimpButtonClass parent_class;
void (* color_changed) (GimpColorButton *gcb); void (* color_changed) (GimpColorButton *button);
}; };
@ -71,12 +71,12 @@ GtkWidget * gimp_color_button_new (const gchar *title,
const GimpRGB *color, const GimpRGB *color,
GimpColorAreaType type); GimpColorAreaType type);
void gimp_color_button_set_color (GimpColorButton *gcb, void gimp_color_button_set_color (GimpColorButton *button,
const GimpRGB *color); const GimpRGB *color);
void gimp_color_button_get_color (GimpColorButton *gcb, void gimp_color_button_get_color (GimpColorButton *button,
GimpRGB *color); GimpRGB *color);
gboolean gimp_color_button_has_alpha (GimpColorButton *gcb); gboolean gimp_color_button_has_alpha (GimpColorButton *button);
void gimp_color_button_set_type (GimpColorButton *gcb, void gimp_color_button_set_type (GimpColorButton *button,
GimpColorAreaType type); GimpColorAreaType type);

View File

@ -273,6 +273,9 @@ gimp_dialog_create_action_area (GimpDialog *dialog,
* @dialog: The #GimpDialog you want to create the action_area for. * @dialog: The #GimpDialog you want to create the action_area for.
* @args: A @va_list as obtained with va_start() describing the action_area * @args: A @va_list as obtained with va_start() describing the action_area
* buttons. * buttons.
*
* This function creates the action area of a #GimpDialog. You will rarely
* need to call it directly. Instead use gimp_dialog_new() or its variants.
**/ **/
void void
gimp_dialog_create_action_areav (GimpDialog *dialog, gimp_dialog_create_action_areav (GimpDialog *dialog,

View File

@ -57,19 +57,19 @@ enum
}; };
static void gimp_file_selection_class_init (GimpFileSelectionClass *klass); static void gimp_file_selection_class_init (GimpFileSelectionClass *klass);
static void gimp_file_selection_init (GimpFileSelection *gfs); static void gimp_file_selection_init (GimpFileSelection *selection);
static void gimp_file_selection_destroy (GtkObject *object); static void gimp_file_selection_destroy (GtkObject *object);
static void gimp_file_selection_entry_callback (GtkWidget *widget, static void gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data); gpointer data);
static gint gimp_file_selection_entry_focus_out_callback (GtkWidget *widget, static gint gimp_file_selection_entry_focus_out_callback (GtkWidget *widget,
GdkEvent *event, GdkEvent *event,
gpointer data); gpointer data);
static void gimp_file_selection_browse_callback (GtkWidget *widget, static void gimp_file_selection_browse_callback (GtkWidget *widget,
gpointer data); gpointer data);
static void gimp_file_selection_check_filename (GimpFileSelection *gfs); static void gimp_file_selection_check_filename (GimpFileSelection *selection);
static guint gimp_file_selection_signals[LAST_SIGNAL] = { 0 }; static guint gimp_file_selection_signals[LAST_SIGNAL] = { 0 };
@ -80,11 +80,11 @@ static GtkHBoxClass *parent_class = NULL;
GType GType
gimp_file_selection_get_type (void) gimp_file_selection_get_type (void)
{ {
static GType gfs_type = 0; static GType selection_type = 0;
if (! gfs_type) if (! selection_type)
{ {
static const GTypeInfo gfs_info = static const GTypeInfo selection_info =
{ {
sizeof (GimpFileSelectionClass), sizeof (GimpFileSelectionClass),
(GBaseInitFunc) NULL, (GBaseInitFunc) NULL,
@ -97,12 +97,12 @@ gimp_file_selection_get_type (void)
(GInstanceInitFunc) gimp_file_selection_init, (GInstanceInitFunc) gimp_file_selection_init,
}; };
gfs_type = g_type_register_static (GTK_TYPE_HBOX, selection_type = g_type_register_static (GTK_TYPE_HBOX,
"GimpFileSelection", "GimpFileSelection",
&gfs_info, 0); &selection_info, 0);
} }
return gfs_type; return selection_type;
} }
static void static void
@ -118,66 +118,66 @@ gimp_file_selection_class_init (GimpFileSelectionClass *klass)
g_signal_new ("filename_changed", g_signal_new ("filename_changed",
G_TYPE_FROM_CLASS (klass), G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpFileSelectionClass, G_STRUCT_OFFSET (GimpFileSelectionClass, filename_changed),
filename_changed),
NULL, NULL, NULL, NULL,
g_cclosure_marshal_VOID__VOID, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
object_class->destroy = gimp_file_selection_destroy; object_class->destroy = gimp_file_selection_destroy;
klass->filename_changed = NULL; klass->filename_changed = NULL;
} }
static void static void
gimp_file_selection_init (GimpFileSelection *gfs) gimp_file_selection_init (GimpFileSelection *selection)
{ {
gfs->title = NULL; selection->title = NULL;
gfs->file_selection = NULL; selection->file_selection = NULL;
gfs->check_valid = FALSE; selection->check_valid = FALSE;
gfs->file_exists = NULL; selection->file_exists = NULL;
gtk_box_set_spacing (GTK_BOX (gfs), 2); gtk_box_set_spacing (GTK_BOX (selection), 2);
gtk_box_set_homogeneous (GTK_BOX (gfs), FALSE); gtk_box_set_homogeneous (GTK_BOX (selection), FALSE);
gfs->browse_button = gtk_button_new_with_label (" ... "); selection->browse_button = gtk_button_new_with_label (" ... ");
gtk_box_pack_end (GTK_BOX (gfs), gfs->browse_button, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (selection),
g_signal_connect (G_OBJECT(gfs->browse_button), "clicked", selection->browse_button, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (selection->browse_button), "clicked",
G_CALLBACK (gimp_file_selection_browse_callback), G_CALLBACK (gimp_file_selection_browse_callback),
gfs); selection);
gtk_widget_show (gfs->browse_button); gtk_widget_show (selection->browse_button);
gfs->entry = gtk_entry_new (); selection->entry = gtk_entry_new ();
gtk_box_pack_end (GTK_BOX (gfs), gfs->entry, TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (selection), selection->entry, TRUE, TRUE, 0);
g_signal_connect (G_OBJECT (gfs->entry), "activate", g_signal_connect (G_OBJECT (selection->entry), "activate",
G_CALLBACK (gimp_file_selection_entry_callback), G_CALLBACK (gimp_file_selection_entry_callback),
gfs); selection);
g_signal_connect (G_OBJECT (gfs->entry), "focus_out_event", g_signal_connect (G_OBJECT (selection->entry), "focus_out_event",
G_CALLBACK (gimp_file_selection_entry_focus_out_callback), G_CALLBACK (gimp_file_selection_entry_focus_out_callback),
gfs); selection);
gtk_widget_show (gfs->entry); gtk_widget_show (selection->entry);
} }
static void static void
gimp_file_selection_destroy (GtkObject *object) gimp_file_selection_destroy (GtkObject *object)
{ {
GimpFileSelection *gfs; GimpFileSelection *selection;
g_return_if_fail (GIMP_IS_FILE_SELECTION (object)); g_return_if_fail (GIMP_IS_FILE_SELECTION (object));
gfs = GIMP_FILE_SELECTION (object); selection = GIMP_FILE_SELECTION (object);
if (gfs->file_selection) if (selection->file_selection)
{ {
gtk_widget_destroy (gfs->file_selection); gtk_widget_destroy (selection->file_selection);
gfs->file_selection = NULL; selection->file_selection = NULL;
} }
if (gfs->title) if (selection->title)
{ {
g_free (gfs->title); g_free (selection->title);
gfs->title = NULL; selection->title = NULL;
} }
if (GTK_OBJECT_CLASS (parent_class)->destroy) if (GTK_OBJECT_CLASS (parent_class)->destroy)
@ -202,46 +202,47 @@ gimp_file_selection_new (const gchar *title,
gboolean dir_only, gboolean dir_only,
gboolean check_valid) gboolean check_valid)
{ {
GimpFileSelection *gfs; GimpFileSelection *selection;
gfs = g_object_new (GIMP_TYPE_FILE_SELECTION, NULL); selection = g_object_new (GIMP_TYPE_FILE_SELECTION, NULL);
gfs->title = g_strdup (title); selection->title = g_strdup (title);
gfs->dir_only = dir_only; selection->dir_only = dir_only;
gfs->check_valid = check_valid; selection->check_valid = check_valid;
if (check_valid) if (check_valid)
{ {
gfs->file_exists = gtk_image_new_from_stock (GTK_STOCK_NO, selection->file_exists = gtk_image_new_from_stock (GTK_STOCK_NO,
GTK_ICON_SIZE_BUTTON); GTK_ICON_SIZE_BUTTON);
gtk_box_pack_start (GTK_BOX (gfs), gfs->file_exists, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (selection),
gtk_widget_show (gfs->file_exists); selection->file_exists, FALSE, FALSE, 0);
gtk_widget_show (selection->file_exists);
} }
gimp_file_selection_set_filename (gfs, filename); gimp_file_selection_set_filename (selection, filename);
return GTK_WIDGET (gfs); return GTK_WIDGET (selection);
} }
/** /**
* gimp_file_selection_get_filename: * gimp_file_selection_get_filename:
* @gfs: The file selection you want to know the filename from. * @selection: The file selection you want to know the filename from.
* *
* Note that you have to g_free() the returned string. * Note that you have to g_free() the returned string.
* *
* Returns: The file or directory the user has entered. * Returns: The file or directory the user has entered.
**/ **/
gchar * gchar *
gimp_file_selection_get_filename (GimpFileSelection *gfs) gimp_file_selection_get_filename (GimpFileSelection *selection)
{ {
g_return_val_if_fail (GIMP_IS_FILE_SELECTION (gfs), NULL); g_return_val_if_fail (GIMP_IS_FILE_SELECTION (selection), NULL);
return gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1); return gtk_editable_get_chars (GTK_EDITABLE (selection->entry), 0, -1);
} }
/** /**
* gimp_file_selection_set_filename: * gimp_file_selection_set_filename:
* @gfs: The file selection you want to set the filename for. * @selection: The file selection you want to set the filename for.
* @filename: The new filename. * @filename: The new filename.
* *
* If you specified @check_valid as #TRUE in gimp_file_selection_new() * If you specified @check_valid as #TRUE in gimp_file_selection_new()
@ -250,27 +251,27 @@ gimp_file_selection_get_filename (GimpFileSelection *gfs)
* *
*/ */
void void
gimp_file_selection_set_filename (GimpFileSelection *gfs, gimp_file_selection_set_filename (GimpFileSelection *selection,
const gchar *filename) const gchar *filename)
{ {
g_return_if_fail (GIMP_IS_FILE_SELECTION (gfs)); g_return_if_fail (GIMP_IS_FILE_SELECTION (selection));
gtk_entry_set_text (GTK_ENTRY (gfs->entry), filename ? filename : ""); gtk_entry_set_text (GTK_ENTRY (selection->entry), filename ? filename : "");
/* update everything /* update everything
*/ */
gimp_file_selection_entry_callback (gfs->entry, (gpointer) gfs); gimp_file_selection_entry_callback (selection->entry, (gpointer) selection);
} }
static void static void
gimp_file_selection_entry_callback (GtkWidget *widget, gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpFileSelection *gfs; GimpFileSelection *selection;
gchar *filename; gchar *filename;
gint len; gint len;
gfs = GIMP_FILE_SELECTION (data); selection = GIMP_FILE_SELECTION (data);
/* filenames still need more sanity checking /* filenames still need more sanity checking
* (erase double G_DIR_SEPARATORS, ...) * (erase double G_DIR_SEPARATORS, ...)
@ -282,24 +283,24 @@ gimp_file_selection_entry_callback (GtkWidget *widget,
(filename[len - 1] == G_DIR_SEPARATOR)) (filename[len - 1] == G_DIR_SEPARATOR))
filename[len - 1] = '\0'; filename[len - 1] = '\0';
g_signal_handlers_block_by_func (G_OBJECT (gfs->entry), g_signal_handlers_block_by_func (G_OBJECT (selection->entry),
gimp_file_selection_entry_callback, gimp_file_selection_entry_callback,
gfs); selection);
gtk_entry_set_text (GTK_ENTRY (gfs->entry), filename); gtk_entry_set_text (GTK_ENTRY (selection->entry), filename);
g_signal_handlers_unblock_by_func (G_OBJECT (gfs->entry), g_signal_handlers_unblock_by_func (G_OBJECT (selection->entry),
gimp_file_selection_entry_callback, gimp_file_selection_entry_callback,
gfs); selection);
if (gfs->file_selection) if (selection->file_selection)
gtk_file_selection_set_filename (GTK_FILE_SELECTION (gfs->file_selection), gtk_file_selection_set_filename (GTK_FILE_SELECTION (selection->file_selection),
filename); filename);
g_free (filename); g_free (filename);
gimp_file_selection_check_filename (gfs); gimp_file_selection_check_filename (selection);
gtk_editable_set_position (GTK_EDITABLE (gfs->entry), -1); gtk_editable_set_position (GTK_EDITABLE (selection->entry), -1);
g_signal_emit (G_OBJECT (gfs), g_signal_emit (G_OBJECT (selection),
gimp_file_selection_signals[FILENAME_CHANGED], 0); gimp_file_selection_signals[FILENAME_CHANGED], 0);
} }
@ -318,115 +319,117 @@ static void
gimp_file_selection_filesel_ok_callback (GtkWidget *widget, gimp_file_selection_filesel_ok_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpFileSelection *gfs; GimpFileSelection *selection;
const gchar *filename; const gchar *filename;
gfs = GIMP_FILE_SELECTION (data); selection = GIMP_FILE_SELECTION (data);
filename = filename =
gtk_file_selection_get_filename (GTK_FILE_SELECTION (gfs->file_selection)); gtk_file_selection_get_filename (GTK_FILE_SELECTION (selection->file_selection));
gtk_entry_set_text (GTK_ENTRY (gfs->entry), filename); gtk_entry_set_text (GTK_ENTRY (selection->entry), filename);
gtk_widget_hide (gfs->file_selection); gtk_widget_hide (selection->file_selection);
/* update everything */ /* update everything */
gimp_file_selection_entry_callback (gfs->entry, data); gimp_file_selection_entry_callback (selection->entry, data);
} }
static void static void
gimp_file_selection_browse_callback (GtkWidget *widget, gimp_file_selection_browse_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpFileSelection *gfs; GimpFileSelection *selection;
gchar *filename; gchar *filename;
gfs = GIMP_FILE_SELECTION (data); selection = GIMP_FILE_SELECTION (data);
filename = gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1); filename = gtk_editable_get_chars (GTK_EDITABLE (selection->entry), 0, -1);
if (gfs->file_selection == NULL) if (selection->file_selection == NULL)
{ {
if (gfs->dir_only) if (selection->dir_only)
{ {
gfs->file_selection = selection->file_selection =
gtk_file_selection_new (gfs->title ? gtk_file_selection_new (selection->title ?
gfs->title : _("Select Folder")); selection->title : _("Select Folder"));
/* hiding these widgets uses internal gtk+ knowledge, but it's /* hiding these widgets uses internal gtk+ knowledge, but it's
* easier than creating my own directory browser -- michael * easier than creating my own directory browser -- michael
*/ */
gtk_widget_hide gtk_widget_hide
(GTK_FILE_SELECTION (gfs->file_selection)->fileop_del_file); (GTK_FILE_SELECTION (selection->file_selection)->fileop_del_file);
gtk_widget_hide gtk_widget_hide
(GTK_FILE_SELECTION (gfs->file_selection)->file_list->parent); (GTK_FILE_SELECTION (selection->file_selection)->file_list->parent);
} }
else else
{ {
gfs->file_selection = selection->file_selection =
gtk_file_selection_new (gfs->title ? gtk_file_selection_new (selection->title ?
gfs->title : _("Select File")); selection->title : _("Select File"));
} }
gtk_window_set_position (GTK_WINDOW (gfs->file_selection), gtk_window_set_position (GTK_WINDOW (selection->file_selection),
GTK_WIN_POS_MOUSE); GTK_WIN_POS_MOUSE);
gtk_window_set_wmclass (GTK_WINDOW (gfs->file_selection), gtk_window_set_wmclass (GTK_WINDOW (selection->file_selection),
"file_select", "Gimp"); "file_select", "Gimp");
/* slightly compress the dialog */ /* slightly compress the dialog */
gtk_container_set_border_width (GTK_CONTAINER (gfs->file_selection), 2); gtk_container_set_border_width (GTK_CONTAINER (selection->file_selection),
gtk_container_set_border_width (GTK_CONTAINER (GTK_FILE_SELECTION (gfs->file_selection)->button_area), 2); 2);
gtk_container_set_border_width (GTK_CONTAINER (GTK_FILE_SELECTION (selection->file_selection)->button_area),
2);
g_signal_connect g_signal_connect
(G_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->ok_button), (G_OBJECT (GTK_FILE_SELECTION (selection->file_selection)->ok_button),
"clicked", "clicked",
G_CALLBACK (gimp_file_selection_filesel_ok_callback), G_CALLBACK (gimp_file_selection_filesel_ok_callback),
gfs); selection);
g_signal_connect g_signal_connect
(G_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->selection_entry), (G_OBJECT (GTK_FILE_SELECTION (selection->file_selection)->selection_entry),
"activate", "activate",
G_CALLBACK (gimp_file_selection_filesel_ok_callback), G_CALLBACK (gimp_file_selection_filesel_ok_callback),
gfs); selection);
g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->cancel_button), g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION (selection->file_selection)->cancel_button),
"clicked", "clicked",
G_CALLBACK (gtk_widget_hide), G_CALLBACK (gtk_widget_hide),
gfs->file_selection); selection->file_selection);
g_signal_connect_swapped (GTK_OBJECT (gfs), "unmap", g_signal_connect_swapped (GTK_OBJECT (selection), "unmap",
G_CALLBACK (gtk_widget_hide), G_CALLBACK (gtk_widget_hide),
gfs->file_selection); selection->file_selection);
g_signal_connect_swapped (GTK_OBJECT (gfs->file_selection), g_signal_connect_swapped (GTK_OBJECT (selection->file_selection),
"delete_event", "delete_event",
G_CALLBACK (gtk_widget_hide), G_CALLBACK (gtk_widget_hide),
gfs->file_selection); selection->file_selection);
} }
gtk_file_selection_set_filename (GTK_FILE_SELECTION (gfs->file_selection), gtk_file_selection_set_filename (GTK_FILE_SELECTION (selection->file_selection),
filename); filename);
gtk_window_present (GTK_WINDOW (gfs->file_selection)); gtk_window_present (GTK_WINDOW (selection->file_selection));
} }
static void static void
gimp_file_selection_check_filename (GimpFileSelection *gfs) gimp_file_selection_check_filename (GimpFileSelection *selection)
{ {
gchar *filename; gchar *filename;
gboolean exists; gboolean exists;
if (! gfs->check_valid) if (! selection->check_valid)
return; return;
if (gfs->file_exists == NULL) if (selection->file_exists == NULL)
return; return;
filename = gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1); filename = gtk_editable_get_chars (GTK_EDITABLE (selection->entry), 0, -1);
if (gfs->dir_only) if (selection->dir_only)
exists = g_file_test (filename, G_FILE_TEST_IS_DIR); exists = g_file_test (filename, G_FILE_TEST_IS_DIR);
else else
exists = g_file_test (filename, G_FILE_TEST_IS_REGULAR); exists = g_file_test (filename, G_FILE_TEST_IS_REGULAR);
g_free (filename); g_free (filename);
gtk_image_set_from_stock (GTK_IMAGE (gfs->file_exists), gtk_image_set_from_stock (GTK_IMAGE (selection->file_exists),
exists ? GTK_STOCK_YES : GTK_STOCK_NO, exists ? GTK_STOCK_YES : GTK_STOCK_NO,
GTK_ICON_SIZE_BUTTON); GTK_ICON_SIZE_BUTTON);
} }

View File

@ -57,7 +57,7 @@ struct _GimpFileSelectionClass
{ {
GtkHBoxClass parent_class; GtkHBoxClass parent_class;
void (* filename_changed) (GimpFileSelection *gfs); void (* filename_changed) (GimpFileSelection *selection);
}; };
@ -68,9 +68,9 @@ GtkWidget * gimp_file_selection_new (const gchar *title,
gboolean dir_only, gboolean dir_only,
gboolean check_valid); gboolean check_valid);
gchar * gimp_file_selection_get_filename (GimpFileSelection *gfs); gchar * gimp_file_selection_get_filename (GimpFileSelection *selection);
void gimp_file_selection_set_filename (GimpFileSelection *gfs, void gimp_file_selection_set_filename (GimpFileSelection *selection,
const gchar *filename); const gchar *filename);

View File

@ -57,19 +57,19 @@ enum
}; };
static void gimp_file_selection_class_init (GimpFileSelectionClass *klass); static void gimp_file_selection_class_init (GimpFileSelectionClass *klass);
static void gimp_file_selection_init (GimpFileSelection *gfs); static void gimp_file_selection_init (GimpFileSelection *selection);
static void gimp_file_selection_destroy (GtkObject *object); static void gimp_file_selection_destroy (GtkObject *object);
static void gimp_file_selection_entry_callback (GtkWidget *widget, static void gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data); gpointer data);
static gint gimp_file_selection_entry_focus_out_callback (GtkWidget *widget, static gint gimp_file_selection_entry_focus_out_callback (GtkWidget *widget,
GdkEvent *event, GdkEvent *event,
gpointer data); gpointer data);
static void gimp_file_selection_browse_callback (GtkWidget *widget, static void gimp_file_selection_browse_callback (GtkWidget *widget,
gpointer data); gpointer data);
static void gimp_file_selection_check_filename (GimpFileSelection *gfs); static void gimp_file_selection_check_filename (GimpFileSelection *selection);
static guint gimp_file_selection_signals[LAST_SIGNAL] = { 0 }; static guint gimp_file_selection_signals[LAST_SIGNAL] = { 0 };
@ -80,11 +80,11 @@ static GtkHBoxClass *parent_class = NULL;
GType GType
gimp_file_selection_get_type (void) gimp_file_selection_get_type (void)
{ {
static GType gfs_type = 0; static GType selection_type = 0;
if (! gfs_type) if (! selection_type)
{ {
static const GTypeInfo gfs_info = static const GTypeInfo selection_info =
{ {
sizeof (GimpFileSelectionClass), sizeof (GimpFileSelectionClass),
(GBaseInitFunc) NULL, (GBaseInitFunc) NULL,
@ -97,12 +97,12 @@ gimp_file_selection_get_type (void)
(GInstanceInitFunc) gimp_file_selection_init, (GInstanceInitFunc) gimp_file_selection_init,
}; };
gfs_type = g_type_register_static (GTK_TYPE_HBOX, selection_type = g_type_register_static (GTK_TYPE_HBOX,
"GimpFileSelection", "GimpFileSelection",
&gfs_info, 0); &selection_info, 0);
} }
return gfs_type; return selection_type;
} }
static void static void
@ -118,66 +118,66 @@ gimp_file_selection_class_init (GimpFileSelectionClass *klass)
g_signal_new ("filename_changed", g_signal_new ("filename_changed",
G_TYPE_FROM_CLASS (klass), G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpFileSelectionClass, G_STRUCT_OFFSET (GimpFileSelectionClass, filename_changed),
filename_changed),
NULL, NULL, NULL, NULL,
g_cclosure_marshal_VOID__VOID, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
object_class->destroy = gimp_file_selection_destroy; object_class->destroy = gimp_file_selection_destroy;
klass->filename_changed = NULL; klass->filename_changed = NULL;
} }
static void static void
gimp_file_selection_init (GimpFileSelection *gfs) gimp_file_selection_init (GimpFileSelection *selection)
{ {
gfs->title = NULL; selection->title = NULL;
gfs->file_selection = NULL; selection->file_selection = NULL;
gfs->check_valid = FALSE; selection->check_valid = FALSE;
gfs->file_exists = NULL; selection->file_exists = NULL;
gtk_box_set_spacing (GTK_BOX (gfs), 2); gtk_box_set_spacing (GTK_BOX (selection), 2);
gtk_box_set_homogeneous (GTK_BOX (gfs), FALSE); gtk_box_set_homogeneous (GTK_BOX (selection), FALSE);
gfs->browse_button = gtk_button_new_with_label (" ... "); selection->browse_button = gtk_button_new_with_label (" ... ");
gtk_box_pack_end (GTK_BOX (gfs), gfs->browse_button, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (selection),
g_signal_connect (G_OBJECT(gfs->browse_button), "clicked", selection->browse_button, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (selection->browse_button), "clicked",
G_CALLBACK (gimp_file_selection_browse_callback), G_CALLBACK (gimp_file_selection_browse_callback),
gfs); selection);
gtk_widget_show (gfs->browse_button); gtk_widget_show (selection->browse_button);
gfs->entry = gtk_entry_new (); selection->entry = gtk_entry_new ();
gtk_box_pack_end (GTK_BOX (gfs), gfs->entry, TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (selection), selection->entry, TRUE, TRUE, 0);
g_signal_connect (G_OBJECT (gfs->entry), "activate", g_signal_connect (G_OBJECT (selection->entry), "activate",
G_CALLBACK (gimp_file_selection_entry_callback), G_CALLBACK (gimp_file_selection_entry_callback),
gfs); selection);
g_signal_connect (G_OBJECT (gfs->entry), "focus_out_event", g_signal_connect (G_OBJECT (selection->entry), "focus_out_event",
G_CALLBACK (gimp_file_selection_entry_focus_out_callback), G_CALLBACK (gimp_file_selection_entry_focus_out_callback),
gfs); selection);
gtk_widget_show (gfs->entry); gtk_widget_show (selection->entry);
} }
static void static void
gimp_file_selection_destroy (GtkObject *object) gimp_file_selection_destroy (GtkObject *object)
{ {
GimpFileSelection *gfs; GimpFileSelection *selection;
g_return_if_fail (GIMP_IS_FILE_SELECTION (object)); g_return_if_fail (GIMP_IS_FILE_SELECTION (object));
gfs = GIMP_FILE_SELECTION (object); selection = GIMP_FILE_SELECTION (object);
if (gfs->file_selection) if (selection->file_selection)
{ {
gtk_widget_destroy (gfs->file_selection); gtk_widget_destroy (selection->file_selection);
gfs->file_selection = NULL; selection->file_selection = NULL;
} }
if (gfs->title) if (selection->title)
{ {
g_free (gfs->title); g_free (selection->title);
gfs->title = NULL; selection->title = NULL;
} }
if (GTK_OBJECT_CLASS (parent_class)->destroy) if (GTK_OBJECT_CLASS (parent_class)->destroy)
@ -202,46 +202,47 @@ gimp_file_selection_new (const gchar *title,
gboolean dir_only, gboolean dir_only,
gboolean check_valid) gboolean check_valid)
{ {
GimpFileSelection *gfs; GimpFileSelection *selection;
gfs = g_object_new (GIMP_TYPE_FILE_SELECTION, NULL); selection = g_object_new (GIMP_TYPE_FILE_SELECTION, NULL);
gfs->title = g_strdup (title); selection->title = g_strdup (title);
gfs->dir_only = dir_only; selection->dir_only = dir_only;
gfs->check_valid = check_valid; selection->check_valid = check_valid;
if (check_valid) if (check_valid)
{ {
gfs->file_exists = gtk_image_new_from_stock (GTK_STOCK_NO, selection->file_exists = gtk_image_new_from_stock (GTK_STOCK_NO,
GTK_ICON_SIZE_BUTTON); GTK_ICON_SIZE_BUTTON);
gtk_box_pack_start (GTK_BOX (gfs), gfs->file_exists, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (selection),
gtk_widget_show (gfs->file_exists); selection->file_exists, FALSE, FALSE, 0);
gtk_widget_show (selection->file_exists);
} }
gimp_file_selection_set_filename (gfs, filename); gimp_file_selection_set_filename (selection, filename);
return GTK_WIDGET (gfs); return GTK_WIDGET (selection);
} }
/** /**
* gimp_file_selection_get_filename: * gimp_file_selection_get_filename:
* @gfs: The file selection you want to know the filename from. * @selection: The file selection you want to know the filename from.
* *
* Note that you have to g_free() the returned string. * Note that you have to g_free() the returned string.
* *
* Returns: The file or directory the user has entered. * Returns: The file or directory the user has entered.
**/ **/
gchar * gchar *
gimp_file_selection_get_filename (GimpFileSelection *gfs) gimp_file_selection_get_filename (GimpFileSelection *selection)
{ {
g_return_val_if_fail (GIMP_IS_FILE_SELECTION (gfs), NULL); g_return_val_if_fail (GIMP_IS_FILE_SELECTION (selection), NULL);
return gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1); return gtk_editable_get_chars (GTK_EDITABLE (selection->entry), 0, -1);
} }
/** /**
* gimp_file_selection_set_filename: * gimp_file_selection_set_filename:
* @gfs: The file selection you want to set the filename for. * @selection: The file selection you want to set the filename for.
* @filename: The new filename. * @filename: The new filename.
* *
* If you specified @check_valid as #TRUE in gimp_file_selection_new() * If you specified @check_valid as #TRUE in gimp_file_selection_new()
@ -250,27 +251,27 @@ gimp_file_selection_get_filename (GimpFileSelection *gfs)
* *
*/ */
void void
gimp_file_selection_set_filename (GimpFileSelection *gfs, gimp_file_selection_set_filename (GimpFileSelection *selection,
const gchar *filename) const gchar *filename)
{ {
g_return_if_fail (GIMP_IS_FILE_SELECTION (gfs)); g_return_if_fail (GIMP_IS_FILE_SELECTION (selection));
gtk_entry_set_text (GTK_ENTRY (gfs->entry), filename ? filename : ""); gtk_entry_set_text (GTK_ENTRY (selection->entry), filename ? filename : "");
/* update everything /* update everything
*/ */
gimp_file_selection_entry_callback (gfs->entry, (gpointer) gfs); gimp_file_selection_entry_callback (selection->entry, (gpointer) selection);
} }
static void static void
gimp_file_selection_entry_callback (GtkWidget *widget, gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpFileSelection *gfs; GimpFileSelection *selection;
gchar *filename; gchar *filename;
gint len; gint len;
gfs = GIMP_FILE_SELECTION (data); selection = GIMP_FILE_SELECTION (data);
/* filenames still need more sanity checking /* filenames still need more sanity checking
* (erase double G_DIR_SEPARATORS, ...) * (erase double G_DIR_SEPARATORS, ...)
@ -282,24 +283,24 @@ gimp_file_selection_entry_callback (GtkWidget *widget,
(filename[len - 1] == G_DIR_SEPARATOR)) (filename[len - 1] == G_DIR_SEPARATOR))
filename[len - 1] = '\0'; filename[len - 1] = '\0';
g_signal_handlers_block_by_func (G_OBJECT (gfs->entry), g_signal_handlers_block_by_func (G_OBJECT (selection->entry),
gimp_file_selection_entry_callback, gimp_file_selection_entry_callback,
gfs); selection);
gtk_entry_set_text (GTK_ENTRY (gfs->entry), filename); gtk_entry_set_text (GTK_ENTRY (selection->entry), filename);
g_signal_handlers_unblock_by_func (G_OBJECT (gfs->entry), g_signal_handlers_unblock_by_func (G_OBJECT (selection->entry),
gimp_file_selection_entry_callback, gimp_file_selection_entry_callback,
gfs); selection);
if (gfs->file_selection) if (selection->file_selection)
gtk_file_selection_set_filename (GTK_FILE_SELECTION (gfs->file_selection), gtk_file_selection_set_filename (GTK_FILE_SELECTION (selection->file_selection),
filename); filename);
g_free (filename); g_free (filename);
gimp_file_selection_check_filename (gfs); gimp_file_selection_check_filename (selection);
gtk_editable_set_position (GTK_EDITABLE (gfs->entry), -1); gtk_editable_set_position (GTK_EDITABLE (selection->entry), -1);
g_signal_emit (G_OBJECT (gfs), g_signal_emit (G_OBJECT (selection),
gimp_file_selection_signals[FILENAME_CHANGED], 0); gimp_file_selection_signals[FILENAME_CHANGED], 0);
} }
@ -318,115 +319,117 @@ static void
gimp_file_selection_filesel_ok_callback (GtkWidget *widget, gimp_file_selection_filesel_ok_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpFileSelection *gfs; GimpFileSelection *selection;
const gchar *filename; const gchar *filename;
gfs = GIMP_FILE_SELECTION (data); selection = GIMP_FILE_SELECTION (data);
filename = filename =
gtk_file_selection_get_filename (GTK_FILE_SELECTION (gfs->file_selection)); gtk_file_selection_get_filename (GTK_FILE_SELECTION (selection->file_selection));
gtk_entry_set_text (GTK_ENTRY (gfs->entry), filename); gtk_entry_set_text (GTK_ENTRY (selection->entry), filename);
gtk_widget_hide (gfs->file_selection); gtk_widget_hide (selection->file_selection);
/* update everything */ /* update everything */
gimp_file_selection_entry_callback (gfs->entry, data); gimp_file_selection_entry_callback (selection->entry, data);
} }
static void static void
gimp_file_selection_browse_callback (GtkWidget *widget, gimp_file_selection_browse_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpFileSelection *gfs; GimpFileSelection *selection;
gchar *filename; gchar *filename;
gfs = GIMP_FILE_SELECTION (data); selection = GIMP_FILE_SELECTION (data);
filename = gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1); filename = gtk_editable_get_chars (GTK_EDITABLE (selection->entry), 0, -1);
if (gfs->file_selection == NULL) if (selection->file_selection == NULL)
{ {
if (gfs->dir_only) if (selection->dir_only)
{ {
gfs->file_selection = selection->file_selection =
gtk_file_selection_new (gfs->title ? gtk_file_selection_new (selection->title ?
gfs->title : _("Select Folder")); selection->title : _("Select Folder"));
/* hiding these widgets uses internal gtk+ knowledge, but it's /* hiding these widgets uses internal gtk+ knowledge, but it's
* easier than creating my own directory browser -- michael * easier than creating my own directory browser -- michael
*/ */
gtk_widget_hide gtk_widget_hide
(GTK_FILE_SELECTION (gfs->file_selection)->fileop_del_file); (GTK_FILE_SELECTION (selection->file_selection)->fileop_del_file);
gtk_widget_hide gtk_widget_hide
(GTK_FILE_SELECTION (gfs->file_selection)->file_list->parent); (GTK_FILE_SELECTION (selection->file_selection)->file_list->parent);
} }
else else
{ {
gfs->file_selection = selection->file_selection =
gtk_file_selection_new (gfs->title ? gtk_file_selection_new (selection->title ?
gfs->title : _("Select File")); selection->title : _("Select File"));
} }
gtk_window_set_position (GTK_WINDOW (gfs->file_selection), gtk_window_set_position (GTK_WINDOW (selection->file_selection),
GTK_WIN_POS_MOUSE); GTK_WIN_POS_MOUSE);
gtk_window_set_wmclass (GTK_WINDOW (gfs->file_selection), gtk_window_set_wmclass (GTK_WINDOW (selection->file_selection),
"file_select", "Gimp"); "file_select", "Gimp");
/* slightly compress the dialog */ /* slightly compress the dialog */
gtk_container_set_border_width (GTK_CONTAINER (gfs->file_selection), 2); gtk_container_set_border_width (GTK_CONTAINER (selection->file_selection),
gtk_container_set_border_width (GTK_CONTAINER (GTK_FILE_SELECTION (gfs->file_selection)->button_area), 2); 2);
gtk_container_set_border_width (GTK_CONTAINER (GTK_FILE_SELECTION (selection->file_selection)->button_area),
2);
g_signal_connect g_signal_connect
(G_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->ok_button), (G_OBJECT (GTK_FILE_SELECTION (selection->file_selection)->ok_button),
"clicked", "clicked",
G_CALLBACK (gimp_file_selection_filesel_ok_callback), G_CALLBACK (gimp_file_selection_filesel_ok_callback),
gfs); selection);
g_signal_connect g_signal_connect
(G_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->selection_entry), (G_OBJECT (GTK_FILE_SELECTION (selection->file_selection)->selection_entry),
"activate", "activate",
G_CALLBACK (gimp_file_selection_filesel_ok_callback), G_CALLBACK (gimp_file_selection_filesel_ok_callback),
gfs); selection);
g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->cancel_button), g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION (selection->file_selection)->cancel_button),
"clicked", "clicked",
G_CALLBACK (gtk_widget_hide), G_CALLBACK (gtk_widget_hide),
gfs->file_selection); selection->file_selection);
g_signal_connect_swapped (GTK_OBJECT (gfs), "unmap", g_signal_connect_swapped (GTK_OBJECT (selection), "unmap",
G_CALLBACK (gtk_widget_hide), G_CALLBACK (gtk_widget_hide),
gfs->file_selection); selection->file_selection);
g_signal_connect_swapped (GTK_OBJECT (gfs->file_selection), g_signal_connect_swapped (GTK_OBJECT (selection->file_selection),
"delete_event", "delete_event",
G_CALLBACK (gtk_widget_hide), G_CALLBACK (gtk_widget_hide),
gfs->file_selection); selection->file_selection);
} }
gtk_file_selection_set_filename (GTK_FILE_SELECTION (gfs->file_selection), gtk_file_selection_set_filename (GTK_FILE_SELECTION (selection->file_selection),
filename); filename);
gtk_window_present (GTK_WINDOW (gfs->file_selection)); gtk_window_present (GTK_WINDOW (selection->file_selection));
} }
static void static void
gimp_file_selection_check_filename (GimpFileSelection *gfs) gimp_file_selection_check_filename (GimpFileSelection *selection)
{ {
gchar *filename; gchar *filename;
gboolean exists; gboolean exists;
if (! gfs->check_valid) if (! selection->check_valid)
return; return;
if (gfs->file_exists == NULL) if (selection->file_exists == NULL)
return; return;
filename = gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1); filename = gtk_editable_get_chars (GTK_EDITABLE (selection->entry), 0, -1);
if (gfs->dir_only) if (selection->dir_only)
exists = g_file_test (filename, G_FILE_TEST_IS_DIR); exists = g_file_test (filename, G_FILE_TEST_IS_DIR);
else else
exists = g_file_test (filename, G_FILE_TEST_IS_REGULAR); exists = g_file_test (filename, G_FILE_TEST_IS_REGULAR);
g_free (filename); g_free (filename);
gtk_image_set_from_stock (GTK_IMAGE (gfs->file_exists), gtk_image_set_from_stock (GTK_IMAGE (selection->file_exists),
exists ? GTK_STOCK_YES : GTK_STOCK_NO, exists ? GTK_STOCK_YES : GTK_STOCK_NO,
GTK_ICON_SIZE_BUTTON); GTK_ICON_SIZE_BUTTON);
} }

View File

@ -57,7 +57,7 @@ struct _GimpFileSelectionClass
{ {
GtkHBoxClass parent_class; GtkHBoxClass parent_class;
void (* filename_changed) (GimpFileSelection *gfs); void (* filename_changed) (GimpFileSelection *selection);
}; };
@ -68,9 +68,9 @@ GtkWidget * gimp_file_selection_new (const gchar *title,
gboolean dir_only, gboolean dir_only,
gboolean check_valid); gboolean check_valid);
gchar * gimp_file_selection_get_filename (GimpFileSelection *gfs); gchar * gimp_file_selection_get_filename (GimpFileSelection *selection);
void gimp_file_selection_set_filename (GimpFileSelection *gfs, void gimp_file_selection_set_filename (GimpFileSelection *selection,
const gchar *filename); const gchar *filename);

View File

@ -212,10 +212,10 @@ gimp_offset_area_set_size (GimpOffsetArea *offset_area,
} }
/** /**
* gimp_offset_area_set_size: * gimp_offset_area_set_offsets:
* @offset_area: a #GimpOffsetArea. * @offset_area: a #GimpOffsetArea.
* @width: the X offset * @offset_x: the X offset
* @height: the Y offset * @offset_y: the Y offset
* *
* Sets the offsets of the image/drawable displayed by the #GimpOffsetArea. * Sets the offsets of the image/drawable displayed by the #GimpOffsetArea.
* It does not emit the %offsets_changed signal. * It does not emit the %offsets_changed signal.

View File

@ -168,6 +168,13 @@ gimp_pick_button_destroy (GtkObject *object)
/* public functions */ /* public functions */
/**
* gimp_pick_button_new:
*
* Creates a new #GimpPickButton widget.
*
* Returns: A new #GimpPickButton widget.
**/
GtkWidget * GtkWidget *
gimp_pick_button_new (void) gimp_pick_button_new (void)
{ {

View File

@ -211,6 +211,8 @@ create_query_box (const gchar *title,
* @callback: The function which will be called when the user selects "OK". * @callback: The function which will be called when the user selects "OK".
* @data: The callback's user data. * @data: The callback's user data.
* *
* Creates a new #GtkDialog that queries the user for a string value.
*
* Returns: A pointer to the new #GtkDialog. * Returns: A pointer to the new #GtkDialog.
**/ **/
GtkWidget * GtkWidget *
@ -265,6 +267,8 @@ gimp_query_string_box (const gchar *title,
* @callback: The function which will be called when the user selects "OK". * @callback: The function which will be called when the user selects "OK".
* @data: The callback's user data. * @data: The callback's user data.
* *
* Creates a new #GtkDialog that queries the user for an integer value.
*
* Returns: A pointer to the new #GtkDialog. * Returns: A pointer to the new #GtkDialog.
**/ **/
GtkWidget * GtkWidget *
@ -323,6 +327,8 @@ gimp_query_int_box (const gchar *title,
* @callback: The function which will be called when the user selects "OK". * @callback: The function which will be called when the user selects "OK".
* @data: The callback's user data. * @data: The callback's user data.
* *
* Creates a new #GtkDialog that queries the user for a double value.
*
* Returns: A pointer to the new #GtkDialog. * Returns: A pointer to the new #GtkDialog.
**/ **/
GtkWidget * GtkWidget *
@ -388,6 +394,9 @@ gimp_query_double_box (const gchar *title,
* @callback: The function which will be called when the user selects "OK". * @callback: The function which will be called when the user selects "OK".
* @data: The callback's user data. * @data: The callback's user data.
* *
* Creates a new #GtkDialog that queries the user for a size using a
* #GimpSizeEntry.
*
* Returns: A pointer to the new #GtkDialog. * Returns: A pointer to the new #GtkDialog.
**/ **/
GtkWidget * GtkWidget *
@ -459,6 +468,8 @@ gimp_query_size_box (const gchar *title,
* of the buttons. * of the buttons.
* @data: The callback's user data. * @data: The callback's user data.
* *
* Creates a new #GtkDialog that asks the user to do a boolean decision.
*
* Returns: A pointer to the new #GtkDialog. * Returns: A pointer to the new #GtkDialog.
**/ **/
GtkWidget * GtkWidget *

View File

@ -83,6 +83,8 @@ gimp_widgets_init (void)
* @menu_only: #TRUE if the function should return a #GtkMenu only. * @menu_only: #TRUE if the function should return a #GtkMenu only.
* @...: A #NULL terminated @va_list describing the menu items. * @...: A #NULL terminated @va_list describing the menu items.
* *
* Convenience function to create a #GtkOptionMenu or a #GtkMenu.
*
* Returns: A #GtkOptionMenu or a #GtkMenu (depending on @menu_only). * Returns: A #GtkOptionMenu or a #GtkMenu (depending on @menu_only).
**/ **/
GtkWidget * GtkWidget *
@ -195,6 +197,8 @@ gimp_option_menu_new (gboolean menu_only,
* @initial: The @item_data of the initially selected menu item. * @initial: The @item_data of the initially selected menu item.
* @...: A #NULL terminated @va_list describing the menu items. * @...: A #NULL terminated @va_list describing the menu items.
* *
* Convenience function to create a #GtkOptionMenu or a #GtkMenu.
*
* Returns: A #GtkOptionMenu or a #GtkMenu (depending on @menu_only). * Returns: A #GtkOptionMenu or a #GtkMenu (depending on @menu_only).
**/ **/
GtkWidget * GtkWidget *
@ -296,6 +300,10 @@ gimp_option_menu_new2 (gboolean menu_only,
* @option_menu: A #GtkOptionMenu as returned by gimp_option_menu_new() or * @option_menu: A #GtkOptionMenu as returned by gimp_option_menu_new() or
* gimp_option_menu_new2(). * gimp_option_menu_new2().
* @item_data: The @item_data of the menu item you want to select. * @item_data: The @item_data of the menu item you want to select.
*
* Iterates over all entries in a #GtkOptionMenu and selects the one with the
* matching @item_data. Probably only makes sense to use with a #GtkOptionMenu
* that was created using gimp_option_menu_new() or gimp_option_menu_new2().
**/ **/
void void
gimp_option_menu_set_history (GtkOptionMenu *option_menu, gimp_option_menu_set_history (GtkOptionMenu *option_menu,
@ -374,6 +382,9 @@ gimp_option_menu_set_sensitive (GtkOptionMenu *option_menu,
* @frame_title: The title of the Frame or #NULL if you don't want a title. * @frame_title: The title of the Frame or #NULL if you don't want a title.
* @...: A #NULL terminated @va_list describing the radio buttons. * @...: A #NULL terminated @va_list describing the radio buttons.
* *
* Convenience function to create a group of radio buttons embedded into
* a #GtkFrame or #GtkVbox.
*
* Returns: A #GtkFrame or #GtkVbox (depending on @in_frame). * Returns: A #GtkFrame or #GtkVbox (depending on @in_frame).
**/ **/
GtkWidget * GtkWidget *
@ -482,6 +493,9 @@ gimp_radio_group_new (gboolean in_frame,
* @...: A #NULL terminated @va_list describing * @...: A #NULL terminated @va_list describing
* the radio buttons. * the radio buttons.
* *
* Convenience function to create a group of radio buttons embedded into
* a #GtkFrame or #GtkVbox.
*
* Returns: A #GtkFrame or #GtkVbox (depending on @in_frame). * Returns: A #GtkFrame or #GtkVbox (depending on @in_frame).
**/ **/
GtkWidget * GtkWidget *
@ -571,6 +585,14 @@ gimp_radio_group_new2 (gboolean in_frame,
return vbox; return vbox;
} }
/**
* gimp_radio_group_set_active:
* @radio_button: Pointer to a #GtkRadioButton.
* @item_data: The @item_data of the radio button you want to select.
*
* Calls gtk_toggle_button_set_active() with the radio button that was created
* with a matching @item_data.
**/
void void
gimp_radio_group_set_active (GtkRadioButton *radio_button, gimp_radio_group_set_active (GtkRadioButton *radio_button,
gpointer item_data) gpointer item_data)
@ -650,7 +672,7 @@ gimp_scale_entry_unconstrained_adjustment_callback (GtkAdjustment *adjustment,
adjustment); adjustment);
} }
GtkObject * static GtkObject *
gimp_scale_entry_new_internal (gboolean color_scale, gimp_scale_entry_new_internal (gboolean color_scale,
GtkTable *table, GtkTable *table,
gint column, gint column,
@ -1083,9 +1105,11 @@ gimp_coordinates_callback (GtkWidget *widget,
* @ysize_0: The Y value which will be treated as 0%. * @ysize_0: The Y value which will be treated as 0%.
* @ysize_100: The Y value which will be treated as 100%. * @ysize_100: The Y value which will be treated as 100%.
* *
* Returns: A #GimpSizeEntry with two fields for x/y coordinates/sizes with * Convenience function that creates a #GimpSizeEntry with two fields for x/y
* a #GimpChainButton attached to constrain either the two fields' * coordinates/sizes with a #GimpChainButton attached to constrain either the
* values or the ratio between them. * two fields' values or the ratio between them.
*
* Returns: The new #GimpSizeEntry.
**/ **/
GtkWidget * GtkWidget *
gimp_coordinates_new (GimpUnit unit, gimp_coordinates_new (GimpUnit unit,
@ -1202,7 +1226,10 @@ gimp_coordinates_new (GimpUnit unit,
* @xpm_data: The XPM data which will be passed to gimp_pixmap_new(). * @xpm_data: The XPM data which will be passed to gimp_pixmap_new().
* @text: An optional text which will appear right of the pixmap. * @text: An optional text which will appear right of the pixmap.
* *
* Returns: A #GtkButton with a #GimpPixmap and an optional #GtkLabel. * Convenience function that creates a #GtkButton with a #GimpPixmap and an
* optional #GtkLabel.
*
* Returns: The new #GtkButton.
**/ **/
GtkWidget * GtkWidget *
gimp_pixmap_button_new (gchar **xpm_data, gimp_pixmap_button_new (gchar **xpm_data,

View File

@ -98,7 +98,6 @@ EXPORTS
gimp_radio_group_set_active gimp_radio_group_set_active
gimp_random_seed_new gimp_random_seed_new
gimp_scale_entry_new gimp_scale_entry_new
gimp_scale_entry_new_internal
gimp_scale_entry_set_sensitive gimp_scale_entry_set_sensitive
gimp_size_entry_add_field gimp_size_entry_add_field
gimp_size_entry_attach_label gimp_size_entry_attach_label