Commit af18ab43 authored by Tim Janik's avatar Tim Janik Committed by Tim Janik

complete api change to honour message contexts. unfortunaltely this also

Sun Mar  1 22:59:09 1998  Tim Janik  <timj@gimp.org>

        * gtk/gtkstatusbar.h:
        * gtk/gtkstatusbar.c: complete api change to honour message contexts.
        unfortunaltely this also involved argument changes on the signal
        emissions which will not be caught by the compiler. your callbacks
        should look like:
        void  message_text_popped (GtkStatusbar   *statusbar,
                                   guint           context_id,
                                   const gchar    *text,
                                   gpointer        func_data);

        * gtk/gtkwidget.c (gtk_widget_set_rc_style): eliminated bug about
        initial signal emission.
        (gtk_widget_set_parent): don't ensure style, just call
        gtk_widget_set_style_recurse.
        (gtk_widget_set_style_recurse): only change a widget's rc styles if
        if there has already been a lookup.

        * gtk/testgtk.c: adaptions for statusbar widget.
        substituted notebook pixmaps with pixmaps from fvwm, since
        we don't know where the originals came from.

        * gtk/gtkobject.c (gtk_object_data_destroy): call the destroy
        notifier with the objects data, not its internal structure.

        * gtk/gtkspinbutton.c (gtk_spin_button_button_press): small
        fix from lars.
parent 3fb589b2
Sun Mar 1 22:59:09 1998 Tim Janik <timj@gimp.org>
* gtk/gtkstatusbar.h:
* gtk/gtkstatusbar.c: complete api change to honour message contexts.
unfortunaltely this also involved argument changes on the signal
emissions which will not be caught by the compiler. your callbacks
should look like:
void message_text_popped (GtkStatusbar *statusbar,
guint context_id,
const gchar *text,
gpointer func_data);
* gtk/gtkwidget.c (gtk_widget_set_rc_style): eliminated bug about
initial signal emission.
(gtk_widget_set_parent): don't ensure style, just call
gtk_widget_set_style_recurse.
(gtk_widget_set_style_recurse): only change a widget's rc styles if
if there has already been a lookup.
* gtk/testgtk.c: adaptions for statusbar widget.
substituted notebook pixmaps with pixmaps from fvwm, since
we don't know where the originals came from.
* gtk/gtkobject.c (gtk_object_data_destroy): call the destroy
notifier with the objects data, not its internal structure.
* gtk/gtkspinbutton.c (gtk_spin_button_button_press): small
fix from lars.
Sun Mar 1 15:08:13 CST 1998 Shawn T. Amundson <amundson@gimp.org>
* docs/*.texi changes from Greg Mclean.
......
Sun Mar 1 22:59:09 1998 Tim Janik <timj@gimp.org>
* gtk/gtkstatusbar.h:
* gtk/gtkstatusbar.c: complete api change to honour message contexts.
unfortunaltely this also involved argument changes on the signal
emissions which will not be caught by the compiler. your callbacks
should look like:
void message_text_popped (GtkStatusbar *statusbar,
guint context_id,
const gchar *text,
gpointer func_data);
* gtk/gtkwidget.c (gtk_widget_set_rc_style): eliminated bug about
initial signal emission.
(gtk_widget_set_parent): don't ensure style, just call
gtk_widget_set_style_recurse.
(gtk_widget_set_style_recurse): only change a widget's rc styles if
if there has already been a lookup.
* gtk/testgtk.c: adaptions for statusbar widget.
substituted notebook pixmaps with pixmaps from fvwm, since
we don't know where the originals came from.
* gtk/gtkobject.c (gtk_object_data_destroy): call the destroy
notifier with the objects data, not its internal structure.
* gtk/gtkspinbutton.c (gtk_spin_button_button_press): small
fix from lars.
Sun Mar 1 15:08:13 CST 1998 Shawn T. Amundson <amundson@gimp.org>
* docs/*.texi changes from Greg Mclean.
......
Sun Mar 1 22:59:09 1998 Tim Janik <timj@gimp.org>
* gtk/gtkstatusbar.h:
* gtk/gtkstatusbar.c: complete api change to honour message contexts.
unfortunaltely this also involved argument changes on the signal
emissions which will not be caught by the compiler. your callbacks
should look like:
void message_text_popped (GtkStatusbar *statusbar,
guint context_id,
const gchar *text,
gpointer func_data);
* gtk/gtkwidget.c (gtk_widget_set_rc_style): eliminated bug about
initial signal emission.
(gtk_widget_set_parent): don't ensure style, just call
gtk_widget_set_style_recurse.
(gtk_widget_set_style_recurse): only change a widget's rc styles if
if there has already been a lookup.
* gtk/testgtk.c: adaptions for statusbar widget.
substituted notebook pixmaps with pixmaps from fvwm, since
we don't know where the originals came from.
* gtk/gtkobject.c (gtk_object_data_destroy): call the destroy
notifier with the objects data, not its internal structure.
* gtk/gtkspinbutton.c (gtk_spin_button_button_press): small
fix from lars.
Sun Mar 1 15:08:13 CST 1998 Shawn T. Amundson <amundson@gimp.org>
* docs/*.texi changes from Greg Mclean.
......
Sun Mar 1 22:59:09 1998 Tim Janik <timj@gimp.org>
* gtk/gtkstatusbar.h:
* gtk/gtkstatusbar.c: complete api change to honour message contexts.
unfortunaltely this also involved argument changes on the signal
emissions which will not be caught by the compiler. your callbacks
should look like:
void message_text_popped (GtkStatusbar *statusbar,
guint context_id,
const gchar *text,
gpointer func_data);
* gtk/gtkwidget.c (gtk_widget_set_rc_style): eliminated bug about
initial signal emission.
(gtk_widget_set_parent): don't ensure style, just call
gtk_widget_set_style_recurse.
(gtk_widget_set_style_recurse): only change a widget's rc styles if
if there has already been a lookup.
* gtk/testgtk.c: adaptions for statusbar widget.
substituted notebook pixmaps with pixmaps from fvwm, since
we don't know where the originals came from.
* gtk/gtkobject.c (gtk_object_data_destroy): call the destroy
notifier with the objects data, not its internal structure.
* gtk/gtkspinbutton.c (gtk_spin_button_button_press): small
fix from lars.
Sun Mar 1 15:08:13 CST 1998 Shawn T. Amundson <amundson@gimp.org>
* docs/*.texi changes from Greg Mclean.
......
Sun Mar 1 22:59:09 1998 Tim Janik <timj@gimp.org>
* gtk/gtkstatusbar.h:
* gtk/gtkstatusbar.c: complete api change to honour message contexts.
unfortunaltely this also involved argument changes on the signal
emissions which will not be caught by the compiler. your callbacks
should look like:
void message_text_popped (GtkStatusbar *statusbar,
guint context_id,
const gchar *text,
gpointer func_data);
* gtk/gtkwidget.c (gtk_widget_set_rc_style): eliminated bug about
initial signal emission.
(gtk_widget_set_parent): don't ensure style, just call
gtk_widget_set_style_recurse.
(gtk_widget_set_style_recurse): only change a widget's rc styles if
if there has already been a lookup.
* gtk/testgtk.c: adaptions for statusbar widget.
substituted notebook pixmaps with pixmaps from fvwm, since
we don't know where the originals came from.
* gtk/gtkobject.c (gtk_object_data_destroy): call the destroy
notifier with the objects data, not its internal structure.
* gtk/gtkspinbutton.c (gtk_spin_button_button_press): small
fix from lars.
Sun Mar 1 15:08:13 CST 1998 Shawn T. Amundson <amundson@gimp.org>
* docs/*.texi changes from Greg Mclean.
......
Sun Mar 1 22:59:09 1998 Tim Janik <timj@gimp.org>
* gtk/gtkstatusbar.h:
* gtk/gtkstatusbar.c: complete api change to honour message contexts.
unfortunaltely this also involved argument changes on the signal
emissions which will not be caught by the compiler. your callbacks
should look like:
void message_text_popped (GtkStatusbar *statusbar,
guint context_id,
const gchar *text,
gpointer func_data);
* gtk/gtkwidget.c (gtk_widget_set_rc_style): eliminated bug about
initial signal emission.
(gtk_widget_set_parent): don't ensure style, just call
gtk_widget_set_style_recurse.
(gtk_widget_set_style_recurse): only change a widget's rc styles if
if there has already been a lookup.
* gtk/testgtk.c: adaptions for statusbar widget.
substituted notebook pixmaps with pixmaps from fvwm, since
we don't know where the originals came from.
* gtk/gtkobject.c (gtk_object_data_destroy): call the destroy
notifier with the objects data, not its internal structure.
* gtk/gtkspinbutton.c (gtk_spin_button_button_press): small
fix from lars.
Sun Mar 1 15:08:13 CST 1998 Shawn T. Amundson <amundson@gimp.org>
* docs/*.texi changes from Greg Mclean.
......
Sun Mar 1 22:59:09 1998 Tim Janik <timj@gimp.org>
* gtk/gtkstatusbar.h:
* gtk/gtkstatusbar.c: complete api change to honour message contexts.
unfortunaltely this also involved argument changes on the signal
emissions which will not be caught by the compiler. your callbacks
should look like:
void message_text_popped (GtkStatusbar *statusbar,
guint context_id,
const gchar *text,
gpointer func_data);
* gtk/gtkwidget.c (gtk_widget_set_rc_style): eliminated bug about
initial signal emission.
(gtk_widget_set_parent): don't ensure style, just call
gtk_widget_set_style_recurse.
(gtk_widget_set_style_recurse): only change a widget's rc styles if
if there has already been a lookup.
* gtk/testgtk.c: adaptions for statusbar widget.
substituted notebook pixmaps with pixmaps from fvwm, since
we don't know where the originals came from.
* gtk/gtkobject.c (gtk_object_data_destroy): call the destroy
notifier with the objects data, not its internal structure.
* gtk/gtkspinbutton.c (gtk_spin_button_button_press): small
fix from lars.
Sun Mar 1 15:08:13 CST 1998 Shawn T. Amundson <amundson@gimp.org>
* docs/*.texi changes from Greg Mclean.
......
......@@ -1272,7 +1272,7 @@ gtk_object_data_destroy (GtkObjectData *odata)
g_return_if_fail (odata != NULL);
if (odata->destroy)
odata->destroy (odata);
odata->destroy (odata->data);
g_mem_chunk_free (object_data_mem_chunk, odata);
}
......
......@@ -528,9 +528,6 @@ gtk_spin_button_button_press (GtkWidget *widget,
spin = GTK_SPIN_BUTTON (widget);
if (event->type != GDK_BUTTON_PRESS)
return FALSE;
if (!spin->button)
{
if (event->window == spin->panel)
......
......@@ -31,13 +31,16 @@ enum
};
typedef void (*SignalTextP) (GtkObject *object,
guint context_id,
const gchar *text,
gpointer func_data);
static void gtk_statusbar_class_init (GtkStatusbarClass *class);
static void gtk_statusbar_init (GtkStatusbar *statusbar);
static void gtk_statusbar_destroy (GtkObject *object);
static void gtk_statusbar_finalize (GtkObject *object);
static void gtk_statusbar_update (GtkStatusbar *statusbar,
guint context_id,
const gchar *text);
static GtkContainerClass *parent_class;
......@@ -76,7 +79,8 @@ gtk_statusbar_marshal_text_p (GtkObject *object,
SignalTextP sfunc = (SignalTextP) func;
(* sfunc) (object,
GTK_VALUE_STRING (args[0]),
GTK_VALUE_UINT (args[0]),
GTK_VALUE_STRING (args[1]),
func_data);
}
......@@ -99,7 +103,8 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
object_class->type,
GTK_SIGNAL_OFFSET (GtkStatusbarClass, text_pushed),
gtk_statusbar_marshal_text_p,
GTK_TYPE_NONE, 1,
GTK_TYPE_NONE, 2,
GTK_TYPE_UINT,
GTK_TYPE_STRING);
statusbar_signals[SIGNAL_TEXT_POPPED] =
gtk_signal_new ("text_popped",
......@@ -107,11 +112,13 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
object_class->type,
GTK_SIGNAL_OFFSET (GtkStatusbarClass, text_popped),
gtk_statusbar_marshal_text_p,
GTK_TYPE_NONE, 1,
GTK_TYPE_NONE, 2,
GTK_TYPE_UINT,
GTK_TYPE_STRING);
gtk_object_class_add_signals (object_class, statusbar_signals, SIGNAL_LAST);
object_class->destroy = gtk_statusbar_destroy;
object_class->finalize = gtk_statusbar_finalize;
class->messages_mem_chunk = g_mem_chunk_new ("GtkStatusBar messages mem chunk",
sizeof (GtkStatusbarMsg),
......@@ -142,8 +149,10 @@ gtk_statusbar_init (GtkStatusbar *statusbar)
gtk_container_add (GTK_CONTAINER (statusbar->frame), statusbar->label);
gtk_widget_show (statusbar->label);
statusbar->seq_status_id = 1;
statusbar->seq_context_id = 1;
statusbar->seq_message_id = 1;
statusbar->messages = NULL;
statusbar->keys = NULL;
}
GtkWidget*
......@@ -154,6 +163,7 @@ gtk_statusbar_new ()
static void
gtk_statusbar_update (GtkStatusbar *statusbar,
guint context_id,
const gchar *text)
{
g_return_if_fail (statusbar != NULL);
......@@ -165,8 +175,37 @@ gtk_statusbar_update (GtkStatusbar *statusbar,
gtk_label_set (GTK_LABEL (statusbar->label), text);
}
guint
gtk_statusbar_get_context_id (GtkStatusbar *statusbar,
const gchar *context_description)
{
gchar *string;
guint *id;
g_return_val_if_fail (statusbar != NULL, 0);
g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), 0);
g_return_val_if_fail (context_description != NULL, 0);
/* we need to preserve namespaces on object datas */
string = g_strconcat ("gtk-status-bar-context:", context_description, NULL);
id = gtk_object_get_data (GTK_OBJECT (statusbar), string);
if (!id)
{
id = g_new (guint, 1);
*id = statusbar->seq_context_id++;
gtk_object_set_data_full (GTK_OBJECT (statusbar), string, id, (GtkDestroyNotify) g_free);
statusbar->keys = g_slist_prepend (statusbar->keys, string);
}
else
g_free (string);
return *id;
}
guint
gtk_statusbar_push (GtkStatusbar *statusbar,
guint context_id,
const gchar *text)
{
GtkStatusbarMsg *msg;
......@@ -175,65 +214,79 @@ gtk_statusbar_push (GtkStatusbar *statusbar,
g_return_val_if_fail (statusbar != NULL, 0);
g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), 0);
g_return_val_if_fail (text != NULL, 0);
g_return_val_if_fail (context_id > 0, 0);
class = GTK_STATUSBAR_CLASS (GTK_OBJECT (statusbar)->klass);
msg = g_chunk_new (GtkStatusbarMsg, class->messages_mem_chunk);
msg->text = g_strdup (text);
msg->status_id = statusbar->seq_status_id++;
msg->context_id = context_id;
msg->message_id = statusbar->seq_message_id++;
statusbar->messages = g_list_prepend (statusbar->messages, msg);
statusbar->messages = g_slist_prepend (statusbar->messages, msg);
gtk_signal_emit (GTK_OBJECT (statusbar), statusbar_signals[SIGNAL_TEXT_PUSHED], msg->text);
gtk_signal_emit (GTK_OBJECT (statusbar),
statusbar_signals[SIGNAL_TEXT_PUSHED],
msg->context_id,
msg->text);
return msg->status_id;
return msg->message_id;
}
void
gtk_statusbar_pop (GtkStatusbar *statusbar)
gtk_statusbar_pop (GtkStatusbar *statusbar,
guint context_id)
{
GtkStatusbarMsg *msg;
g_return_if_fail (statusbar != NULL);
g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
g_return_if_fail (context_id > 0);
if (statusbar->messages)
{
GList *list;
GSList *list;
GtkStatusbarClass *class;
list = statusbar->messages;
msg = list->data;
class = GTK_STATUSBAR_CLASS (GTK_OBJECT (statusbar)->klass);
statusbar->messages = g_list_remove_link (statusbar->messages, list);
statusbar->messages = g_slist_remove_link (statusbar->messages, list);
g_free (msg->text);
g_mem_chunk_free (class->messages_mem_chunk, msg);
g_list_free_1 (list);
g_slist_free_1 (list);
}
msg = statusbar->messages ? statusbar->messages->data : NULL;
gtk_signal_emit (GTK_OBJECT (statusbar), statusbar_signals[SIGNAL_TEXT_POPPED],
gtk_signal_emit (GTK_OBJECT (statusbar),
statusbar_signals[SIGNAL_TEXT_POPPED],
(guint) (msg ? msg->context_id : 0),
msg ? msg->text : NULL);
}
void
gtk_statusbar_steal (GtkStatusbar *statusbar,
guint status_id)
gtk_statusbar_remove (GtkStatusbar *statusbar,
guint context_id,
guint message_id)
{
GtkStatusbarMsg *msg;
g_return_if_fail (statusbar != NULL);
g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
g_return_if_fail (context_id > 0);
g_return_if_fail (message_id > 0);
msg = statusbar->messages ? statusbar->messages->data : NULL;
if (msg)
{
GList *list;
if (msg->status_id == status_id)
GSList *list;
/* care about signal emission if the topmost item is removed */
if (msg->context_id == context_id &&
msg->message_id == message_id)
{
gtk_statusbar_pop (statusbar);
gtk_statusbar_pop (statusbar, context_id);
return;
}
......@@ -241,15 +294,16 @@ gtk_statusbar_steal (GtkStatusbar *statusbar,
{
msg = list->data;
if (msg->status_id == status_id)
if (msg->context_id == context_id &&
msg->message_id == message_id)
{
GtkStatusbarClass *class;
class = GTK_STATUSBAR_CLASS (GTK_OBJECT (statusbar)->klass);
statusbar->messages = g_list_remove_link (statusbar->messages, list);
statusbar->messages = g_slist_remove_link (statusbar->messages, list);
g_free (msg->text);
g_mem_chunk_free (class->messages_mem_chunk, msg);
g_list_free_1 (list);
g_slist_free_1 (list);
break;
}
......@@ -262,7 +316,7 @@ gtk_statusbar_destroy (GtkObject *object)
{
GtkStatusbar *statusbar;
GtkStatusbarClass *class;
GList *list;
GSList *list;
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_STATUSBAR (object));
......@@ -278,9 +332,28 @@ gtk_statusbar_destroy (GtkObject *object)
g_free (msg->text);
g_mem_chunk_free (class->messages_mem_chunk, msg);
}
g_list_free (statusbar->messages);
g_slist_free (statusbar->messages);
statusbar->messages = NULL;
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
gtk_statusbar_finalize (GtkObject *object)
{
GtkStatusbar *statusbar;
GSList *list;
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_STATUSBAR (object));
statusbar = GTK_STATUSBAR (object);
for (list = statusbar->keys; list; list = list->next)
g_free (list->data);
g_slist_free (statusbar->messages);
statusbar->keys = NULL;
printf("huhu\n");
GTK_OBJECT_CLASS (parent_class)->finalize (object);
}
......@@ -41,9 +41,11 @@ struct _GtkStatusbar
GtkWidget *frame;
GtkWidget *label;
GList *messages;
GSList *messages;
GSList *keys;
guint seq_status_id;
guint seq_context_id;
guint seq_message_id;
};
struct _GtkStatusbarClass
......@@ -53,26 +55,33 @@ struct _GtkStatusbarClass
GMemChunk *messages_mem_chunk;
void (*text_pushed) (GtkStatusbar *statusbar,
guint context_id,
const gchar *text);
void (*text_popped) (GtkStatusbar *statusbar,
guint context_id,
const gchar *text);
};
struct _GtkStatusbarMsg
{
gchar *text;
guint status_id;
guint context_id;
guint message_id;
};
guint gtk_statusbar_get_type (void);
GtkWidget* gtk_statusbar_new (void);
/* Returns StatusID used for gtk_statusbar_push */
guint gtk_statusbar_push (GtkStatusbar *statusbar,
guint gtk_statusbar_get_context_id (GtkStatusbar *statusbar,
const gchar *context_description);
/* Returns message_id used for gtk_statusbar_remove */
guint gtk_statusbar_push (GtkStatusbar *statusbar,
guint context_id,
const gchar *text);
void gtk_statusbar_pop (GtkStatusbar *statusbar);
void gtk_statusbar_steal (GtkStatusbar *statusbar,
guint status_id);
void gtk_statusbar_pop (GtkStatusbar *statusbar,
guint context_id);
void gtk_statusbar_remove (GtkStatusbar *statusbar,
guint context_id,
guint message_id);
......
......@@ -125,7 +125,7 @@ typedef void (*GtkWidgetSignal6) (GtkObject *object,
GtkObject *arg1,
gpointer data);
typedef void (*GtkWidgetSignal7) (GtkObject *object,
gpointer *arg1,
gpointer arg1,
gpointer data);
typedef struct _GtkStateData GtkStateData;
......@@ -2326,15 +2326,7 @@ gtk_widget_set_parent (GtkWidget *widget,
while (parent->parent != NULL)
parent = parent->parent;
if (GTK_WIDGET_TOPLEVEL (parent))
{
gtk_widget_ensure_style (widget);
if (GTK_IS_CONTAINER (widget))
gtk_container_foreach (GTK_CONTAINER (widget),
gtk_widget_set_style_recurse,
NULL);
}
gtk_widget_set_style_recurse (widget, NULL);
gtk_signal_emit (GTK_OBJECT (widget), widget_signals[PARENT_SET], NULL);
}
......@@ -2413,9 +2405,8 @@ gtk_widget_set_rc_style (GtkWidget *widget)
}
else
{
g_assert (initial_emission == TRUE); /* FIXME: remove this line */
gtk_widget_set_style_internal (widget, widget->style, TRUE);
if (initial_emission)
gtk_widget_set_style_internal (widget, widget->style, TRUE);
}
}
}
......@@ -2508,7 +2499,7 @@ static void
gtk_widget_set_style_recurse (GtkWidget *widget,
gpointer client_data)
{
if (!GTK_WIDGET_USER_STYLE (widget))
if (GTK_WIDGET_RC_STYLE (widget))
gtk_widget_set_rc_style (widget);
if (GTK_IS_CONTAINER (widget))
......
......@@ -800,31 +800,64 @@ statusbar_push (GtkWidget *button,
sprintf (text, "something %d", statusbar_counter++);
gtk_statusbar_push (statusbar, text);
gtk_statusbar_push (statusbar, 1, text);
}
static void
statusbar_pop (GtkWidget *button,
GtkStatusbar *statusbar)
{
gtk_statusbar_pop (statusbar);
gtk_statusbar_pop (statusbar, 1);
}
static void
statusbar_steal (GtkWidget *button,
GtkStatusbar *statusbar)
{
gtk_statusbar_steal (statusbar, 4);
gtk_statusbar_remove (statusbar, 1, 4);
}
static void
statusbar_popped (GtkStatusbar *statusbar,
guint context_id,
const gchar *text)
{
if (!statusbar->messages)
statusbar_counter = 1;
}
static void
statusbar_contexts (GtkWidget *button,
GtkStatusbar *statusbar)
{
gchar *string;
string = "any context";
g_print ("GtkStatusBar: context=\"%s\", context_id=%d\n",
string,
gtk_statusbar_get_context_id (statusbar, string));
string = "idle messages";
g_print ("GtkStatusBar: context=\"%s\", context_id=%d\n",
string,
gtk_statusbar_get_context_id (statusbar, string));