GtkWIdget::style_set initial emission,

read up in docs/style.txt on this ;)
This commit is contained in:
Tim Janik 1998-02-27 22:09:20 +00:00
parent 693fa02b83
commit b2e6c9723a
5 changed files with 54 additions and 28 deletions

View File

@ -57,26 +57,31 @@ gtk_style_copy ()
GtkWidget::style_set
This signal will be emitted for a widget once its style changes with
the previous style supplied.
the GtkWidgetClass implements a default handler for this signal that
will set the widget's window's background of widgets that provide their
own windows according to the new style.
Derived widgets need to overide this default handler, if:
- their size requisition depends on the current style.
(e.g., on the style's fonts)
- they set the background of widget->window to something other than.
style->bg. (e.g., GtkListItem)
- the widget provides windows other than widget->window.
- the widget has any other stored dependencies on the style.
This signal will be emitted for a widget once its style changes with
an additional argument previous_style wich will hold the widget->style
avlue from a previous emission.
The initial emission of this signal is guaranteed to happen prior
to any GtkWidget::size_request emission, and will have the previous_style
argument set to NULL.
The GtkWidgetClass implements a default handler for this signal that
will set the widget's window's background of widgets that provide their
own windows according to the new style.
Derived widgets need to overide this default handler, if:
- their size requisition depends on the current style.
(e.g., on the style's fonts)
- they set the background of widget->window to something other than.
style->bg. (e.g., GtkListItem)
- the widget provides windows other than widget->window.
- the widget has any other stored dependencies on the style.
Flag indications:
!GTK_RC_STYLE && !GTK_USER_STYLE:
The widget has it's default style set, and no rc lookup has been
performed.
The widget has it's default style set, no rc lookup has been
performed, the widget has not been size requested yet and is
therefore not yet realized.
GTK_USER_STYLE:
GTK_RC_STYLE is not set.
@ -86,9 +91,8 @@ GTK_USER_STYLE:
GTK_RC_STYLE:
GTK_USER_STYLE is not set.
If the widget has a saved default style, it has been assigned an
rc style.
If the widget does not have a saved default style, it still has its
default style but an rc lookup has already been performed.
rc style. If the widget does not have a saved default style, it still
has its default style but an rc lookup has already been performed.
- Tim Janik <timj@gimp.org>

View File

@ -67,9 +67,6 @@
#define LAST_INDEX(t, m) ((m).index == TEXT_LENGTH(t))
#define CACHE_DATA(c) (*(LineParams*)(c)->data)
#define GTK_TEXT_INDEX(t, index) ((index) < (t)->gap_position ? (t)->text[index] : \
(t)->text[(index) + (t)->gap_size])
typedef struct _TextFont TextFont;
typedef struct _TextProperty TextProperty;
typedef struct _TabStopMark TabStopMark;

View File

@ -200,7 +200,8 @@ static void gtk_widget_propagate_state (GtkWidget *widget,
static void gtk_widget_draw_children_recurse (GtkWidget *widget,
gpointer client_data);
static void gtk_widget_set_style_internal (GtkWidget *widget,
GtkStyle *style);
GtkStyle *style,
gboolean initial_emission);
static void gtk_widget_set_style_recurse (GtkWidget *widget,
gpointer client_data);
@ -1631,6 +1632,7 @@ gtk_widget_size_request (GtkWidget *widget,
g_return_if_fail (widget != NULL);
gtk_widget_ref (widget);
gtk_widget_ensure_style (widget);
gtk_signal_emit (GTK_OBJECT (widget), widget_signals[SIZE_REQUEST],
requisition);
aux_info = gtk_object_get_data (GTK_OBJECT (widget), aux_info_key);
@ -2337,10 +2339,13 @@ gtk_widget_set_style (GtkWidget *widget,
GtkStyle *style)
{
GtkStyle *default_style;
gboolean initial_emission;
g_return_if_fail (widget != NULL);
g_return_if_fail (style != NULL);
initial_emission = !GTK_WIDGET_RC_STYLE (widget) && !GTK_WIDGET_USER_STYLE (widget);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_RC_STYLE);
GTK_PRIVATE_SET_FLAG (widget, GTK_USER_STYLE);
@ -2351,7 +2356,7 @@ gtk_widget_set_style (GtkWidget *widget,
gtk_object_set_data (GTK_OBJECT (widget), saved_default_style, widget->style);
}
gtk_widget_set_style_internal (widget, style);
gtk_widget_set_style_internal (widget, style, initial_emission);
}
void
@ -2367,9 +2372,12 @@ gtk_widget_set_rc_style (GtkWidget *widget)
{
GtkStyle *saved_style;
GtkStyle *new_style;
gboolean initial_emission;
g_return_if_fail (widget != NULL);
initial_emission = !GTK_WIDGET_RC_STYLE (widget) && !GTK_WIDGET_USER_STYLE (widget);
GTK_PRIVATE_UNSET_FLAG (widget, GTK_USER_STYLE);
GTK_WIDGET_SET_FLAGS (widget, GTK_RC_STYLE);
@ -2382,16 +2390,24 @@ gtk_widget_set_rc_style (GtkWidget *widget)
gtk_style_ref (widget->style);
gtk_object_set_data (GTK_OBJECT (widget), saved_default_style, widget->style);
}
gtk_widget_set_style_internal (widget, new_style);
gtk_widget_set_style_internal (widget, new_style, initial_emission);
}
else
{
if (saved_style)
{
g_assert (initial_emission == FALSE); /* FIXME: remove this line */
gtk_object_remove_data (GTK_OBJECT (widget), saved_default_style);
gtk_widget_set_style_internal (widget, saved_style);
gtk_widget_set_style_internal (widget, saved_style, initial_emission);
gtk_style_unref (saved_style);
}
else
{
g_assert (initial_emission == TRUE); /* FIXME: remove this line */
gtk_widget_set_style_internal (widget, new_style, TRUE);
}
}
}
@ -2414,7 +2430,8 @@ gtk_widget_style_set (GtkWidget *widget,
static void
gtk_widget_set_style_internal (GtkWidget *widget,
GtkStyle *style)
GtkStyle *style,
gboolean initial_emission)
{
g_return_if_fail (widget != NULL);
g_return_if_fail (style != NULL);
@ -2433,7 +2450,9 @@ gtk_widget_set_style_internal (GtkWidget *widget,
if (GTK_WIDGET_REALIZED (widget))
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_signal_emit (GTK_OBJECT (widget), widget_signals[STYLE_SET], previous_style);
gtk_signal_emit (GTK_OBJECT (widget),
widget_signals[STYLE_SET],
initial_emission ? NULL : previous_style);
gtk_style_unref (previous_style);
if (widget->parent)
@ -2450,6 +2469,12 @@ gtk_widget_set_style_internal (GtkWidget *widget,
gtk_widget_queue_draw (widget);
}
}
else if (initial_emission)
{
gtk_signal_emit (GTK_OBJECT (widget),
widget_signals[STYLE_SET],
NULL);
}
}
static void

View File

@ -36,7 +36,7 @@ style "button"
style 'main_button' = 'button'
{
font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"
bg[PRELIGHT] = { 0, 0x00, 0.75 }
bg[PRELIGHT] = { 0, 0.75, 0x00 }
}
style "toggle_button" = "button"

View File

@ -36,7 +36,7 @@ style "button"
style 'main_button' = 'button'
{
font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"
bg[PRELIGHT] = { 0, 0x00, 0.75 }
bg[PRELIGHT] = { 0, 0.75, 0x00 }
}
style "toggle_button" = "button"