Commit 50c8c56f authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

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.
parent d41e99de
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>
 
* libgimpwidgets/Makefile.am
......
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>
* libgimpwidgets/libgimpwidgets-docs.sgml
......
......@@ -56,9 +56,10 @@ up two GimpSizeEntries (see #GimpSizeEntry) linked with a #GimpChainButton.
</para>
@gcb:
@button:
@active:
<!-- # Unused Parameters # -->
@gcb:
@is_active:
......@@ -67,8 +68,10 @@ up two GimpSizeEntries (see #GimpSizeEntry) linked with a #GimpChainButton.
</para>
@gcb:
@button:
@Returns:
<!-- # Unused Parameters # -->
@gcb:
<!-- ##### SIGNAL GimpChainButton::toggled ##### -->
......
......@@ -47,8 +47,10 @@ color, the "color_changed" signal is emitted.
</para>
@gcb:
@button:
@color:
<!-- # Unused Parameters # -->
@gcb:
<!-- ##### FUNCTION gimp_color_button_get_color ##### -->
......@@ -56,8 +58,10 @@ color, the "color_changed" signal is emitted.
</para>
@gcb:
@button:
@color:
<!-- # Unused Parameters # -->
@gcb:
<!-- ##### FUNCTION gimp_color_button_has_alpha ##### -->
......@@ -65,8 +69,10 @@ color, the "color_changed" signal is emitted.
</para>
@gcb:
@button:
@Returns:
<!-- # Unused Parameters # -->
@gcb:
<!-- ##### FUNCTION gimp_color_button_set_type ##### -->
......@@ -74,9 +80,10 @@ color, the "color_changed" signal is emitted.
</para>
@gcb:
@button:
@type:
<!-- # Unused Parameters # -->
@gcb:
@alpha:
......
......@@ -54,8 +54,10 @@ will be emitted.
</para>
@gfs:
@selection:
@Returns:
<!-- # Unused Parameters # -->
@gfs:
<!-- ##### FUNCTION gimp_file_selection_set_filename ##### -->
......@@ -63,8 +65,10 @@ will be emitted.
</para>
@gfs:
@selection:
@filename:
<!-- # Unused Parameters # -->
@gfs:
<!-- ##### SIGNAL GimpFileSelection::filename-changed ##### -->
......
......@@ -2,11 +2,14 @@
GimpMemsizeEntry
<!-- ##### SECTION Short_Description ##### -->
A composite widget that allows to enter a memory size.
<!-- ##### SECTION Long_Description ##### -->
<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>
<!-- ##### SECTION See_Also ##### -->
......@@ -16,7 +19,7 @@ GimpMemsizeEntry
<!-- ##### STRUCT GimpMemsizeEntry ##### -->
<para>
The #GimpSizeEntry struct is considered private.
</para>
......
......@@ -175,13 +175,12 @@ Note that you have to g_free() the returned string.
@callback:
@data:
@Returns:
<!-- # Unused Parameters # -->
@eek:
<!-- ##### MACRO GIMP_QUERY_BOX_VBOX ##### -->
<para>
A macro to access the #GtkVBox in a #GimpQueryBox. Useful if you want to add
more widgets.
</para>
@qbox:
......
......@@ -35,14 +35,14 @@ enum
};
static void gimp_chain_button_class_init (GimpChainButtonClass *klass);
static void gimp_chain_button_init (GimpChainButton *gcb);
static void gimp_chain_button_class_init (GimpChainButtonClass *klass);
static void gimp_chain_button_init (GimpChainButton *button);
static void gimp_chain_button_clicked_callback (GtkWidget *widget,
GimpChainButton *gcb);
static gint gimp_chain_button_draw_lines (GtkWidget *widget,
GdkEventExpose *eevent,
GimpChainButton *gcb);
static void gimp_chain_button_clicked_callback (GtkWidget *widget,
GimpChainButton *button);
static gboolean gimp_chain_button_draw_lines (GtkWidget *widget,
GdkEventExpose *eevent,
GimpChainButton *button);
static const gchar *gimp_chain_stock_items[] =
......@@ -62,11 +62,11 @@ static GtkTableClass *parent_class = NULL;
GType
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),
(GBaseInitFunc) NULL,
......@@ -79,12 +79,11 @@ gimp_chain_button_get_type (void)
(GInstanceInitFunc) gimp_chain_button_init,
};
gcb_type = g_type_register_static (GTK_TYPE_TABLE,
"GimpChainButton",
&gcb_info, 0);
button_type = g_type_register_static (GTK_TYPE_TABLE, "GimpChainButton",
&button_info, 0);
}
return gcb_type;
return button_type;
}
static void
......@@ -105,29 +104,30 @@ gimp_chain_button_class_init (GimpChainButtonClass *klass)
}
static void
gimp_chain_button_init (GimpChainButton *gcb)
gimp_chain_button_init (GimpChainButton *button)
{
gcb->position = GIMP_CHAIN_TOP;
gcb->active = FALSE;
button->position = GIMP_CHAIN_TOP;
button->active = FALSE;
gcb->line1 = gtk_drawing_area_new ();
gcb->line2 = gtk_drawing_area_new ();
gcb->image = gtk_image_new ();
button->line1 = gtk_drawing_area_new ();
button->line2 = gtk_drawing_area_new ();
button->image = gtk_image_new ();
gcb->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);
button->button = gtk_button_new ();
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),
gcb);
g_signal_connect (G_OBJECT (gcb->line1), "expose_event",
button);
g_signal_connect (G_OBJECT (button->line1), "expose_event",
G_CALLBACK (gimp_chain_button_draw_lines),
gcb);
g_signal_connect (G_OBJECT (gcb->line2), "expose_event",
button);
g_signal_connect (G_OBJECT (button->line2), "expose_event",
G_CALLBACK (gimp_chain_button_draw_lines),
gcb);
button);
}
......@@ -152,97 +152,101 @@ gimp_chain_button_init (GimpChainButton *gcb)
GtkWidget *
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 (gcb->image),
gimp_chain_stock_items[((position & GIMP_CHAIN_LEFT) << 1) + ! gcb->active],
(GTK_IMAGE (button->image),
gimp_chain_stock_items[((position & GIMP_CHAIN_LEFT) << 1) + ! button->active],
GTK_ICON_SIZE_BUTTON);
if (position & GIMP_CHAIN_LEFT) /* are we a vertical chainbutton? */
{
gtk_table_resize (GTK_TABLE (gcb), 3, 1);
gtk_table_attach (GTK_TABLE (gcb), gcb->button, 0, 1, 1, 2,
gtk_table_resize (GTK_TABLE (button), 3, 1);
gtk_table_attach (GTK_TABLE (button), button->button, 0, 1, 1, 2,
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 (gcb), gcb->line2, 0, 1, 2, 3);
gtk_table_attach_defaults (GTK_TABLE (button),
button->line1, 0, 1, 0, 1);
gtk_table_attach_defaults (GTK_TABLE (button),
button->line2, 0, 1, 2, 3);
}
else
{
gtk_table_resize (GTK_TABLE (gcb), 1, 3);
gtk_table_attach (GTK_TABLE (gcb), gcb->button, 1, 2, 0, 1,
gtk_table_resize (GTK_TABLE (button), 1, 3);
gtk_table_attach (GTK_TABLE (button), button->button, 1, 2, 0, 1,
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 (gcb), gcb->line2, 2, 3, 0, 1);
gtk_table_attach_defaults (GTK_TABLE (button),
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 (gcb->line1);
gtk_widget_show (gcb->line2);
gtk_widget_show (button->button);
gtk_widget_show (button->line1);
gtk_widget_show (button->line2);
return GTK_WIDGET (gcb);
return GTK_WIDGET (button);
}
/**
* gimp_chain_button_set_active:
* @gcb: Pointer to a #GimpChainButton.
* @button: Pointer to a #GimpChainButton.
* @active: The new state.
*
* Sets the state of the #GimpChainButton to be either locked (#TRUE) or
* unlocked (#FALSE) and changes the showed pixmap to reflect the new state.
*/
void
gimp_chain_button_set_active (GimpChainButton *gcb,
gimp_chain_button_set_active (GimpChainButton *button,
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 (gcb->image),
gimp_chain_stock_items[((gcb->position & GIMP_CHAIN_LEFT) << 1) + ! gcb->active],
(GTK_IMAGE (button->image),
gimp_chain_stock_items[((button->position & GIMP_CHAIN_LEFT) << 1) + ! button->active],
GTK_ICON_SIZE_BUTTON);
}
}
/**
* gimp_chain_button_get_active
* @gcb: Pointer to a #GimpChainButton.
* @button: Pointer to a #GimpChainButton.
*
* Checks the state of the #GimpChainButton.
*
* Returns: TRUE if the #GimpChainButton is active (locked).
*/
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
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,
GdkEventExpose *eevent,
GimpChainButton *gcb)
GimpChainButton *button)
{
GdkPoint points[3];
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
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].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:
points[0].x += SHORT_LINE;
......
......@@ -72,7 +72,7 @@ struct _GimpChainButtonClass
{
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);
void gimp_chain_button_set_active (GimpChainButton *gcb,
void gimp_chain_button_set_active (GimpChainButton *button,
gboolean active);
gboolean gimp_chain_button_get_active (GimpChainButton *gcb);
gboolean gimp_chain_button_get_active (GimpChainButton *button);
G_END_DECLS
......
......@@ -278,8 +278,9 @@ gimp_color_area_new (const GimpRGB *color,
/**
* gimp_color_area_set_color:
* @area: Pointer to a #GimpColorArea.
* @color:
* @color: Pointer to a #GimpRGB struct that defines the new color.
*
* Sets @area to a different @color.
**/
void
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
gimp_color_area_get_color (GimpColorArea *area,
GimpRGB *color)
......@@ -310,6 +318,15 @@ gimp_color_area_get_color (GimpColorArea *area,
*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
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;
}
/**
* 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
gimp_color_area_set_type (GimpColorArea *area,
GimpColorAreaType type)
......
......@@ -63,7 +63,7 @@ struct _GimpColorAreaClass
{
GtkDrawingAreaClass parent_class;
void (* color_changed) (GimpColorArea *gca);
void (* color_changed) (GimpColorArea *area);
};
......
......@@ -56,8 +56,8 @@ enum
static void gimp_color_button_class_init (GimpColorButtonClass *klass);
static void gimp_color_button_init (GimpColorButton *gcb);
static void gimp_color_button_destroy (GtkObject *object);
static void gimp_color_button_init (GimpColorButton *button);
static void gimp_color_button_destroy (GtkObject *object);
static gboolean gimp_color_button_button_press (GtkWidget *widget,
GdkEventButton *bevent);
......@@ -101,11 +101,11 @@ static GimpButtonClass * parent_class = NULL;
GType
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),
(GBaseInitFunc) NULL,
......@@ -118,12 +118,12 @@ gimp_color_button_get_type (void)
(GInstanceInitFunc) gimp_color_button_init,
};
gcb_type = g_type_register_static (GIMP_TYPE_BUTTON,
button_type = g_type_register_static (GIMP_TYPE_BUTTON,
"GimpColorButton",
&gcb_info, 0);
&button_info, 0);
}
return gcb_type;
return button_type;
}
static void
......@@ -159,54 +159,54 @@ gimp_color_button_class_init (GimpColorButtonClass *klass)
}
static void
gimp_color_button_init (GimpColorButton *gcb)
gimp_color_button_init (GimpColorButton *button)
{
GimpRGB color;
gcb->title = NULL;
gcb->dialog = NULL;
button->title = NULL;
button->dialog = NULL;
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
gcb->color_area = gimp_color_area_new (&color, FALSE, GDK_BUTTON2_MASK);
g_signal_connect (G_OBJECT (gcb->color_area), "color_changed",
button->color_area = gimp_color_area_new (&color, FALSE, GDK_BUTTON2_MASK);
g_signal_connect (G_OBJECT (button->color_area), "color_changed",
G_CALLBACK (gimp_color_button_color_changed),
gcb);
button);
gtk_container_add (GTK_CONTAINER (gcb), gcb->color_area);
gtk_widget_show (gcb->color_area);
gtk_container_add (GTK_CONTAINER (button), button->color_area);
gtk_widget_show (button->color_area);
/* right-click opens a popup */
gcb->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);
gtk_item_factory_set_translate_func (gcb->item_factory,
button->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);
gtk_item_factory_set_translate_func (button->item_factory,
gimp_color_button_menu_translate,
NULL, NULL);
gtk_item_factory_create_items (gcb->item_factory,
G_N_ELEMENTS (menu_items), menu_items, gcb);
gtk_item_factory_create_items (button->item_factory,
G_N_ELEMENTS (menu_items), menu_items, button);
}
static void
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);
gcb->title = NULL;
g_free (button->title);
button->title = NULL;
}
if (gcb->dialog)
if (button->dialog)
{
gtk_widget_destroy (gcb->dialog);
gcb->dialog = NULL;
gtk_widget_destroy (button->dialog);