Blame docs/styles.txt

Packit 98cdb6
HANDLING WIDGET STYLES
Packit 98cdb6
======================
Packit 98cdb6
Packit 98cdb6
Packit 98cdb6
A widget gets created with a default style.
Packit 98cdb6
The global default style can be affected by gtk_widget_set_default_style()
Packit 98cdb6
and can be queried by gtk_widget_get_default_style().
Packit 98cdb6
The initial style that is assigned to a widget as default style upon
Packit 98cdb6
creation can be affected by wrapping the widget's creation as follows:
Packit 98cdb6
gtk_widget_push_style (my_style);
Packit 98cdb6
widget = gtk_type_new (gtk_button_get_type ());
Packit 98cdb6
gtk_widget_pop_style ();
Packit 98cdb6
Packit 98cdb6
There are certain functions to affect widget styles after a widget's
Packit 98cdb6
creation:
Packit 98cdb6
Packit 98cdb6
gtk_widget_set_style ()
Packit 98cdb6
  Save the default style and set a user style.
Packit 98cdb6
  This will override a previously set user style or
Packit 98cdb6
  previously set rc styles.
Packit 98cdb6
Packit 98cdb6
gtk_widget_set_rc_style ()
Packit 98cdb6
  Set GTK_RC_STYLE to indicate that an rc lookup has been performed.
Packit 98cdb6
  If there is an rc style for a widget, set it and save the default style,
Packit 98cdb6
  restore the default style otherwise.
Packit 98cdb6
  This will override a previously set user style or rc style.
Packit 98cdb6
Packit 98cdb6
gtk_widget_reset_rc_styles ()
Packit 98cdb6
  Descends through a widget hierarchy and sets the rc style
Packit 98cdb6
  on all widgets that don't have a user style set.
Packit 98cdb6
Packit 98cdb6
gtk_widget_restore_default_style ()
Packit 98cdb6
  Reset the widget's style to the default style, this is only useful if
Packit 98cdb6
  the widgets default style had been saved by previous calls to
Packit 98cdb6
  gtk_widget_set_style() or gtk_widget_set_rc_style().
Packit 98cdb6
Packit 98cdb6
gtk_widget_ensure_style ()
Packit 98cdb6
  Ensure that the widget either has a user style set, or an rc lookup
Packit 98cdb6
  has been performed.
Packit 98cdb6
Packit 98cdb6
gtk_rc_get_style ()
Packit 98cdb6
  Return an rc style for a widget if there is one.
Packit 98cdb6
Packit 98cdb6
gtk_widget_set_name ()
Packit 98cdb6
  Change widget name, and perform a new rc lookup if no user style
Packit 98cdb6
  is set.
Packit 98cdb6
Packit 98cdb6
gtk_widget_realize ()
Packit 98cdb6
  Besides realizing the widget this function will:
Packit 98cdb6
  - perform an rc lookup if necessary,
Packit 98cdb6
  - attach a widget's style.
Packit 98cdb6
Packit 98cdb6
gtk_widget_get_style ()
Packit 98cdb6
  Return a widgets style, this function will perform an rc lookup
Packit 98cdb6
  if necessary.
Packit 98cdb6
Packit 98cdb6
gtk_widget_set_parent ()
Packit 98cdb6
  This function will perform rc lookups recursively for all widgets
Packit 98cdb6
  that do not have a user style set.
Packit 98cdb6
Packit 98cdb6
gtk_style_copy ()
Packit 98cdb6
  This function can be used to copy a widget's style.
Packit 98cdb6
  The style can subsequently be changed (e.g., by modifications to the
Packit 98cdb6
  red/green/blue values of a certain color) and then be applied to the
Packit 98cdb6
  widget via gtk_widget_set_style().
Packit 98cdb6
Packit 98cdb6
Packit 98cdb6
GtkWidget::style_set
Packit 98cdb6
  This signal will be emitted for a widget once its style changes with
Packit 98cdb6
  an additional argument previous_style which will hold the widget->style
Packit 98cdb6
  value from a previous emission.
Packit 98cdb6
  The initial emission of this signal is guaranteed to happen prior
Packit 98cdb6
  to any GtkWidget::size_request emission, and will have the previous_style
Packit 98cdb6
  argument set to NULL.
Packit 98cdb6
  The GtkWidgetClass implements a default handler for this signal that
Packit 98cdb6
  will set the widget's window's background of widgets that provide their
Packit 98cdb6
  own windows according to the new style.
Packit 98cdb6
  Derived widgets need to override this default handler, if:
Packit 98cdb6
  - their size requisition depends on the current style.
Packit 98cdb6
    (e.g., on the style's fonts)
Packit 98cdb6
  - they set the background of widget->window to something other than.
Packit 98cdb6
    style->bg. (e.g., GtkListItem)
Packit 98cdb6
  - the widget provides windows other than widget->window.
Packit 98cdb6
  - the widget has any other stored dependencies on the style.
Packit 98cdb6
                   
Packit 98cdb6
Packit 98cdb6
Packit 98cdb6
Flag indications:
Packit 98cdb6
Packit 98cdb6
!GTK_RC_STYLE && !GTK_USER_STYLE:
Packit 98cdb6
  The widget has its default style set, no rc lookup has been
Packit 98cdb6
  performed, the widget has not been size requested yet and is
Packit 98cdb6
  therefore not yet realized.
Packit 98cdb6
Packit 98cdb6
GTK_USER_STYLE:
Packit 98cdb6
  GTK_RC_STYLE is not set.
Packit 98cdb6
  The widget has a user style assigned, and its default style has been
Packit 98cdb6
  saved.
Packit 98cdb6
Packit 98cdb6
GTK_RC_STYLE:
Packit 98cdb6
  GTK_USER_STYLE is not set.
Packit 98cdb6
  If the widget has a saved default style, it has been assigned an
Packit 98cdb6
  rc style. If the widget does not have a saved default style, it still
Packit 98cdb6
  has its default style but an rc lookup has already been performed.
Packit 98cdb6
Packit 98cdb6
Packit 98cdb6
	- Tim Janik <timj@gimp.org>
Packit 98cdb6
	  1998/02/27