Commit e01d9645 authored by Sven Neumann's avatar Sven Neumann
Browse files

made parasites use g* types and documented gimpchainbutton


--Sven
parent 0a6a2aa3
Sat Feb 12 03:14:02 CET 2000 Sven Neumann <sven@gimp.org>
* libgimp/gimpchainbutton.c: documenation and code cleanup
* app/gimpparasite.h
* libgimp/parasite.[ch]: use g* types
Mon Feb 7 17:37:40 GMT 2000 Nick Lamb <njl195@zepler.org.uk>
 
* app/menus.c: Move Help as per gimp-devel. Try it and report back
......
......@@ -22,9 +22,9 @@
void gimp_init_parasites (void);
void gimp_parasite_attach (Parasite *p);
void gimp_parasite_detach (const char *name);
Parasite * gimp_parasite_find (const char *name);
char ** gimp_parasite_list (gint *count);
void gimp_parasite_detach (const gchar *name);
Parasite * gimp_parasite_find (const gchar *name);
gchar ** gimp_parasite_list (gint *count);
void gimp_parasiterc_save (void);
void gimp_parasiterc_load (void);
......
......@@ -22,9 +22,9 @@
void gimp_init_parasites (void);
void gimp_parasite_attach (Parasite *p);
void gimp_parasite_detach (const char *name);
Parasite * gimp_parasite_find (const char *name);
char ** gimp_parasite_list (gint *count);
void gimp_parasite_detach (const gchar *name);
Parasite * gimp_parasite_find (const gchar *name);
gchar ** gimp_parasite_list (gint *count);
void gimp_parasiterc_save (void);
void gimp_parasiterc_load (void);
......
......@@ -22,9 +22,9 @@
void gimp_init_parasites (void);
void gimp_parasite_attach (Parasite *p);
void gimp_parasite_detach (const char *name);
Parasite * gimp_parasite_find (const char *name);
char ** gimp_parasite_list (gint *count);
void gimp_parasite_detach (const gchar *name);
Parasite * gimp_parasite_find (const gchar *name);
gchar ** gimp_parasite_list (gint *count);
void gimp_parasiterc_save (void);
void gimp_parasiterc_load (void);
......
Sat Feb 12 03:14:38 CET 2000 Sven Neumann <sven@gimp.org>
* devel-docs/libgimp/tmpl/gimpchainbutton.sgml: documented
GimpChainButton
2000-02-08 Michael Natterer <mitch@gimp.org>
* libgimp/libgimp-decl.txt
......
......@@ -2,16 +2,28 @@
GimpChainButton
<!-- ##### SECTION Short_Description ##### -->
Widget to visually connect two entry widgets.
<!-- ##### SECTION Long_Description ##### -->
<para>
This widget provides a button showing either a linked or a broken
chain that can be used to link two entries, spinbuttons, colors
or other GUI elements and show that they may be locked. Use it for
example to connect X and Y ratios to provide the possibility of a
constrained aspect ratio.
</para>
<para>
The #GimpChainButton only gives visual feedback, it does not really
connect widgets. You have to take care of locking the values yourself
by checking the state of the #GimpChainButton whenever a value changes
in one of the connected widgets and adjusting the other value if
necessary.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
You may want to use the convenience function gimp_coordinates_new() to set
up two GimpSizeEntries (see #GimpSizeEntry) linked with a #GimpChainbutton.
</para>
<!-- ##### STRUCT GimpChainButton ##### -->
......@@ -22,10 +34,11 @@ GimpChainButton
<!-- ##### MACRO GIMP_CHAIN_BUTTON ##### -->
<para>
Checks if the passed pointer is a pointer to a #GimpChainButton and
performes the cast if valid.
</para>
@obj:
@obj: The pointer to cast.
<!-- ##### ENUM GimpChainPosition ##### -->
......@@ -33,10 +46,14 @@ GimpChainButton
</para>
@GIMP_CHAIN_TOP:
@GIMP_CHAIN_LEFT:
@GIMP_CHAIN_BOTTOM:
@GIMP_CHAIN_RIGHT:
@GIMP_CHAIN_TOP: Use if the GimpChainButton is used attached to the top of
the widgets it connects.
@GIMP_CHAIN_LEFT: Use if the GimpChainButton is used attached to the left of
the widgets it connects.
@GIMP_CHAIN_BOTTOM: Use if the GimpChainButton is used attached to the bottom
of the widgets it connects.
@GIMP_CHAIN_RIGHT: Use if the GimpChainButton is used attached to the right of
the widgets it connects.
<!-- ##### FUNCTION gimp_chain_button_new ##### -->
<para>
......
......@@ -18,7 +18,6 @@
*/
#include "gimpchainbutton.h"
#include "pixmaps/chain.xpm"
static gchar **gimp_chain_xpm[] =
......@@ -34,8 +33,8 @@ static gchar **gimp_chain_broken_xpm[] =
};
static void gimp_chain_button_destroy (GtkObject *object);
static void gimp_chain_button_realize_callback (GtkWidget *widget,
GimpChainButton *gcb);
static void gimp_chain_button_realize (GtkWidget *widget);
static void gimp_chain_button_clicked_callback (GtkWidget *widget,
GimpChainButton *gcb);
static void gimp_chain_button_draw_lines (GtkWidget *widget,
......@@ -69,12 +68,16 @@ static void
gimp_chain_button_class_init (GimpChainButtonClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (gtk_table_get_type ());
object_class->destroy = gimp_chain_button_destroy;
widget_class->realize = gimp_chain_button_realize;
}
static void
......@@ -93,12 +96,6 @@ gimp_chain_button_init (GimpChainButton *gcb)
gtk_signal_connect (GTK_OBJECT(gcb->button), "clicked",
GTK_SIGNAL_FUNC (gimp_chain_button_clicked_callback), gcb);
/* That's all we do here, since setting the pixmaps won't work before
the parent window is realized.
We connect to the realized-signal instead and do the rest there. */
gtk_signal_connect (GTK_OBJECT (gcb), "realize",
GTK_SIGNAL_FUNC (gimp_chain_button_realize_callback),
gcb);
gtk_signal_connect (GTK_OBJECT (gcb->line1), "expose_event",
GTK_SIGNAL_FUNC (gimp_chain_button_draw_lines),
gcb);
......@@ -132,7 +129,23 @@ gimp_chain_button_get_type (void)
return gcb_type;
}
/**
* gimp_chain_button_new:
* @position: The position you are going to use for the button
* with respect to the widgets you want to chain.
*
* Creates a new #GimpChainButton widget. This returns a button
* showing either a broken or a linked chain and small clamps
* attached to both sides that visually group the two widgets
* you want to connect. This widget looks best when attached
* to a table taking up two columns (or rows respectively) next
* to the widgets that it is supposed to connect. It may work
* for more than two widgets, but the look is optimized for two.
*
* Returns: Pointer to the new #GimpChainButton, which is inactive
* by default. Use gimp_chain_button_set_active() to
* change its state.
*/
GtkWidget *
gimp_chain_button_new (GimpChainPosition position)
{
......@@ -166,23 +179,70 @@ gimp_chain_button_new (GimpChainPosition position)
return GTK_WIDGET (gcb);
}
/**
* gimp_chain_button_set_active:
* @gcb: Pointer to a #GimpChainButton.
* @is_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,
gboolean is_active)
{
g_return_if_fail (gcb != NULL);
g_return_if_fail (GIMP_IS_CHAIN_BUTTON (gcb));
if (gcb->active != is_active)
{
gcb->active = is_active;
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (gcb)))
return;
if (gcb->active)
gtk_pixmap_set (GTK_PIXMAP(gcb->pixmap), gcb->chain, gcb->chain_mask);
else
gtk_pixmap_set (GTK_PIXMAP(gcb->pixmap), gcb->broken, gcb->broken_mask);
}
}
/**
* gimp_chain_button_get_active
* @gcb: 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)
{
g_return_val_if_fail (gcb != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_CHAIN_BUTTON (gcb), FALSE);
return gcb->active;
}
static void
gimp_chain_button_realize_callback (GtkWidget *widget,
GimpChainButton *gcb)
gimp_chain_button_realize (GtkWidget *widget)
{
GtkStyle *style;
GtkWidget *parent;
GimpChainButton *gcb;
GtkStyle *style;
parent = GTK_WIDGET (gcb)->parent;
if (!GTK_WIDGET_REALIZED (parent))
return;
gcb = GIMP_CHAIN_BUTTON (widget);
style = gtk_widget_get_style (parent);
gcb->chain = gdk_pixmap_create_from_xpm_d (parent->window,
if (GTK_WIDGET_CLASS (parent_class)->realize)
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
style = gtk_widget_get_style (widget);
gcb->chain = gdk_pixmap_create_from_xpm_d (widget->window,
&gcb->chain_mask,
&style->bg[GTK_STATE_NORMAL],
gimp_chain_xpm[gcb->position % 2]);
gcb->broken = gdk_pixmap_create_from_xpm_d (parent->window,
gcb->broken = gdk_pixmap_create_from_xpm_d (widget->window,
&gcb->broken_mask,
&style->bg[GTK_STATE_NORMAL],
gimp_chain_broken_xpm[gcb->position % 2]);
......@@ -298,33 +358,3 @@ gimp_chain_button_draw_lines (GtkWidget *widget,
3,
FALSE);
}
void
gimp_chain_button_set_active (GimpChainButton *gcb,
gboolean is_active)
{
g_return_if_fail (gcb != NULL);
g_return_if_fail (GIMP_IS_CHAIN_BUTTON (gcb));
if (gcb->active != is_active)
{
gcb->active = is_active;
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (gcb)))
return;
if (gcb->active)
gtk_pixmap_set (GTK_PIXMAP(gcb->pixmap), gcb->chain, gcb->chain_mask);
else
gtk_pixmap_set (GTK_PIXMAP(gcb->pixmap), gcb->broken, gcb->broken_mask);
}
}
gboolean
gimp_chain_button_get_active (GimpChainButton *gcb)
{
g_return_val_if_fail (gcb != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_CHAIN_BUTTON (gcb), FALSE);
return gcb->active;
}
......@@ -37,10 +37,10 @@ static void
parasite_print (Parasite *p)
{
if (p == NULL)
{
printf("(pid %d)attempt to print a null parasite\n", getpid());
return;
}
{
printf("(pid %d)attempt to print a null parasite\n", getpid());
return;
}
printf("(pid %d), parasite: %p\n", getpid(), p);
if (p->name)
printf("\tname: %s\n", p->name);
......@@ -54,10 +54,10 @@ parasite_print (Parasite *p)
#endif
Parasite *
parasite_new (const char *name,
guint32 flags,
guint32 size,
const void *data)
parasite_new (const gchar *name,
guint32 flags,
guint32 size,
const gpointer data)
{
Parasite *p;
p = g_new (Parasite, 1);
......@@ -91,7 +91,7 @@ parasite_free (Parasite *parasite)
int
parasite_is_type (const Parasite *parasite,
const char *name)
const gchar *name)
{
if (!parasite || !parasite->name)
return FALSE;
......@@ -107,7 +107,7 @@ parasite_copy (const Parasite *parasite)
parasite->size, parasite->data);
}
int
gboolean
parasite_compare (const Parasite *a,
const Parasite *b)
{
......@@ -130,7 +130,7 @@ parasite_flags (const Parasite *p)
return p->flags;
}
int
gboolean
parasite_is_persistent (const Parasite *p)
{
if (p == NULL)
......@@ -138,7 +138,7 @@ parasite_is_persistent (const Parasite *p)
return (p->flags & PARASITE_PERSISTENT);
}
int
gboolean
parasite_is_undoable (const Parasite *p)
{
if (p == NULL)
......@@ -146,7 +146,7 @@ parasite_is_undoable (const Parasite *p)
return (p->flags & PARASITE_UNDOABLE);
}
int
gboolean
parasite_has_flag (const Parasite *p,
gulong flag)
{
......@@ -155,7 +155,7 @@ parasite_has_flag (const Parasite *p,
return (p->flags & flag);
}
const char *
const gchar *
parasite_name (const Parasite *p)
{
if (p)
......@@ -171,7 +171,7 @@ parasite_data (const Parasite *p)
return NULL;
}
long
glong
parasite_data_size (const Parasite *p)
{
if (p)
......
......@@ -22,7 +22,8 @@
#include <glib.h>
#include <stdio.h>
#include <libgimp/parasiteF.h>
#include "libgimp/parasiteF.h"
#ifdef __cplusplus
extern "C" {
......@@ -39,23 +40,27 @@ extern "C" {
#define PARASITE_GRANDPARENT_PERSISTENT (PARASITE_PERSISTENT << 16)
#define PARASITE_GRANDPARENT_UNDOABLE (PARASITE_UNDOABLE << 16)
Parasite *parasite_new (const char *name, guint32 flags,
guint32 size, const void *data);
void parasite_free (Parasite *parasite);
Parasite *parasite_copy (const Parasite *parasite);
Parasite *parasite_new (const gchar *name,
guint32 flags,
guint32 size,
const gpointer data);
void parasite_free (Parasite *parasite);
Parasite *parasite_copy (const Parasite *parasite);
int parasite_compare (const Parasite *a, const Parasite *b);
gboolean parasite_compare (const Parasite *a,
const Parasite *b);
int parasite_is_type (const Parasite *parasite,
const char *name);
int parasite_is_persistent (const Parasite *p);
int parasite_is_undoable (const Parasite *p);
int parasite_has_flag (const Parasite *p, gulong flag);
gulong parasite_flags (const Parasite *p);
const char *parasite_name (const Parasite *p);
void *parasite_data (const Parasite *p);
long parasite_data_size (const Parasite *p);
gboolean parasite_is_type (const Parasite *parasite,
const gchar *name);
gboolean parasite_is_persistent (const Parasite *p);
gboolean parasite_is_undoable (const Parasite *p);
gboolean parasite_has_flag (const Parasite *p,
gulong flag);
gulong parasite_flags (const Parasite *p);
const gchar *parasite_name (const Parasite *p);
void *parasite_data (const Parasite *p);
glong parasite_data_size (const Parasite *p);
......
......@@ -37,10 +37,10 @@ static void
parasite_print (Parasite *p)
{
if (p == NULL)
{
printf("(pid %d)attempt to print a null parasite\n", getpid());
return;
}
{
printf("(pid %d)attempt to print a null parasite\n", getpid());
return;
}
printf("(pid %d), parasite: %p\n", getpid(), p);
if (p->name)
printf("\tname: %s\n", p->name);
......@@ -54,10 +54,10 @@ parasite_print (Parasite *p)
#endif
Parasite *
parasite_new (const char *name,
guint32 flags,
guint32 size,
const void *data)
parasite_new (const gchar *name,
guint32 flags,
guint32 size,
const gpointer data)
{
Parasite *p;
p = g_new (Parasite, 1);
......@@ -91,7 +91,7 @@ parasite_free (Parasite *parasite)
int
parasite_is_type (const Parasite *parasite,
const char *name)
const gchar *name)
{
if (!parasite || !parasite->name)
return FALSE;
......@@ -107,7 +107,7 @@ parasite_copy (const Parasite *parasite)
parasite->size, parasite->data);
}
int
gboolean
parasite_compare (const Parasite *a,
const Parasite *b)
{
......@@ -130,7 +130,7 @@ parasite_flags (const Parasite *p)
return p->flags;
}
int
gboolean
parasite_is_persistent (const Parasite *p)
{
if (p == NULL)
......@@ -138,7 +138,7 @@ parasite_is_persistent (const Parasite *p)
return (p->flags & PARASITE_PERSISTENT);
}
int
gboolean
parasite_is_undoable (const Parasite *p)
{
if (p == NULL)
......@@ -146,7 +146,7 @@ parasite_is_undoable (const Parasite *p)
return (p->flags & PARASITE_UNDOABLE);
}
int
gboolean
parasite_has_flag (const Parasite *p,
gulong flag)
{
......@@ -155,7 +155,7 @@ parasite_has_flag (const Parasite *p,
return (p->flags & flag);
}
const char *
const gchar *
parasite_name (const Parasite *p)
{
if (p)
......@@ -171,7 +171,7 @@ parasite_data (const Parasite *p)
return NULL;
}
long
glong
parasite_data_size (const Parasite *p)
{
if (p)
......
......@@ -22,7 +22,8 @@
#include <glib.h>
#include <stdio.h>
#include <libgimp/parasiteF.h>
#include "libgimp/parasiteF.h"
#ifdef __cplusplus
extern "C" {
......@@ -39,23 +40,27 @@ extern "C" {
#define PARASITE_GRANDPARENT_PERSISTENT (PARASITE_PERSISTENT << 16)
#define PARASITE_GRANDPARENT_UNDOABLE (PARASITE_UNDOABLE << 16)
Parasite *parasite_new (const char *name, guint32 flags,
guint32 size, const void *data);
void parasite_free (Parasite *parasite);
Parasite *parasite_copy (const Parasite *parasite);
Parasite *parasite_new (const gchar *name,
guint32 flags,
guint32 size,
const gpointer data);
void parasite_free (Parasite *parasite);
Parasite *parasite_copy (const Parasite *parasite);
int parasite_compare (const Parasite *a, const Parasite *b);
gboolean parasite_compare (const Parasite *a,
const Parasite *b);
int parasite_is_type (const Parasite *parasite,
const char *name);
int parasite_is_persistent (const Parasite *p);
int parasite_is_undoable (const Parasite *p);
int parasite_has_flag (const Parasite *p, gulong flag);
gulong parasite_flags (const Parasite *p);
const char *parasite_name (const Parasite *p);
void *parasite_data (const Parasite *p);
long parasite_data_size (const Parasite *p);
gboolean parasite_is_type (const Parasite *parasite,
const gchar *name);
gboolean parasite_is_persistent (const Parasite *p);
gboolean parasite_is_undoable (const Parasite *p);
gboolean parasite_has_flag (const Parasite *p,
gulong flag);
gulong parasite_flags (const Parasite *p);
const gchar *parasite_name (const Parasite *p);
void *parasite_data (const Parasite *p);
glong parasite_data_size (const Parasite *p);
......
......@@ -37,10 +37,10 @@ static void
parasite_print (Parasite *p)
{
if (p == NULL)
{
printf("(pid %d)attempt to print a null parasite\n", getpid());
return;
}
{
printf("(pid %d)attempt to print a null parasite\n", getpid());
return;
}
printf("(pid %d), parasite: %p\n", getpid(), p);
if (p->name)
printf("\tname: %s\n", p->name);
......@@ -54,10 +54,10 @@ parasite_print (Parasite *p)
#endif
Parasite *
parasite_new (const char *name,
guint32 flags,
guint32 size,
const void *data)
parasite_new (const gchar *name,
guint32 flags,
guint32 size,
const gpointer data)
{
Parasite *p;
p = g_new (Parasite, 1);
......@@ -91,7 +91,7 @@ parasite_free (Parasite *parasite)
int
parasite_is_type (const Parasite *parasite,
const char *name)
const gchar *name)