forked from AuroraMiddleware/gtk
9595c55184
Fri May 12 17:13:32 2000 Tim Janik <timj@gtk.org> * docs/Changes-1.4.txt: documented necessary changes for 1.4 transition. * gtk/gtktext.c: made the adjustments no-construct args, simply provide default adjustments. (gtk_text_destroy): release adjustments. * gtk/gtkprogressbar.c (gtk_progress_bar_class_init): made the adjustment argument non-construct. * gtk/gtkprogress.c (gtk_progress_destroy): release adjustment here, instead of in finalize. (gtk_progress_get_text_from_value): (gtk_progress_get_current_text): (gtk_progress_set_value): (gtk_progress_get_percentage_from_value): (gtk_progress_get_current_percentage): (gtk_progress_set_percentage): (gtk_progress_configure): ensure an adjustment is present. Thu May 11 01:24:08 2000 Tim Janik <timj@gtk.org> * gtk/gtkcolorsel.[hc]: * gtk/gtkcolorseldialog.[hc]: * gtk/gtkhsv.[hc]: major code cleanups, destroy handlers need to chain their parent implementation, use bit fields for boolean values, don't create unused widgets, usage of glib types, braces go on their own lines, function argument alignment, #include directives etc. etc. etc.. * gtk/Makefile.am (gtk_public_h_sources): install gtkhsv.h. Wed May 10 23:29:52 2000 Tim Janik <timj@gtk.org> * gtk/gtktoolbar.c (gtk_toolbar_destroy): don't unref a NULL tooltips. * gtk/gtkfilesel.c (gtk_file_selection_destroy): don't free a cmpl_state of NULL. * gtk/gtkcombo.c (gtk_combo_item_destroy): don#t keep references to freed data. (gtk_combo_destroy): don't keep a pointer to a destroyed window. * gtk/gtkmenu.c (gtk_menu_init): reset the menu's toplevel pointer to NULL when the toplevel is getting destroyed. (gtk_menu_set_tearoff_state): same here for the tearoff_window. (gtk_menu_destroy): (gtk_menu_init): store the information of whether we have to readd the initial child ref_count during destruction in a new GtkMenu field needs_destruction_ref_count. * gtk/gtkviewport.c: SHAME! ok this one is tricky, so i note it here, those reading: learn from my mistake! ;) in order for set_?adjustment to support a default adjustemnt if invoked with an adjustment pointer of NULL, the code read (pseudo): if (v->adjustment) unref (v->adjustment); if (!adjustment) adjustment = adjustment_new (); if (v->adjustment != adjustment) v->adjustment = ref (adjustment); now imagine the first unref to actually free the old adjustment and adjustment_new() creating a new adjustment from the very same memory portion. here, the latter comparision will unintendedly fail, and all hell breaks loose. (gtk_viewport_set_hadjustment): (gtk_viewport_set_vadjustment): reset viewport->?adjustment to NULL after unreferencing it. * gtk/gtkcontainer.[hc]: removed toplevel registration functions: gtk_container_register_toplevel(), gtk_container_unregister_toplevel() and gtk_container_get_toplevels() which had wrong semantics anyways: it didn't reference and copy the list. * gtk/gtkwindow.c: we take over the container toplevel registration bussiness now. windows are registered across multiple destructions, untill they are finalized. the initial implicit reference count users are holding on windows is removed with the first destruction though. (gtk_window_init): ref & sink and set has_user_ref_count, got rid of gtk_container_register_toplevel() call. add window to toplevel_list. (gtk_window_destroy): unref the window if has_user_ref_count is still set, got rid of call to gtk_container_unregister_toplevel(). (gtk_window_finalize): remove window from toplevel list. (gtk_window_list_toplevels): new function to return a newly created list with referenced toplevels. (gtk_window_read_rcfiles): use gtk_window_list_toplevels(). * gtk/gtkhscale.c (gtk_hscale_class_init): made the GtkRange adjustment a non-construct arg. * gtk/gtkvscale.c (gtk_vscale_class_init): likewise. * gtk/gtkhscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkvscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkrange.c: added some realized checks. (gtk_range_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. remove timer. (gtk_range_get_adjustment): demand create adjustment. * gtk/gtkviewport.c: made h/v adjustment non-construct args. we simply create them on demand now and get rid of them in the destroy handler. (gtk_viewport_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. (gtk_viewport_get_hadjustment): (gtk_viewport_get_vadjustment): (gtk_viewport_size_allocate): demand create h/v adjustment if required. * gtk/gtkwidget.c (gtk_widget_finalize): duplicate part of the gtk_widget_real_destroy () functionality. (gtk_widget_real_destroy): reinitialize with a new style, instead of setting widget->style to NULL. Fri May 5 13:02:09 2000 Tim Janik <timj@gtk.org> * gtk/gtkcalendar.c: * gtk/gtkbutton.c: ported _get_type() implementation over to GType, either to preserve memchunks allocation facilities, or because Gtk+ 1.0 GtkTypeInfo was still being used. * gtk/gtkobject.[hc]: derive from GObject. ported various functions over. prepare for ::destroy to be emitted multiple times. removed reference tracer magic. chain into GObjectClass.shutdown() to emit ::destroy signal. * gtk/gtksignal.c: removed assumptions about GTK_TYPE_OBJECT being fundamental. * gtk/gtkmain.c: removed gtk_object_post_arg_parsing_init() cludge. * gtk/gtksocket.c: * gtk/gtkplug.c: * gtk/gtklayout.c: * gtk/gtklabel.c: * gtk/gtkargcollector.c: * gtk/gtkarg.c: various fixups to work with GTK_TYPE_OBJECT not being a fundamental anymore, and to work with the new type system (nuked fundamental type varargs clutter). * gtk/*.c: install finalize handlers in the GObjectClass part of the class structure. changed direct GTK_OBJECT()->klass accesses to GTK_*_GET_CLASS(). changed direct object_class->type accesses to GTK_CLASS_TYPE(). * gtktypeutils.[hc]: use the reserved fundamental ids provided by GType. made most of the GTK_*() type macros and Gtk* typedefs simple wrappers around macros and types provided by GType. most notably, a significant portion of the old API vanished: GTK_TYPE_MAKE(), GTK_TYPE_SEQNO(), GTK_TYPE_FLAT_FIRST, GTK_TYPE_FLAT_LAST, GTK_TYPE_STRUCTURED_FIRST, GTK_TYPE_STRUCTURED_LAST, GTK_TYPE_ARGS, GTK_TYPE_CALLBACK, GTK_TYPE_C_CALLBACK, GTK_TYPE_FOREIGN, GtkTypeQuery, gtk_type_query(), gtk_type_set_varargs_type(), gtk_type_get_varargs_type(), gtk_type_check_object_cast(), gtk_type_check_class_cast(), gtk_type_describe_tree(), gtk_type_describe_heritage(), gtk_type_free(), gtk_type_children_types(), gtk_type_set_chunk_alloc(), gtk_type_register_enum(), gtk_type_register_flags(), gtk_type_parent_class(). replacements, where available are described in ../docs/Changes-1.4.txt. implemented compatibility functions for the remaining API. * configure.in: depend on glib 1.3.1, use gobject module.
1280 lines
34 KiB
C
1280 lines
34 KiB
C
/* GTK - The GIMP Toolkit
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
* GtkToolbar copyright (C) Federico Mena
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library 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
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
/*
|
|
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
* files for a list of changes. These files are distributed with
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
*/
|
|
|
|
#include "gtkbutton.h"
|
|
#include "gtktogglebutton.h"
|
|
#include "gtkradiobutton.h"
|
|
#include "gtklabel.h"
|
|
#include "gtkvbox.h"
|
|
#include "gtkhbox.h"
|
|
#include "gtktoolbar.h"
|
|
|
|
|
|
#define DEFAULT_SPACE_SIZE 5
|
|
#define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_EMPTY
|
|
|
|
#define SPACE_LINE_DIVISION 10
|
|
#define SPACE_LINE_START 3
|
|
#define SPACE_LINE_END 7
|
|
|
|
enum {
|
|
ARG_0,
|
|
ARG_ORIENTATION,
|
|
ARG_TOOLBAR_STYLE,
|
|
ARG_SPACE_SIZE,
|
|
ARG_SPACE_STYLE,
|
|
ARG_RELIEF
|
|
};
|
|
|
|
enum {
|
|
ORIENTATION_CHANGED,
|
|
STYLE_CHANGED,
|
|
LAST_SIGNAL
|
|
};
|
|
|
|
typedef struct _GtkToolbarChildSpace GtkToolbarChildSpace;
|
|
struct _GtkToolbarChildSpace
|
|
{
|
|
GtkToolbarChild child;
|
|
|
|
gint alloc_x, alloc_y;
|
|
};
|
|
|
|
static void gtk_toolbar_class_init (GtkToolbarClass *class);
|
|
static void gtk_toolbar_init (GtkToolbar *toolbar);
|
|
static void gtk_toolbar_set_arg (GtkObject *object,
|
|
GtkArg *arg,
|
|
guint arg_id);
|
|
static void gtk_toolbar_get_arg (GtkObject *object,
|
|
GtkArg *arg,
|
|
guint arg_id);
|
|
static void gtk_toolbar_destroy (GtkObject *object);
|
|
static void gtk_toolbar_map (GtkWidget *widget);
|
|
static void gtk_toolbar_unmap (GtkWidget *widget);
|
|
static void gtk_toolbar_draw (GtkWidget *widget,
|
|
GdkRectangle *area);
|
|
static gint gtk_toolbar_expose (GtkWidget *widget,
|
|
GdkEventExpose *event);
|
|
static void gtk_toolbar_size_request (GtkWidget *widget,
|
|
GtkRequisition *requisition);
|
|
static void gtk_toolbar_size_allocate (GtkWidget *widget,
|
|
GtkAllocation *allocation);
|
|
static void gtk_toolbar_add (GtkContainer *container,
|
|
GtkWidget *widget);
|
|
static void gtk_toolbar_remove (GtkContainer *container,
|
|
GtkWidget *widget);
|
|
static void gtk_toolbar_forall (GtkContainer *container,
|
|
gboolean include_internals,
|
|
GtkCallback callback,
|
|
gpointer callback_data);
|
|
static void gtk_real_toolbar_orientation_changed (GtkToolbar *toolbar,
|
|
GtkOrientation orientation);
|
|
static void gtk_real_toolbar_style_changed (GtkToolbar *toolbar,
|
|
GtkToolbarStyle style);
|
|
|
|
|
|
static GtkContainerClass *parent_class;
|
|
|
|
static guint toolbar_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
GtkType
|
|
gtk_toolbar_get_type (void)
|
|
{
|
|
static GtkType toolbar_type = 0;
|
|
|
|
if (!toolbar_type)
|
|
{
|
|
static const GtkTypeInfo toolbar_info =
|
|
{
|
|
"GtkToolbar",
|
|
sizeof (GtkToolbar),
|
|
sizeof (GtkToolbarClass),
|
|
(GtkClassInitFunc) gtk_toolbar_class_init,
|
|
(GtkObjectInitFunc) gtk_toolbar_init,
|
|
/* reserved_1 */ NULL,
|
|
/* reserved_2 */ NULL,
|
|
(GtkClassInitFunc) NULL,
|
|
};
|
|
|
|
toolbar_type = gtk_type_unique (gtk_container_get_type (), &toolbar_info);
|
|
}
|
|
|
|
return toolbar_type;
|
|
}
|
|
|
|
static void
|
|
gtk_toolbar_class_init (GtkToolbarClass *class)
|
|
{
|
|
GtkObjectClass *object_class;
|
|
GtkWidgetClass *widget_class;
|
|
GtkContainerClass *container_class;
|
|
|
|
object_class = (GtkObjectClass *) class;
|
|
widget_class = (GtkWidgetClass *) class;
|
|
container_class = (GtkContainerClass *) class;
|
|
|
|
parent_class = gtk_type_class (gtk_container_get_type ());
|
|
|
|
toolbar_signals[ORIENTATION_CHANGED] =
|
|
gtk_signal_new ("orientation_changed",
|
|
GTK_RUN_FIRST,
|
|
GTK_CLASS_TYPE (object_class),
|
|
GTK_SIGNAL_OFFSET (GtkToolbarClass, orientation_changed),
|
|
gtk_marshal_NONE__INT,
|
|
GTK_TYPE_NONE, 1,
|
|
GTK_TYPE_INT);
|
|
toolbar_signals[STYLE_CHANGED] =
|
|
gtk_signal_new ("style_changed",
|
|
GTK_RUN_FIRST,
|
|
GTK_CLASS_TYPE (object_class),
|
|
GTK_SIGNAL_OFFSET (GtkToolbarClass, style_changed),
|
|
gtk_marshal_NONE__INT,
|
|
GTK_TYPE_NONE, 1,
|
|
GTK_TYPE_INT);
|
|
|
|
gtk_object_class_add_signals (object_class, toolbar_signals, LAST_SIGNAL);
|
|
|
|
object_class->destroy = gtk_toolbar_destroy;
|
|
object_class->set_arg = gtk_toolbar_set_arg;
|
|
object_class->get_arg = gtk_toolbar_get_arg;
|
|
|
|
widget_class->map = gtk_toolbar_map;
|
|
widget_class->unmap = gtk_toolbar_unmap;
|
|
widget_class->draw = gtk_toolbar_draw;
|
|
widget_class->expose_event = gtk_toolbar_expose;
|
|
widget_class->size_request = gtk_toolbar_size_request;
|
|
widget_class->size_allocate = gtk_toolbar_size_allocate;
|
|
|
|
container_class->add = gtk_toolbar_add;
|
|
container_class->remove = gtk_toolbar_remove;
|
|
container_class->forall = gtk_toolbar_forall;
|
|
container_class->focus = NULL;
|
|
|
|
class->orientation_changed = gtk_real_toolbar_orientation_changed;
|
|
class->style_changed = gtk_real_toolbar_style_changed;
|
|
|
|
gtk_object_add_arg_type ("GtkToolbar::orientation", GTK_TYPE_ORIENTATION,
|
|
GTK_ARG_READWRITE, ARG_ORIENTATION);
|
|
gtk_object_add_arg_type ("GtkToolbar::toolbar_style", GTK_TYPE_TOOLBAR_STYLE,
|
|
GTK_ARG_READWRITE, ARG_TOOLBAR_STYLE);
|
|
gtk_object_add_arg_type ("GtkToolbar::space_size", GTK_TYPE_UINT,
|
|
GTK_ARG_READWRITE, ARG_SPACE_SIZE);
|
|
gtk_object_add_arg_type ("GtkToolbar::space_style", GTK_TYPE_TOOLBAR_SPACE_STYLE,
|
|
GTK_ARG_READWRITE, ARG_SPACE_STYLE);
|
|
gtk_object_add_arg_type ("GtkToolbar::relief", GTK_TYPE_RELIEF_STYLE,
|
|
GTK_ARG_READWRITE, ARG_RELIEF);
|
|
}
|
|
|
|
static void
|
|
gtk_toolbar_init (GtkToolbar *toolbar)
|
|
{
|
|
GTK_WIDGET_SET_FLAGS (toolbar, GTK_NO_WINDOW);
|
|
GTK_WIDGET_UNSET_FLAGS (toolbar, GTK_CAN_FOCUS);
|
|
|
|
toolbar->num_children = 0;
|
|
toolbar->children = NULL;
|
|
toolbar->orientation = GTK_ORIENTATION_HORIZONTAL;
|
|
toolbar->style = GTK_TOOLBAR_ICONS;
|
|
toolbar->relief = GTK_RELIEF_NORMAL;
|
|
toolbar->space_size = DEFAULT_SPACE_SIZE;
|
|
toolbar->space_style = DEFAULT_SPACE_STYLE;
|
|
toolbar->tooltips = gtk_tooltips_new ();
|
|
toolbar->button_maxw = 0;
|
|
toolbar->button_maxh = 0;
|
|
}
|
|
|
|
static void
|
|
gtk_toolbar_set_arg (GtkObject *object,
|
|
GtkArg *arg,
|
|
guint arg_id)
|
|
{
|
|
GtkToolbar *toolbar = GTK_TOOLBAR (object);
|
|
|
|
switch (arg_id)
|
|
{
|
|
case ARG_ORIENTATION:
|
|
gtk_toolbar_set_orientation (toolbar, GTK_VALUE_ENUM (*arg));
|
|
break;
|
|
case ARG_TOOLBAR_STYLE:
|
|
gtk_toolbar_set_style (toolbar, GTK_VALUE_ENUM (*arg));
|
|
break;
|
|
case ARG_SPACE_SIZE:
|
|
gtk_toolbar_set_space_size (toolbar, GTK_VALUE_UINT (*arg));
|
|
break;
|
|
case ARG_SPACE_STYLE:
|
|
gtk_toolbar_set_space_style (toolbar, GTK_VALUE_ENUM (*arg));
|
|
break;
|
|
case ARG_RELIEF:
|
|
gtk_toolbar_set_button_relief (toolbar, GTK_VALUE_ENUM (*arg));
|
|
break;
|
|
}
|
|
}
|
|
|
|
static void
|
|
gtk_toolbar_get_arg (GtkObject *object,
|
|
GtkArg *arg,
|
|
guint arg_id)
|
|
{
|
|
GtkToolbar *toolbar = GTK_TOOLBAR (object);
|
|
|
|
switch (arg_id)
|
|
{
|
|
case ARG_ORIENTATION:
|
|
GTK_VALUE_ENUM (*arg) = toolbar->orientation;
|
|
break;
|
|
case ARG_TOOLBAR_STYLE:
|
|
GTK_VALUE_ENUM (*arg) = toolbar->style;
|
|
break;
|
|
case ARG_SPACE_SIZE:
|
|
GTK_VALUE_UINT (*arg) = toolbar->space_size;
|
|
break;
|
|
case ARG_SPACE_STYLE:
|
|
GTK_VALUE_ENUM (*arg) = toolbar->space_style;
|
|
break;
|
|
case ARG_RELIEF:
|
|
GTK_VALUE_ENUM (*arg) = toolbar->relief;
|
|
break;
|
|
default:
|
|
arg->type = GTK_TYPE_INVALID;
|
|
break;
|
|
}
|
|
}
|
|
|
|
GtkWidget*
|
|
gtk_toolbar_new (GtkOrientation orientation,
|
|
GtkToolbarStyle style)
|
|
{
|
|
GtkToolbar *toolbar;
|
|
|
|
toolbar = gtk_type_new (gtk_toolbar_get_type ());
|
|
|
|
toolbar->orientation = orientation;
|
|
toolbar->style = style;
|
|
|
|
return GTK_WIDGET (toolbar);
|
|
}
|
|
|
|
static void
|
|
gtk_toolbar_destroy (GtkObject *object)
|
|
{
|
|
GtkToolbar *toolbar;
|
|
GList *children;
|
|
|
|
g_return_if_fail (object != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (object));
|
|
|
|
toolbar = GTK_TOOLBAR (object);
|
|
|
|
if (toolbar->tooltips)
|
|
{
|
|
gtk_object_unref (GTK_OBJECT (toolbar->tooltips));
|
|
toolbar->tooltips = NULL;
|
|
}
|
|
|
|
for (children = toolbar->children; children; children = children->next)
|
|
{
|
|
GtkToolbarChild *child;
|
|
|
|
child = children->data;
|
|
|
|
if (child->type != GTK_TOOLBAR_CHILD_SPACE)
|
|
{
|
|
gtk_widget_ref (child->widget);
|
|
gtk_widget_unparent (child->widget);
|
|
gtk_widget_destroy (child->widget);
|
|
gtk_widget_unref (child->widget);
|
|
}
|
|
|
|
g_free (child);
|
|
}
|
|
g_list_free (toolbar->children);
|
|
toolbar->children = NULL;
|
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
|
}
|
|
|
|
static void
|
|
gtk_toolbar_map (GtkWidget *widget)
|
|
{
|
|
GtkToolbar *toolbar;
|
|
GList *children;
|
|
GtkToolbarChild *child;
|
|
|
|
g_return_if_fail (widget != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (widget));
|
|
|
|
toolbar = GTK_TOOLBAR (widget);
|
|
GTK_WIDGET_SET_FLAGS (toolbar, GTK_MAPPED);
|
|
|
|
for (children = toolbar->children; children; children = children->next)
|
|
{
|
|
child = children->data;
|
|
|
|
if ((child->type != GTK_TOOLBAR_CHILD_SPACE)
|
|
&& GTK_WIDGET_VISIBLE (child->widget) && !GTK_WIDGET_MAPPED (child->widget))
|
|
gtk_widget_map (child->widget);
|
|
}
|
|
}
|
|
|
|
static void
|
|
gtk_toolbar_unmap (GtkWidget *widget)
|
|
{
|
|
GtkToolbar *toolbar;
|
|
GList *children;
|
|
GtkToolbarChild *child;
|
|
|
|
g_return_if_fail (widget != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (widget));
|
|
|
|
toolbar = GTK_TOOLBAR (widget);
|
|
GTK_WIDGET_UNSET_FLAGS (toolbar, GTK_MAPPED);
|
|
|
|
for (children = toolbar->children; children; children = children->next)
|
|
{
|
|
child = children->data;
|
|
|
|
if ((child->type != GTK_TOOLBAR_CHILD_SPACE)
|
|
&& GTK_WIDGET_VISIBLE (child->widget) && GTK_WIDGET_MAPPED (child->widget))
|
|
gtk_widget_unmap (child->widget);
|
|
}
|
|
}
|
|
|
|
static void
|
|
gtk_toolbar_paint_space_line (GtkWidget *widget,
|
|
GdkRectangle *area,
|
|
GtkToolbarChild *child)
|
|
{
|
|
GtkToolbar *toolbar;
|
|
GtkToolbarChildSpace *child_space;
|
|
|
|
g_return_if_fail (widget != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (widget));
|
|
g_return_if_fail (child != NULL);
|
|
g_return_if_fail (child->type == GTK_TOOLBAR_CHILD_SPACE);
|
|
|
|
toolbar = GTK_TOOLBAR (widget);
|
|
|
|
child_space = (GtkToolbarChildSpace *) child;
|
|
|
|
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
gtk_paint_vline (widget->style, widget->window,
|
|
GTK_WIDGET_STATE (widget), area, widget,
|
|
"toolbar",
|
|
child_space->alloc_y + toolbar->button_maxh *
|
|
SPACE_LINE_START / SPACE_LINE_DIVISION,
|
|
child_space->alloc_y + toolbar->button_maxh *
|
|
SPACE_LINE_END / SPACE_LINE_DIVISION,
|
|
child_space->alloc_x +
|
|
(toolbar->space_size -
|
|
widget->style->klass->xthickness) / 2);
|
|
else
|
|
gtk_paint_hline (widget->style, widget->window,
|
|
GTK_WIDGET_STATE (widget), area, widget,
|
|
"toolbar",
|
|
child_space->alloc_x + toolbar->button_maxw *
|
|
SPACE_LINE_START / SPACE_LINE_DIVISION,
|
|
child_space->alloc_x + toolbar->button_maxw *
|
|
SPACE_LINE_END / SPACE_LINE_DIVISION,
|
|
child_space->alloc_y +
|
|
(toolbar->space_size -
|
|
widget->style->klass->ythickness) / 2);
|
|
}
|
|
|
|
static void
|
|
gtk_toolbar_draw (GtkWidget *widget,
|
|
GdkRectangle *area)
|
|
{
|
|
GtkToolbar *toolbar;
|
|
GList *children;
|
|
GtkToolbarChild *child;
|
|
GdkRectangle child_area;
|
|
|
|
g_return_if_fail (widget != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (widget));
|
|
|
|
if (GTK_WIDGET_DRAWABLE (widget))
|
|
{
|
|
toolbar = GTK_TOOLBAR (widget);
|
|
|
|
for (children = toolbar->children; children; children = children->next)
|
|
{
|
|
child = children->data;
|
|
|
|
if (child->type == GTK_TOOLBAR_CHILD_SPACE)
|
|
{
|
|
if (toolbar->space_style == GTK_TOOLBAR_SPACE_LINE)
|
|
gtk_toolbar_paint_space_line (widget, area, child);
|
|
}
|
|
else if (gtk_widget_intersect (child->widget, area, &child_area))
|
|
gtk_widget_draw (child->widget, &child_area);
|
|
}
|
|
}
|
|
}
|
|
|
|
static gint
|
|
gtk_toolbar_expose (GtkWidget *widget,
|
|
GdkEventExpose *event)
|
|
{
|
|
GtkToolbar *toolbar;
|
|
GList *children;
|
|
GtkToolbarChild *child;
|
|
GdkEventExpose child_event;
|
|
|
|
g_return_val_if_fail (widget != NULL, FALSE);
|
|
g_return_val_if_fail (GTK_IS_TOOLBAR (widget), FALSE);
|
|
g_return_val_if_fail (event != NULL, FALSE);
|
|
|
|
if (GTK_WIDGET_DRAWABLE (widget))
|
|
{
|
|
toolbar = GTK_TOOLBAR (widget);
|
|
|
|
child_event = *event;
|
|
|
|
for (children = toolbar->children; children; children = children->next)
|
|
{
|
|
child = children->data;
|
|
|
|
if (child->type == GTK_TOOLBAR_CHILD_SPACE)
|
|
{
|
|
if (toolbar->space_style == GTK_TOOLBAR_SPACE_LINE)
|
|
gtk_toolbar_paint_space_line (widget, &event->area, child);
|
|
}
|
|
else if (GTK_WIDGET_NO_WINDOW (child->widget)
|
|
&& gtk_widget_intersect (child->widget, &event->area, &child_event.area))
|
|
gtk_widget_event (child->widget, (GdkEvent *) &child_event);
|
|
}
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
static void
|
|
gtk_toolbar_size_request (GtkWidget *widget,
|
|
GtkRequisition *requisition)
|
|
{
|
|
GtkToolbar *toolbar;
|
|
GList *children;
|
|
GtkToolbarChild *child;
|
|
gint nbuttons;
|
|
gint button_maxw, button_maxh;
|
|
gint widget_maxw, widget_maxh;
|
|
GtkRequisition child_requisition;
|
|
|
|
g_return_if_fail (widget != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (widget));
|
|
g_return_if_fail (requisition != NULL);
|
|
|
|
toolbar = GTK_TOOLBAR (widget);
|
|
|
|
requisition->width = GTK_CONTAINER (toolbar)->border_width * 2;
|
|
requisition->height = GTK_CONTAINER (toolbar)->border_width * 2;
|
|
nbuttons = 0;
|
|
button_maxw = 0;
|
|
button_maxh = 0;
|
|
widget_maxw = 0;
|
|
widget_maxh = 0;
|
|
|
|
for (children = toolbar->children; children; children = children->next)
|
|
{
|
|
child = children->data;
|
|
|
|
switch (child->type)
|
|
{
|
|
case GTK_TOOLBAR_CHILD_SPACE:
|
|
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
requisition->width += toolbar->space_size;
|
|
else
|
|
requisition->height += toolbar->space_size;
|
|
|
|
break;
|
|
|
|
case GTK_TOOLBAR_CHILD_BUTTON:
|
|
case GTK_TOOLBAR_CHILD_RADIOBUTTON:
|
|
case GTK_TOOLBAR_CHILD_TOGGLEBUTTON:
|
|
if (GTK_WIDGET_VISIBLE (child->widget))
|
|
{
|
|
gtk_widget_size_request (child->widget, &child_requisition);
|
|
|
|
nbuttons++;
|
|
button_maxw = MAX (button_maxw, child_requisition.width);
|
|
button_maxh = MAX (button_maxh, child_requisition.height);
|
|
}
|
|
|
|
break;
|
|
|
|
case GTK_TOOLBAR_CHILD_WIDGET:
|
|
if (GTK_WIDGET_VISIBLE (child->widget))
|
|
{
|
|
gtk_widget_size_request (child->widget, &child_requisition);
|
|
|
|
widget_maxw = MAX (widget_maxw, child_requisition.width);
|
|
widget_maxh = MAX (widget_maxh, child_requisition.height);
|
|
|
|
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
requisition->width += child_requisition.width;
|
|
else
|
|
requisition->height += child_requisition.height;
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
g_assert_not_reached ();
|
|
}
|
|
}
|
|
|
|
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
{
|
|
requisition->width += nbuttons * button_maxw;
|
|
requisition->height += MAX (button_maxh, widget_maxh);
|
|
}
|
|
else
|
|
{
|
|
requisition->width += MAX (button_maxw, widget_maxw);
|
|
requisition->height += nbuttons * button_maxh;
|
|
}
|
|
|
|
toolbar->button_maxw = button_maxw;
|
|
toolbar->button_maxh = button_maxh;
|
|
}
|
|
|
|
static void
|
|
gtk_toolbar_size_allocate (GtkWidget *widget,
|
|
GtkAllocation *allocation)
|
|
{
|
|
GtkToolbar *toolbar;
|
|
GList *children;
|
|
GtkToolbarChild *child;
|
|
GtkToolbarChildSpace *child_space;
|
|
GtkAllocation alloc;
|
|
GtkRequisition child_requisition;
|
|
gint border_width;
|
|
|
|
g_return_if_fail (widget != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (widget));
|
|
g_return_if_fail (allocation != NULL);
|
|
|
|
toolbar = GTK_TOOLBAR (widget);
|
|
widget->allocation = *allocation;
|
|
|
|
border_width = GTK_CONTAINER (toolbar)->border_width;
|
|
|
|
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
alloc.x = allocation->x + border_width;
|
|
else
|
|
alloc.y = allocation->y + border_width;
|
|
|
|
for (children = toolbar->children; children; children = children->next)
|
|
{
|
|
child = children->data;
|
|
|
|
switch (child->type)
|
|
{
|
|
case GTK_TOOLBAR_CHILD_SPACE:
|
|
|
|
child_space = (GtkToolbarChildSpace *) child;
|
|
|
|
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
{
|
|
child_space->alloc_x = alloc.x;
|
|
child_space->alloc_y = allocation->y + (allocation->height - toolbar->button_maxh) / 2;
|
|
alloc.x += toolbar->space_size;
|
|
}
|
|
else
|
|
{
|
|
child_space->alloc_x = allocation->x + (allocation->width - toolbar->button_maxw) / 2;
|
|
child_space->alloc_y = alloc.y;
|
|
alloc.y += toolbar->space_size;
|
|
}
|
|
|
|
break;
|
|
|
|
case GTK_TOOLBAR_CHILD_BUTTON:
|
|
case GTK_TOOLBAR_CHILD_RADIOBUTTON:
|
|
case GTK_TOOLBAR_CHILD_TOGGLEBUTTON:
|
|
if (!GTK_WIDGET_VISIBLE (child->widget))
|
|
break;
|
|
|
|
alloc.width = toolbar->button_maxw;
|
|
alloc.height = toolbar->button_maxh;
|
|
|
|
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
alloc.y = allocation->y + (allocation->height - toolbar->button_maxh) / 2;
|
|
else
|
|
alloc.x = allocation->x + (allocation->width - toolbar->button_maxw) / 2;
|
|
|
|
gtk_widget_size_allocate (child->widget, &alloc);
|
|
|
|
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
alloc.x += toolbar->button_maxw;
|
|
else
|
|
alloc.y += toolbar->button_maxh;
|
|
|
|
break;
|
|
|
|
case GTK_TOOLBAR_CHILD_WIDGET:
|
|
if (!GTK_WIDGET_VISIBLE (child->widget))
|
|
break;
|
|
|
|
gtk_widget_get_child_requisition (child->widget, &child_requisition);
|
|
|
|
alloc.width = child_requisition.width;
|
|
alloc.height = child_requisition.height;
|
|
|
|
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
alloc.y = allocation->y + (allocation->height - child_requisition.height) / 2;
|
|
else
|
|
alloc.x = allocation->x + (allocation->width - child_requisition.width) / 2;
|
|
|
|
gtk_widget_size_allocate (child->widget, &alloc);
|
|
|
|
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
alloc.x += child_requisition.width;
|
|
else
|
|
alloc.y += child_requisition.height;
|
|
|
|
break;
|
|
|
|
default:
|
|
g_assert_not_reached ();
|
|
}
|
|
}
|
|
}
|
|
|
|
static void
|
|
gtk_toolbar_add (GtkContainer *container,
|
|
GtkWidget *widget)
|
|
{
|
|
g_return_if_fail (container != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (container));
|
|
g_return_if_fail (widget != NULL);
|
|
|
|
gtk_toolbar_append_widget (GTK_TOOLBAR (container), widget, NULL, NULL);
|
|
}
|
|
|
|
static void
|
|
gtk_toolbar_remove (GtkContainer *container,
|
|
GtkWidget *widget)
|
|
{
|
|
GtkToolbar *toolbar;
|
|
GList *children;
|
|
GtkToolbarChild *child;
|
|
|
|
g_return_if_fail (container != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (container));
|
|
g_return_if_fail (widget != NULL);
|
|
|
|
toolbar = GTK_TOOLBAR (container);
|
|
|
|
for (children = toolbar->children; children; children = children->next)
|
|
{
|
|
child = children->data;
|
|
|
|
if ((child->type != GTK_TOOLBAR_CHILD_SPACE) && (child->widget == widget))
|
|
{
|
|
gboolean was_visible;
|
|
|
|
was_visible = GTK_WIDGET_VISIBLE (widget);
|
|
gtk_widget_unparent (widget);
|
|
|
|
toolbar->children = g_list_remove_link (toolbar->children, children);
|
|
g_free (child);
|
|
g_list_free (children);
|
|
toolbar->num_children--;
|
|
|
|
if (was_visible && GTK_WIDGET_VISIBLE (container))
|
|
gtk_widget_queue_resize (GTK_WIDGET (container));
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
static void
|
|
gtk_toolbar_forall (GtkContainer *container,
|
|
gboolean include_internals,
|
|
GtkCallback callback,
|
|
gpointer callback_data)
|
|
{
|
|
GtkToolbar *toolbar;
|
|
GList *children;
|
|
GtkToolbarChild *child;
|
|
|
|
g_return_if_fail (container != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (container));
|
|
g_return_if_fail (callback != NULL);
|
|
|
|
toolbar = GTK_TOOLBAR (container);
|
|
|
|
for (children = toolbar->children; children; children = children->next)
|
|
{
|
|
child = children->data;
|
|
|
|
if (child->type != GTK_TOOLBAR_CHILD_SPACE)
|
|
(*callback) (child->widget, callback_data);
|
|
}
|
|
}
|
|
|
|
GtkWidget *
|
|
gtk_toolbar_append_item (GtkToolbar *toolbar,
|
|
const char *text,
|
|
const char *tooltip_text,
|
|
const char *tooltip_private_text,
|
|
GtkWidget *icon,
|
|
GtkSignalFunc callback,
|
|
gpointer user_data)
|
|
{
|
|
return gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_BUTTON,
|
|
NULL, text,
|
|
tooltip_text, tooltip_private_text,
|
|
icon, callback, user_data,
|
|
toolbar->num_children);
|
|
}
|
|
|
|
GtkWidget *
|
|
gtk_toolbar_prepend_item (GtkToolbar *toolbar,
|
|
const char *text,
|
|
const char *tooltip_text,
|
|
const char *tooltip_private_text,
|
|
GtkWidget *icon,
|
|
GtkSignalFunc callback,
|
|
gpointer user_data)
|
|
{
|
|
return gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_BUTTON,
|
|
NULL, text,
|
|
tooltip_text, tooltip_private_text,
|
|
icon, callback, user_data,
|
|
0);
|
|
}
|
|
|
|
GtkWidget *
|
|
gtk_toolbar_insert_item (GtkToolbar *toolbar,
|
|
const char *text,
|
|
const char *tooltip_text,
|
|
const char *tooltip_private_text,
|
|
GtkWidget *icon,
|
|
GtkSignalFunc callback,
|
|
gpointer user_data,
|
|
gint position)
|
|
{
|
|
return gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_BUTTON,
|
|
NULL, text,
|
|
tooltip_text, tooltip_private_text,
|
|
icon, callback, user_data,
|
|
position);
|
|
}
|
|
|
|
void
|
|
gtk_toolbar_append_space (GtkToolbar *toolbar)
|
|
{
|
|
gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_SPACE,
|
|
NULL, NULL,
|
|
NULL, NULL,
|
|
NULL, NULL, NULL,
|
|
toolbar->num_children);
|
|
}
|
|
|
|
void
|
|
gtk_toolbar_prepend_space (GtkToolbar *toolbar)
|
|
{
|
|
gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_SPACE,
|
|
NULL, NULL,
|
|
NULL, NULL,
|
|
NULL, NULL, NULL,
|
|
0);
|
|
}
|
|
|
|
void
|
|
gtk_toolbar_insert_space (GtkToolbar *toolbar,
|
|
gint position)
|
|
{
|
|
gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_SPACE,
|
|
NULL, NULL,
|
|
NULL, NULL,
|
|
NULL, NULL, NULL,
|
|
position);
|
|
}
|
|
|
|
void
|
|
gtk_toolbar_append_widget (GtkToolbar *toolbar,
|
|
GtkWidget *widget,
|
|
const gchar *tooltip_text,
|
|
const gchar *tooltip_private_text)
|
|
{
|
|
gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_WIDGET,
|
|
widget, NULL,
|
|
tooltip_text, tooltip_private_text,
|
|
NULL, NULL, NULL,
|
|
toolbar->num_children);
|
|
}
|
|
|
|
void
|
|
gtk_toolbar_prepend_widget (GtkToolbar *toolbar,
|
|
GtkWidget *widget,
|
|
const gchar *tooltip_text,
|
|
const gchar *tooltip_private_text)
|
|
{
|
|
gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_WIDGET,
|
|
widget, NULL,
|
|
tooltip_text, tooltip_private_text,
|
|
NULL, NULL, NULL,
|
|
toolbar->num_children);
|
|
}
|
|
|
|
void
|
|
gtk_toolbar_insert_widget (GtkToolbar *toolbar,
|
|
GtkWidget *widget,
|
|
const char *tooltip_text,
|
|
const char *tooltip_private_text,
|
|
gint position)
|
|
{
|
|
gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_WIDGET,
|
|
widget, NULL,
|
|
tooltip_text, tooltip_private_text,
|
|
NULL, NULL, NULL,
|
|
position);
|
|
}
|
|
|
|
GtkWidget*
|
|
gtk_toolbar_append_element (GtkToolbar *toolbar,
|
|
GtkToolbarChildType type,
|
|
GtkWidget *widget,
|
|
const char *text,
|
|
const char *tooltip_text,
|
|
const char *tooltip_private_text,
|
|
GtkWidget *icon,
|
|
GtkSignalFunc callback,
|
|
gpointer user_data)
|
|
{
|
|
return gtk_toolbar_insert_element (toolbar, type, widget, text,
|
|
tooltip_text, tooltip_private_text,
|
|
icon, callback, user_data,
|
|
toolbar->num_children);
|
|
}
|
|
|
|
GtkWidget *
|
|
gtk_toolbar_prepend_element (GtkToolbar *toolbar,
|
|
GtkToolbarChildType type,
|
|
GtkWidget *widget,
|
|
const char *text,
|
|
const char *tooltip_text,
|
|
const char *tooltip_private_text,
|
|
GtkWidget *icon,
|
|
GtkSignalFunc callback,
|
|
gpointer user_data)
|
|
{
|
|
return gtk_toolbar_insert_element (toolbar, type, widget, text,
|
|
tooltip_text, tooltip_private_text,
|
|
icon, callback, user_data, 0);
|
|
}
|
|
|
|
GtkWidget *
|
|
gtk_toolbar_insert_element (GtkToolbar *toolbar,
|
|
GtkToolbarChildType type,
|
|
GtkWidget *widget,
|
|
const char *text,
|
|
const char *tooltip_text,
|
|
const char *tooltip_private_text,
|
|
GtkWidget *icon,
|
|
GtkSignalFunc callback,
|
|
gpointer user_data,
|
|
gint position)
|
|
{
|
|
GtkToolbarChild *child;
|
|
GtkWidget *box;
|
|
|
|
g_return_val_if_fail (toolbar != NULL, NULL);
|
|
g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), NULL);
|
|
if (type == GTK_TOOLBAR_CHILD_WIDGET)
|
|
{
|
|
g_return_val_if_fail (widget != NULL, NULL);
|
|
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
|
}
|
|
else if (type != GTK_TOOLBAR_CHILD_RADIOBUTTON)
|
|
g_return_val_if_fail (widget == NULL, NULL);
|
|
|
|
if (type == GTK_TOOLBAR_CHILD_SPACE)
|
|
child = (GtkToolbarChild *) g_new (GtkToolbarChildSpace, 1);
|
|
else
|
|
child = g_new (GtkToolbarChild, 1);
|
|
|
|
child->type = type;
|
|
child->icon = NULL;
|
|
child->label = NULL;
|
|
|
|
switch (type)
|
|
{
|
|
case GTK_TOOLBAR_CHILD_SPACE:
|
|
child->widget = NULL;
|
|
((GtkToolbarChildSpace *) child)->alloc_x =
|
|
((GtkToolbarChildSpace *) child)->alloc_y = 0;
|
|
break;
|
|
|
|
case GTK_TOOLBAR_CHILD_WIDGET:
|
|
child->widget = widget;
|
|
break;
|
|
|
|
case GTK_TOOLBAR_CHILD_BUTTON:
|
|
case GTK_TOOLBAR_CHILD_TOGGLEBUTTON:
|
|
case GTK_TOOLBAR_CHILD_RADIOBUTTON:
|
|
if (type == GTK_TOOLBAR_CHILD_BUTTON)
|
|
{
|
|
child->widget = gtk_button_new ();
|
|
gtk_button_set_relief (GTK_BUTTON (child->widget), toolbar->relief);
|
|
}
|
|
else if (type == GTK_TOOLBAR_CHILD_TOGGLEBUTTON)
|
|
{
|
|
child->widget = gtk_toggle_button_new ();
|
|
gtk_button_set_relief (GTK_BUTTON (child->widget), toolbar->relief);
|
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (child->widget),
|
|
FALSE);
|
|
}
|
|
else
|
|
{
|
|
child->widget = gtk_radio_button_new (widget
|
|
? gtk_radio_button_group (GTK_RADIO_BUTTON (widget))
|
|
: NULL);
|
|
gtk_button_set_relief (GTK_BUTTON (child->widget), toolbar->relief);
|
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (child->widget), FALSE);
|
|
}
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (child->widget, GTK_CAN_FOCUS);
|
|
|
|
if (callback)
|
|
gtk_signal_connect (GTK_OBJECT (child->widget), "clicked",
|
|
callback, user_data);
|
|
|
|
if (toolbar->style == GTK_TOOLBAR_BOTH_HORIZ)
|
|
box = gtk_hbox_new (FALSE, 0);
|
|
else
|
|
box = gtk_vbox_new (FALSE, 0);
|
|
gtk_container_add (GTK_CONTAINER (child->widget), box);
|
|
gtk_widget_show (box);
|
|
|
|
if (text)
|
|
{
|
|
child->label = gtk_label_new (text);
|
|
gtk_box_pack_end (GTK_BOX (box), child->label, FALSE, FALSE, 0);
|
|
if (toolbar->style != GTK_TOOLBAR_ICONS)
|
|
gtk_widget_show (child->label);
|
|
}
|
|
|
|
if (icon)
|
|
{
|
|
child->icon = GTK_WIDGET (icon);
|
|
gtk_box_pack_end (GTK_BOX (box), child->icon, FALSE, FALSE, 0);
|
|
if (toolbar->style != GTK_TOOLBAR_TEXT)
|
|
gtk_widget_show (child->icon);
|
|
}
|
|
|
|
gtk_widget_show (child->widget);
|
|
break;
|
|
|
|
default:
|
|
g_assert_not_reached ();
|
|
}
|
|
|
|
if ((type != GTK_TOOLBAR_CHILD_SPACE) && tooltip_text)
|
|
gtk_tooltips_set_tip (toolbar->tooltips, child->widget,
|
|
tooltip_text, tooltip_private_text);
|
|
|
|
toolbar->children = g_list_insert (toolbar->children, child, position);
|
|
toolbar->num_children++;
|
|
|
|
if (type != GTK_TOOLBAR_CHILD_SPACE)
|
|
{
|
|
gtk_widget_set_parent (child->widget, GTK_WIDGET (toolbar));
|
|
|
|
if (GTK_WIDGET_REALIZED (child->widget->parent))
|
|
gtk_widget_realize (child->widget);
|
|
|
|
if (GTK_WIDGET_VISIBLE (child->widget->parent) && GTK_WIDGET_VISIBLE (child->widget))
|
|
{
|
|
if (GTK_WIDGET_MAPPED (child->widget->parent))
|
|
gtk_widget_map (child->widget);
|
|
|
|
gtk_widget_queue_resize (child->widget);
|
|
}
|
|
}
|
|
else
|
|
gtk_widget_queue_resize (GTK_WIDGET (toolbar));
|
|
|
|
return child->widget;
|
|
}
|
|
|
|
void
|
|
gtk_toolbar_set_orientation (GtkToolbar *toolbar,
|
|
GtkOrientation orientation)
|
|
{
|
|
g_return_if_fail (toolbar != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
|
|
|
|
gtk_signal_emit (GTK_OBJECT (toolbar), toolbar_signals[ORIENTATION_CHANGED], orientation);
|
|
}
|
|
|
|
void
|
|
gtk_toolbar_set_style (GtkToolbar *toolbar,
|
|
GtkToolbarStyle style)
|
|
{
|
|
g_return_if_fail (toolbar != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
|
|
|
|
gtk_signal_emit (GTK_OBJECT (toolbar), toolbar_signals[STYLE_CHANGED], style);
|
|
}
|
|
|
|
void
|
|
gtk_toolbar_set_space_size (GtkToolbar *toolbar,
|
|
gint space_size)
|
|
{
|
|
g_return_if_fail (toolbar != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
|
|
|
|
if (toolbar->space_size != space_size)
|
|
{
|
|
toolbar->space_size = space_size;
|
|
gtk_widget_queue_resize (GTK_WIDGET (toolbar));
|
|
}
|
|
}
|
|
|
|
void
|
|
gtk_toolbar_set_space_style (GtkToolbar *toolbar,
|
|
GtkToolbarSpaceStyle space_style)
|
|
{
|
|
g_return_if_fail (toolbar != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
|
|
|
|
if (toolbar->space_style != space_style)
|
|
{
|
|
toolbar->space_style = space_style;
|
|
gtk_widget_queue_resize (GTK_WIDGET (toolbar));
|
|
}
|
|
}
|
|
|
|
void
|
|
gtk_toolbar_set_tooltips (GtkToolbar *toolbar,
|
|
gint enable)
|
|
{
|
|
g_return_if_fail (toolbar != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
|
|
|
|
if (enable)
|
|
gtk_tooltips_enable (toolbar->tooltips);
|
|
else
|
|
gtk_tooltips_disable (toolbar->tooltips);
|
|
}
|
|
|
|
void
|
|
gtk_toolbar_set_button_relief (GtkToolbar *toolbar,
|
|
GtkReliefStyle relief)
|
|
{
|
|
GList *children;
|
|
GtkToolbarChild *child;
|
|
|
|
g_return_if_fail (toolbar != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
|
|
|
|
if (toolbar->relief != relief)
|
|
{
|
|
toolbar->relief = relief;
|
|
|
|
for (children = toolbar->children; children; children = children->next)
|
|
{
|
|
child = children->data;
|
|
if (child->type == GTK_TOOLBAR_CHILD_BUTTON ||
|
|
child->type == GTK_TOOLBAR_CHILD_RADIOBUTTON ||
|
|
child->type == GTK_TOOLBAR_CHILD_TOGGLEBUTTON)
|
|
gtk_button_set_relief (GTK_BUTTON (child->widget), relief);
|
|
}
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (toolbar));
|
|
}
|
|
}
|
|
|
|
GtkReliefStyle
|
|
gtk_toolbar_get_button_relief (GtkToolbar *toolbar)
|
|
{
|
|
g_return_val_if_fail (toolbar != NULL, GTK_RELIEF_NORMAL);
|
|
g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), GTK_RELIEF_NORMAL);
|
|
|
|
return toolbar->relief;
|
|
}
|
|
|
|
static void
|
|
gtk_real_toolbar_orientation_changed (GtkToolbar *toolbar,
|
|
GtkOrientation orientation)
|
|
{
|
|
g_return_if_fail (toolbar != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
|
|
|
|
if (toolbar->orientation != orientation)
|
|
{
|
|
toolbar->orientation = orientation;
|
|
gtk_widget_queue_resize (GTK_WIDGET (toolbar));
|
|
}
|
|
}
|
|
|
|
static void
|
|
gtk_real_toolbar_style_changed (GtkToolbar *toolbar,
|
|
GtkToolbarStyle style)
|
|
{
|
|
GList *children;
|
|
GtkToolbarChild *child;
|
|
GtkWidget* box = NULL;
|
|
|
|
g_return_if_fail (toolbar != NULL);
|
|
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
|
|
|
|
if (toolbar->style != style)
|
|
{
|
|
toolbar->style = style;
|
|
|
|
for (children = toolbar->children; children; children = children->next)
|
|
{
|
|
child = children->data;
|
|
|
|
if (child->type == GTK_TOOLBAR_CHILD_BUTTON ||
|
|
child->type == GTK_TOOLBAR_CHILD_RADIOBUTTON ||
|
|
child->type == GTK_TOOLBAR_CHILD_TOGGLEBUTTON)
|
|
switch (style)
|
|
{
|
|
case GTK_TOOLBAR_ICONS:
|
|
if (child->icon && !GTK_WIDGET_VISIBLE (child->icon))
|
|
gtk_widget_show (child->icon);
|
|
|
|
if (child->label && GTK_WIDGET_VISIBLE (child->label))
|
|
gtk_widget_hide (child->label);
|
|
|
|
break;
|
|
|
|
case GTK_TOOLBAR_TEXT:
|
|
if (child->icon && GTK_WIDGET_VISIBLE (child->icon))
|
|
gtk_widget_hide (child->icon);
|
|
|
|
if (child->label && !GTK_WIDGET_VISIBLE (child->label))
|
|
gtk_widget_show (child->label);
|
|
|
|
break;
|
|
|
|
case GTK_TOOLBAR_BOTH:
|
|
if (child->icon && !GTK_WIDGET_VISIBLE (child->icon))
|
|
gtk_widget_show (child->icon);
|
|
|
|
if (child->label && !GTK_WIDGET_VISIBLE (child->label))
|
|
gtk_widget_show (child->label);
|
|
|
|
box = (GtkWidget*)gtk_container_children (GTK_CONTAINER (child->widget))->data;
|
|
|
|
if (GTK_IS_HBOX (box))
|
|
{
|
|
if (child->icon)
|
|
{
|
|
gtk_object_ref (GTK_OBJECT (child->icon));
|
|
gtk_container_remove (GTK_CONTAINER (box),
|
|
child->icon);
|
|
}
|
|
if (child->label)
|
|
{
|
|
gtk_object_ref (GTK_OBJECT (child->label));
|
|
gtk_container_remove (GTK_CONTAINER (box),
|
|
child->label);
|
|
}
|
|
gtk_container_remove (GTK_CONTAINER (child->widget),
|
|
box);
|
|
|
|
box = gtk_vbox_new (FALSE, 0);
|
|
gtk_widget_show (box);
|
|
|
|
if (child->label)
|
|
{
|
|
gtk_box_pack_end (GTK_BOX (box), child->label, FALSE, FALSE, 0);
|
|
gtk_object_unref (GTK_OBJECT (child->label));
|
|
}
|
|
if (child->icon)
|
|
{
|
|
gtk_box_pack_end (GTK_BOX (box), child->icon, FALSE, FALSE, 0);
|
|
gtk_object_unref (GTK_OBJECT (child->icon));
|
|
}
|
|
gtk_container_add (GTK_CONTAINER (child->widget),
|
|
box);
|
|
}
|
|
|
|
break;
|
|
|
|
case GTK_TOOLBAR_BOTH_HORIZ:
|
|
if (child->icon && !GTK_WIDGET_VISIBLE (child->icon))
|
|
gtk_widget_show (child->icon);
|
|
if (child->label && !GTK_WIDGET_VISIBLE (child->label))
|
|
gtk_widget_show (child->label);
|
|
|
|
box = (GtkWidget*)gtk_container_children (GTK_CONTAINER (child->widget))->data;
|
|
|
|
if (GTK_IS_VBOX (box))
|
|
{
|
|
if (child->icon)
|
|
{
|
|
gtk_object_ref (GTK_OBJECT (child->icon));
|
|
gtk_container_remove (GTK_CONTAINER (box),
|
|
child->icon);
|
|
}
|
|
if (child->label)
|
|
{
|
|
gtk_object_ref (GTK_OBJECT (child->label));
|
|
gtk_container_remove (GTK_CONTAINER (box),
|
|
child->label);
|
|
}
|
|
gtk_container_remove (GTK_CONTAINER (child->widget),
|
|
box);
|
|
|
|
box = gtk_hbox_new (FALSE, 0);
|
|
gtk_widget_show (box);
|
|
|
|
if (child->label)
|
|
{
|
|
gtk_box_pack_end (GTK_BOX (box), child->label, TRUE, TRUE, 0);
|
|
gtk_object_unref (GTK_OBJECT (child->label));
|
|
}
|
|
if (child->icon)
|
|
{
|
|
gtk_box_pack_end (GTK_BOX (box), child->icon, FALSE, FALSE, 0);
|
|
gtk_object_unref (GTK_OBJECT (child->icon));
|
|
}
|
|
gtk_container_add (GTK_CONTAINER (child->widget), box);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
g_assert_not_reached ();
|
|
}
|
|
}
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (toolbar));
|
|
}
|
|
}
|