Blame gtk/gtktoolbar.c

Packit Service fb6fa5
/* GTK - The GIMP Toolkit
Packit Service fb6fa5
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
Packit Service fb6fa5
 * GtkToolbar copyright (C) Federico Mena
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Copyright (C) 2002 Anders Carlsson <andersca@gnome.org>
Packit Service fb6fa5
 * Copyright (C) 2002 James Henstridge <james@daa.com.au>
Packit Service fb6fa5
 * Copyright (C) 2003, 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * This library is free software; you can redistribute it and/or
Packit Service fb6fa5
 * modify it under the terms of the GNU Lesser General Public
Packit Service fb6fa5
 * License as published by the Free Software Foundation; either
Packit Service fb6fa5
 * version 2 of the License, or (at your option) any later version.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * This library is distributed in the hope that it will be useful,
Packit Service fb6fa5
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service fb6fa5
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service fb6fa5
 * Lesser General Public License for more details.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * You should have received a copy of the GNU Lesser General Public
Packit Service fb6fa5
 * License along with this library; if not, write to the
Packit Service fb6fa5
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit Service fb6fa5
 * Boston, MA 02111-1307, USA.
Packit Service fb6fa5
 */
Packit Service fb6fa5
Packit Service fb6fa5
/*
Packit Service fb6fa5
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
Packit Service fb6fa5
 * file for a list of people on the GTK+ Team.  See the ChangeLog
Packit Service fb6fa5
 * files for a list of changes.  These files are distributed with
Packit Service fb6fa5
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
Packit Service fb6fa5
 */
Packit Service fb6fa5
Packit Service fb6fa5
#undef GTK_DISABLE_DEPRECATED
Packit Service fb6fa5
Packit Service fb6fa5
#include "config.h"
Packit Service fb6fa5
Packit Service fb6fa5
#include <math.h>
Packit Service fb6fa5
#include <string.h>
Packit Service fb6fa5
Packit Service fb6fa5
#include <gdk/gdkkeysyms.h>
Packit Service fb6fa5
Packit Service fb6fa5
#include "gtkarrow.h"
Packit Service fb6fa5
#include "gtkbindings.h"
Packit Service fb6fa5
#include "gtkhbox.h"
Packit Service fb6fa5
#include "gtkimage.h"
Packit Service fb6fa5
#include "gtklabel.h"
Packit Service fb6fa5
#include "gtkmain.h"
Packit Service fb6fa5
#include "gtkmarshalers.h"
Packit Service fb6fa5
#include "gtkmenu.h"
Packit Service fb6fa5
#include "gtkorientable.h"
Packit Service fb6fa5
#include "gtkradiobutton.h"
Packit Service fb6fa5
#include "gtkradiotoolbutton.h"
Packit Service fb6fa5
#include "gtkseparatormenuitem.h"
Packit Service fb6fa5
#include "gtkseparatortoolitem.h"
Packit Service fb6fa5
#include "gtkstock.h"
Packit Service fb6fa5
#include "gtktoolbar.h"
Packit Service fb6fa5
#include "gtktoolshell.h"
Packit Service fb6fa5
#include "gtkvbox.h"
Packit Service fb6fa5
#include "gtkprivate.h"
Packit Service fb6fa5
#include "gtkintl.h"
Packit Service fb6fa5
#include "gtkalias.h"
Packit Service fb6fa5
Packit Service fb6fa5
typedef struct _ToolbarContent ToolbarContent;
Packit Service fb6fa5
Packit Service fb6fa5
#define DEFAULT_IPADDING    0
Packit Service fb6fa5
Packit Service fb6fa5
#define DEFAULT_SPACE_SIZE  12
Packit Service fb6fa5
#define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_LINE
Packit Service fb6fa5
#define SPACE_LINE_DIVISION 10.0
Packit Service fb6fa5
#define SPACE_LINE_START    2.0
Packit Service fb6fa5
#define SPACE_LINE_END      8.0
Packit Service fb6fa5
Packit Service fb6fa5
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_LARGE_TOOLBAR
Packit Service fb6fa5
#define DEFAULT_TOOLBAR_STYLE GTK_TOOLBAR_BOTH
Packit Service fb6fa5
#define DEFAULT_ANIMATION_STATE TRUE
Packit Service fb6fa5
Packit Service fb6fa5
#define MAX_HOMOGENEOUS_N_CHARS 13 /* Items that are wider than this do not participate
Packit Service fb6fa5
				    * in the homogeneous game. In units of
Packit Service fb6fa5
				    * pango_font_get_estimated_char_width().
Packit Service fb6fa5
				    */
Packit Service fb6fa5
#define SLIDE_SPEED 600.0	   /* How fast the items slide, in pixels per second */
Packit Service fb6fa5
#define ACCEL_THRESHOLD 0.18	   /* After how much time in seconds will items start speeding up */
Packit Service fb6fa5
Packit Service fb6fa5
#define MIXED_API_WARNING						\
Packit Service fb6fa5
    "Mixing deprecated and non-deprecated GtkToolbar API is not allowed"
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
/* Properties */
Packit Service fb6fa5
enum {
Packit Service fb6fa5
  PROP_0,
Packit Service fb6fa5
  PROP_ORIENTATION,
Packit Service fb6fa5
  PROP_TOOLBAR_STYLE,
Packit Service fb6fa5
  PROP_SHOW_ARROW,
Packit Service fb6fa5
  PROP_TOOLTIPS,
Packit Service fb6fa5
  PROP_ICON_SIZE,
Packit Service fb6fa5
  PROP_ICON_SIZE_SET
Packit Service fb6fa5
};
Packit Service fb6fa5
Packit Service fb6fa5
/* Child properties */
Packit Service fb6fa5
enum {
Packit Service fb6fa5
  CHILD_PROP_0,
Packit Service fb6fa5
  CHILD_PROP_EXPAND,
Packit Service fb6fa5
  CHILD_PROP_HOMOGENEOUS
Packit Service fb6fa5
};
Packit Service fb6fa5
Packit Service fb6fa5
/* Signals */
Packit Service fb6fa5
enum {
Packit Service fb6fa5
  ORIENTATION_CHANGED,
Packit Service fb6fa5
  STYLE_CHANGED,
Packit Service fb6fa5
  POPUP_CONTEXT_MENU,
Packit Service fb6fa5
  FOCUS_HOME_OR_END,
Packit Service fb6fa5
  LAST_SIGNAL
Packit Service fb6fa5
};
Packit Service fb6fa5
Packit Service fb6fa5
/* API mode */
Packit Service fb6fa5
typedef enum {
Packit Service fb6fa5
  DONT_KNOW,
Packit Service fb6fa5
  OLD_API,
Packit Service fb6fa5
  NEW_API
Packit Service fb6fa5
} ApiMode;
Packit Service fb6fa5
Packit Service fb6fa5
typedef enum {
Packit Service fb6fa5
  TOOL_ITEM,
Packit Service fb6fa5
  COMPATIBILITY
Packit Service fb6fa5
} ContentType;
Packit Service fb6fa5
Packit Service fb6fa5
typedef enum {
Packit Service fb6fa5
  NOT_ALLOCATED,
Packit Service fb6fa5
  NORMAL,
Packit Service fb6fa5
  HIDDEN,
Packit Service fb6fa5
  OVERFLOWN
Packit Service fb6fa5
} ItemState;
Packit Service fb6fa5
Packit Service fb6fa5
struct _GtkToolbarPrivate
Packit Service fb6fa5
{
Packit Service fb6fa5
  GList	*	content;
Packit Service fb6fa5
  
Packit Service fb6fa5
  GtkWidget *	arrow;
Packit Service fb6fa5
  GtkWidget *	arrow_button;
Packit Service fb6fa5
  GtkMenu *	menu;
Packit Service fb6fa5
  
Packit Service fb6fa5
  GdkWindow *	event_window;
Packit Service fb6fa5
  ApiMode	api_mode;
Packit Service fb6fa5
  GtkSettings *	settings;
Packit Service fb6fa5
  int		idle_id;
Packit Service fb6fa5
  GtkToolItem *	highlight_tool_item;
Packit Service fb6fa5
  gint		max_homogeneous_pixels;
Packit Service fb6fa5
  
Packit Service fb6fa5
  GTimer *	timer;
Packit Service fb6fa5
Packit Service fb6fa5
  gulong        settings_connection;
Packit Service fb6fa5
Packit Service fb6fa5
  guint         show_arrow : 1;
Packit Service fb6fa5
  guint         need_sync : 1;
Packit Service fb6fa5
  guint         is_sliding : 1;
Packit Service fb6fa5
  guint         need_rebuild : 1;  /* whether the overflow menu should be regenerated */
Packit Service fb6fa5
  guint         animation : 1;
Packit Service fb6fa5
};
Packit Service fb6fa5
Packit Service fb6fa5
static void       gtk_toolbar_set_property         (GObject             *object,
Packit Service fb6fa5
						    guint                prop_id,
Packit Service fb6fa5
						    const GValue        *value,
Packit Service fb6fa5
						    GParamSpec          *pspec);
Packit Service fb6fa5
static void       gtk_toolbar_get_property         (GObject             *object,
Packit Service fb6fa5
						    guint                prop_id,
Packit Service fb6fa5
						    GValue              *value,
Packit Service fb6fa5
						    GParamSpec          *pspec);
Packit Service fb6fa5
static gint       gtk_toolbar_expose               (GtkWidget           *widget,
Packit Service fb6fa5
						    GdkEventExpose      *event);
Packit Service fb6fa5
static void       gtk_toolbar_realize              (GtkWidget           *widget);
Packit Service fb6fa5
static void       gtk_toolbar_unrealize            (GtkWidget           *widget);
Packit Service fb6fa5
static void       gtk_toolbar_size_request         (GtkWidget           *widget,
Packit Service fb6fa5
						    GtkRequisition      *requisition);
Packit Service fb6fa5
static void       gtk_toolbar_size_allocate        (GtkWidget           *widget,
Packit Service fb6fa5
						    GtkAllocation       *allocation);
Packit Service fb6fa5
static void       gtk_toolbar_style_set            (GtkWidget           *widget,
Packit Service fb6fa5
						    GtkStyle            *prev_style);
Packit Service fb6fa5
static gboolean   gtk_toolbar_focus                (GtkWidget           *widget,
Packit Service fb6fa5
						    GtkDirectionType     dir);
Packit Service fb6fa5
static void       gtk_toolbar_move_focus           (GtkWidget           *widget,
Packit Service fb6fa5
						    GtkDirectionType     dir);
Packit Service fb6fa5
static void       gtk_toolbar_screen_changed       (GtkWidget           *widget,
Packit Service fb6fa5
						    GdkScreen           *previous_screen);
Packit Service fb6fa5
static void       gtk_toolbar_map                  (GtkWidget           *widget);
Packit Service fb6fa5
static void       gtk_toolbar_unmap                (GtkWidget           *widget);
Packit Service fb6fa5
static void       gtk_toolbar_set_child_property   (GtkContainer        *container,
Packit Service fb6fa5
						    GtkWidget           *child,
Packit Service fb6fa5
						    guint                property_id,
Packit Service fb6fa5
						    const GValue        *value,
Packit Service fb6fa5
						    GParamSpec          *pspec);
Packit Service fb6fa5
static void       gtk_toolbar_get_child_property   (GtkContainer        *container,
Packit Service fb6fa5
						    GtkWidget           *child,
Packit Service fb6fa5
						    guint                property_id,
Packit Service fb6fa5
						    GValue              *value,
Packit Service fb6fa5
						    GParamSpec          *pspec);
Packit Service fb6fa5
static void       gtk_toolbar_dispose              (GObject             *object);
Packit Service fb6fa5
static void       gtk_toolbar_finalize             (GObject             *object);
Packit Service fb6fa5
static void       gtk_toolbar_show_all             (GtkWidget           *widget);
Packit Service fb6fa5
static void       gtk_toolbar_hide_all             (GtkWidget           *widget);
Packit Service fb6fa5
static void       gtk_toolbar_add                  (GtkContainer        *container,
Packit Service fb6fa5
						    GtkWidget           *widget);
Packit Service fb6fa5
static void       gtk_toolbar_remove               (GtkContainer        *container,
Packit Service fb6fa5
						    GtkWidget           *widget);
Packit Service fb6fa5
static void       gtk_toolbar_forall               (GtkContainer        *container,
Packit Service fb6fa5
						    gboolean             include_internals,
Packit Service fb6fa5
						    GtkCallback          callback,
Packit Service fb6fa5
						    gpointer             callback_data);
Packit Service fb6fa5
static GType      gtk_toolbar_child_type           (GtkContainer        *container);
Packit Service fb6fa5
static void       gtk_toolbar_orientation_changed  (GtkToolbar          *toolbar,
Packit Service fb6fa5
						    GtkOrientation       orientation);
Packit Service fb6fa5
static void       gtk_toolbar_real_style_changed   (GtkToolbar          *toolbar,
Packit Service fb6fa5
						    GtkToolbarStyle      style);
Packit Service fb6fa5
static gboolean   gtk_toolbar_focus_home_or_end    (GtkToolbar          *toolbar,
Packit Service fb6fa5
						    gboolean             focus_home);
Packit Service fb6fa5
static gboolean   gtk_toolbar_button_press         (GtkWidget           *toolbar,
Packit Service fb6fa5
						    GdkEventButton      *event);
Packit Service fb6fa5
static gboolean   gtk_toolbar_arrow_button_press   (GtkWidget           *button,
Packit Service fb6fa5
						    GdkEventButton      *event,
Packit Service fb6fa5
						    GtkToolbar          *toolbar);
Packit Service fb6fa5
static void       gtk_toolbar_arrow_button_clicked (GtkWidget           *button,
Packit Service fb6fa5
						    GtkToolbar          *toolbar);
Packit Service fb6fa5
static void       gtk_toolbar_update_button_relief (GtkToolbar          *toolbar);
Packit Service fb6fa5
static gboolean   gtk_toolbar_popup_menu           (GtkWidget           *toolbar);
Packit Service fb6fa5
static GtkWidget *internal_insert_element          (GtkToolbar          *toolbar,
Packit Service fb6fa5
						    GtkToolbarChildType  type,
Packit Service fb6fa5
						    GtkWidget           *widget,
Packit Service fb6fa5
						    const char          *text,
Packit Service fb6fa5
						    const char          *tooltip_text,
Packit Service fb6fa5
						    const char          *tooltip_private_text,
Packit Service fb6fa5
						    GtkWidget           *icon,
Packit Service fb6fa5
						    GCallback            callback,
Packit Service fb6fa5
						    gpointer             user_data,
Packit Service fb6fa5
						    gint                 position,
Packit Service fb6fa5
						    gboolean             use_stock);
Packit Service fb6fa5
static void       gtk_toolbar_reconfigured         (GtkToolbar          *toolbar);
Packit Service fb6fa5
static gboolean   gtk_toolbar_check_new_api        (GtkToolbar          *toolbar);
Packit Service fb6fa5
static gboolean   gtk_toolbar_check_old_api        (GtkToolbar          *toolbar);
Packit Service fb6fa5
Packit Service fb6fa5
static GtkReliefStyle       get_button_relief    (GtkToolbar *toolbar);
Packit Service fb6fa5
static gint                 get_internal_padding (GtkToolbar *toolbar);
Packit Service fb6fa5
static gint                 get_max_child_expand (GtkToolbar *toolbar);
Packit Service fb6fa5
static GtkShadowType        get_shadow_type      (GtkToolbar *toolbar);
Packit Service fb6fa5
static gint                 get_space_size       (GtkToolbar *toolbar);
Packit Service fb6fa5
static GtkToolbarSpaceStyle get_space_style      (GtkToolbar *toolbar);
Packit Service fb6fa5
Packit Service fb6fa5
/* methods on ToolbarContent 'class' */
Packit Service fb6fa5
static ToolbarContent *toolbar_content_new_tool_item        (GtkToolbar          *toolbar,
Packit Service fb6fa5
							     GtkToolItem         *item,
Packit Service fb6fa5
							     gboolean             is_placeholder,
Packit Service fb6fa5
							     gint                 pos);
Packit Service fb6fa5
static ToolbarContent *toolbar_content_new_compatibility    (GtkToolbar          *toolbar,
Packit Service fb6fa5
							     GtkToolbarChildType  type,
Packit Service fb6fa5
							     GtkWidget           *widget,
Packit Service fb6fa5
							     GtkWidget           *icon,
Packit Service fb6fa5
							     GtkWidget           *label,
Packit Service fb6fa5
							     gint                 pos);
Packit Service fb6fa5
static void            toolbar_content_remove               (ToolbarContent      *content,
Packit Service fb6fa5
							     GtkToolbar          *toolbar);
Packit Service fb6fa5
static void            toolbar_content_free                 (ToolbarContent      *content);
Packit Service fb6fa5
static void            toolbar_content_expose               (ToolbarContent      *content,
Packit Service fb6fa5
							     GtkContainer        *container,
Packit Service fb6fa5
							     GdkEventExpose      *expose);
Packit Service fb6fa5
static gboolean        toolbar_content_visible              (ToolbarContent      *content,
Packit Service fb6fa5
							     GtkToolbar          *toolbar);
Packit Service fb6fa5
static void            toolbar_content_size_request         (ToolbarContent      *content,
Packit Service fb6fa5
							     GtkToolbar          *toolbar,
Packit Service fb6fa5
							     GtkRequisition      *requisition);
Packit Service fb6fa5
static gboolean        toolbar_content_is_homogeneous       (ToolbarContent      *content,
Packit Service fb6fa5
							     GtkToolbar          *toolbar);
Packit Service fb6fa5
static gboolean        toolbar_content_is_placeholder       (ToolbarContent      *content);
Packit Service fb6fa5
static gboolean        toolbar_content_disappearing         (ToolbarContent      *content);
Packit Service fb6fa5
static ItemState       toolbar_content_get_state            (ToolbarContent      *content);
Packit Service fb6fa5
static gboolean        toolbar_content_child_visible        (ToolbarContent      *content);
Packit Service fb6fa5
static void            toolbar_content_get_goal_allocation  (ToolbarContent      *content,
Packit Service fb6fa5
							     GtkAllocation       *allocation);
Packit Service fb6fa5
static void            toolbar_content_get_allocation       (ToolbarContent      *content,
Packit Service fb6fa5
							     GtkAllocation       *allocation);
Packit Service fb6fa5
static void            toolbar_content_set_start_allocation (ToolbarContent      *content,
Packit Service fb6fa5
							     GtkAllocation       *new_start_allocation);
Packit Service fb6fa5
static void            toolbar_content_get_start_allocation (ToolbarContent      *content,
Packit Service fb6fa5
							     GtkAllocation       *start_allocation);
Packit Service fb6fa5
static gboolean        toolbar_content_get_expand           (ToolbarContent      *content);
Packit Service fb6fa5
static void            toolbar_content_set_goal_allocation  (ToolbarContent      *content,
Packit Service fb6fa5
							     GtkAllocation       *allocation);
Packit Service fb6fa5
static void            toolbar_content_set_child_visible    (ToolbarContent      *content,
Packit Service fb6fa5
							     GtkToolbar          *toolbar,
Packit Service fb6fa5
							     gboolean             visible);
Packit Service fb6fa5
static void            toolbar_content_size_allocate        (ToolbarContent      *content,
Packit Service fb6fa5
							     GtkAllocation       *allocation);
Packit Service fb6fa5
static void            toolbar_content_set_state            (ToolbarContent      *content,
Packit Service fb6fa5
							     ItemState            new_state);
Packit Service fb6fa5
static GtkWidget *     toolbar_content_get_widget           (ToolbarContent      *content);
Packit Service fb6fa5
static void            toolbar_content_set_disappearing     (ToolbarContent      *content,
Packit Service fb6fa5
							     gboolean             disappearing);
Packit Service fb6fa5
static void            toolbar_content_set_size_request     (ToolbarContent      *content,
Packit Service fb6fa5
							     gint                 width,
Packit Service fb6fa5
							     gint                 height);
Packit Service fb6fa5
static void            toolbar_content_toolbar_reconfigured (ToolbarContent      *content,
Packit Service fb6fa5
							     GtkToolbar          *toolbar);
Packit Service fb6fa5
static GtkWidget *     toolbar_content_retrieve_menu_item   (ToolbarContent      *content);
Packit Service fb6fa5
static gboolean        toolbar_content_has_proxy_menu_item  (ToolbarContent	 *content);
Packit Service fb6fa5
static gboolean        toolbar_content_is_separator         (ToolbarContent      *content);
Packit Service fb6fa5
static void            toolbar_content_show_all             (ToolbarContent      *content);
Packit Service fb6fa5
static void            toolbar_content_hide_all             (ToolbarContent      *content);
Packit Service fb6fa5
static void	       toolbar_content_set_expand	    (ToolbarContent      *content,
Packit Service fb6fa5
							     gboolean		  expand);
Packit Service fb6fa5
Packit Service fb6fa5
static void            toolbar_tool_shell_iface_init        (GtkToolShellIface   *iface);
Packit Service fb6fa5
static GtkIconSize     toolbar_get_icon_size                (GtkToolShell        *shell);
Packit Service fb6fa5
static GtkOrientation  toolbar_get_orientation              (GtkToolShell        *shell);
Packit Service fb6fa5
static GtkToolbarStyle toolbar_get_style                    (GtkToolShell        *shell);
Packit Service fb6fa5
static GtkReliefStyle  toolbar_get_relief_style             (GtkToolShell        *shell);
Packit Service fb6fa5
static void            toolbar_rebuild_menu                 (GtkToolShell        *shell);
Packit Service fb6fa5
Packit Service fb6fa5
#define GTK_TOOLBAR_GET_PRIVATE(o)  \
Packit Service fb6fa5
  (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_TOOLBAR, GtkToolbarPrivate))
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
G_DEFINE_TYPE_WITH_CODE (GtkToolbar, gtk_toolbar, GTK_TYPE_CONTAINER,
Packit Service fb6fa5
                         G_IMPLEMENT_INTERFACE (GTK_TYPE_TOOL_SHELL,
Packit Service fb6fa5
                                                toolbar_tool_shell_iface_init)
Packit Service fb6fa5
                         G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE,
Packit Service fb6fa5
                                                NULL))
Packit Service fb6fa5
Packit Service fb6fa5
static guint toolbar_signals[LAST_SIGNAL] = { 0 };
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
add_arrow_bindings (GtkBindingSet   *binding_set,
Packit Service fb6fa5
		    guint            keysym,
Packit Service fb6fa5
		    GtkDirectionType dir)
Packit Service fb6fa5
{
Packit Service fb6fa5
  guint keypad_keysym = keysym - GDK_Left + GDK_KP_Left;
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_binding_entry_add_signal (binding_set, keysym, 0,
Packit Service fb6fa5
                                "move-focus", 1,
Packit Service fb6fa5
                                GTK_TYPE_DIRECTION_TYPE, dir);
Packit Service fb6fa5
  gtk_binding_entry_add_signal (binding_set, keypad_keysym, 0,
Packit Service fb6fa5
                                "move-focus", 1,
Packit Service fb6fa5
                                GTK_TYPE_DIRECTION_TYPE, dir);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
add_ctrl_tab_bindings (GtkBindingSet    *binding_set,
Packit Service fb6fa5
		       GdkModifierType   modifiers,
Packit Service fb6fa5
		       GtkDirectionType  direction)
Packit Service fb6fa5
{
Packit Service fb6fa5
  gtk_binding_entry_add_signal (binding_set,
Packit Service fb6fa5
				GDK_Tab, GDK_CONTROL_MASK | modifiers,
Packit Service fb6fa5
				"move-focus", 1,
Packit Service fb6fa5
				GTK_TYPE_DIRECTION_TYPE, direction);
Packit Service fb6fa5
  gtk_binding_entry_add_signal (binding_set,
Packit Service fb6fa5
				GDK_KP_Tab, GDK_CONTROL_MASK | modifiers,
Packit Service fb6fa5
				"move-focus", 1,
Packit Service fb6fa5
				GTK_TYPE_DIRECTION_TYPE, direction);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_class_init (GtkToolbarClass *klass)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GObjectClass *gobject_class;
Packit Service fb6fa5
  GtkWidgetClass *widget_class;
Packit Service fb6fa5
  GtkContainerClass *container_class;
Packit Service fb6fa5
  GtkBindingSet *binding_set;
Packit Service fb6fa5
  
Packit Service fb6fa5
  gobject_class = (GObjectClass *)klass;
Packit Service fb6fa5
  widget_class = (GtkWidgetClass *)klass;
Packit Service fb6fa5
  container_class = (GtkContainerClass *)klass;
Packit Service fb6fa5
  
Packit Service fb6fa5
  gobject_class->set_property = gtk_toolbar_set_property;
Packit Service fb6fa5
  gobject_class->get_property = gtk_toolbar_get_property;
Packit Service fb6fa5
  gobject_class->dispose = gtk_toolbar_dispose;
Packit Service fb6fa5
  gobject_class->finalize = gtk_toolbar_finalize;
Packit Service fb6fa5
Packit Service fb6fa5
  widget_class->button_press_event = gtk_toolbar_button_press;
Packit Service fb6fa5
  widget_class->expose_event = gtk_toolbar_expose;
Packit Service fb6fa5
  widget_class->size_request = gtk_toolbar_size_request;
Packit Service fb6fa5
  widget_class->size_allocate = gtk_toolbar_size_allocate;
Packit Service fb6fa5
  widget_class->style_set = gtk_toolbar_style_set;
Packit Service fb6fa5
  widget_class->focus = gtk_toolbar_focus;
Packit Service fb6fa5
Packit Service fb6fa5
  /* need to override the base class function via override_class_handler,
Packit Service fb6fa5
   * because the signal slot is not available in GtkWidgetClass
Packit Service fb6fa5
   */
Packit Service fb6fa5
  g_signal_override_class_handler ("move-focus",
Packit Service fb6fa5
                                   GTK_TYPE_TOOLBAR,
Packit Service fb6fa5
                                   G_CALLBACK (gtk_toolbar_move_focus));
Packit Service fb6fa5
Packit Service fb6fa5
  widget_class->screen_changed = gtk_toolbar_screen_changed;
Packit Service fb6fa5
  widget_class->realize = gtk_toolbar_realize;
Packit Service fb6fa5
  widget_class->unrealize = gtk_toolbar_unrealize;
Packit Service fb6fa5
  widget_class->map = gtk_toolbar_map;
Packit Service fb6fa5
  widget_class->unmap = gtk_toolbar_unmap;
Packit Service fb6fa5
  widget_class->popup_menu = gtk_toolbar_popup_menu;
Packit Service fb6fa5
  widget_class->show_all = gtk_toolbar_show_all;
Packit Service fb6fa5
  widget_class->hide_all = gtk_toolbar_hide_all;
Packit Service fb6fa5
  
Packit Service fb6fa5
  container_class->add    = gtk_toolbar_add;
Packit Service fb6fa5
  container_class->remove = gtk_toolbar_remove;
Packit Service fb6fa5
  container_class->forall = gtk_toolbar_forall;
Packit Service fb6fa5
  container_class->child_type = gtk_toolbar_child_type;
Packit Service fb6fa5
  container_class->get_child_property = gtk_toolbar_get_child_property;
Packit Service fb6fa5
  container_class->set_child_property = gtk_toolbar_set_child_property;
Packit Service fb6fa5
  
Packit Service fb6fa5
  klass->orientation_changed = gtk_toolbar_orientation_changed;
Packit Service fb6fa5
  klass->style_changed = gtk_toolbar_real_style_changed;
Packit Service fb6fa5
  
Packit Service fb6fa5
  /**
Packit Service fb6fa5
   * GtkToolbar::orientation-changed:
Packit Service fb6fa5
   * @toolbar: the object which emitted the signal
Packit Service fb6fa5
   * @orientation: the new #GtkOrientation of the toolbar
Packit Service fb6fa5
   *
Packit Service fb6fa5
   * Emitted when the orientation of the toolbar changes.
Packit Service fb6fa5
   */
Packit Service fb6fa5
  toolbar_signals[ORIENTATION_CHANGED] =
Packit Service fb6fa5
    g_signal_new (I_("orientation-changed"),
Packit Service fb6fa5
		  G_OBJECT_CLASS_TYPE (klass),
Packit Service fb6fa5
		  G_SIGNAL_RUN_FIRST,
Packit Service fb6fa5
		  G_STRUCT_OFFSET (GtkToolbarClass, orientation_changed),
Packit Service fb6fa5
		  NULL, NULL,
Packit Service fb6fa5
		  g_cclosure_marshal_VOID__ENUM,
Packit Service fb6fa5
		  G_TYPE_NONE, 1,
Packit Service fb6fa5
		  GTK_TYPE_ORIENTATION);
Packit Service fb6fa5
  /**
Packit Service fb6fa5
   * GtkToolbar::style-changed:
Packit Service fb6fa5
   * @toolbar: The #GtkToolbar which emitted the signal
Packit Service fb6fa5
   * @style: the new #GtkToolbarStyle of the toolbar
Packit Service fb6fa5
   *
Packit Service fb6fa5
   * Emitted when the style of the toolbar changes. 
Packit Service fb6fa5
   */
Packit Service fb6fa5
  toolbar_signals[STYLE_CHANGED] =
Packit Service fb6fa5
    g_signal_new (I_("style-changed"),
Packit Service fb6fa5
		  G_OBJECT_CLASS_TYPE (klass),
Packit Service fb6fa5
		  G_SIGNAL_RUN_FIRST,
Packit Service fb6fa5
		  G_STRUCT_OFFSET (GtkToolbarClass, style_changed),
Packit Service fb6fa5
		  NULL, NULL,
Packit Service fb6fa5
		  g_cclosure_marshal_VOID__ENUM,
Packit Service fb6fa5
		  G_TYPE_NONE, 1,
Packit Service fb6fa5
		  GTK_TYPE_TOOLBAR_STYLE);
Packit Service fb6fa5
  /**
Packit Service fb6fa5
   * GtkToolbar::popup-context-menu:
Packit Service fb6fa5
   * @toolbar: the #GtkToolbar which emitted the signal
Packit Service fb6fa5
   * @x: the x coordinate of the point where the menu should appear
Packit Service fb6fa5
   * @y: the y coordinate of the point where the menu should appear
Packit Service fb6fa5
   * @button: the mouse button the user pressed, or -1
Packit Service fb6fa5
   *
Packit Service fb6fa5
   * Emitted when the user right-clicks the toolbar or uses the
Packit Service fb6fa5
   * keybinding to display a popup menu.
Packit Service fb6fa5
   *
Packit Service fb6fa5
   * Application developers should handle this signal if they want
Packit Service fb6fa5
   * to display a context menu on the toolbar. The context-menu should
Packit Service fb6fa5
   * appear at the coordinates given by @x and @y. The mouse button
Packit Service fb6fa5
   * number is given by the @button parameter. If the menu was popped
Packit Service fb6fa5
   * up using the keybaord, @button is -1.
Packit Service fb6fa5
   *
Packit Service fb6fa5
   * Return value: return %TRUE if the signal was handled, %FALSE if not
Packit Service fb6fa5
   */
Packit Service fb6fa5
  toolbar_signals[POPUP_CONTEXT_MENU] =
Packit Service fb6fa5
    g_signal_new (I_("popup-context-menu"),
Packit Service fb6fa5
		  G_OBJECT_CLASS_TYPE (klass),
Packit Service fb6fa5
		  G_SIGNAL_RUN_LAST,
Packit Service fb6fa5
		  G_STRUCT_OFFSET (GtkToolbarClass, popup_context_menu),
Packit Service fb6fa5
		  _gtk_boolean_handled_accumulator, NULL,
Packit Service fb6fa5
		  _gtk_marshal_BOOLEAN__INT_INT_INT,
Packit Service fb6fa5
		  G_TYPE_BOOLEAN, 3,
Packit Service fb6fa5
		  G_TYPE_INT, G_TYPE_INT,
Packit Service fb6fa5
		  G_TYPE_INT);
Packit Service fb6fa5
Packit Service fb6fa5
  /**
Packit Service fb6fa5
   * GtkToolbar::focus-home-or-end:
Packit Service fb6fa5
   * @toolbar: the #GtkToolbar which emitted the signal
Packit Service fb6fa5
   * @focus_home: %TRUE if the first item should be focused
Packit Service fb6fa5
   *
Packit Service fb6fa5
   * A keybinding signal used internally by GTK+. This signal can't
Packit Service fb6fa5
   * be used in application code
Packit Service fb6fa5
   *
Packit Service fb6fa5
   * Return value: %TRUE if the signal was handled, %FALSE if not
Packit Service fb6fa5
   */
Packit Service fb6fa5
  toolbar_signals[FOCUS_HOME_OR_END] =
Packit Service fb6fa5
    g_signal_new_class_handler (I_("focus-home-or-end"),
Packit Service fb6fa5
                                G_OBJECT_CLASS_TYPE (klass),
Packit Service fb6fa5
                                G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
Packit Service fb6fa5
                                G_CALLBACK (gtk_toolbar_focus_home_or_end),
Packit Service fb6fa5
                                NULL, NULL,
Packit Service fb6fa5
                                _gtk_marshal_BOOLEAN__BOOLEAN,
Packit Service fb6fa5
                                G_TYPE_BOOLEAN, 1,
Packit Service fb6fa5
                                G_TYPE_BOOLEAN);
Packit Service fb6fa5
Packit Service fb6fa5
  /* properties */
Packit Service fb6fa5
  g_object_class_override_property (gobject_class,
Packit Service fb6fa5
                                    PROP_ORIENTATION,
Packit Service fb6fa5
                                    "orientation");
Packit Service fb6fa5
Packit Service fb6fa5
  g_object_class_install_property (gobject_class,
Packit Service fb6fa5
				   PROP_TOOLBAR_STYLE,
Packit Service fb6fa5
				   g_param_spec_enum ("toolbar-style",
Packit Service fb6fa5
 						      P_("Toolbar Style"),
Packit Service fb6fa5
 						      P_("How to draw the toolbar"),
Packit Service fb6fa5
 						      GTK_TYPE_TOOLBAR_STYLE,
Packit Service fb6fa5
 						      DEFAULT_TOOLBAR_STYLE,
Packit Service fb6fa5
 						      GTK_PARAM_READWRITE));
Packit Service fb6fa5
  g_object_class_install_property (gobject_class,
Packit Service fb6fa5
				   PROP_SHOW_ARROW,
Packit Service fb6fa5
				   g_param_spec_boolean ("show-arrow",
Packit Service fb6fa5
							 P_("Show Arrow"),
Packit Service fb6fa5
							 P_("If an arrow should be shown if the toolbar doesn't fit"),
Packit Service fb6fa5
							 TRUE,
Packit Service fb6fa5
							 GTK_PARAM_READWRITE));
Packit Service fb6fa5
  
Packit Service fb6fa5
Packit Service fb6fa5
  /**
Packit Service fb6fa5
   * GtkToolbar:tooltips:
Packit Service fb6fa5
   * 
Packit Service fb6fa5
   * If the tooltips of the toolbar should be active or not.
Packit Service fb6fa5
   * 
Packit Service fb6fa5
   * Since: 2.8
Packit Service fb6fa5
   */
Packit Service fb6fa5
  g_object_class_install_property (gobject_class,
Packit Service fb6fa5
				   PROP_TOOLTIPS,
Packit Service fb6fa5
				   g_param_spec_boolean ("tooltips",
Packit Service fb6fa5
							 P_("Tooltips"),
Packit Service fb6fa5
							 P_("If the tooltips of the toolbar should be active or not"),
Packit Service fb6fa5
							 TRUE,
Packit Service fb6fa5
							 GTK_PARAM_READWRITE));
Packit Service fb6fa5
  
Packit Service fb6fa5
Packit Service fb6fa5
  /**
Packit Service fb6fa5
   * GtkToolbar:icon-size:
Packit Service fb6fa5
   *
Packit Service fb6fa5
   * The size of the icons in a toolbar is normally determined by
Packit Service fb6fa5
   * the toolbar-icon-size setting. When this property is set, it 
Packit Service fb6fa5
   * overrides the setting. 
Packit Service fb6fa5
   * 
Packit Service fb6fa5
   * This should only be used for special-purpose toolbars, normal
Packit Service fb6fa5
   * application toolbars should respect the user preferences for the
Packit Service fb6fa5
   * size of icons.
Packit Service fb6fa5
   *
Packit Service fb6fa5
   * Since: 2.10
Packit Service fb6fa5
   */
Packit Service fb6fa5
  g_object_class_install_property (gobject_class,
Packit Service fb6fa5
				   PROP_ICON_SIZE,
Packit Service fb6fa5
				   g_param_spec_int ("icon-size",
Packit Service fb6fa5
						     P_("Icon size"),
Packit Service fb6fa5
						     P_("Size of icons in this toolbar"),
Packit Service fb6fa5
						     0, G_MAXINT,
Packit Service fb6fa5
						     DEFAULT_ICON_SIZE,
Packit Service fb6fa5
						     GTK_PARAM_READWRITE));  
Packit Service fb6fa5
Packit Service fb6fa5
  /**
Packit Service fb6fa5
   * GtkToolbar:icon-size-set:
Packit Service fb6fa5
   *
Packit Service fb6fa5
   * Is %TRUE if the icon-size property has been set.
Packit Service fb6fa5
   *
Packit Service fb6fa5
   * Since: 2.10
Packit Service fb6fa5
   */
Packit Service fb6fa5
  g_object_class_install_property (gobject_class,
Packit Service fb6fa5
				   PROP_ICON_SIZE_SET,
Packit Service fb6fa5
				   g_param_spec_boolean ("icon-size-set",
Packit Service fb6fa5
							 P_("Icon size set"),
Packit Service fb6fa5
							 P_("Whether the icon-size property has been set"),
Packit Service fb6fa5
							 FALSE,
Packit Service fb6fa5
							 GTK_PARAM_READWRITE));  
Packit Service fb6fa5
Packit Service fb6fa5
  /* child properties */
Packit Service fb6fa5
  gtk_container_class_install_child_property (container_class,
Packit Service fb6fa5
					      CHILD_PROP_EXPAND,
Packit Service fb6fa5
					      g_param_spec_boolean ("expand", 
Packit Service fb6fa5
								    P_("Expand"), 
Packit Service fb6fa5
								    P_("Whether the item should receive extra space when the toolbar grows"),
Packit Service fb6fa5
								    FALSE,
Packit Service fb6fa5
								    GTK_PARAM_READWRITE));
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_container_class_install_child_property (container_class,
Packit Service fb6fa5
					      CHILD_PROP_HOMOGENEOUS,
Packit Service fb6fa5
					      g_param_spec_boolean ("homogeneous", 
Packit Service fb6fa5
								    P_("Homogeneous"), 
Packit Service fb6fa5
								    P_("Whether the item should be the same size as other homogeneous items"),
Packit Service fb6fa5
								    FALSE,
Packit Service fb6fa5
								    GTK_PARAM_READWRITE));
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* style properties */
Packit Service fb6fa5
  gtk_widget_class_install_style_property (widget_class,
Packit Service fb6fa5
					   g_param_spec_int ("space-size",
Packit Service fb6fa5
							     P_("Spacer size"),
Packit Service fb6fa5
							     P_("Size of spacers"),
Packit Service fb6fa5
							     0,
Packit Service fb6fa5
							     G_MAXINT,
Packit Service fb6fa5
                                                             DEFAULT_SPACE_SIZE,
Packit Service fb6fa5
							     GTK_PARAM_READABLE));
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_widget_class_install_style_property (widget_class,
Packit Service fb6fa5
					   g_param_spec_int ("internal-padding",
Packit Service fb6fa5
							     P_("Internal padding"),
Packit Service fb6fa5
							     P_("Amount of border space between the toolbar shadow and the buttons"),
Packit Service fb6fa5
							     0,
Packit Service fb6fa5
							     G_MAXINT,
Packit Service fb6fa5
                                                             DEFAULT_IPADDING,
Packit Service fb6fa5
                                                             GTK_PARAM_READABLE));
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_widget_class_install_style_property (widget_class,
Packit Service fb6fa5
                                           g_param_spec_int ("max-child-expand",
Packit Service fb6fa5
                                                             P_("Maximum child expand"),
Packit Service fb6fa5
                                                             P_("Maximum amount of space an expandable item will be given"),
Packit Service fb6fa5
                                                             0,
Packit Service fb6fa5
                                                             G_MAXINT,
Packit Service fb6fa5
                                                             G_MAXINT,
Packit Service fb6fa5
                                                             GTK_PARAM_READABLE));
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_widget_class_install_style_property (widget_class,
Packit Service fb6fa5
					   g_param_spec_enum ("space-style",
Packit Service fb6fa5
							      P_("Space style"),
Packit Service fb6fa5
							      P_("Whether spacers are vertical lines or just blank"),
Packit Service fb6fa5
                                                              GTK_TYPE_TOOLBAR_SPACE_STYLE,
Packit Service fb6fa5
                                                              DEFAULT_SPACE_STYLE,
Packit Service fb6fa5
                                                              GTK_PARAM_READABLE));
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_widget_class_install_style_property (widget_class,
Packit Service fb6fa5
					   g_param_spec_enum ("button-relief",
Packit Service fb6fa5
							      P_("Button relief"),
Packit Service fb6fa5
							      P_("Type of bevel around toolbar buttons"),
Packit Service fb6fa5
                                                              GTK_TYPE_RELIEF_STYLE,
Packit Service fb6fa5
                                                              GTK_RELIEF_NONE,
Packit Service fb6fa5
                                                              GTK_PARAM_READABLE));
Packit Service fb6fa5
  gtk_widget_class_install_style_property (widget_class,
Packit Service fb6fa5
                                           g_param_spec_enum ("shadow-type",
Packit Service fb6fa5
                                                              P_("Shadow type"),
Packit Service fb6fa5
                                                              P_("Style of bevel around the toolbar"),
Packit Service fb6fa5
                                                              GTK_TYPE_SHADOW_TYPE,
Packit Service fb6fa5
                                                              GTK_SHADOW_OUT,
Packit Service fb6fa5
                                                              GTK_PARAM_READABLE));
Packit Service fb6fa5
Packit Service fb6fa5
  binding_set = gtk_binding_set_by_class (klass);
Packit Service fb6fa5
  
Packit Service fb6fa5
  add_arrow_bindings (binding_set, GDK_Left, GTK_DIR_LEFT);
Packit Service fb6fa5
  add_arrow_bindings (binding_set, GDK_Right, GTK_DIR_RIGHT);
Packit Service fb6fa5
  add_arrow_bindings (binding_set, GDK_Up, GTK_DIR_UP);
Packit Service fb6fa5
  add_arrow_bindings (binding_set, GDK_Down, GTK_DIR_DOWN);
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Home, 0,
Packit Service fb6fa5
                                "focus-home-or-end", 1,
Packit Service fb6fa5
				G_TYPE_BOOLEAN, TRUE);
Packit Service fb6fa5
  gtk_binding_entry_add_signal (binding_set, GDK_Home, 0,
Packit Service fb6fa5
                                "focus-home-or-end", 1,
Packit Service fb6fa5
				G_TYPE_BOOLEAN, TRUE);
Packit Service fb6fa5
  gtk_binding_entry_add_signal (binding_set, GDK_KP_End, 0,
Packit Service fb6fa5
                                "focus-home-or-end", 1,
Packit Service fb6fa5
				G_TYPE_BOOLEAN, FALSE);
Packit Service fb6fa5
  gtk_binding_entry_add_signal (binding_set, GDK_End, 0,
Packit Service fb6fa5
                                "focus-home-or-end", 1,
Packit Service fb6fa5
				G_TYPE_BOOLEAN, FALSE);
Packit Service fb6fa5
  
Packit Service fb6fa5
  add_ctrl_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD);
Packit Service fb6fa5
  add_ctrl_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_type_class_add_private (gobject_class, sizeof (GtkToolbarPrivate));  
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
toolbar_tool_shell_iface_init (GtkToolShellIface *iface)
Packit Service fb6fa5
{
Packit Service fb6fa5
  iface->get_icon_size    = toolbar_get_icon_size;
Packit Service fb6fa5
  iface->get_orientation  = toolbar_get_orientation;
Packit Service fb6fa5
  iface->get_style        = toolbar_get_style;
Packit Service fb6fa5
  iface->get_relief_style = toolbar_get_relief_style;
Packit Service fb6fa5
  iface->rebuild_menu     = toolbar_rebuild_menu;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_init (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv;
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_widget_set_can_focus (GTK_WIDGET (toolbar), FALSE);
Packit Service fb6fa5
  gtk_widget_set_has_window (GTK_WIDGET (toolbar), FALSE);
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  toolbar->orientation = GTK_ORIENTATION_HORIZONTAL;
Packit Service fb6fa5
  toolbar->style = DEFAULT_TOOLBAR_STYLE;
Packit Service fb6fa5
  toolbar->icon_size = DEFAULT_ICON_SIZE;
Packit Service fb6fa5
  priv->animation = DEFAULT_ANIMATION_STATE;
Packit Service fb6fa5
  toolbar->tooltips = gtk_tooltips_new ();
Packit Service fb6fa5
  g_object_ref_sink (toolbar->tooltips);
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv->arrow_button = gtk_toggle_button_new ();
Packit Service fb6fa5
  g_signal_connect (priv->arrow_button, "button-press-event",
Packit Service fb6fa5
		    G_CALLBACK (gtk_toolbar_arrow_button_press), toolbar);
Packit Service fb6fa5
  g_signal_connect (priv->arrow_button, "clicked",
Packit Service fb6fa5
		    G_CALLBACK (gtk_toolbar_arrow_button_clicked), toolbar);
Packit Service fb6fa5
  gtk_button_set_relief (GTK_BUTTON (priv->arrow_button),
Packit Service fb6fa5
			 get_button_relief (toolbar));
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv->api_mode = DONT_KNOW;
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_button_set_focus_on_click (GTK_BUTTON (priv->arrow_button), FALSE);
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
Packit Service fb6fa5
  gtk_widget_set_name (priv->arrow, "gtk-toolbar-arrow");
Packit Service fb6fa5
  gtk_widget_show (priv->arrow);
Packit Service fb6fa5
  gtk_container_add (GTK_CONTAINER (priv->arrow_button), priv->arrow);
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_widget_set_parent (priv->arrow_button, GTK_WIDGET (toolbar));
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* which child position a drop will occur at */
Packit Service fb6fa5
  priv->menu = NULL;
Packit Service fb6fa5
  priv->show_arrow = TRUE;
Packit Service fb6fa5
  priv->settings = NULL;
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv->max_homogeneous_pixels = -1;
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv->timer = g_timer_new ();
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_set_property (GObject      *object,
Packit Service fb6fa5
			  guint         prop_id,
Packit Service fb6fa5
			  const GValue *value,
Packit Service fb6fa5
			  GParamSpec   *pspec)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (object);
Packit Service fb6fa5
  
Packit Service fb6fa5
  switch (prop_id)
Packit Service fb6fa5
    {
Packit Service fb6fa5
    case PROP_ORIENTATION:
Packit Service fb6fa5
      g_signal_emit (toolbar, toolbar_signals[ORIENTATION_CHANGED], 0,
Packit Service fb6fa5
                     g_value_get_enum (value));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_TOOLBAR_STYLE:
Packit Service fb6fa5
      gtk_toolbar_set_style (toolbar, g_value_get_enum (value));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_SHOW_ARROW:
Packit Service fb6fa5
      gtk_toolbar_set_show_arrow (toolbar, g_value_get_boolean (value));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_TOOLTIPS:
Packit Service fb6fa5
      gtk_toolbar_set_tooltips (toolbar, g_value_get_boolean (value));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_ICON_SIZE:
Packit Service fb6fa5
      gtk_toolbar_set_icon_size (toolbar, g_value_get_int (value));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_ICON_SIZE_SET:
Packit Service fb6fa5
      if (g_value_get_boolean (value))
Packit Service fb6fa5
	toolbar->icon_size_set = TRUE;
Packit Service fb6fa5
      else
Packit Service fb6fa5
	gtk_toolbar_unset_icon_size (toolbar);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    default:
Packit Service fb6fa5
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_get_property (GObject    *object,
Packit Service fb6fa5
			  guint       prop_id,
Packit Service fb6fa5
			  GValue     *value,
Packit Service fb6fa5
			  GParamSpec *pspec)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (object);
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  switch (prop_id)
Packit Service fb6fa5
    {
Packit Service fb6fa5
    case PROP_ORIENTATION:
Packit Service fb6fa5
      g_value_set_enum (value, toolbar->orientation);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_TOOLBAR_STYLE:
Packit Service fb6fa5
      g_value_set_enum (value, toolbar->style);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_SHOW_ARROW:
Packit Service fb6fa5
      g_value_set_boolean (value, priv->show_arrow);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_TOOLTIPS:
Packit Service fb6fa5
      g_value_set_boolean (value, gtk_toolbar_get_tooltips (toolbar));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_ICON_SIZE:
Packit Service fb6fa5
      g_value_set_int (value, gtk_toolbar_get_icon_size (toolbar));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_ICON_SIZE_SET:
Packit Service fb6fa5
      g_value_set_boolean (value, toolbar->icon_size_set);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    default:
Packit Service fb6fa5
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_map (GtkWidget *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (widget);
Packit Service fb6fa5
  
Packit Service fb6fa5
  GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->map (widget);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (priv->event_window)
Packit Service fb6fa5
    gdk_window_show_unraised (priv->event_window);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_unmap (GtkWidget *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (widget);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (priv->event_window)
Packit Service fb6fa5
    gdk_window_hide (priv->event_window);
Packit Service fb6fa5
  
Packit Service fb6fa5
  GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->unmap (widget);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_realize (GtkWidget *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (widget);
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  GdkWindowAttr attributes;
Packit Service fb6fa5
  gint attributes_mask;
Packit Service fb6fa5
  gint border_width;
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_widget_set_realized (widget, TRUE);
Packit Service fb6fa5
  
Packit Service fb6fa5
  border_width = GTK_CONTAINER (widget)->border_width;
Packit Service fb6fa5
  
Packit Service fb6fa5
  attributes.wclass = GDK_INPUT_ONLY;
Packit Service fb6fa5
  attributes.window_type = GDK_WINDOW_CHILD;
Packit Service fb6fa5
  attributes.x = widget->allocation.x + border_width;
Packit Service fb6fa5
  attributes.y = widget->allocation.y + border_width;
Packit Service fb6fa5
  attributes.width = widget->allocation.width - border_width * 2;
Packit Service fb6fa5
  attributes.height = widget->allocation.height - border_width * 2;
Packit Service fb6fa5
  attributes.event_mask = gtk_widget_get_events (widget);
Packit Service fb6fa5
  attributes.event_mask |= (GDK_BUTTON_PRESS_MASK |
Packit Service fb6fa5
			    GDK_BUTTON_RELEASE_MASK |
Packit Service fb6fa5
			    GDK_ENTER_NOTIFY_MASK |
Packit Service fb6fa5
			    GDK_LEAVE_NOTIFY_MASK);
Packit Service fb6fa5
  
Packit Service fb6fa5
  attributes_mask = GDK_WA_X | GDK_WA_Y;
Packit Service fb6fa5
  
Packit Service fb6fa5
  widget->window = gtk_widget_get_parent_window (widget);
Packit Service fb6fa5
  g_object_ref (widget->window);
Packit Service fb6fa5
  widget->style = gtk_style_attach (widget->style, widget->window);
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
Packit Service fb6fa5
				       &attributes, attributes_mask);
Packit Service fb6fa5
  gdk_window_set_user_data (priv->event_window, toolbar);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_unrealize (GtkWidget *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (widget);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (priv->event_window)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gdk_window_set_user_data (priv->event_window, NULL);
Packit Service fb6fa5
      gdk_window_destroy (priv->event_window);
Packit Service fb6fa5
      priv->event_window = NULL;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->unrealize (widget);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gint
Packit Service fb6fa5
gtk_toolbar_expose (GtkWidget      *widget,
Packit Service fb6fa5
		    GdkEventExpose *event)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (widget);
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  gint border_width;
Packit Service fb6fa5
  
Packit Service fb6fa5
  border_width = GTK_CONTAINER (widget)->border_width;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (gtk_widget_is_drawable (widget))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gtk_paint_box (widget->style,
Packit Service fb6fa5
		     widget->window,
Packit Service fb6fa5
                     gtk_widget_get_state (widget),
Packit Service fb6fa5
                     get_shadow_type (toolbar),
Packit Service fb6fa5
		     &event->area, widget, "toolbar",
Packit Service fb6fa5
		     border_width + widget->allocation.x,
Packit Service fb6fa5
                     border_width + widget->allocation.y,
Packit Service fb6fa5
		     widget->allocation.width - 2 * border_width,
Packit Service fb6fa5
                     widget->allocation.height - 2 * border_width);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      toolbar_content_expose (content, GTK_CONTAINER (widget), event);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_container_propagate_expose (GTK_CONTAINER (widget),
Packit Service fb6fa5
				  priv->arrow_button,
Packit Service fb6fa5
				  event);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return FALSE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_size_request (GtkWidget      *widget,
Packit Service fb6fa5
			  GtkRequisition *requisition)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (widget);
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  gint max_child_height;
Packit Service fb6fa5
  gint max_child_width;
Packit Service fb6fa5
  gint max_homogeneous_child_width;
Packit Service fb6fa5
  gint max_homogeneous_child_height;
Packit Service fb6fa5
  gint homogeneous_size;
Packit Service fb6fa5
  gint long_req;
Packit Service fb6fa5
  gint pack_front_size;
Packit Service fb6fa5
  gint ipadding;
Packit Service fb6fa5
  GtkRequisition arrow_requisition;
Packit Service fb6fa5
  
Packit Service fb6fa5
  max_homogeneous_child_width = 0;
Packit Service fb6fa5
  max_homogeneous_child_height = 0;
Packit Service fb6fa5
  max_child_width = 0;
Packit Service fb6fa5
  max_child_height = 0;
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GtkRequisition requisition;
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (!toolbar_content_visible (content, toolbar))
Packit Service fb6fa5
	continue;
Packit Service fb6fa5
      
Packit Service fb6fa5
      toolbar_content_size_request (content, toolbar, &requisition);
Packit Service fb6fa5
Packit Service fb6fa5
      max_child_width = MAX (max_child_width, requisition.width);
Packit Service fb6fa5
      max_child_height = MAX (max_child_height, requisition.height);
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (toolbar_content_is_homogeneous (content, toolbar))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  max_homogeneous_child_width = MAX (max_homogeneous_child_width, requisition.width);
Packit Service fb6fa5
	  max_homogeneous_child_height = MAX (max_homogeneous_child_height, requisition.height);
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
Packit Service fb6fa5
    homogeneous_size = max_homogeneous_child_width;
Packit Service fb6fa5
  else
Packit Service fb6fa5
    homogeneous_size = max_homogeneous_child_height;
Packit Service fb6fa5
  
Packit Service fb6fa5
  pack_front_size = 0;
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      guint size;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (!toolbar_content_visible (content, toolbar))
Packit Service fb6fa5
	continue;
Packit Service fb6fa5
Packit Service fb6fa5
      if (toolbar_content_is_homogeneous (content, toolbar))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  size = homogeneous_size;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  GtkRequisition requisition;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  toolbar_content_size_request (content, toolbar, &requisition);
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
Packit Service fb6fa5
	    size = requisition.width;
Packit Service fb6fa5
	  else
Packit Service fb6fa5
	    size = requisition.height;
Packit Service fb6fa5
	}
Packit Service fb6fa5
Packit Service fb6fa5
      pack_front_size += size;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (priv->show_arrow && priv->api_mode == NEW_API)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gtk_widget_size_request (priv->arrow_button, &arrow_requisition);
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
Packit Service fb6fa5
	long_req = arrow_requisition.width;
Packit Service fb6fa5
      else
Packit Service fb6fa5
	long_req = arrow_requisition.height;
Packit Service fb6fa5
      
Packit Service fb6fa5
      /* There is no point requesting space for the arrow if that would take
Packit Service fb6fa5
       * up more space than all the items combined
Packit Service fb6fa5
       */
Packit Service fb6fa5
      long_req = MIN (long_req, pack_front_size);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      arrow_requisition.height = 0;
Packit Service fb6fa5
      arrow_requisition.width = 0;
Packit Service fb6fa5
      
Packit Service fb6fa5
      long_req = pack_front_size;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      requisition->width = long_req;
Packit Service fb6fa5
      requisition->height = MAX (max_child_height, arrow_requisition.height);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      requisition->height = long_req;
Packit Service fb6fa5
      requisition->width = MAX (max_child_width, arrow_requisition.width);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* Extra spacing */
Packit Service fb6fa5
  ipadding = get_internal_padding (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  requisition->width += 2 * (ipadding + GTK_CONTAINER (toolbar)->border_width);
Packit Service fb6fa5
  requisition->height += 2 * (ipadding + GTK_CONTAINER (toolbar)->border_width);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (get_shadow_type (toolbar) != GTK_SHADOW_NONE)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      requisition->width += 2 * widget->style->xthickness;
Packit Service fb6fa5
      requisition->height += 2 * widget->style->ythickness;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  toolbar->button_maxw = max_homogeneous_child_width;
Packit Service fb6fa5
  toolbar->button_maxh = max_homogeneous_child_height;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gint
Packit Service fb6fa5
position (GtkToolbar *toolbar,
Packit Service fb6fa5
          gint        from,
Packit Service fb6fa5
          gint        to,
Packit Service fb6fa5
          gdouble     elapsed)
Packit Service fb6fa5
{
Packit Service fb6fa5
  gint n_pixels;
Packit Service fb6fa5
Packit Service fb6fa5
  if (! GTK_TOOLBAR_GET_PRIVATE (toolbar)->animation)
Packit Service fb6fa5
    return to;
Packit Service fb6fa5
Packit Service fb6fa5
  if (elapsed <= ACCEL_THRESHOLD)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      n_pixels = SLIDE_SPEED * elapsed;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      /* The formula is a second degree polynomial in
Packit Service fb6fa5
       * @elapsed that has the line SLIDE_SPEED * @elapsed
Packit Service fb6fa5
       * as tangent for @elapsed == ACCEL_THRESHOLD.
Packit Service fb6fa5
       * This makes @n_pixels a smooth function of elapsed time.
Packit Service fb6fa5
       */
Packit Service fb6fa5
      n_pixels = (SLIDE_SPEED / ACCEL_THRESHOLD) * elapsed * elapsed -
Packit Service fb6fa5
	SLIDE_SPEED * elapsed + SLIDE_SPEED * ACCEL_THRESHOLD;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  if (to > from)
Packit Service fb6fa5
    return MIN (from + n_pixels, to);
Packit Service fb6fa5
  else
Packit Service fb6fa5
    return MAX (from - n_pixels, to);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
compute_intermediate_allocation (GtkToolbar          *toolbar,
Packit Service fb6fa5
				 const GtkAllocation *start,
Packit Service fb6fa5
				 const GtkAllocation *goal,
Packit Service fb6fa5
				 GtkAllocation       *intermediate)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  gdouble elapsed = g_timer_elapsed (priv->timer, NULL);
Packit Service fb6fa5
Packit Service fb6fa5
  intermediate->x      = position (toolbar, start->x, goal->x, elapsed);
Packit Service fb6fa5
  intermediate->y      = position (toolbar, start->y, goal->y, elapsed);
Packit Service fb6fa5
  intermediate->width  = position (toolbar, start->x + start->width,
Packit Service fb6fa5
                                   goal->x + goal->width,
Packit Service fb6fa5
                                   elapsed) - intermediate->x;
Packit Service fb6fa5
  intermediate->height = position (toolbar, start->y + start->height,
Packit Service fb6fa5
                                   goal->y + goal->height,
Packit Service fb6fa5
                                   elapsed) - intermediate->y;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
fixup_allocation_for_rtl (gint           total_size,
Packit Service fb6fa5
			  GtkAllocation *allocation)
Packit Service fb6fa5
{
Packit Service fb6fa5
  allocation->x += (total_size - (2 * allocation->x + allocation->width));
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
fixup_allocation_for_vertical (GtkAllocation *allocation)
Packit Service fb6fa5
{
Packit Service fb6fa5
  gint tmp;
Packit Service fb6fa5
  
Packit Service fb6fa5
  tmp = allocation->x;
Packit Service fb6fa5
  allocation->x = allocation->y;
Packit Service fb6fa5
  allocation->y = tmp;
Packit Service fb6fa5
  
Packit Service fb6fa5
  tmp = allocation->width;
Packit Service fb6fa5
  allocation->width = allocation->height;
Packit Service fb6fa5
  allocation->height = tmp;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gint
Packit Service fb6fa5
get_item_size (GtkToolbar     *toolbar,
Packit Service fb6fa5
	       ToolbarContent *content)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkRequisition requisition;
Packit Service fb6fa5
  
Packit Service fb6fa5
  toolbar_content_size_request (content, toolbar, &requisition);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (toolbar_content_is_homogeneous (content, toolbar))
Packit Service fb6fa5
	return toolbar->button_maxw;
Packit Service fb6fa5
      else
Packit Service fb6fa5
	return requisition.width;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (toolbar_content_is_homogeneous (content, toolbar))
Packit Service fb6fa5
	return toolbar->button_maxh;
Packit Service fb6fa5
      else
Packit Service fb6fa5
	return requisition.height;
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gboolean
Packit Service fb6fa5
slide_idle_handler (gpointer data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar = data;
Packit Service fb6fa5
  GtkToolbarPrivate *priv;
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (priv->need_sync)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gdk_flush ();
Packit Service fb6fa5
      priv->need_sync = FALSE;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      ItemState state;
Packit Service fb6fa5
      GtkAllocation goal_allocation;
Packit Service fb6fa5
      GtkAllocation allocation;
Packit Service fb6fa5
      gboolean cont;
Packit Service fb6fa5
Packit Service fb6fa5
      state = toolbar_content_get_state (content);
Packit Service fb6fa5
      toolbar_content_get_goal_allocation (content, &goal_allocation);
Packit Service fb6fa5
      toolbar_content_get_allocation (content, &allocation);
Packit Service fb6fa5
      
Packit Service fb6fa5
      cont = FALSE;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (state == NOT_ALLOCATED)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  /* an unallocated item means that size allocate has to
Packit Service fb6fa5
	   * called at least once more
Packit Service fb6fa5
	   */
Packit Service fb6fa5
	  cont = TRUE;
Packit Service fb6fa5
	}
Packit Service fb6fa5
Packit Service fb6fa5
      /* An invisible item with a goal allocation of
Packit Service fb6fa5
       * 0 is already at its goal.
Packit Service fb6fa5
       */
Packit Service fb6fa5
      if ((state == NORMAL || state == OVERFLOWN) &&
Packit Service fb6fa5
	  ((goal_allocation.width != 0 &&
Packit Service fb6fa5
	    goal_allocation.height != 0) ||
Packit Service fb6fa5
	   toolbar_content_child_visible (content)))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  if ((goal_allocation.x != allocation.x ||
Packit Service fb6fa5
	       goal_allocation.y != allocation.y ||
Packit Service fb6fa5
	       goal_allocation.width != allocation.width ||
Packit Service fb6fa5
	       goal_allocation.height != allocation.height))
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      /* An item is not in its right position yet. Note
Packit Service fb6fa5
	       * that OVERFLOWN items do get an allocation in
Packit Service fb6fa5
	       * gtk_toolbar_size_allocate(). This way you can see
Packit Service fb6fa5
	       * them slide back in when you drag an item off the
Packit Service fb6fa5
	       * toolbar.
Packit Service fb6fa5
	       */
Packit Service fb6fa5
	      cont = TRUE;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
Packit Service fb6fa5
      if (toolbar_content_is_placeholder (content) &&
Packit Service fb6fa5
	  toolbar_content_disappearing (content) &&
Packit Service fb6fa5
	  toolbar_content_child_visible (content))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  /* A disappearing placeholder is still visible.
Packit Service fb6fa5
	   */
Packit Service fb6fa5
	     
Packit Service fb6fa5
	  cont = TRUE;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (cont)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  gtk_widget_queue_resize_no_redraw (GTK_WIDGET (toolbar));
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  return TRUE;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_widget_queue_resize_no_redraw (GTK_WIDGET (toolbar));
Packit Service fb6fa5
Packit Service fb6fa5
  priv->is_sliding = FALSE;
Packit Service fb6fa5
  priv->idle_id = 0;
Packit Service fb6fa5
Packit Service fb6fa5
  return FALSE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gboolean
Packit Service fb6fa5
rect_within (GtkAllocation *a1,
Packit Service fb6fa5
	     GtkAllocation *a2)
Packit Service fb6fa5
{
Packit Service fb6fa5
  return (a1->x >= a2->x                         &&
Packit Service fb6fa5
	  a1->x + a1->width <= a2->x + a2->width &&
Packit Service fb6fa5
	  a1->y >= a2->y			 &&
Packit Service fb6fa5
	  a1->y + a1->height <= a2->y + a2->height);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkWidget *widget = GTK_WIDGET (toolbar);
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  gint cur_x;
Packit Service fb6fa5
  gint cur_y;
Packit Service fb6fa5
  gint border_width;
Packit Service fb6fa5
  gboolean rtl;
Packit Service fb6fa5
  gboolean vertical;
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* Start the sliding. This function copies the allocation of every
Packit Service fb6fa5
   * item into content->start_allocation. For items that haven't
Packit Service fb6fa5
   * been allocated yet, we calculate their position and save that
Packit Service fb6fa5
   * in start_allocatino along with zero width and zero height.
Packit Service fb6fa5
   *
Packit Service fb6fa5
   * FIXME: It would be nice if we could share this code with
Packit Service fb6fa5
   * the equivalent in gtk_widget_size_allocate().
Packit Service fb6fa5
   */
Packit Service fb6fa5
  priv->is_sliding = TRUE;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (!priv->idle_id)
Packit Service fb6fa5
    priv->idle_id = gdk_threads_add_idle (slide_idle_handler, toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
Packit Service fb6fa5
  vertical = (toolbar->orientation == GTK_ORIENTATION_VERTICAL);
Packit Service fb6fa5
  border_width = get_internal_padding (toolbar) + GTK_CONTAINER (toolbar)->border_width;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (rtl)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      cur_x = widget->allocation.width - border_width - widget->style->xthickness;
Packit Service fb6fa5
      cur_y = widget->allocation.height - border_width - widget->style->ythickness;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      cur_x = border_width + widget->style->xthickness;
Packit Service fb6fa5
      cur_y = border_width + widget->style->ythickness;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  cur_x += widget->allocation.x;
Packit Service fb6fa5
  cur_y += widget->allocation.y;
Packit Service fb6fa5
  
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      GtkAllocation new_start_allocation;
Packit Service fb6fa5
      GtkAllocation item_allocation;
Packit Service fb6fa5
      ItemState state;
Packit Service fb6fa5
      
Packit Service fb6fa5
      state = toolbar_content_get_state (content);
Packit Service fb6fa5
      toolbar_content_get_allocation (content, &item_allocation);
Packit Service fb6fa5
      
Packit Service fb6fa5
      if ((state == NORMAL &&
Packit Service fb6fa5
	   rect_within (&item_allocation, &(widget->allocation))) ||
Packit Service fb6fa5
	  state == OVERFLOWN)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  new_start_allocation = item_allocation;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  new_start_allocation.x = cur_x;
Packit Service fb6fa5
	  new_start_allocation.y = cur_y;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (vertical)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      new_start_allocation.width = widget->allocation.width -
Packit Service fb6fa5
		2 * border_width - 2 * widget->style->xthickness;
Packit Service fb6fa5
	      new_start_allocation.height = 0;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  else
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      new_start_allocation.width = 0;
Packit Service fb6fa5
	      new_start_allocation.height = widget->allocation.height -
Packit Service fb6fa5
		2 * border_width - 2 * widget->style->ythickness;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (vertical)
Packit Service fb6fa5
	cur_y = new_start_allocation.y + new_start_allocation.height;
Packit Service fb6fa5
      else if (rtl)
Packit Service fb6fa5
	cur_x = new_start_allocation.x;
Packit Service fb6fa5
      else
Packit Service fb6fa5
	cur_x = new_start_allocation.x + new_start_allocation.width;
Packit Service fb6fa5
      
Packit Service fb6fa5
      toolbar_content_set_start_allocation (content, &new_start_allocation);
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  /* This resize will run before the first idle handler. This
Packit Service fb6fa5
   * will make sure that items get the right goal allocation
Packit Service fb6fa5
   * so that the idle handler will not immediately return
Packit Service fb6fa5
   * FALSE
Packit Service fb6fa5
   */
Packit Service fb6fa5
  gtk_widget_queue_resize_no_redraw (GTK_WIDGET (toolbar));
Packit Service fb6fa5
  g_timer_reset (priv->timer);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_stop_sliding (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (priv->is_sliding)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GList *list;
Packit Service fb6fa5
      
Packit Service fb6fa5
      priv->is_sliding = FALSE;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (priv->idle_id)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  g_source_remove (priv->idle_id);
Packit Service fb6fa5
	  priv->idle_id = 0;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      list = priv->content;
Packit Service fb6fa5
      while (list)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  ToolbarContent *content = list->data;
Packit Service fb6fa5
	  list = list->next;
Packit Service fb6fa5
Packit Service fb6fa5
	  if (toolbar_content_is_placeholder (content))
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      toolbar_content_remove (content, toolbar);
Packit Service fb6fa5
	      toolbar_content_free (content);
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      gtk_widget_queue_resize_no_redraw (GTK_WIDGET (toolbar));
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
remove_item (GtkWidget *menu_item,
Packit Service fb6fa5
	     gpointer   data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  gtk_container_remove (GTK_CONTAINER (menu_item->parent), menu_item);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
menu_deactivated (GtkWidget  *menu,
Packit Service fb6fa5
		  GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->arrow_button), FALSE);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
menu_detached (GtkWidget  *toolbar,
Packit Service fb6fa5
	       GtkMenu    *menu)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  priv->menu = NULL;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
rebuild_menu (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  GList *list, *children;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (!priv->menu)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      priv->menu = GTK_MENU (gtk_menu_new());
Packit Service fb6fa5
      gtk_menu_attach_to_widget (priv->menu,
Packit Service fb6fa5
				 GTK_WIDGET (toolbar),
Packit Service fb6fa5
				 menu_detached);
Packit Service fb6fa5
Packit Service fb6fa5
      g_signal_connect (priv->menu, "deactivate",
Packit Service fb6fa5
                        G_CALLBACK (menu_deactivated), toolbar);
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_container_foreach (GTK_CONTAINER (priv->menu), remove_item, NULL);
Packit Service fb6fa5
  
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (toolbar_content_get_state (content) == OVERFLOWN &&
Packit Service fb6fa5
	  !toolbar_content_is_placeholder (content))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  GtkWidget *menu_item = toolbar_content_retrieve_menu_item (content);
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (menu_item)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      g_assert (GTK_IS_MENU_ITEM (menu_item));
Packit Service fb6fa5
	      gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), menu_item);
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  /* Remove leading and trailing separator items */
Packit Service fb6fa5
  children = gtk_container_get_children (GTK_CONTAINER (priv->menu));
Packit Service fb6fa5
  
Packit Service fb6fa5
  list = children;
Packit Service fb6fa5
  while (list && GTK_IS_SEPARATOR_MENU_ITEM (list->data))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GtkWidget *child = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      gtk_container_remove (GTK_CONTAINER (priv->menu), child);
Packit Service fb6fa5
      list = list->next;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  g_list_free (children);
Packit Service fb6fa5
Packit Service fb6fa5
  /* Regenerate the list of children so we don't try to remove items twice */
Packit Service fb6fa5
  children = gtk_container_get_children (GTK_CONTAINER (priv->menu));
Packit Service fb6fa5
Packit Service fb6fa5
  list = g_list_last (children);
Packit Service fb6fa5
  while (list && GTK_IS_SEPARATOR_MENU_ITEM (list->data))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GtkWidget *child = list->data;
Packit Service fb6fa5
Packit Service fb6fa5
      gtk_container_remove (GTK_CONTAINER (priv->menu), child);
Packit Service fb6fa5
      list = list->prev;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  g_list_free (children);
Packit Service fb6fa5
Packit Service fb6fa5
  priv->need_rebuild = FALSE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_size_allocate (GtkWidget     *widget,
Packit Service fb6fa5
			   GtkAllocation *allocation)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (widget);
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  GtkAllocation *allocations;
Packit Service fb6fa5
  ItemState *new_states;
Packit Service fb6fa5
  GtkAllocation arrow_allocation;
Packit Service fb6fa5
  gint arrow_size;
Packit Service fb6fa5
  gint size, pos, short_size;
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  gint i;
Packit Service fb6fa5
  gboolean need_arrow;
Packit Service fb6fa5
  gint n_expand_items;
Packit Service fb6fa5
  gint border_width;
Packit Service fb6fa5
  gint available_size;
Packit Service fb6fa5
  gint n_items;
Packit Service fb6fa5
  gint needed_size;
Packit Service fb6fa5
  GtkRequisition arrow_requisition;
Packit Service fb6fa5
  gboolean overflowing;
Packit Service fb6fa5
  gboolean size_changed;
Packit Service fb6fa5
  gdouble elapsed;
Packit Service fb6fa5
  GtkAllocation item_area;
Packit Service fb6fa5
  GtkShadowType shadow_type;
Packit Service fb6fa5
  
Packit Service fb6fa5
  size_changed = FALSE;
Packit Service fb6fa5
  if (widget->allocation.x != allocation->x		||
Packit Service fb6fa5
      widget->allocation.y != allocation->y		||
Packit Service fb6fa5
      widget->allocation.width != allocation->width	||
Packit Service fb6fa5
      widget->allocation.height != allocation->height)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      size_changed = TRUE;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (size_changed)
Packit Service fb6fa5
    gtk_toolbar_stop_sliding (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  widget->allocation = *allocation;
Packit Service fb6fa5
  
Packit Service fb6fa5
  border_width = GTK_CONTAINER (toolbar)->border_width;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (gtk_widget_get_realized (widget))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gdk_window_move_resize (priv->event_window,
Packit Service fb6fa5
                              allocation->x + border_width,
Packit Service fb6fa5
                              allocation->y + border_width,
Packit Service fb6fa5
                              allocation->width - border_width * 2,
Packit Service fb6fa5
                              allocation->height - border_width * 2);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  border_width += get_internal_padding (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_widget_get_child_requisition (GTK_WIDGET (priv->arrow_button),
Packit Service fb6fa5
				    &arrow_requisition);
Packit Service fb6fa5
  
Packit Service fb6fa5
  shadow_type = get_shadow_type (toolbar);
Packit Service fb6fa5
Packit Service fb6fa5
  if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      available_size = size = allocation->width - 2 * border_width;
Packit Service fb6fa5
      short_size = allocation->height - 2 * border_width;
Packit Service fb6fa5
      arrow_size = arrow_requisition.width;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (shadow_type != GTK_SHADOW_NONE)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  available_size -= 2 * widget->style->xthickness;
Packit Service fb6fa5
	  short_size -= 2 * widget->style->ythickness;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      available_size = size = allocation->height - 2 * border_width;
Packit Service fb6fa5
      short_size = allocation->width - 2 * border_width;
Packit Service fb6fa5
      arrow_size = arrow_requisition.height;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (shadow_type != GTK_SHADOW_NONE)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  available_size -= 2 * widget->style->ythickness;
Packit Service fb6fa5
	  short_size -= 2 * widget->style->xthickness;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  n_items = g_list_length (priv->content);
Packit Service fb6fa5
  allocations = g_new0 (GtkAllocation, n_items);
Packit Service fb6fa5
  new_states = g_new0 (ItemState, n_items);
Packit Service fb6fa5
  
Packit Service fb6fa5
  needed_size = 0;
Packit Service fb6fa5
  need_arrow = FALSE;
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (toolbar_content_visible (content, toolbar))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  needed_size += get_item_size (toolbar, content);
Packit Service fb6fa5
Packit Service fb6fa5
	  /* Do we need an arrow?
Packit Service fb6fa5
	   *
Packit Service fb6fa5
	   * Assume we don't, and see if any non-separator item with a
Packit Service fb6fa5
	   * proxy menu item is then going to overflow.
Packit Service fb6fa5
	   */
Packit Service fb6fa5
	  if (needed_size > available_size			&&
Packit Service fb6fa5
	      !need_arrow					&&
Packit Service fb6fa5
	      priv->show_arrow					&&
Packit Service fb6fa5
	      priv->api_mode == NEW_API				&&
Packit Service fb6fa5
	      toolbar_content_has_proxy_menu_item (content)	&&
Packit Service fb6fa5
	      !toolbar_content_is_separator (content))
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      need_arrow = TRUE;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (need_arrow)
Packit Service fb6fa5
    size = available_size - arrow_size;
Packit Service fb6fa5
  else
Packit Service fb6fa5
    size = available_size;
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* calculate widths and states of items */
Packit Service fb6fa5
  overflowing = FALSE;
Packit Service fb6fa5
  for (list = priv->content, i = 0; list != NULL; list = list->next, ++i)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      gint item_size;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (!toolbar_content_visible (content, toolbar))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  new_states[i] = HIDDEN;
Packit Service fb6fa5
	  continue;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      item_size = get_item_size (toolbar, content);
Packit Service fb6fa5
      if (item_size <= size && !overflowing)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  size -= item_size;
Packit Service fb6fa5
	  allocations[i].width = item_size;
Packit Service fb6fa5
	  new_states[i] = NORMAL;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  overflowing = TRUE;
Packit Service fb6fa5
	  new_states[i] = OVERFLOWN;
Packit Service fb6fa5
	  allocations[i].width = item_size;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* calculate width of arrow */  
Packit Service fb6fa5
  if (need_arrow)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      arrow_allocation.width = arrow_size;
Packit Service fb6fa5
      arrow_allocation.height = MAX (short_size, 1);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* expand expandable items */
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* We don't expand when there is an overflow menu, because that leads to
Packit Service fb6fa5
   * weird jumps when items get moved to the overflow menu and the expanding
Packit Service fb6fa5
   * items suddenly get a lot of extra space
Packit Service fb6fa5
   */
Packit Service fb6fa5
  if (!overflowing)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gint max_child_expand;
Packit Service fb6fa5
      n_expand_items = 0;
Packit Service fb6fa5
      
Packit Service fb6fa5
      for (i = 0, list = priv->content; list != NULL; list = list->next, ++i)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  ToolbarContent *content = list->data;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (toolbar_content_get_expand (content) && new_states[i] == NORMAL)
Packit Service fb6fa5
	    n_expand_items++;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      max_child_expand = get_max_child_expand (toolbar);
Packit Service fb6fa5
      for (list = priv->content, i = 0; list != NULL; list = list->next, ++i)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  ToolbarContent *content = list->data;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (toolbar_content_get_expand (content) && new_states[i] == NORMAL)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      gint extra = size / n_expand_items;
Packit Service fb6fa5
	      if (size % n_expand_items != 0)
Packit Service fb6fa5
		extra++;
Packit Service fb6fa5
Packit Service fb6fa5
              if (extra > max_child_expand)
Packit Service fb6fa5
                extra = max_child_expand;
Packit Service fb6fa5
Packit Service fb6fa5
	      allocations[i].width += extra;
Packit Service fb6fa5
	      size -= extra;
Packit Service fb6fa5
	      n_expand_items--;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      g_assert (n_expand_items == 0);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* position items */
Packit Service fb6fa5
  pos = border_width;
Packit Service fb6fa5
  for (list = priv->content, i = 0; list != NULL; list = list->next, ++i)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      /* both NORMAL and OVERFLOWN items get a position. This ensures
Packit Service fb6fa5
       * that sliding will work for OVERFLOWN items too
Packit Service fb6fa5
       */
Packit Service fb6fa5
      if (new_states[i] == NORMAL ||
Packit Service fb6fa5
	  new_states[i] == OVERFLOWN)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  allocations[i].x = pos;
Packit Service fb6fa5
	  allocations[i].y = border_width;
Packit Service fb6fa5
	  allocations[i].height = short_size;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  pos += allocations[i].width;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* position arrow */
Packit Service fb6fa5
  if (need_arrow)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      arrow_allocation.x = available_size - border_width - arrow_allocation.width;
Packit Service fb6fa5
      arrow_allocation.y = border_width;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  item_area.x = border_width;
Packit Service fb6fa5
  item_area.y = border_width;
Packit Service fb6fa5
  item_area.width = available_size - (need_arrow? arrow_size : 0);
Packit Service fb6fa5
  item_area.height = short_size;
Packit Service fb6fa5
Packit Service fb6fa5
  /* fix up allocations in the vertical or RTL cases */
Packit Service fb6fa5
  if (toolbar->orientation == GTK_ORIENTATION_VERTICAL)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      for (i = 0; i < n_items; ++i)
Packit Service fb6fa5
	fixup_allocation_for_vertical (&(allocations[i]));
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (need_arrow)
Packit Service fb6fa5
	fixup_allocation_for_vertical (&arrow_allocation);
Packit Service fb6fa5
Packit Service fb6fa5
      fixup_allocation_for_vertical (&item_area);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_RTL)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      for (i = 0; i < n_items; ++i)
Packit Service fb6fa5
	fixup_allocation_for_rtl (available_size, &(allocations[i]));
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (need_arrow)
Packit Service fb6fa5
	fixup_allocation_for_rtl (available_size, &arrow_allocation);
Packit Service fb6fa5
Packit Service fb6fa5
      fixup_allocation_for_rtl (available_size, &item_area);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* translate the items by allocation->(x,y) */
Packit Service fb6fa5
  for (i = 0; i < n_items; ++i)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      allocations[i].x += allocation->x;
Packit Service fb6fa5
      allocations[i].y += allocation->y;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (shadow_type != GTK_SHADOW_NONE)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  allocations[i].x += widget->style->xthickness;
Packit Service fb6fa5
	  allocations[i].y += widget->style->ythickness;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (need_arrow)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      arrow_allocation.x += allocation->x;
Packit Service fb6fa5
      arrow_allocation.y += allocation->y;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (shadow_type != GTK_SHADOW_NONE)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  arrow_allocation.x += widget->style->xthickness;
Packit Service fb6fa5
	  arrow_allocation.y += widget->style->ythickness;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  item_area.x += allocation->x;
Packit Service fb6fa5
  item_area.y += allocation->y;
Packit Service fb6fa5
  if (shadow_type != GTK_SHADOW_NONE)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      item_area.x += widget->style->xthickness;
Packit Service fb6fa5
      item_area.y += widget->style->ythickness;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  /* did anything change? */
Packit Service fb6fa5
  for (list = priv->content, i = 0; list != NULL; list = list->next, i++)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (toolbar_content_get_state (content) == NORMAL &&
Packit Service fb6fa5
	  new_states[i] != NORMAL)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  /* an item disappeared and we didn't change size, so begin sliding */
Packit Service fb6fa5
	  if (!size_changed && priv->api_mode == NEW_API)
Packit Service fb6fa5
	    gtk_toolbar_begin_sliding (toolbar);
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* finally allocate the items */
Packit Service fb6fa5
  if (priv->is_sliding)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      for (list = priv->content, i = 0; list != NULL; list = list->next, i++)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  ToolbarContent *content = list->data;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  toolbar_content_set_goal_allocation (content, &(allocations[i]));
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  elapsed = g_timer_elapsed (priv->timer, NULL);
Packit Service fb6fa5
  for (list = priv->content, i = 0; list != NULL; list = list->next, ++i)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
Packit Service fb6fa5
      if (new_states[i] == OVERFLOWN ||
Packit Service fb6fa5
	  new_states[i] == NORMAL)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  GtkAllocation alloc;
Packit Service fb6fa5
	  GtkAllocation start_allocation = { 0, };
Packit Service fb6fa5
	  GtkAllocation goal_allocation;
Packit Service fb6fa5
Packit Service fb6fa5
	  if (priv->is_sliding)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      toolbar_content_get_start_allocation (content, &start_allocation);
Packit Service fb6fa5
	      toolbar_content_get_goal_allocation (content, &goal_allocation);
Packit Service fb6fa5
	      
Packit Service fb6fa5
	      compute_intermediate_allocation (toolbar,
Packit Service fb6fa5
					       &start_allocation,
Packit Service fb6fa5
					       &goal_allocation,
Packit Service fb6fa5
					       &alloc);
Packit Service fb6fa5
Packit Service fb6fa5
	      priv->need_sync = TRUE;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  else
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      alloc = allocations[i];
Packit Service fb6fa5
	    }
Packit Service fb6fa5
Packit Service fb6fa5
	  if (alloc.width <= 0 || alloc.height <= 0)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      toolbar_content_set_child_visible (content, toolbar, FALSE);
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  else
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      if (!rect_within (&alloc, &item_area))
Packit Service fb6fa5
		{
Packit Service fb6fa5
		  toolbar_content_set_child_visible (content, toolbar, FALSE);
Packit Service fb6fa5
		  toolbar_content_size_allocate (content, &alloc);
Packit Service fb6fa5
		}
Packit Service fb6fa5
	      else
Packit Service fb6fa5
		{
Packit Service fb6fa5
		  toolbar_content_set_child_visible (content, toolbar, TRUE);
Packit Service fb6fa5
		  toolbar_content_size_allocate (content, &alloc);
Packit Service fb6fa5
		}
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  toolbar_content_set_child_visible (content, toolbar, FALSE);
Packit Service fb6fa5
	}
Packit Service fb6fa5
	  
Packit Service fb6fa5
      toolbar_content_set_state (content, new_states[i]);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (priv->menu && priv->need_rebuild)
Packit Service fb6fa5
    rebuild_menu (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (need_arrow)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gtk_widget_size_allocate (GTK_WIDGET (priv->arrow_button),
Packit Service fb6fa5
				&arrow_allocation);
Packit Service fb6fa5
      gtk_widget_show (GTK_WIDGET (priv->arrow_button));
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gtk_widget_hide (GTK_WIDGET (priv->arrow_button));
Packit Service fb6fa5
Packit Service fb6fa5
      if (priv->menu && gtk_widget_get_visible (GTK_WIDGET (priv->menu)))
Packit Service fb6fa5
	gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->menu));
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  g_free (allocations);
Packit Service fb6fa5
  g_free (new_states);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_update_button_relief (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  GtkReliefStyle relief;
Packit Service fb6fa5
Packit Service fb6fa5
  relief = get_button_relief (toolbar);
Packit Service fb6fa5
Packit Service fb6fa5
  if (relief != gtk_button_get_relief (GTK_BUTTON (priv->arrow_button)))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gtk_toolbar_reconfigured (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
      gtk_button_set_relief (GTK_BUTTON (priv->arrow_button), relief);
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_style_set (GtkWidget *widget,
Packit Service fb6fa5
		       GtkStyle  *prev_style)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (widget);
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv->max_homogeneous_pixels = -1;
Packit Service fb6fa5
Packit Service fb6fa5
  if (gtk_widget_get_realized (widget))
Packit Service fb6fa5
    gtk_style_set_background (widget->style, widget->window, widget->state);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (prev_style)
Packit Service fb6fa5
    gtk_toolbar_update_button_relief (GTK_TOOLBAR (widget));
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static GList *
Packit Service fb6fa5
gtk_toolbar_list_children_in_focus_order (GtkToolbar       *toolbar,
Packit Service fb6fa5
					  GtkDirectionType  dir)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  GList *result = NULL;
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  gboolean rtl;
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* generate list of children in reverse logical order */
Packit Service fb6fa5
  
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      GtkWidget *widget;
Packit Service fb6fa5
      
Packit Service fb6fa5
      widget = toolbar_content_get_widget (content);
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (widget)
Packit Service fb6fa5
	result = g_list_prepend (result, widget);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  result = g_list_prepend (result, priv->arrow_button);
Packit Service fb6fa5
  
Packit Service fb6fa5
  rtl = (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_RTL);
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* move in logical order when
Packit Service fb6fa5
   *
Packit Service fb6fa5
   *	- dir is TAB_FORWARD
Packit Service fb6fa5
   *
Packit Service fb6fa5
   *	- in RTL mode and moving left or up
Packit Service fb6fa5
   *
Packit Service fb6fa5
   *    - in LTR mode and moving right or down
Packit Service fb6fa5
   */
Packit Service fb6fa5
  if (dir == GTK_DIR_TAB_FORWARD                                        ||
Packit Service fb6fa5
      (rtl  && (dir == GTK_DIR_UP   || dir == GTK_DIR_LEFT))		||
Packit Service fb6fa5
      (!rtl && (dir == GTK_DIR_DOWN || dir == GTK_DIR_RIGHT)))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      result = g_list_reverse (result);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  return result;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gboolean
Packit Service fb6fa5
gtk_toolbar_focus_home_or_end (GtkToolbar *toolbar,
Packit Service fb6fa5
			       gboolean    focus_home)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GList *children, *list;
Packit Service fb6fa5
  GtkDirectionType dir = focus_home? GTK_DIR_RIGHT : GTK_DIR_LEFT;
Packit Service fb6fa5
  
Packit Service fb6fa5
  children = gtk_toolbar_list_children_in_focus_order (toolbar, dir);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_RTL)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      children = g_list_reverse (children);
Packit Service fb6fa5
      
Packit Service fb6fa5
      dir = (dir == GTK_DIR_RIGHT)? GTK_DIR_LEFT : GTK_DIR_RIGHT;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  for (list = children; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GtkWidget *child = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (GTK_CONTAINER (toolbar)->focus_child == child)
Packit Service fb6fa5
	break;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (gtk_widget_get_mapped (child) && gtk_widget_child_focus (child, dir))
Packit Service fb6fa5
	break;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_list_free (children);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return TRUE;
Packit Service fb6fa5
}   
Packit Service fb6fa5
Packit Service fb6fa5
/* Keybinding handler. This function is called when the user presses
Packit Service fb6fa5
 * Ctrl TAB or an arrow key.
Packit Service fb6fa5
 */
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_move_focus (GtkWidget        *widget,
Packit Service fb6fa5
			GtkDirectionType  dir)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (widget);
Packit Service fb6fa5
  GtkContainer *container = GTK_CONTAINER (toolbar);
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  gboolean try_focus = FALSE;
Packit Service fb6fa5
  GList *children;
Packit Service fb6fa5
Packit Service fb6fa5
  if (container->focus_child &&
Packit Service fb6fa5
      gtk_widget_child_focus (container->focus_child, dir))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      return;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  children = gtk_toolbar_list_children_in_focus_order (toolbar, dir);
Packit Service fb6fa5
  
Packit Service fb6fa5
  for (list = children; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GtkWidget *child = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (try_focus && gtk_widget_get_mapped (child) && gtk_widget_child_focus (child, dir))
Packit Service fb6fa5
	break;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (child == GTK_CONTAINER (toolbar)->focus_child)
Packit Service fb6fa5
	try_focus = TRUE;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_list_free (children);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/* The focus handler for the toolbar. It called when the user presses
Packit Service fb6fa5
 * TAB or otherwise tries to focus the toolbar.
Packit Service fb6fa5
 */
Packit Service fb6fa5
static gboolean
Packit Service fb6fa5
gtk_toolbar_focus (GtkWidget        *widget,
Packit Service fb6fa5
		   GtkDirectionType  dir)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (widget);
Packit Service fb6fa5
  GList *children, *list;
Packit Service fb6fa5
  gboolean result = FALSE;
Packit Service fb6fa5
Packit Service fb6fa5
  /* if focus is already somewhere inside the toolbar then return FALSE.
Packit Service fb6fa5
   * The only way focus can stay inside the toolbar is when the user presses
Packit Service fb6fa5
   * arrow keys or Ctrl TAB (both of which are handled by the
Packit Service fb6fa5
   * gtk_toolbar_move_focus() keybinding function.
Packit Service fb6fa5
   */
Packit Service fb6fa5
  if (GTK_CONTAINER (widget)->focus_child)
Packit Service fb6fa5
    return FALSE;
Packit Service fb6fa5
Packit Service fb6fa5
  children = gtk_toolbar_list_children_in_focus_order (toolbar, dir);
Packit Service fb6fa5
Packit Service fb6fa5
  for (list = children; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GtkWidget *child = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (gtk_widget_get_mapped (child) && gtk_widget_child_focus (child, dir))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  result = TRUE;
Packit Service fb6fa5
	  break;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  g_list_free (children);
Packit Service fb6fa5
Packit Service fb6fa5
  return result;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static GtkSettings *
Packit Service fb6fa5
toolbar_get_settings (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  return priv->settings;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
style_change_notify (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  if (!toolbar->style_set)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      /* pretend it was set, then unset, thus reverting to new default */
Packit Service fb6fa5
      toolbar->style_set = TRUE;
Packit Service fb6fa5
      gtk_toolbar_unset_style (toolbar);
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
icon_size_change_notify (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  if (!toolbar->icon_size_set)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      /* pretend it was set, then unset, thus reverting to new default */
Packit Service fb6fa5
      toolbar->icon_size_set = TRUE;
Packit Service fb6fa5
      gtk_toolbar_unset_icon_size (toolbar);
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
animation_change_notify (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  GtkSettings *settings = toolbar_get_settings (toolbar);
Packit Service fb6fa5
  gboolean animation;
Packit Service fb6fa5
Packit Service fb6fa5
  if (settings)
Packit Service fb6fa5
    g_object_get (settings,
Packit Service fb6fa5
                  "gtk-enable-animations", &animation,
Packit Service fb6fa5
                  NULL);
Packit Service fb6fa5
  else
Packit Service fb6fa5
    animation = DEFAULT_ANIMATION_STATE;
Packit Service fb6fa5
Packit Service fb6fa5
  priv->animation = animation;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
settings_change_notify (GtkSettings      *settings,
Packit Service fb6fa5
                        const GParamSpec *pspec,
Packit Service fb6fa5
                        GtkToolbar       *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  if (! strcmp (pspec->name, "gtk-toolbar-style"))
Packit Service fb6fa5
    style_change_notify (toolbar);
Packit Service fb6fa5
  else if (! strcmp (pspec->name, "gtk-toolbar-icon-size"))
Packit Service fb6fa5
    icon_size_change_notify (toolbar);
Packit Service fb6fa5
  else if (! strcmp (pspec->name, "gtk-enable-animations"))
Packit Service fb6fa5
    animation_change_notify (toolbar);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_screen_changed (GtkWidget *widget,
Packit Service fb6fa5
			    GdkScreen *previous_screen)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (widget);
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (widget);
Packit Service fb6fa5
  GtkSettings *old_settings = toolbar_get_settings (toolbar);
Packit Service fb6fa5
  GtkSettings *settings;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (gtk_widget_has_screen (GTK_WIDGET (toolbar)))
Packit Service fb6fa5
    settings = gtk_widget_get_settings (GTK_WIDGET (toolbar));
Packit Service fb6fa5
  else
Packit Service fb6fa5
    settings = NULL;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (settings == old_settings)
Packit Service fb6fa5
    return;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (old_settings)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      g_signal_handler_disconnect (old_settings, priv->settings_connection);
Packit Service fb6fa5
Packit Service fb6fa5
      g_object_unref (old_settings);
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  if (settings)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      priv->settings_connection =
Packit Service fb6fa5
	g_signal_connect (settings, "notify",
Packit Service fb6fa5
                          G_CALLBACK (settings_change_notify),
Packit Service fb6fa5
                          toolbar);
Packit Service fb6fa5
Packit Service fb6fa5
      priv->settings = g_object_ref (settings);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    priv->settings = NULL;
Packit Service fb6fa5
Packit Service fb6fa5
  style_change_notify (toolbar);
Packit Service fb6fa5
  icon_size_change_notify (toolbar);
Packit Service fb6fa5
  animation_change_notify (toolbar);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static int
Packit Service fb6fa5
find_drop_index (GtkToolbar *toolbar,
Packit Service fb6fa5
		 gint        x,
Packit Service fb6fa5
		 gint        y)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  GList *interesting_content;
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  GtkOrientation orientation;
Packit Service fb6fa5
  GtkTextDirection direction;
Packit Service fb6fa5
  gint best_distance = G_MAXINT;
Packit Service fb6fa5
  gint distance;
Packit Service fb6fa5
  gint cursor;
Packit Service fb6fa5
  gint pos;
Packit Service fb6fa5
  ToolbarContent *best_content;
Packit Service fb6fa5
  GtkAllocation allocation;
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* list items we care about wrt. drag and drop */
Packit Service fb6fa5
  interesting_content = NULL;
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (toolbar_content_get_state (content) == NORMAL)
Packit Service fb6fa5
	interesting_content = g_list_prepend (interesting_content, content);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  interesting_content = g_list_reverse (interesting_content);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (!interesting_content)
Packit Service fb6fa5
    return 0;
Packit Service fb6fa5
  
Packit Service fb6fa5
  orientation = toolbar->orientation;
Packit Service fb6fa5
  direction = gtk_widget_get_direction (GTK_WIDGET (toolbar));
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* distance to first interesting item */
Packit Service fb6fa5
  best_content = interesting_content->data;
Packit Service fb6fa5
  toolbar_content_get_allocation (best_content, &allocation);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (orientation == GTK_ORIENTATION_HORIZONTAL)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      cursor = x;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (direction == GTK_TEXT_DIR_LTR)
Packit Service fb6fa5
	pos = allocation.x;
Packit Service fb6fa5
      else
Packit Service fb6fa5
	pos = allocation.x + allocation.width;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      cursor = y;
Packit Service fb6fa5
      pos = allocation.y;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  best_content = NULL;
Packit Service fb6fa5
  best_distance = ABS (pos - cursor);
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* distance to far end of each item */
Packit Service fb6fa5
  for (list = interesting_content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      toolbar_content_get_allocation (content, &allocation);
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (orientation == GTK_ORIENTATION_HORIZONTAL)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  if (direction == GTK_TEXT_DIR_LTR)
Packit Service fb6fa5
	    pos = allocation.x + allocation.width;
Packit Service fb6fa5
	  else
Packit Service fb6fa5
	    pos = allocation.x;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  pos = allocation.y + allocation.height;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      distance = ABS (pos - cursor);
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (distance < best_distance)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  best_distance = distance;
Packit Service fb6fa5
	  best_content = content;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_list_free (interesting_content);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (!best_content)
Packit Service fb6fa5
    return 0;
Packit Service fb6fa5
  else
Packit Service fb6fa5
    return g_list_index (priv->content, best_content) + 1;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
reset_all_placeholders (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      if (toolbar_content_is_placeholder (content))
Packit Service fb6fa5
	toolbar_content_set_disappearing (content, TRUE);
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gint
Packit Service fb6fa5
physical_to_logical (GtkToolbar *toolbar,
Packit Service fb6fa5
		     gint        physical)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  int logical;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_assert (physical >= 0);
Packit Service fb6fa5
  
Packit Service fb6fa5
  logical = 0;
Packit Service fb6fa5
  for (list = priv->content; list && physical > 0; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (!toolbar_content_is_placeholder (content))
Packit Service fb6fa5
	logical++;
Packit Service fb6fa5
      physical--;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_assert (physical == 0);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return logical;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gint
Packit Service fb6fa5
logical_to_physical (GtkToolbar *toolbar,
Packit Service fb6fa5
		     gint        logical)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  gint physical;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_assert (logical >= 0);
Packit Service fb6fa5
  
Packit Service fb6fa5
  physical = 0;
Packit Service fb6fa5
  for (list = priv->content; list; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (!toolbar_content_is_placeholder (content))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  if (logical == 0)
Packit Service fb6fa5
	    break;
Packit Service fb6fa5
	  logical--;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      physical++;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_assert (logical == 0);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return physical;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_set_drop_highlight_item:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 * @tool_item: (allow-none): a #GtkToolItem, or %NULL to turn of highlighting
Packit Service fb6fa5
 * @index_: a position on @toolbar
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Highlights @toolbar to give an idea of what it would look like
Packit Service fb6fa5
 * if @item was added to @toolbar at the position indicated by @index_.
Packit Service fb6fa5
 * If @item is %NULL, highlighting is turned off. In that case @index_ 
Packit Service fb6fa5
 * is ignored.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * The @tool_item passed to this function must not be part of any widget
Packit Service fb6fa5
 * hierarchy. When an item is set as drop highlight item it can not
Packit Service fb6fa5
 * added to any widget hierarchy or used as highlight item for another
Packit Service fb6fa5
 * toolbar.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Since: 2.4
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_toolbar_set_drop_highlight_item (GtkToolbar  *toolbar,
Packit Service fb6fa5
				     GtkToolItem *tool_item,
Packit Service fb6fa5
				     gint         index_)
Packit Service fb6fa5
{
Packit Service fb6fa5
  ToolbarContent *content;
Packit Service fb6fa5
  GtkToolbarPrivate *priv;
Packit Service fb6fa5
  gint n_items;
Packit Service fb6fa5
  GtkRequisition requisition;
Packit Service fb6fa5
  GtkRequisition old_requisition;
Packit Service fb6fa5
  gboolean restart_sliding;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
Packit Service fb6fa5
  g_return_if_fail (tool_item == NULL || GTK_IS_TOOL_ITEM (tool_item));
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_toolbar_check_new_api (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (!tool_item)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (priv->highlight_tool_item)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  gtk_widget_unparent (GTK_WIDGET (priv->highlight_tool_item));
Packit Service fb6fa5
	  g_object_unref (priv->highlight_tool_item);
Packit Service fb6fa5
	  priv->highlight_tool_item = NULL;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      reset_all_placeholders (toolbar);
Packit Service fb6fa5
      gtk_toolbar_begin_sliding (toolbar);
Packit Service fb6fa5
      return;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  n_items = gtk_toolbar_get_n_items (toolbar);
Packit Service fb6fa5
  if (index_ < 0 || index_ > n_items)
Packit Service fb6fa5
    index_ = n_items;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (tool_item != priv->highlight_tool_item)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (priv->highlight_tool_item)
Packit Service fb6fa5
	g_object_unref (priv->highlight_tool_item);
Packit Service fb6fa5
      
Packit Service fb6fa5
      g_object_ref_sink (tool_item);
Packit Service fb6fa5
      
Packit Service fb6fa5
      priv->highlight_tool_item = tool_item;
Packit Service fb6fa5
      
Packit Service fb6fa5
      gtk_widget_set_parent (GTK_WIDGET (priv->highlight_tool_item),
Packit Service fb6fa5
			     GTK_WIDGET (toolbar));
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  index_ = logical_to_physical (toolbar, index_);
Packit Service fb6fa5
  
Packit Service fb6fa5
  content = g_list_nth_data (priv->content, index_);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (index_ > 0)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *prev_content;
Packit Service fb6fa5
      
Packit Service fb6fa5
      prev_content = g_list_nth_data (priv->content, index_ - 1);
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (prev_content && toolbar_content_is_placeholder (prev_content))
Packit Service fb6fa5
	content = prev_content;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (!content || !toolbar_content_is_placeholder (content))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GtkWidget *placeholder;
Packit Service fb6fa5
      
Packit Service fb6fa5
      placeholder = GTK_WIDGET (gtk_separator_tool_item_new ());
Packit Service fb6fa5
Packit Service fb6fa5
      content = toolbar_content_new_tool_item (toolbar,
Packit Service fb6fa5
					       GTK_TOOL_ITEM (placeholder),
Packit Service fb6fa5
					       TRUE, index_);
Packit Service fb6fa5
      gtk_widget_show (placeholder);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_assert (content);
Packit Service fb6fa5
  g_assert (toolbar_content_is_placeholder (content));
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_widget_size_request (GTK_WIDGET (priv->highlight_tool_item),
Packit Service fb6fa5
			   &requisition);
Packit Service fb6fa5
Packit Service fb6fa5
  toolbar_content_set_expand (content, gtk_tool_item_get_expand (tool_item));
Packit Service fb6fa5
  
Packit Service fb6fa5
  restart_sliding = FALSE;
Packit Service fb6fa5
  toolbar_content_size_request (content, toolbar, &old_requisition);
Packit Service fb6fa5
  if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      requisition.height = -1;
Packit Service fb6fa5
      if (requisition.width != old_requisition.width)
Packit Service fb6fa5
	restart_sliding = TRUE;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      requisition.width = -1;
Packit Service fb6fa5
      if (requisition.height != old_requisition.height)
Packit Service fb6fa5
	restart_sliding = TRUE;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  if (toolbar_content_disappearing (content))
Packit Service fb6fa5
    restart_sliding = TRUE;
Packit Service fb6fa5
  
Packit Service fb6fa5
  reset_all_placeholders (toolbar);
Packit Service fb6fa5
  toolbar_content_set_disappearing (content, FALSE);
Packit Service fb6fa5
  
Packit Service fb6fa5
  toolbar_content_set_size_request (content,
Packit Service fb6fa5
				    requisition.width, requisition.height);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (restart_sliding)
Packit Service fb6fa5
    gtk_toolbar_begin_sliding (toolbar);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_get_child_property (GtkContainer *container,
Packit Service fb6fa5
				GtkWidget    *child,
Packit Service fb6fa5
				guint         property_id,
Packit Service fb6fa5
				GValue       *value,
Packit Service fb6fa5
				GParamSpec   *pspec)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolItem *item = GTK_TOOL_ITEM (child);
Packit Service fb6fa5
  
Packit Service fb6fa5
  switch (property_id)
Packit Service fb6fa5
    {
Packit Service fb6fa5
    case CHILD_PROP_HOMOGENEOUS:
Packit Service fb6fa5
      g_value_set_boolean (value, gtk_tool_item_get_homogeneous (item));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
      
Packit Service fb6fa5
    case CHILD_PROP_EXPAND:
Packit Service fb6fa5
      g_value_set_boolean (value, gtk_tool_item_get_expand (item));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
      
Packit Service fb6fa5
    default:
Packit Service fb6fa5
      GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_set_child_property (GtkContainer *container,
Packit Service fb6fa5
				GtkWidget    *child,
Packit Service fb6fa5
				guint         property_id,
Packit Service fb6fa5
				const GValue *value,
Packit Service fb6fa5
				GParamSpec   *pspec)
Packit Service fb6fa5
{
Packit Service fb6fa5
  switch (property_id)
Packit Service fb6fa5
    {
Packit Service fb6fa5
    case CHILD_PROP_HOMOGENEOUS:
Packit Service fb6fa5
      gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (child), g_value_get_boolean (value));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
      
Packit Service fb6fa5
    case CHILD_PROP_EXPAND:
Packit Service fb6fa5
      gtk_tool_item_set_expand (GTK_TOOL_ITEM (child), g_value_get_boolean (value));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
      
Packit Service fb6fa5
    default:
Packit Service fb6fa5
      GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_show_all (GtkWidget *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (widget);
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      toolbar_content_show_all (content);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_widget_show (widget);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_hide_all (GtkWidget *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (widget);
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      
Packit Service fb6fa5
      toolbar_content_hide_all (content);
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_widget_hide (widget);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_add (GtkContainer *container,
Packit Service fb6fa5
		 GtkWidget    *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (container);
Packit Service fb6fa5
Packit Service fb6fa5
  if (GTK_IS_TOOL_ITEM (widget))
Packit Service fb6fa5
    gtk_toolbar_insert (toolbar, GTK_TOOL_ITEM (widget), -1);
Packit Service fb6fa5
  else
Packit Service fb6fa5
    gtk_toolbar_append_widget (toolbar, widget, NULL, NULL);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_remove (GtkContainer *container,
Packit Service fb6fa5
		    GtkWidget    *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (container);
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  ToolbarContent *content_to_remove;
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
Packit Service fb6fa5
  content_to_remove = NULL;
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      GtkWidget *child;
Packit Service fb6fa5
      
Packit Service fb6fa5
      child = toolbar_content_get_widget (content);
Packit Service fb6fa5
      if (child && child == widget)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  content_to_remove = content;
Packit Service fb6fa5
	  break;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_if_fail (content_to_remove != NULL);
Packit Service fb6fa5
  
Packit Service fb6fa5
  toolbar_content_remove (content_to_remove, toolbar);
Packit Service fb6fa5
  toolbar_content_free (content_to_remove);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_forall (GtkContainer *container,
Packit Service fb6fa5
		    gboolean	  include_internals,
Packit Service fb6fa5
		    GtkCallback   callback,
Packit Service fb6fa5
		    gpointer      callback_data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (container);
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_if_fail (callback != NULL);
Packit Service fb6fa5
  
Packit Service fb6fa5
  list = priv->content;
Packit Service fb6fa5
  while (list)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      GList *next = list->next;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (include_internals || !toolbar_content_is_placeholder (content))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  GtkWidget *child = toolbar_content_get_widget (content);
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (child)
Packit Service fb6fa5
	    callback (child, callback_data);
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      list = next;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (include_internals && priv->arrow_button)
Packit Service fb6fa5
    callback (priv->arrow_button, callback_data);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static GType
Packit Service fb6fa5
gtk_toolbar_child_type (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  return GTK_TYPE_TOOL_ITEM;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_reconfigured (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  
Packit Service fb6fa5
  list = priv->content;
Packit Service fb6fa5
  while (list)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      GList *next = list->next;
Packit Service fb6fa5
      
Packit Service fb6fa5
      toolbar_content_toolbar_reconfigured (content, toolbar);
Packit Service fb6fa5
      
Packit Service fb6fa5
      list = next;
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_orientation_changed (GtkToolbar    *toolbar,
Packit Service fb6fa5
				 GtkOrientation orientation)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  if (toolbar->orientation != orientation)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      toolbar->orientation = orientation;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (orientation == GTK_ORIENTATION_HORIZONTAL)
Packit Service fb6fa5
	gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_DOWN, GTK_SHADOW_NONE);
Packit Service fb6fa5
      else
Packit Service fb6fa5
	gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
Packit Service fb6fa5
      
Packit Service fb6fa5
      gtk_toolbar_reconfigured (toolbar);
Packit Service fb6fa5
      
Packit Service fb6fa5
      gtk_widget_queue_resize (GTK_WIDGET (toolbar));
Packit Service fb6fa5
      g_object_notify (G_OBJECT (toolbar), "orientation");
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_real_style_changed (GtkToolbar     *toolbar,
Packit Service fb6fa5
				GtkToolbarStyle style)
Packit Service fb6fa5
{
Packit Service fb6fa5
  if (toolbar->style != style)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      toolbar->style = style;
Packit Service fb6fa5
      
Packit Service fb6fa5
      gtk_toolbar_reconfigured (toolbar);
Packit Service fb6fa5
      
Packit Service fb6fa5
      gtk_widget_queue_resize (GTK_WIDGET (toolbar));
Packit Service fb6fa5
      g_object_notify (G_OBJECT (toolbar), "toolbar-style");
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
menu_position_func (GtkMenu  *menu,
Packit Service fb6fa5
		    gint     *x,
Packit Service fb6fa5
		    gint     *y,
Packit Service fb6fa5
		    gboolean *push_in,
Packit Service fb6fa5
		    gpointer  user_data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (user_data);
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  GtkRequisition req;
Packit Service fb6fa5
  GtkRequisition menu_req;
Packit Service fb6fa5
  GdkRectangle monitor;
Packit Service fb6fa5
  gint monitor_num;
Packit Service fb6fa5
  GdkScreen *screen;
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_widget_size_request (priv->arrow_button, &req;;
Packit Service fb6fa5
  gtk_widget_size_request (GTK_WIDGET (menu), &menu_req);
Packit Service fb6fa5
  
Packit Service fb6fa5
  screen = gtk_widget_get_screen (GTK_WIDGET (menu));
Packit Service fb6fa5
  monitor_num = gdk_screen_get_monitor_at_window (screen, priv->arrow_button->window);
Packit Service fb6fa5
  if (monitor_num < 0)
Packit Service fb6fa5
    monitor_num = 0;
Packit Service fb6fa5
  gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
Packit Service fb6fa5
Packit Service fb6fa5
  gdk_window_get_origin (GTK_BUTTON (priv->arrow_button)->event_window, x, y);
Packit Service fb6fa5
  if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR) 
Packit Service fb6fa5
	*x += priv->arrow_button->allocation.width - req.width;
Packit Service fb6fa5
      else 
Packit Service fb6fa5
	*x += req.width - menu_req.width;
Packit Service fb6fa5
Packit Service fb6fa5
      if ((*y + priv->arrow_button->allocation.height + menu_req.height) <= monitor.y + monitor.height)
Packit Service fb6fa5
	*y += priv->arrow_button->allocation.height;
Packit Service fb6fa5
      else if ((*y - menu_req.height) >= monitor.y)
Packit Service fb6fa5
	*y -= menu_req.height;
Packit Service fb6fa5
      else if (monitor.y + monitor.height - (*y + priv->arrow_button->allocation.height) > *y)
Packit Service fb6fa5
	*y += priv->arrow_button->allocation.height;
Packit Service fb6fa5
      else
Packit Service fb6fa5
	*y -= menu_req.height;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else 
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR) 
Packit Service fb6fa5
	*x += priv->arrow_button->allocation.width;
Packit Service fb6fa5
      else 
Packit Service fb6fa5
	*x -= menu_req.width;
Packit Service fb6fa5
Packit Service fb6fa5
      if (*y + menu_req.height > monitor.y + monitor.height &&
Packit Service fb6fa5
	  *y + priv->arrow_button->allocation.height - monitor.y > monitor.y + monitor.height - *y)
Packit Service fb6fa5
	*y += priv->arrow_button->allocation.height - menu_req.height;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  *push_in = FALSE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
show_menu (GtkToolbar     *toolbar,
Packit Service fb6fa5
	   GdkEventButton *event)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
Packit Service fb6fa5
  rebuild_menu (toolbar);
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_widget_show_all (GTK_WIDGET (priv->menu));
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_menu_popup (priv->menu, NULL, NULL,
Packit Service fb6fa5
		  menu_position_func, toolbar,
Packit Service fb6fa5
		  event? event->button : 0,
Packit Service fb6fa5
		  event? event->time : gtk_get_current_event_time());
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_arrow_button_clicked (GtkWidget  *button,
Packit Service fb6fa5
				  GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);  
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->arrow_button)) &&
Packit Service fb6fa5
      (!priv->menu || !gtk_widget_get_visible (GTK_WIDGET (priv->menu))))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      /* We only get here when the button is clicked with the keyboard,
Packit Service fb6fa5
       * because mouse button presses result in the menu being shown so
Packit Service fb6fa5
       * that priv->menu would be non-NULL and visible.
Packit Service fb6fa5
       */
Packit Service fb6fa5
      show_menu (toolbar, NULL);
Packit Service fb6fa5
      gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE);
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gboolean
Packit Service fb6fa5
gtk_toolbar_arrow_button_press (GtkWidget      *button,
Packit Service fb6fa5
				GdkEventButton *event,
Packit Service fb6fa5
				GtkToolbar     *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  show_menu (toolbar, event);
Packit Service fb6fa5
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return TRUE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gboolean
Packit Service fb6fa5
gtk_toolbar_button_press (GtkWidget      *toolbar,
Packit Service fb6fa5
    			  GdkEventButton *event)
Packit Service fb6fa5
{
Packit Service 47ab3b
  GtkWidget *window;
Packit Service 47ab3b
Packit Service fb6fa5
  if (_gtk_button_event_triggers_context_menu (event))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gboolean return_value;
Packit Service fb6fa5
      
Packit Service fb6fa5
      g_signal_emit (toolbar, toolbar_signals[POPUP_CONTEXT_MENU], 0,
Packit Service fb6fa5
		     (int)event->x_root, (int)event->y_root, event->button,
Packit Service fb6fa5
		     &return_value);
Packit Service fb6fa5
      
Packit Service fb6fa5
      return return_value;
Packit Service fb6fa5
    }
Packit Service 47ab3b
Packit Service 47ab3b
  window = gtk_widget_get_toplevel (toolbar);
Packit Service 47ab3b
Packit Service 47ab3b
  if (window)
Packit Service 47ab3b
    {
Packit Service 47ab3b
      gboolean window_drag = FALSE;
Packit Service 47ab3b
Packit Service 47ab3b
      gtk_widget_style_get (toolbar,
Packit Service 47ab3b
                            "window-dragging", &window_drag,
Packit Service 47ab3b
                            NULL);
Packit Service 47ab3b
Packit Service 47ab3b
      if (window_drag)
Packit Service 47ab3b
        {
Packit Service 47ab3b
          gtk_window_begin_move_drag (GTK_WINDOW (window),
Packit Service 47ab3b
                                      event->button,
Packit Service 47ab3b
                                      event->x_root,
Packit Service 47ab3b
                                      event->y_root,
Packit Service 47ab3b
                                      event->time);
Packit Service 47ab3b
Packit Service 47ab3b
          return TRUE;
Packit Service 47ab3b
        }
Packit Service 47ab3b
    }
Packit Service 47ab3b
Packit Service fb6fa5
  return FALSE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gboolean
Packit Service fb6fa5
gtk_toolbar_popup_menu (GtkWidget *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  gboolean return_value;
Packit Service fb6fa5
  /* This function is the handler for the "popup menu" keybinding,
Packit Service fb6fa5
   * ie., it is called when the user presses Shift F10
Packit Service fb6fa5
   */
Packit Service fb6fa5
  g_signal_emit (toolbar, toolbar_signals[POPUP_CONTEXT_MENU], 0,
Packit Service fb6fa5
		 -1, -1, -1, &return_value);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return return_value;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_new:
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Creates a new toolbar. 
Packit Service fb6fa5
 
Packit Service fb6fa5
 * Return Value: the newly-created toolbar.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
GtkWidget *
Packit Service fb6fa5
gtk_toolbar_new (void)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar;
Packit Service fb6fa5
  
Packit Service fb6fa5
  toolbar = g_object_new (GTK_TYPE_TOOLBAR, NULL);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return GTK_WIDGET (toolbar);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_insert:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 * @item: a #GtkToolItem
Packit Service fb6fa5
 * @pos: the position of the new item
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Insert a #GtkToolItem into the toolbar at position @pos. If @pos is
Packit Service fb6fa5
 * 0 the item is prepended to the start of the toolbar. If @pos is
Packit Service fb6fa5
 * negative, the item is appended to the end of the toolbar.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Since: 2.4
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_toolbar_insert (GtkToolbar  *toolbar,
Packit Service fb6fa5
		    GtkToolItem *item,
Packit Service fb6fa5
		    gint         pos)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TOOL_ITEM (item));
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (!gtk_toolbar_check_new_api (toolbar))
Packit Service fb6fa5
    return;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (pos >= 0)
Packit Service fb6fa5
    pos = logical_to_physical (toolbar, pos);
Packit Service fb6fa5
Packit Service fb6fa5
  toolbar_content_new_tool_item (toolbar, item, FALSE, pos);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_get_item_index:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 * @item: a #GtkToolItem that is a child of @toolbar
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Returns the position of @item on the toolbar, starting from 0.
Packit Service fb6fa5
 * It is an error if @item is not a child of the toolbar.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Return value: the position of item on the toolbar.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Since: 2.4
Packit Service fb6fa5
 **/
Packit Service fb6fa5
gint
Packit Service fb6fa5
gtk_toolbar_get_item_index (GtkToolbar  *toolbar,
Packit Service fb6fa5
			    GtkToolItem *item)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv;
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  int n;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), -1);
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TOOL_ITEM (item), -1);
Packit Service fb6fa5
  g_return_val_if_fail (GTK_WIDGET (item)->parent == GTK_WIDGET (toolbar), -1);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (!gtk_toolbar_check_new_api (toolbar))
Packit Service fb6fa5
    return -1;
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  n = 0;
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
      GtkWidget *widget;
Packit Service fb6fa5
      
Packit Service fb6fa5
      widget = toolbar_content_get_widget (content);
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (item == GTK_TOOL_ITEM (widget))
Packit Service fb6fa5
	break;
Packit Service fb6fa5
      
Packit Service fb6fa5
      ++n;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  return physical_to_logical (toolbar, n);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_set_orientation:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar.
Packit Service fb6fa5
 * @orientation: a new #GtkOrientation.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Sets whether a toolbar should appear horizontally or vertically.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Deprecated: 2.16: Use gtk_orientable_set_orientation() instead.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_toolbar_set_orientation (GtkToolbar     *toolbar,
Packit Service fb6fa5
			     GtkOrientation  orientation)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_signal_emit (toolbar, toolbar_signals[ORIENTATION_CHANGED], 0, orientation);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_get_orientation:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Retrieves the current orientation of the toolbar. See
Packit Service fb6fa5
 * gtk_toolbar_set_orientation().
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: the orientation
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Deprecated: 2.16: Use gtk_orientable_get_orientation() instead.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
GtkOrientation
Packit Service fb6fa5
gtk_toolbar_get_orientation (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), GTK_ORIENTATION_HORIZONTAL);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return toolbar->orientation;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_set_style:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar.
Packit Service fb6fa5
 * @style: the new style for @toolbar.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Alters the view of @toolbar to display either icons only, text only, or both.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_toolbar_set_style (GtkToolbar      *toolbar,
Packit Service fb6fa5
		       GtkToolbarStyle  style)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
Packit Service fb6fa5
  
Packit Service fb6fa5
  toolbar->style_set = TRUE;  
Packit Service fb6fa5
  g_signal_emit (toolbar, toolbar_signals[STYLE_CHANGED], 0, style);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_get_style:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Retrieves whether the toolbar has text, icons, or both . See
Packit Service fb6fa5
 * gtk_toolbar_set_style().
Packit Service fb6fa5
 
Packit Service fb6fa5
 * Return value: the current style of @toolbar
Packit Service fb6fa5
 **/
Packit Service fb6fa5
GtkToolbarStyle
Packit Service fb6fa5
gtk_toolbar_get_style (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), DEFAULT_TOOLBAR_STYLE);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return toolbar->style;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_unset_style:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Unsets a toolbar style set with gtk_toolbar_set_style(), so that
Packit Service fb6fa5
 * user preferences will be used to determine the toolbar style.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_toolbar_unset_style (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarStyle style;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (toolbar->style_set)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GtkSettings *settings = toolbar_get_settings (toolbar);
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (settings)
Packit Service fb6fa5
	g_object_get (settings,
Packit Service fb6fa5
		      "gtk-toolbar-style", &style,
Packit Service fb6fa5
		      NULL);
Packit Service fb6fa5
      else
Packit Service fb6fa5
	style = DEFAULT_TOOLBAR_STYLE;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (style != toolbar->style)
Packit Service fb6fa5
	g_signal_emit (toolbar, toolbar_signals[STYLE_CHANGED], 0, style);
Packit Service fb6fa5
      
Packit Service fb6fa5
      toolbar->style_set = FALSE;
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_set_tooltips:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar.
Packit Service fb6fa5
 * @enable: set to %FALSE to disable the tooltips, or %TRUE to enable them.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Sets if the tooltips of a toolbar should be active or not.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Deprecated: 2.14: The toolkit-wide #GtkSettings:gtk-enable-tooltips property
Packit Service fb6fa5
 * is now used instead.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_toolbar_set_tooltips (GtkToolbar *toolbar,
Packit Service fb6fa5
			  gboolean    enable)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (enable)
Packit Service fb6fa5
    gtk_tooltips_enable (toolbar->tooltips);
Packit Service fb6fa5
  else
Packit Service fb6fa5
    gtk_tooltips_disable (toolbar->tooltips);
Packit Service fb6fa5
Packit Service fb6fa5
  g_object_notify (G_OBJECT (toolbar), "tooltips");
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_get_tooltips:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Retrieves whether tooltips are enabled. See
Packit Service fb6fa5
 * gtk_toolbar_set_tooltips().
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: %TRUE if tooltips are enabled
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Deprecated: 2.14: The toolkit-wide #GtkSettings:gtk-enable-tooltips property
Packit Service fb6fa5
 * is now used instead.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
gboolean
Packit Service fb6fa5
gtk_toolbar_get_tooltips (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), FALSE);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return TRUE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_get_n_items:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Returns the number of items on the toolbar.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Return value: the number of items on the toolbar
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Since: 2.4
Packit Service fb6fa5
 **/
Packit Service fb6fa5
gint
Packit Service fb6fa5
gtk_toolbar_get_n_items (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), -1);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (!gtk_toolbar_check_new_api (toolbar))
Packit Service fb6fa5
    return -1;
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return physical_to_logical (toolbar, g_list_length (priv->content));
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_get_nth_item:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 * @n: A position on the toolbar
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Returns the @n'th item on @toolbar, or %NULL if the
Packit Service fb6fa5
 * toolbar does not contain an @n'th item.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: (transfer none): The @n'th #GtkToolItem on @toolbar,
Packit Service fb6fa5
 *     or %NULL if there isn't an @n'th item.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Since: 2.4
Packit Service fb6fa5
 **/
Packit Service fb6fa5
GtkToolItem *
Packit Service fb6fa5
gtk_toolbar_get_nth_item (GtkToolbar *toolbar,
Packit Service fb6fa5
			  gint        n)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv;
Packit Service fb6fa5
  ToolbarContent *content;
Packit Service fb6fa5
  gint n_items;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), NULL);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (!gtk_toolbar_check_new_api (toolbar))
Packit Service fb6fa5
    return NULL;
Packit Service fb6fa5
  
Packit Service fb6fa5
  n_items = gtk_toolbar_get_n_items (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (n < 0 || n >= n_items)
Packit Service fb6fa5
    return NULL;
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  content = g_list_nth_data (priv->content, logical_to_physical (toolbar, n));
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_assert (content);
Packit Service fb6fa5
  g_assert (!toolbar_content_is_placeholder (content));
Packit Service fb6fa5
  
Packit Service fb6fa5
  return GTK_TOOL_ITEM (toolbar_content_get_widget (content));
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_get_icon_size:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Retrieves the icon size for the toolbar. See gtk_toolbar_set_icon_size().
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: (type int): the current icon size for the icons on
Packit Service fb6fa5
 * the toolbar.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
GtkIconSize
Packit Service fb6fa5
gtk_toolbar_get_icon_size (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), DEFAULT_ICON_SIZE);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return toolbar->icon_size;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_get_relief_style:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Returns the relief style of buttons on @toolbar. See
Packit Service fb6fa5
 * gtk_button_set_relief().
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Return value: The relief style of buttons on @toolbar.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Since: 2.4
Packit Service fb6fa5
 **/
Packit Service fb6fa5
GtkReliefStyle
Packit Service fb6fa5
gtk_toolbar_get_relief_style (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), GTK_RELIEF_NONE);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return get_button_relief (toolbar);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_set_show_arrow:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 * @show_arrow: Whether to show an overflow menu
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Sets whether to show an overflow menu when @toolbar isn’t allocated enough
Packit Service fb6fa5
 * size to show all of its items. If %TRUE, items which can’t fit in @toolbar,
Packit Service fb6fa5
 * and which have a proxy menu item set by gtk_tool_item_set_proxy_menu_item()
Packit Service fb6fa5
 * or #GtkToolItem::create-menu-proxy, will be available in an overflow menu,
Packit Service fb6fa5
 * which can be opened by an added arrow button. If %FALSE, @toolbar will
Packit Service fb6fa5
 * request enough size to fit all of its child items without any overflow.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Since: 2.4
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_toolbar_set_show_arrow (GtkToolbar *toolbar,
Packit Service fb6fa5
			    gboolean    show_arrow)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  show_arrow = show_arrow != FALSE;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (priv->show_arrow != show_arrow)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      priv->show_arrow = show_arrow;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (!priv->show_arrow)
Packit Service fb6fa5
	gtk_widget_hide (priv->arrow_button);
Packit Service fb6fa5
      
Packit Service fb6fa5
      gtk_widget_queue_resize (GTK_WIDGET (toolbar));      
Packit Service fb6fa5
      g_object_notify (G_OBJECT (toolbar), "show-arrow");
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_get_show_arrow:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Returns whether the toolbar has an overflow menu.
Packit Service fb6fa5
 * See gtk_toolbar_set_show_arrow().
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Return value: %TRUE if the toolbar has an overflow menu.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Since: 2.4
Packit Service fb6fa5
 **/
Packit Service fb6fa5
gboolean
Packit Service fb6fa5
gtk_toolbar_get_show_arrow (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbarPrivate *priv;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), FALSE);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (!gtk_toolbar_check_new_api (toolbar))
Packit Service fb6fa5
    return FALSE;
Packit Service fb6fa5
  
Packit Service fb6fa5
  priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return priv->show_arrow;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_get_drop_index:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 * @x: x coordinate of a point on the toolbar
Packit Service fb6fa5
 * @y: y coordinate of a point on the toolbar
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Returns the position corresponding to the indicated point on
Packit Service fb6fa5
 * @toolbar. This is useful when dragging items to the toolbar:
Packit Service fb6fa5
 * this function returns the position a new item should be
Packit Service fb6fa5
 * inserted.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * @x and @y are in @toolbar coordinates.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Return value: The position corresponding to the point (@x, @y) on the toolbar.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Since: 2.4
Packit Service fb6fa5
 **/
Packit Service fb6fa5
gint
Packit Service fb6fa5
gtk_toolbar_get_drop_index (GtkToolbar *toolbar,
Packit Service fb6fa5
			    gint        x,
Packit Service fb6fa5
			    gint        y)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), -1);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (!gtk_toolbar_check_new_api (toolbar))
Packit Service fb6fa5
    return -1;
Packit Service fb6fa5
  
Packit Service fb6fa5
  return physical_to_logical (toolbar, find_drop_index (toolbar, x, y));
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_dispose (GObject *object)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (object);
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
Packit Service fb6fa5
  if (priv->arrow_button)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gtk_widget_unparent (priv->arrow_button);
Packit Service fb6fa5
      priv->arrow_button = NULL;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  if (priv->menu)
Packit Service fb6fa5
    gtk_widget_destroy (GTK_WIDGET (priv->menu));
Packit Service fb6fa5
Packit Service fb6fa5
  G_OBJECT_CLASS (gtk_toolbar_parent_class)->dispose (object);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_toolbar_finalize (GObject *object)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
  GtkToolbar *toolbar = GTK_TOOLBAR (object);
Packit Service fb6fa5
  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (toolbar->tooltips)
Packit Service fb6fa5
    g_object_unref (toolbar->tooltips);
Packit Service fb6fa5
Packit Service fb6fa5
  for (list = priv->content; list != NULL; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      ToolbarContent *content = list->data;
Packit Service fb6fa5
Packit Service fb6fa5
      toolbar_content_free (content);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_list_free (priv->content);
Packit Service fb6fa5
  g_list_free (toolbar->children);
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_timer_destroy (priv->timer);
Packit Service fb6fa5
Packit Service fb6fa5
  if (priv->idle_id)
Packit Service fb6fa5
    g_source_remove (priv->idle_id);
Packit Service fb6fa5
Packit Service fb6fa5
  G_OBJECT_CLASS (gtk_toolbar_parent_class)->finalize (object);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_set_icon_size:
Packit Service fb6fa5
 * @toolbar: A #GtkToolbar
Packit Service fb6fa5
 * @icon_size: (type int): The #GtkIconSize that stock icons in the
Packit Service fb6fa5
 *     toolbar shall have.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * This function sets the size of stock icons in the toolbar. You
Packit Service fb6fa5
 * can call it both before you add the icons and after they've been
Packit Service fb6fa5
 * added. The size you set will override user preferences for the default
Packit Service fb6fa5
 * icon size.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * This should only be used for special-purpose toolbars, normal
Packit Service fb6fa5
 * application toolbars should respect the user preferences for the
Packit Service fb6fa5
 * size of icons.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_toolbar_set_icon_size (GtkToolbar  *toolbar,
Packit Service fb6fa5
			   GtkIconSize  icon_size)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
Packit Service fb6fa5
  g_return_if_fail (icon_size != GTK_ICON_SIZE_INVALID);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (!toolbar->icon_size_set)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      toolbar->icon_size_set = TRUE;  
Packit Service fb6fa5
      g_object_notify (G_OBJECT (toolbar), "icon-size-set");
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  if (toolbar->icon_size == icon_size)
Packit Service fb6fa5
    return;
Packit Service fb6fa5
  
Packit Service fb6fa5
  toolbar->icon_size = icon_size;
Packit Service fb6fa5
  g_object_notify (G_OBJECT (toolbar), "icon-size");
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_toolbar_reconfigured (toolbar);
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_widget_queue_resize (GTK_WIDGET (toolbar));
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_toolbar_unset_icon_size:
Packit Service fb6fa5
 * @toolbar: a #GtkToolbar
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Unsets toolbar icon size set with gtk_toolbar_set_icon_size(), so that
Packit Service fb6fa5
 * user preferences will be used to determine the icon size.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_toolbar_unset_icon_size (GtkToolbar *toolbar)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkIconSize size;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (toolbar->icon_size_set)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GtkSettings *settings = toolbar_get_settings (toolbar);
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (settings)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  g_object_get (settings,
Packit Service fb6fa5
			"gtk-toolbar-icon-size", &size,
Packit Service fb6fa5
			NULL);
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else
Packit Service fb6fa5
	size = DEFAULT_ICON_SIZE;
Packit Service fb6fa5