Commit aaa3ef21 authored by Michael Natterer's avatar Michael Natterer Committed by Michael Natterer

app/Makefile.am new files. Does nothing yet. Checked in because I found

1999-06-17  Michael Natterer  <mitschel@cs.tu-berlin.de>

	* app/Makefile.am
	* app/gimpcontext.[ch]: new files. Does nothing yet. Checked in
	because I found some bugs while hacking it:

	* libgimp/gimpchainbutton.[ch]
	* libgimp/gimpfileselection.[ch]
	* libgimp/gimppatheditor.[ch]
	* libgimp/gimpsizeentry.[ch]
	* libgimp/gimpunitmenu.[ch]: fixed some cut & paste bugs and some
	gtk 1.0 artefacts in the object class initialisation code.
parent e99df484
1999-06-17 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/Makefile.am
* app/gimpcontext.[ch]: new files. Does nothing yet. Checked in
because I found some bugs while hacking it:
* libgimp/gimpchainbutton.[ch]
* libgimp/gimpfileselection.[ch]
* libgimp/gimppatheditor.[ch]
* libgimp/gimpsizeentry.[ch]
* libgimp/gimpunitmenu.[ch]: fixed some cut & paste bugs and some
gtk 1.0 artefacts in the object class initialisation code.
1999-06-17 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/preferences_dialog.c: the tree title doesn't behave like a
......
......@@ -181,6 +181,8 @@ gimp_SOURCES = \
gimpbrushlist.h \
gimpbrushlistF.h \
gimpbrushlistP.h \
gimpcontext.c \
gimpcontext.h \
gimphistogram.c \
gimphistogram.h \
gimphistogramP.h \
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gimpcontext.h"
#include "gimpsignal.h"
#define CONTEXT_CHECK_CURRENT(context) \
((context) = (context) ? (context) : current_context)
enum {
OPACITY_CHANGED,
PAINT_MODE_CHANGED,
LAST_SIGNAL
};
static guint gimp_context_signals[LAST_SIGNAL] = { 0 };
static GimpObjectClass* parent_class = NULL;
/* the currently active context */
static GimpContext * current_context = NULL;
/* for later use
static void
gimp_context_destroy (GtkObject *object)
{
GimpContext *context;
g_return_if_fail (object != NULL);
g_return_if_fail (GIMP_IS_CONTEXT (object));
context = GIMP_CONTEXT (object);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
*/
static void
gimp_context_class_init (GimpContextClass *klass)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS (klass);
parent_class = gtk_type_class (gimp_object_get_type ());
gimp_context_signals[OPACITY_CHANGED] =
gimp_signal_new ("opacity_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpContextClass,
opacity_changed),
gimp_sigtype_void);
gimp_context_signals[PAINT_MODE_CHANGED] =
gimp_signal_new ("paint_mode_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpContextClass,
paint_mode_changed),
gimp_sigtype_void);
gtk_object_class_add_signals (object_class, gimp_context_signals,
LAST_SIGNAL);
klass->opacity_changed = NULL;
klass->paint_mode_changed = NULL;
/* object_class->destroy = gimp_context_destroy; */
}
static void
gimp_context_init (GimpContext *context)
{
context->opacity = 1.0;
context->paint_mode = 0;
}
GtkType
gimp_context_get_type (void)
{
static GtkType type = 0;
if(!type)
{
GtkTypeInfo info =
{
"GimpContext",
sizeof(GimpContext),
sizeof(GimpContextClass),
(GtkClassInitFunc) gimp_context_class_init,
(GtkObjectInitFunc) gimp_context_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
type = gtk_type_unique (gimp_object_get_type (), &info);
}
return type;
}
GimpContext *
gimp_context_new (void)
{
GimpContext *context;
context = gtk_type_new (gimp_context_get_type ());
return context;
}
GimpContext *
gimp_context_get_current (void)
{
return current_context;
}
void
gimp_context_set_current (GimpContext *context)
{
current_context = context;
}
gdouble
gimp_context_get_opacity (GimpContext *context)
{
CONTEXT_CHECK_CURRENT (context);
g_return_val_if_fail (context != NULL, 1.0);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), 1.0);
return context->opacity;
}
void
gimp_context_set_opacity (GimpContext *context,
gdouble opacity)
{
CONTEXT_CHECK_CURRENT (context);
g_return_if_fail (context != NULL);
g_return_if_fail (GIMP_IS_CONTEXT (context));
context->opacity = opacity;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[OPACITY_CHANGED]);
}
gint
gimp_context_get_paint_mode (GimpContext *context)
{
CONTEXT_CHECK_CURRENT (context);
g_return_val_if_fail (context != NULL, 0);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), 0);
return context->paint_mode;
}
void
gimp_context_set_paint_mode (GimpContext *context,
gint paint_mode)
{
CONTEXT_CHECK_CURRENT (context);
g_return_if_fail (context != NULL);
g_return_if_fail (GIMP_IS_CONTEXT (context));
context->paint_mode = paint_mode;
gtk_signal_emit (GTK_OBJECT(context),
gimp_context_signals[PAINT_MODE_CHANGED]);
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_CONTEXT_H__
#define __GIMP_CONTEXT_H__
#include "gimpobjectP.h"
#define GIMP_TYPE_CONTEXT (gimp_context_get_type ())
#define GIMP_CONTEXT(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_CONTEXT, GimpContext))
#define GIMP_CONTEXT_CLASS(klass) (GIMP_CHECK_CLASS_CAST (klass, GIMP_TYPE_CONTEXT, GimpContextClass))
#define GIMP_IS_CONTEXT(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_CONTEXT))
#define GIMP_IS_CONTEXT_CLASS(klass) (GIMP_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTEXT))
typedef struct _GimpContext GimpContext;
typedef struct _GimpContextClass GimpContextClass;
struct _GimpContext
{
GimpObject object;
gdouble opacity;
gint paint_mode;
};
struct _GimpContextClass
{
GimpObjectClass parent_class;
void (* opacity_changed) (GimpContext *context);
void (* paint_mode_changed) (GimpContext *context);
};
GtkType gimp_context_get_type (void);
GimpContext * gimp_context_new (void);
/* to be used by the context management system only
*/
GimpContext * gimp_context_get_current (void);
void gimp_context_set_current (GimpContext *context);
/* functions for manipulating a single context
*/
gdouble gimp_context_get_opacity (GimpContext *context);
void gimp_context_set_opacity (GimpContext *context,
gdouble opacity);
gint gimp_context_get_paint_mode (GimpContext *context);
void gimp_context_set_paint_mode (GimpContext *context,
gint paint_mode);
#endif /* __GIMP_CONTEXT_H__ */
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gimpcontext.h"
#include "gimpsignal.h"
#define CONTEXT_CHECK_CURRENT(context) \
((context) = (context) ? (context) : current_context)
enum {
OPACITY_CHANGED,
PAINT_MODE_CHANGED,
LAST_SIGNAL
};
static guint gimp_context_signals[LAST_SIGNAL] = { 0 };
static GimpObjectClass* parent_class = NULL;
/* the currently active context */
static GimpContext * current_context = NULL;
/* for later use
static void
gimp_context_destroy (GtkObject *object)
{
GimpContext *context;
g_return_if_fail (object != NULL);
g_return_if_fail (GIMP_IS_CONTEXT (object));
context = GIMP_CONTEXT (object);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
*/
static void
gimp_context_class_init (GimpContextClass *klass)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS (klass);
parent_class = gtk_type_class (gimp_object_get_type ());
gimp_context_signals[OPACITY_CHANGED] =
gimp_signal_new ("opacity_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpContextClass,
opacity_changed),
gimp_sigtype_void);
gimp_context_signals[PAINT_MODE_CHANGED] =
gimp_signal_new ("paint_mode_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpContextClass,
paint_mode_changed),
gimp_sigtype_void);
gtk_object_class_add_signals (object_class, gimp_context_signals,
LAST_SIGNAL);
klass->opacity_changed = NULL;
klass->paint_mode_changed = NULL;
/* object_class->destroy = gimp_context_destroy; */
}
static void
gimp_context_init (GimpContext *context)
{
context->opacity = 1.0;
context->paint_mode = 0;
}
GtkType
gimp_context_get_type (void)
{
static GtkType type = 0;
if(!type)
{
GtkTypeInfo info =
{
"GimpContext",
sizeof(GimpContext),
sizeof(GimpContextClass),
(GtkClassInitFunc) gimp_context_class_init,
(GtkObjectInitFunc) gimp_context_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
type = gtk_type_unique (gimp_object_get_type (), &info);
}
return type;
}
GimpContext *
gimp_context_new (void)
{
GimpContext *context;
context = gtk_type_new (gimp_context_get_type ());
return context;
}
GimpContext *
gimp_context_get_current (void)
{
return current_context;
}
void
gimp_context_set_current (GimpContext *context)
{
current_context = context;
}
gdouble
gimp_context_get_opacity (GimpContext *context)
{
CONTEXT_CHECK_CURRENT (context);
g_return_val_if_fail (context != NULL, 1.0);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), 1.0);
return context->opacity;
}
void
gimp_context_set_opacity (GimpContext *context,
gdouble opacity)
{
CONTEXT_CHECK_CURRENT (context);
g_return_if_fail (context != NULL);
g_return_if_fail (GIMP_IS_CONTEXT (context));
context->opacity = opacity;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[OPACITY_CHANGED]);
}
gint
gimp_context_get_paint_mode (GimpContext *context)
{
CONTEXT_CHECK_CURRENT (context);
g_return_val_if_fail (context != NULL, 0);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), 0);
return context->paint_mode;
}
void
gimp_context_set_paint_mode (GimpContext *context,
gint paint_mode)
{
CONTEXT_CHECK_CURRENT (context);
g_return_if_fail (context != NULL);
g_return_if_fail (GIMP_IS_CONTEXT (context));
context->paint_mode = paint_mode;
gtk_signal_emit (GTK_OBJECT(context),
gimp_context_signals[PAINT_MODE_CHANGED]);
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_CONTEXT_H__
#define __GIMP_CONTEXT_H__
#include "gimpobjectP.h"
#define GIMP_TYPE_CONTEXT (gimp_context_get_type ())
#define GIMP_CONTEXT(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_CONTEXT, GimpContext))
#define GIMP_CONTEXT_CLASS(klass) (GIMP_CHECK_CLASS_CAST (klass, GIMP_TYPE_CONTEXT, GimpContextClass))
#define GIMP_IS_CONTEXT(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_CONTEXT))
#define GIMP_IS_CONTEXT_CLASS(klass) (GIMP_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTEXT))
typedef struct _GimpContext GimpContext;
typedef struct _GimpContextClass GimpContextClass;
struct _GimpContext
{
GimpObject object;
gdouble opacity;
gint paint_mode;
};
struct _GimpContextClass
{
GimpObjectClass parent_class;
void (* opacity_changed) (GimpContext *context);
void (* paint_mode_changed) (GimpContext *context);
};
GtkType gimp_context_get_type (void);
GimpContext * gimp_context_new (void);
/* to be used by the context management system only
*/
GimpContext * gimp_context_get_current (void);
void gimp_context_set_current (GimpContext *context);
/* functions for manipulating a single context
*/
gdouble gimp_context_get_opacity (GimpContext *context);
void gimp_context_set_opacity (GimpContext *context,
gdouble opacity);
gint gimp_context_get_paint_mode (GimpContext *context);
void gimp_context_set_paint_mode (GimpContext *context,
gint paint_mode);
#endif /* __GIMP_CONTEXT_H__ */
......@@ -37,6 +37,8 @@ static void gimp_chain_button_draw_lines (GtkWidget *widget,
GdkEvent* event,
GimpChainButton *gcb);
static GtkWidgetClass *parent_class = NULL;
static void
gimp_chain_button_class_init (GimpChainButtonClass *class)
{
......@@ -44,7 +46,7 @@ gimp_chain_button_class_init (GimpChainButtonClass *class)
object_class = (GtkObjectClass*) class;
class->gimp_chain_button = NULL;
parent_class = gtk_type_class (gtk_widget_get_type ());
}
static void
......
......@@ -70,8 +70,6 @@ struct _GimpChainButton
struct _GimpChainButtonClass
{
GtkButtonClass parent_class;
void (* gimp_chain_button) (GimpChainButton *gcb);
};
......
......@@ -47,25 +47,18 @@
# endif
#endif
/* callbacks
*/
static void gimp_file_selection_realize (GtkWidget *widget,
gpointer data);
static void gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data);
static int gimp_file_selection_entry_focus_out_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void gimp_file_selection_browse_callback (GtkWidget *widget,
gpointer data);
/* private functions
*/
/* callbacks */
static void gimp_file_selection_realize (GtkWidget *, gpointer);
static void gimp_file_selection_entry_callback (GtkWidget *, gpointer);
static int gimp_file_selection_entry_focus_out_callback (GtkWidget *,
GdkEvent *, gpointer);
static void gimp_file_selection_browse_callback (GtkWidget *, gpointer);
/* private functions */
static void gimp_file_selection_check_filename (GimpFileSelection *gfs);
enum {
GFS_FILENAME_CHANGED_SIGNAL,
FILENAME_CHANGED,
LAST_SIGNAL
};
......@@ -74,7 +67,7 @@ static gint gimp_file_selection_signals[LAST_SIGNAL] = { 0 };
static GtkHBoxClass *parent_class = NULL;
static void
gimp_file_selection_class_destroy (GtkObject *object)
gimp_file_selection_destroy (GtkObject *object)
{
GimpFileSelection *gfs;
......@@ -102,18 +95,20 @@ gimp_file_selection_class_init (GimpFileSelectionClass *class)
parent_class = gtk_type_class (gtk_hbox_get_type ());
gimp_file_selection_signals[GFS_FILENAME_CHANGED_SIGNAL] =
gimp_file_selection_signals[FILENAME_CHANGED] =
gtk_signal_new ("filename_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpFileSelectionClass,
gimp_file_selection),
filename_changed),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class, gimp_file_selection_signals,
LAST_SIGNAL);
object_class->destroy = gimp_file_selection_class_destroy;
class->gimp_file_selection = NULL;
class->filename_changed = NULL;
object_class->destroy = gimp_file_selection_destroy;
}
static void
......@@ -141,16 +136,15 @@ gimp_file_selection_init (GimpFileSelection *gfs)
(GdkEventFunc) gimp_file_selection_entry_focus_out_callback, gfs);
gtk_widget_show (gfs->entry);
/* this callback does the rest (pixmap creation etc.)
*/
/* this callback does the rest (pixmap creation etc.) */
gtk_signal_connect (GTK_OBJECT(gfs), "realize",
GTK_SIGNAL_FUNC(gimp_file_selection_realize), gfs);
}
guint
GtkType
gimp_file_selection_get_type ()
{
static guint gfs_type = 0;
static GtkType gfs_type = 0;
if (!gfs_type)
{
......@@ -172,7 +166,6 @@ gimp_file_selection_get_type ()
return gfs_type;
}
GtkWidget*
gimp_file_selection_new (gchar *title,
gchar *filename,
......@@ -191,7 +184,6 @@ gimp_file_selection_new (gchar *title,
return GTK_WIDGET (gfs);
}
static void
gimp_file_selection_realize (GtkWidget *widget,
gpointer data)
......@@ -226,7 +218,6 @@ gimp_file_selection_realize (GtkWidget *widget,
gtk_widget_show (gfs->file_exists);
}
gchar*
gimp_file_selection_get_filename (GimpFileSelection *gfs)
{
......@@ -236,7 +227,6 @@ gimp_file_selection_get_filename (GimpFileSelection *gfs)
return gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1);
}
void
gimp_file_selection_set_filename (GimpFileSelection *gfs,
gchar *filename)
......@@ -251,7 +241,6 @@ gimp_file_selection_set_filename (GimpFileSelection *gfs,
gimp_file_selection_entry_callback (gfs->entry, (gpointer) gfs);
}
static void
gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data)
......@@ -286,10 +275,9 @@ gimp_file_selection_entry_callback (GtkWidget *widget,
gtk_entry_set_position (GTK_ENTRY (gfs->entry), -1);
gtk_signal_emit (GTK_OBJECT (gfs),
gimp_file_selection_signals[GFS_FILENAME_CHANGED_SIGNAL]);
gimp_file_selection_signals[FILENAME_CHANGED]);
}
static int
gimp_file_selection_entry_focus_out_callback (GtkWidget *widget,
GdkEvent *event,
......@@ -300,9 +288,7 @@ gimp_file_selection_entry_focus_out_callback (GtkWidget *widget,
return TRUE;
}
/* these are local callbacks of gimp_file_selection_browse_callback()
*/
/* local callbacks of gimp_file_selection_browse_callback() */
static void
gimp_file_selection_filesel_ok_callback (GtkWidget *widget,
gpointer data)
......@@ -316,8 +302,7 @@ gimp_file_selection_filesel_ok_callback (GtkWidget *widget,
gtk_entry_set_text (GTK_ENTRY (gfs->entry), filename);
/* update everything
*/
/* update everything */
gimp_file_selection_entry_callback (gfs->entry, data);
}
......@@ -370,25 +355,29 @@ gimp_file_selection_browse_callback (GtkWidget *widget,
gtk_label_set_text (GTK_LABEL (GTK_BIN (GTK_FILE_SELECTION (gfs->file_selection)->ok_button)->child), _("Select"));
gtk_label_set_text (GTK_LABEL (GTK_BIN (GTK_FILE_SELECTION (gfs->file_selection)->cancel_button)->child), _("Close"));
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->ok_button),
"clicked",
(GtkSignalFunc)gimp_file_selection_filesel_ok_callback,
gfs);
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->selection_entry),
"activate",
(GtkSignalFunc)gimp_file_selection_filesel_ok_callback,
gfs);
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->cancel_button),
"clicked",
(GtkSignalFunc)gimp_file_selection_filesel_cancel_callback,
gfs);
gtk_signal_connect (GTK_OBJECT (gfs), "unmap",
(GtkSignalFunc)gimp_file_selection_filesel_cancel_callback,
gfs);
gtk_signal_connect (GTK_OBJECT (gfs->file_selection),
"delete_event",
(GdkEventFunc)gimp_file_selection_filesel_delete_callback,
gfs);
gtk_signal_connect
(GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->ok_button),
"clicked",
(GtkSignalFunc)gimp_file_selection_filesel_ok_callback,
gfs);
gtk_signal_connect
(GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->selection_entry),
"activate",
(GtkSignalFunc)gimp_file_selection_filesel_ok_callback,
gfs);
gtk_signal_connect
(GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->cancel_button),
"clicked",
(GtkSignalFunc)gimp_file_selection_filesel_cancel_callback,
gfs);