| File: | ctk/ctktoolpalette.c |
| Warning: | line 1596, column 10 Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* CtkToolPalette -- A tool palette with categories and DnD support |
| 2 | * Copyright (C) 2008 Openismus GmbH |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Lesser General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2.1 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public |
| 15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 | * |
| 17 | * Authors: |
| 18 | * Mathias Hasselmann |
| 19 | */ |
| 20 | |
| 21 | #include "config.h" |
| 22 | |
| 23 | #include <string.h> |
| 24 | #include <ctk/ctk.h> |
| 25 | |
| 26 | #include "ctktoolpaletteprivate.h" |
| 27 | #include "ctkmarshalers.h" |
| 28 | #include "ctktypebuiltins.h" |
| 29 | #include "ctkprivate.h" |
| 30 | #include "ctkscrollable.h" |
| 31 | #include "ctkorientableprivate.h" |
| 32 | #include "ctkintl.h" |
| 33 | |
| 34 | #define DEFAULT_ICON_SIZECTK_ICON_SIZE_SMALL_TOOLBAR CTK_ICON_SIZE_SMALL_TOOLBAR |
| 35 | #define DEFAULT_ORIENTATIONCTK_ORIENTATION_VERTICAL CTK_ORIENTATION_VERTICAL |
| 36 | #define DEFAULT_TOOLBAR_STYLECTK_TOOLBAR_ICONS CTK_TOOLBAR_ICONS |
| 37 | |
| 38 | #define DEFAULT_CHILD_EXCLUSIVE(0) FALSE(0) |
| 39 | #define DEFAULT_CHILD_EXPAND(0) FALSE(0) |
| 40 | |
| 41 | /** |
| 42 | * SECTION:ctktoolpalette |
| 43 | * @Short_description: A tool palette with categories |
| 44 | * @Title: CtkToolPalette |
| 45 | * |
| 46 | * A #CtkToolPalette allows you to add #CtkToolItems to a palette-like |
| 47 | * container with different categories and drag and drop support. |
| 48 | * |
| 49 | * A #CtkToolPalette is created with a call to ctk_tool_palette_new(). |
| 50 | * |
| 51 | * #CtkToolItems cannot be added directly to a #CtkToolPalette - |
| 52 | * instead they are added to a #CtkToolItemGroup which can than be added |
| 53 | * to a #CtkToolPalette. To add a #CtkToolItemGroup to a #CtkToolPalette, |
| 54 | * use ctk_container_add(). |
| 55 | * |
| 56 | * |[<!-- language="C" --> |
| 57 | * CtkWidget *palette, *group; |
| 58 | * CtkToolItem *item; |
| 59 | * |
| 60 | * palette = ctk_tool_palette_new (); |
| 61 | * group = ctk_tool_item_group_new (_("Test Category")); |
| 62 | * ctk_container_add (CTK_CONTAINER (palette), group); |
| 63 | * |
| 64 | * item = ctk_tool_button_new (NULL, _("_Open")); |
| 65 | * ctk_tool_button_set_icon_name (CTK_TOOL_BUTTON (item), "document-open"); |
| 66 | * ctk_tool_item_group_insert (CTK_TOOL_ITEM_GROUP (group), item, -1); |
| 67 | * ]| |
| 68 | * |
| 69 | * The easiest way to use drag and drop with #CtkToolPalette is to call |
| 70 | * ctk_tool_palette_add_drag_dest() with the desired drag source @palette |
| 71 | * and the desired drag target @widget. Then ctk_tool_palette_get_drag_item() |
| 72 | * can be used to get the dragged item in the #CtkWidget::drag-data-received |
| 73 | * signal handler of the drag target. |
| 74 | * |
| 75 | * |[<!-- language="C" --> |
| 76 | * static void |
| 77 | * passive_canvas_drag_data_received (CtkWidget *widget, |
| 78 | * CdkDragContext *context, |
| 79 | * gint x, |
| 80 | * gint y, |
| 81 | * CtkSelectionData *selection, |
| 82 | * guint info, |
| 83 | * guint time, |
| 84 | * gpointer data) |
| 85 | * { |
| 86 | * CtkWidget *palette; |
| 87 | * CtkWidget *item; |
| 88 | * |
| 89 | * // Get the dragged item |
| 90 | * palette = ctk_widget_get_ancestor (ctk_drag_get_source_widget (context), |
| 91 | * CTK_TYPE_TOOL_PALETTE); |
| 92 | * if (palette != NULL) |
| 93 | * item = ctk_tool_palette_get_drag_item (CTK_TOOL_PALETTE (palette), |
| 94 | * selection); |
| 95 | * |
| 96 | * // Do something with item |
| 97 | * } |
| 98 | * |
| 99 | * CtkWidget *target, palette; |
| 100 | * |
| 101 | * palette = ctk_tool_palette_new (); |
| 102 | * target = ctk_drawing_area_new (); |
| 103 | * |
| 104 | * g_signal_connect (G_OBJECT (target), "drag-data-received", |
| 105 | * G_CALLBACK (passive_canvas_drag_data_received), NULL); |
| 106 | * ctk_tool_palette_add_drag_dest (CTK_TOOL_PALETTE (palette), target, |
| 107 | * CTK_DEST_DEFAULT_ALL, |
| 108 | * CTK_TOOL_PALETTE_DRAG_ITEMS, |
| 109 | * CDK_ACTION_COPY); |
| 110 | * ]| |
| 111 | * |
| 112 | * # CSS nodes |
| 113 | * |
| 114 | * CtkToolPalette has a single CSS node named toolpalette. |
| 115 | * |
| 116 | * Since: 2.20 |
| 117 | */ |
| 118 | |
| 119 | typedef struct _CtkToolItemGroupInfo CtkToolItemGroupInfo; |
| 120 | typedef struct _CtkToolPaletteDragData CtkToolPaletteDragData; |
| 121 | |
| 122 | enum |
| 123 | { |
| 124 | PROP_NONE, |
| 125 | PROP_ICON_SIZE, |
| 126 | PROP_ICON_SIZE_SET, |
| 127 | PROP_ORIENTATION, |
| 128 | PROP_TOOLBAR_STYLE, |
| 129 | PROP_HADJUSTMENT, |
| 130 | PROP_VADJUSTMENT, |
| 131 | PROP_HSCROLL_POLICY, |
| 132 | PROP_VSCROLL_POLICY |
| 133 | }; |
| 134 | |
| 135 | enum |
| 136 | { |
| 137 | CHILD_PROP_NONE, |
| 138 | CHILD_PROP_EXCLUSIVE, |
| 139 | CHILD_PROP_EXPAND, |
| 140 | }; |
| 141 | |
| 142 | struct _CtkToolItemGroupInfo |
| 143 | { |
| 144 | CtkToolItemGroup *widget; |
| 145 | |
| 146 | gulong notify_collapsed; |
| 147 | guint pos; |
| 148 | guint exclusive : 1; |
| 149 | guint expand : 1; |
| 150 | }; |
| 151 | |
| 152 | struct _CtkToolPalettePrivate |
| 153 | { |
| 154 | GPtrArray* groups; |
| 155 | |
| 156 | CtkAdjustment *hadjustment; |
| 157 | CtkAdjustment *vadjustment; |
| 158 | |
| 159 | CtkIconSize icon_size; |
| 160 | gboolean icon_size_set; |
| 161 | CtkOrientation orientation; |
| 162 | CtkToolbarStyle style; |
| 163 | gboolean style_set; |
| 164 | |
| 165 | CtkWidget *expanding_child; |
| 166 | |
| 167 | CtkSizeGroup *text_size_group; |
| 168 | |
| 169 | guint drag_source : 2; |
| 170 | |
| 171 | /* CtkScrollablePolicy needs to be checked when |
| 172 | * driving the scrollable adjustment values */ |
| 173 | guint hscroll_policy : 1; |
| 174 | guint vscroll_policy : 1; |
| 175 | }; |
| 176 | |
| 177 | struct _CtkToolPaletteDragData |
| 178 | { |
| 179 | CtkToolPalette *palette; |
| 180 | CtkWidget *item; |
| 181 | }; |
| 182 | |
| 183 | static CdkAtom dnd_target_atom_item = CDK_NONE((CdkAtom)((gpointer) (gulong) (0))); |
| 184 | static CdkAtom dnd_target_atom_group = CDK_NONE((CdkAtom)((gpointer) (gulong) (0))); |
| 185 | |
| 186 | static const CtkTargetEntry dnd_targets[] = |
| 187 | { |
| 188 | { "application/x-ctk-tool-palette-item", CTK_TARGET_SAME_APP, 0 }, |
| 189 | { "application/x-ctk-tool-palette-group", CTK_TARGET_SAME_APP, 0 }, |
| 190 | }; |
| 191 | |
| 192 | static void ctk_tool_palette_set_hadjustment (CtkToolPalette *palette, |
| 193 | CtkAdjustment *adjustment); |
| 194 | static void ctk_tool_palette_set_vadjustment (CtkToolPalette *palette, |
| 195 | CtkAdjustment *adjustment); |
| 196 | |
| 197 | |
| 198 | G_DEFINE_TYPE_WITH_CODE (CtkToolPalette,static void ctk_tool_palette_init (CtkToolPalette *self); static void ctk_tool_palette_class_init (CtkToolPaletteClass *klass ); static GType ctk_tool_palette_get_type_once (void); static gpointer ctk_tool_palette_parent_class = ((void*)0); static gint CtkToolPalette_private_offset; static void ctk_tool_palette_class_intern_init (gpointer klass) { ctk_tool_palette_parent_class = g_type_class_peek_parent (klass); if (CtkToolPalette_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkToolPalette_private_offset); ctk_tool_palette_class_init ((CtkToolPaletteClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_tool_palette_get_instance_private (CtkToolPalette *self) { return (((gpointer) ((guint8*) (self ) + (glong) (CtkToolPalette_private_offset)))); } GType ctk_tool_palette_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_tool_palette_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_tool_palette_get_type_once ( void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type ()), g_intern_static_string ("CtkToolPalette" ), sizeof (CtkToolPaletteClass), (GClassInitFunc)(void (*)(void )) ctk_tool_palette_class_intern_init, sizeof (CtkToolPalette ), (GInstanceInitFunc)(void (*)(void)) ctk_tool_palette_init, (GTypeFlags) 0); { {{ CtkToolPalette_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkToolPalettePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info ); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_scrollable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } |
| 199 | ctk_tool_palette,static void ctk_tool_palette_init (CtkToolPalette *self); static void ctk_tool_palette_class_init (CtkToolPaletteClass *klass ); static GType ctk_tool_palette_get_type_once (void); static gpointer ctk_tool_palette_parent_class = ((void*)0); static gint CtkToolPalette_private_offset; static void ctk_tool_palette_class_intern_init (gpointer klass) { ctk_tool_palette_parent_class = g_type_class_peek_parent (klass); if (CtkToolPalette_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkToolPalette_private_offset); ctk_tool_palette_class_init ((CtkToolPaletteClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_tool_palette_get_instance_private (CtkToolPalette *self) { return (((gpointer) ((guint8*) (self ) + (glong) (CtkToolPalette_private_offset)))); } GType ctk_tool_palette_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_tool_palette_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_tool_palette_get_type_once ( void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type ()), g_intern_static_string ("CtkToolPalette" ), sizeof (CtkToolPaletteClass), (GClassInitFunc)(void (*)(void )) ctk_tool_palette_class_intern_init, sizeof (CtkToolPalette ), (GInstanceInitFunc)(void (*)(void)) ctk_tool_palette_init, (GTypeFlags) 0); { {{ CtkToolPalette_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkToolPalettePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info ); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_scrollable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } |
| 200 | CTK_TYPE_CONTAINER,static void ctk_tool_palette_init (CtkToolPalette *self); static void ctk_tool_palette_class_init (CtkToolPaletteClass *klass ); static GType ctk_tool_palette_get_type_once (void); static gpointer ctk_tool_palette_parent_class = ((void*)0); static gint CtkToolPalette_private_offset; static void ctk_tool_palette_class_intern_init (gpointer klass) { ctk_tool_palette_parent_class = g_type_class_peek_parent (klass); if (CtkToolPalette_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkToolPalette_private_offset); ctk_tool_palette_class_init ((CtkToolPaletteClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_tool_palette_get_instance_private (CtkToolPalette *self) { return (((gpointer) ((guint8*) (self ) + (glong) (CtkToolPalette_private_offset)))); } GType ctk_tool_palette_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_tool_palette_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_tool_palette_get_type_once ( void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type ()), g_intern_static_string ("CtkToolPalette" ), sizeof (CtkToolPaletteClass), (GClassInitFunc)(void (*)(void )) ctk_tool_palette_class_intern_init, sizeof (CtkToolPalette ), (GInstanceInitFunc)(void (*)(void)) ctk_tool_palette_init, (GTypeFlags) 0); { {{ CtkToolPalette_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkToolPalettePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info ); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_scrollable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } |
| 201 | G_ADD_PRIVATE (CtkToolPalette)static void ctk_tool_palette_init (CtkToolPalette *self); static void ctk_tool_palette_class_init (CtkToolPaletteClass *klass ); static GType ctk_tool_palette_get_type_once (void); static gpointer ctk_tool_palette_parent_class = ((void*)0); static gint CtkToolPalette_private_offset; static void ctk_tool_palette_class_intern_init (gpointer klass) { ctk_tool_palette_parent_class = g_type_class_peek_parent (klass); if (CtkToolPalette_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkToolPalette_private_offset); ctk_tool_palette_class_init ((CtkToolPaletteClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_tool_palette_get_instance_private (CtkToolPalette *self) { return (((gpointer) ((guint8*) (self ) + (glong) (CtkToolPalette_private_offset)))); } GType ctk_tool_palette_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_tool_palette_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_tool_palette_get_type_once ( void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type ()), g_intern_static_string ("CtkToolPalette" ), sizeof (CtkToolPaletteClass), (GClassInitFunc)(void (*)(void )) ctk_tool_palette_class_intern_init, sizeof (CtkToolPalette ), (GInstanceInitFunc)(void (*)(void)) ctk_tool_palette_init, (GTypeFlags) 0); { {{ CtkToolPalette_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkToolPalettePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info ); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_scrollable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } |
| 202 | G_IMPLEMENT_INTERFACE (CTK_TYPE_ORIENTABLE, NULL)static void ctk_tool_palette_init (CtkToolPalette *self); static void ctk_tool_palette_class_init (CtkToolPaletteClass *klass ); static GType ctk_tool_palette_get_type_once (void); static gpointer ctk_tool_palette_parent_class = ((void*)0); static gint CtkToolPalette_private_offset; static void ctk_tool_palette_class_intern_init (gpointer klass) { ctk_tool_palette_parent_class = g_type_class_peek_parent (klass); if (CtkToolPalette_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkToolPalette_private_offset); ctk_tool_palette_class_init ((CtkToolPaletteClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_tool_palette_get_instance_private (CtkToolPalette *self) { return (((gpointer) ((guint8*) (self ) + (glong) (CtkToolPalette_private_offset)))); } GType ctk_tool_palette_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_tool_palette_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_tool_palette_get_type_once ( void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type ()), g_intern_static_string ("CtkToolPalette" ), sizeof (CtkToolPaletteClass), (GClassInitFunc)(void (*)(void )) ctk_tool_palette_class_intern_init, sizeof (CtkToolPalette ), (GInstanceInitFunc)(void (*)(void)) ctk_tool_palette_init, (GTypeFlags) 0); { {{ CtkToolPalette_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkToolPalettePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info ); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_scrollable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } |
| 203 | G_IMPLEMENT_INTERFACE (CTK_TYPE_SCROLLABLE, NULL))static void ctk_tool_palette_init (CtkToolPalette *self); static void ctk_tool_palette_class_init (CtkToolPaletteClass *klass ); static GType ctk_tool_palette_get_type_once (void); static gpointer ctk_tool_palette_parent_class = ((void*)0); static gint CtkToolPalette_private_offset; static void ctk_tool_palette_class_intern_init (gpointer klass) { ctk_tool_palette_parent_class = g_type_class_peek_parent (klass); if (CtkToolPalette_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkToolPalette_private_offset); ctk_tool_palette_class_init ((CtkToolPaletteClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_tool_palette_get_instance_private (CtkToolPalette *self) { return (((gpointer) ((guint8*) (self ) + (glong) (CtkToolPalette_private_offset)))); } GType ctk_tool_palette_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_tool_palette_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_tool_palette_get_type_once ( void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type ()), g_intern_static_string ("CtkToolPalette" ), sizeof (CtkToolPaletteClass), (GClassInitFunc)(void (*)(void )) ctk_tool_palette_class_intern_init, sizeof (CtkToolPalette ), (GInstanceInitFunc)(void (*)(void)) ctk_tool_palette_init, (GTypeFlags) 0); { {{ CtkToolPalette_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkToolPalettePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info ); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_scrollable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } |
| 204 | |
| 205 | static void |
| 206 | ctk_tool_palette_init (CtkToolPalette *palette) |
| 207 | { |
| 208 | palette->priv = ctk_tool_palette_get_instance_private (palette); |
| 209 | palette->priv->groups = g_ptr_array_sized_new (4); |
| 210 | g_ptr_array_set_free_func (palette->priv->groups, g_free); |
| 211 | |
| 212 | palette->priv->icon_size = DEFAULT_ICON_SIZECTK_ICON_SIZE_SMALL_TOOLBAR; |
| 213 | palette->priv->icon_size_set = FALSE(0); |
| 214 | palette->priv->orientation = DEFAULT_ORIENTATIONCTK_ORIENTATION_VERTICAL; |
| 215 | palette->priv->style = DEFAULT_TOOLBAR_STYLECTK_TOOLBAR_ICONS; |
| 216 | palette->priv->style_set = FALSE(0); |
| 217 | |
| 218 | palette->priv->text_size_group = ctk_size_group_new (CTK_SIZE_GROUP_BOTH); |
| 219 | |
| 220 | if (dnd_target_atom_item == CDK_NONE((CdkAtom)((gpointer) (gulong) (0)))) |
| 221 | { |
| 222 | dnd_target_atom_item = cdk_atom_intern_static_string (dnd_targets[0].target); |
| 223 | dnd_target_atom_group = cdk_atom_intern_static_string (dnd_targets[1].target); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | static void |
| 228 | ctk_tool_palette_reconfigured (CtkToolPalette *palette) |
| 229 | { |
| 230 | guint i; |
| 231 | |
| 232 | for (i = 0; i < palette->priv->groups->len; ++i) |
| 233 | { |
| 234 | CtkToolItemGroupInfo *info = g_ptr_array_index (palette->priv->groups, i)((palette->priv->groups)->pdata)[i]; |
| 235 | if (info->widget) |
| 236 | _ctk_tool_item_group_palette_reconfigured (info->widget); |
| 237 | } |
| 238 | |
| 239 | ctk_widget_queue_resize_no_redraw (CTK_WIDGET (palette)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_widget_get_type ()))))))); |
| 240 | } |
| 241 | |
| 242 | static void |
| 243 | ctk_tool_palette_set_property (GObject *object, |
| 244 | guint prop_id, |
| 245 | const GValue *value, |
| 246 | GParamSpec *pspec) |
| 247 | { |
| 248 | CtkToolPalette *palette = CTK_TOOL_PALETTE (object)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (object), ((ctk_tool_palette_get_type ())))))); |
| 249 | |
| 250 | switch (prop_id) |
| 251 | { |
| 252 | case PROP_ICON_SIZE: |
| 253 | if (palette->priv->icon_size != g_value_get_enum (value)) |
| 254 | { |
| 255 | palette->priv->icon_size = g_value_get_enum (value); |
| 256 | ctk_tool_palette_reconfigured (palette); |
| 257 | g_object_notify_by_pspec (object, pspec); |
| 258 | } |
| 259 | break; |
| 260 | |
| 261 | case PROP_ICON_SIZE_SET: |
| 262 | if (palette->priv->icon_size_set != g_value_get_boolean (value)) |
| 263 | { |
| 264 | palette->priv->icon_size_set = g_value_get_boolean (value); |
| 265 | ctk_tool_palette_reconfigured (palette); |
| 266 | g_object_notify_by_pspec (object, pspec); |
| 267 | } |
| 268 | break; |
| 269 | |
| 270 | case PROP_ORIENTATION: |
| 271 | if (palette->priv->orientation != g_value_get_enum (value)) |
| 272 | { |
| 273 | palette->priv->orientation = g_value_get_enum (value); |
| 274 | _ctk_orientable_set_style_classes (CTK_ORIENTABLE (palette)((((CtkOrientable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_orientable_get_type ()))))))); |
| 275 | ctk_tool_palette_reconfigured (palette); |
| 276 | g_object_notify_by_pspec (object, pspec); |
| 277 | } |
| 278 | break; |
| 279 | |
| 280 | case PROP_TOOLBAR_STYLE: |
| 281 | if (palette->priv->style != g_value_get_enum (value)) |
| 282 | { |
| 283 | palette->priv->style = g_value_get_enum (value); |
| 284 | ctk_tool_palette_reconfigured (palette); |
| 285 | g_object_notify_by_pspec (object, pspec); |
| 286 | } |
| 287 | break; |
| 288 | |
| 289 | case PROP_HADJUSTMENT: |
| 290 | ctk_tool_palette_set_hadjustment (palette, g_value_get_object (value)); |
| 291 | break; |
| 292 | |
| 293 | case PROP_VADJUSTMENT: |
| 294 | ctk_tool_palette_set_vadjustment (palette, g_value_get_object (value)); |
| 295 | break; |
| 296 | |
| 297 | case PROP_HSCROLL_POLICY: |
| 298 | if (palette->priv->hscroll_policy != g_value_get_enum (value)) |
| 299 | { |
| 300 | palette->priv->hscroll_policy = g_value_get_enum (value); |
| 301 | ctk_widget_queue_resize (CTK_WIDGET (palette)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_widget_get_type ()))))))); |
| 302 | g_object_notify_by_pspec (object, pspec); |
| 303 | } |
| 304 | break; |
| 305 | |
| 306 | case PROP_VSCROLL_POLICY: |
| 307 | if (palette->priv->vscroll_policy != g_value_get_enum (value)) |
| 308 | { |
| 309 | palette->priv->vscroll_policy = g_value_get_enum (value); |
| 310 | ctk_widget_queue_resize (CTK_WIDGET (palette)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_widget_get_type ()))))))); |
| 311 | g_object_notify_by_pspec (object, pspec); |
| 312 | } |
| 313 | break; |
| 314 | |
| 315 | default: |
| 316 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctktoolpalette.c", 316, ("property"), _glib__property_id, _glib__pspec ->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) ( _glib__pspec))->g_class))->g_type)))), (g_type_name ((( (((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
| 317 | break; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | static void |
| 322 | ctk_tool_palette_get_property (GObject *object, |
| 323 | guint prop_id, |
| 324 | GValue *value, |
| 325 | GParamSpec *pspec) |
| 326 | { |
| 327 | CtkToolPalette *palette = CTK_TOOL_PALETTE (object)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (object), ((ctk_tool_palette_get_type ())))))); |
| 328 | |
| 329 | switch (prop_id) |
| 330 | { |
| 331 | case PROP_ICON_SIZE: |
| 332 | g_value_set_enum (value, ctk_tool_palette_get_icon_size (palette)); |
| 333 | break; |
| 334 | |
| 335 | case PROP_ICON_SIZE_SET: |
| 336 | g_value_set_boolean (value, palette->priv->icon_size_set); |
| 337 | break; |
| 338 | |
| 339 | case PROP_ORIENTATION: |
| 340 | g_value_set_enum (value, palette->priv->orientation); |
| 341 | break; |
| 342 | |
| 343 | case PROP_TOOLBAR_STYLE: |
| 344 | g_value_set_enum (value, ctk_tool_palette_get_style (palette)); |
| 345 | break; |
| 346 | |
| 347 | case PROP_HADJUSTMENT: |
| 348 | g_value_set_object (value, palette->priv->hadjustment); |
| 349 | break; |
| 350 | |
| 351 | case PROP_VADJUSTMENT: |
| 352 | g_value_set_object (value, palette->priv->vadjustment); |
| 353 | break; |
| 354 | |
| 355 | case PROP_HSCROLL_POLICY: |
| 356 | g_value_set_enum (value, palette->priv->hscroll_policy); |
| 357 | break; |
| 358 | |
| 359 | case PROP_VSCROLL_POLICY: |
| 360 | g_value_set_enum (value, palette->priv->vscroll_policy); |
| 361 | break; |
| 362 | |
| 363 | default: |
| 364 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctktoolpalette.c", 364, ("property"), _glib__property_id, _glib__pspec ->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) ( _glib__pspec))->g_class))->g_type)))), (g_type_name ((( (((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
| 365 | break; |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | static void |
| 370 | ctk_tool_palette_dispose (GObject *object) |
| 371 | { |
| 372 | CtkToolPalette *palette = CTK_TOOL_PALETTE (object)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (object), ((ctk_tool_palette_get_type ())))))); |
| 373 | guint i; |
| 374 | |
| 375 | if (palette->priv->hadjustment) |
| 376 | { |
| 377 | g_object_unref (palette->priv->hadjustment); |
| 378 | palette->priv->hadjustment = NULL((void*)0); |
| 379 | } |
| 380 | |
| 381 | if (palette->priv->vadjustment) |
| 382 | { |
| 383 | g_object_unref (palette->priv->vadjustment); |
| 384 | palette->priv->vadjustment = NULL((void*)0); |
| 385 | } |
| 386 | |
| 387 | for (i = 0; i < palette->priv->groups->len; ++i) |
| 388 | { |
| 389 | CtkToolItemGroupInfo *group = g_ptr_array_index (palette->priv->groups, i)((palette->priv->groups)->pdata)[i]; |
| 390 | |
| 391 | if (group->notify_collapsed) |
| 392 | { |
| 393 | g_signal_handler_disconnect (group->widget, group->notify_collapsed); |
| 394 | group->notify_collapsed = 0; |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | if (palette->priv->text_size_group) |
| 399 | { |
| 400 | g_object_unref (palette->priv->text_size_group); |
| 401 | palette->priv->text_size_group = NULL((void*)0); |
| 402 | } |
| 403 | |
| 404 | G_OBJECT_CLASS (ctk_tool_palette_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_tool_palette_parent_class)), (((GType) ((20) << (2))))))))->dispose (object); |
| 405 | } |
| 406 | |
| 407 | static void |
| 408 | ctk_tool_palette_finalize (GObject *object) |
| 409 | { |
| 410 | CtkToolPalette *palette = CTK_TOOL_PALETTE (object)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (object), ((ctk_tool_palette_get_type ())))))); |
| 411 | |
| 412 | g_ptr_array_free (palette->priv->groups, TRUE(!(0))); |
| 413 | |
| 414 | G_OBJECT_CLASS (ctk_tool_palette_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_tool_palette_parent_class)), (((GType) ((20) << (2))))))))->finalize (object); |
| 415 | } |
| 416 | |
| 417 | static void |
| 418 | ctk_tool_palette_size_request (CtkWidget *widget, |
| 419 | CtkRequisition *requisition) |
| 420 | { |
| 421 | CtkToolPalette *palette = CTK_TOOL_PALETTE (widget)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (widget), ((ctk_tool_palette_get_type ())))))); |
| 422 | CtkRequisition child_requisition; |
| 423 | guint border_width; |
| 424 | guint i; |
| 425 | |
| 426 | border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ()))))))); |
| 427 | |
| 428 | requisition->width = 0; |
| 429 | requisition->height = 0; |
| 430 | |
| 431 | for (i = 0; i < palette->priv->groups->len; ++i) |
| 432 | { |
| 433 | CtkToolItemGroupInfo *group = g_ptr_array_index (palette->priv->groups, i)((palette->priv->groups)->pdata)[i]; |
| 434 | |
| 435 | if (!group->widget) |
| 436 | continue; |
| 437 | |
| 438 | ctk_widget_get_preferred_size (CTK_WIDGET (group->widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group->widget)), ((ctk_widget_get_type ())))))), |
| 439 | &child_requisition, NULL((void*)0)); |
| 440 | |
| 441 | if (CTK_ORIENTATION_VERTICAL == palette->priv->orientation) |
| 442 | { |
| 443 | requisition->width = MAX (requisition->width, child_requisition.width)(((requisition->width) > (child_requisition.width)) ? ( requisition->width) : (child_requisition.width)); |
| 444 | requisition->height += child_requisition.height; |
| 445 | } |
| 446 | else |
| 447 | { |
| 448 | requisition->width += child_requisition.width; |
| 449 | requisition->height = MAX (requisition->height, child_requisition.height)(((requisition->height) > (child_requisition.height)) ? (requisition->height) : (child_requisition.height)); |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | requisition->width += border_width * 2; |
| 454 | requisition->height += border_width * 2; |
| 455 | } |
| 456 | |
| 457 | static void |
| 458 | ctk_tool_palette_get_preferred_width (CtkWidget *widget, |
| 459 | gint *minimum, |
| 460 | gint *natural) |
| 461 | { |
| 462 | CtkRequisition requisition; |
| 463 | |
| 464 | ctk_tool_palette_size_request (widget, &requisition); |
| 465 | |
| 466 | *minimum = *natural = requisition.width; |
| 467 | } |
| 468 | |
| 469 | static void |
| 470 | ctk_tool_palette_get_preferred_height (CtkWidget *widget, |
| 471 | gint *minimum, |
| 472 | gint *natural) |
| 473 | { |
| 474 | CtkRequisition requisition; |
| 475 | |
| 476 | ctk_tool_palette_size_request (widget, &requisition); |
| 477 | |
| 478 | *minimum = *natural = requisition.height; |
| 479 | } |
| 480 | |
| 481 | |
| 482 | static void |
| 483 | ctk_tool_palette_size_allocate (CtkWidget *widget, |
| 484 | CtkAllocation *allocation) |
| 485 | { |
| 486 | CtkToolPalette *palette = CTK_TOOL_PALETTE (widget)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (widget), ((ctk_tool_palette_get_type ())))))); |
| 487 | CtkAdjustment *adjustment = NULL((void*)0); |
| 488 | CtkAllocation child_allocation; |
| 489 | |
| 490 | gint n_expand_groups = 0; |
| 491 | gint remaining_space = 0; |
| 492 | gint expand_space = 0; |
| 493 | |
| 494 | gint total_size, page_size; |
| 495 | gint offset = 0; |
| 496 | guint i; |
| 497 | guint border_width; |
| 498 | |
| 499 | gint min_offset = -1, max_offset = -1; |
| 500 | |
| 501 | gint x; |
| 502 | |
| 503 | gint *group_sizes = g_newa (gint, palette->priv->groups->len)((gint*) __builtin_alloca (sizeof (gint) * (gsize) (palette-> priv->groups->len))); |
| 504 | CtkTextDirection direction; |
| 505 | |
| 506 | border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ()))))))); |
| 507 | direction = ctk_widget_get_direction (widget); |
| 508 | |
| 509 | CTK_WIDGET_CLASS (ctk_tool_palette_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_tool_palette_parent_class)), ((ctk_widget_get_type ( )))))))->size_allocate (widget, allocation); |
| 510 | |
| 511 | if (CTK_ORIENTATION_VERTICAL == palette->priv->orientation) |
| 512 | { |
| 513 | adjustment = palette->priv->vadjustment; |
| 514 | page_size = allocation->height; |
| 515 | } |
| 516 | else |
| 517 | { |
| 518 | adjustment = palette->priv->hadjustment; |
| 519 | page_size = allocation->width; |
| 520 | } |
| 521 | |
| 522 | if (adjustment) |
| 523 | offset = ctk_adjustment_get_value (adjustment); |
| 524 | if (CTK_ORIENTATION_HORIZONTAL == palette->priv->orientation && |
| 525 | CTK_TEXT_DIR_RTL == direction) |
| 526 | offset = -offset; |
| 527 | |
| 528 | if (CTK_ORIENTATION_VERTICAL == palette->priv->orientation) |
| 529 | child_allocation.width = allocation->width - border_width * 2; |
| 530 | else |
| 531 | child_allocation.height = allocation->height - border_width * 2; |
| 532 | |
| 533 | if (CTK_ORIENTATION_VERTICAL == palette->priv->orientation) |
| 534 | remaining_space = allocation->height; |
| 535 | else |
| 536 | remaining_space = allocation->width; |
| 537 | |
| 538 | /* figure out the required size of all groups to be able to distribute the |
| 539 | * remaining space on allocation |
| 540 | */ |
| 541 | for (i = 0; i < palette->priv->groups->len; ++i) |
| 542 | { |
| 543 | CtkToolItemGroupInfo *group = g_ptr_array_index (palette->priv->groups, i)((palette->priv->groups)->pdata)[i]; |
| 544 | gint size; |
| 545 | |
| 546 | group_sizes[i] = 0; |
| 547 | |
| 548 | if (!group->widget) |
| 549 | continue; |
| 550 | |
| 551 | widget = CTK_WIDGET (group->widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group->widget)), ((ctk_widget_get_type ())))))); |
| 552 | |
| 553 | if (ctk_tool_item_group_get_n_items (group->widget)) |
| 554 | { |
| 555 | if (CTK_ORIENTATION_VERTICAL == palette->priv->orientation) |
| 556 | size = _ctk_tool_item_group_get_height_for_width (group->widget, child_allocation.width); |
| 557 | else |
| 558 | size = _ctk_tool_item_group_get_width_for_height (group->widget, child_allocation.height); |
| 559 | |
| 560 | if (group->expand && !ctk_tool_item_group_get_collapsed (group->widget)) |
| 561 | n_expand_groups += 1; |
| 562 | } |
| 563 | else |
| 564 | size = 0; |
| 565 | |
| 566 | remaining_space -= size; |
| 567 | group_sizes[i] = size; |
| 568 | |
| 569 | /* if the widget is currently expanding an offset which allows to |
| 570 | * display as much of the widget as possible is calculated |
| 571 | */ |
| 572 | if (widget == palette->priv->expanding_child) |
| 573 | { |
| 574 | gint limit = |
| 575 | CTK_ORIENTATION_VERTICAL == palette->priv->orientation ? |
| 576 | child_allocation.width : child_allocation.height; |
| 577 | |
| 578 | gint real_size; |
| 579 | guint j; |
| 580 | |
| 581 | min_offset = 0; |
| 582 | |
| 583 | for (j = 0; j < i; ++j) |
| 584 | min_offset += group_sizes[j]; |
| 585 | |
| 586 | max_offset = min_offset + group_sizes[i]; |
| 587 | |
| 588 | real_size = _ctk_tool_item_group_get_size_for_limit |
| 589 | (CTK_TOOL_ITEM_GROUP (widget)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (widget), ((ctk_tool_item_group_get_type ())) )))), limit, |
| 590 | CTK_ORIENTATION_VERTICAL == palette->priv->orientation, |
| 591 | FALSE(0)); |
| 592 | |
| 593 | if (size == real_size) |
| 594 | palette->priv->expanding_child = NULL((void*)0); |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | if (n_expand_groups > 0) |
| 599 | { |
| 600 | remaining_space = MAX (0, remaining_space)(((0) > (remaining_space)) ? (0) : (remaining_space)); |
| 601 | expand_space = remaining_space / n_expand_groups; |
| 602 | } |
| 603 | |
| 604 | if (max_offset != -1) |
| 605 | { |
| 606 | gint limit = |
| 607 | CTK_ORIENTATION_VERTICAL == palette->priv->orientation ? |
| 608 | allocation->height : allocation->width; |
| 609 | |
| 610 | offset = MIN (MAX (offset, max_offset - limit), min_offset)((((((offset) > (max_offset - limit)) ? (offset) : (max_offset - limit))) < (min_offset)) ? ((((offset) > (max_offset - limit)) ? (offset) : (max_offset - limit))) : (min_offset) ); |
| 611 | } |
| 612 | |
| 613 | if (remaining_space > 0) |
| 614 | offset = 0; |
| 615 | |
| 616 | x = border_width; |
| 617 | child_allocation.y = border_width; |
| 618 | |
| 619 | if (CTK_ORIENTATION_VERTICAL == palette->priv->orientation) |
| 620 | child_allocation.y -= offset; |
| 621 | else |
| 622 | x -= offset; |
| 623 | |
| 624 | /* allocate all groups at the calculated positions */ |
| 625 | for (i = 0; i < palette->priv->groups->len; ++i) |
| 626 | { |
| 627 | CtkToolItemGroupInfo *group = g_ptr_array_index (palette->priv->groups, i)((palette->priv->groups)->pdata)[i]; |
| 628 | |
| 629 | if (!group->widget) |
| 630 | continue; |
| 631 | |
| 632 | if (ctk_tool_item_group_get_n_items (group->widget)) |
| 633 | { |
| 634 | gint size = group_sizes[i]; |
| 635 | |
| 636 | if (group->expand && !ctk_tool_item_group_get_collapsed (group->widget)) |
| 637 | { |
| 638 | size += MIN (expand_space, remaining_space)(((expand_space) < (remaining_space)) ? (expand_space) : ( remaining_space)); |
| 639 | remaining_space -= expand_space; |
| 640 | } |
| 641 | |
| 642 | if (CTK_ORIENTATION_VERTICAL == palette->priv->orientation) |
| 643 | child_allocation.height = size; |
| 644 | else |
| 645 | child_allocation.width = size; |
| 646 | |
| 647 | if (CTK_ORIENTATION_HORIZONTAL == palette->priv->orientation && |
| 648 | CTK_TEXT_DIR_RTL == direction) |
| 649 | child_allocation.x = allocation->width - x - child_allocation.width; |
| 650 | else |
| 651 | child_allocation.x = x; |
| 652 | |
| 653 | ctk_widget_size_allocate (CTK_WIDGET (group->widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group->widget)), ((ctk_widget_get_type ())))))), &child_allocation); |
| 654 | ctk_widget_show (CTK_WIDGET (group->widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group->widget)), ((ctk_widget_get_type ()))))))); |
| 655 | |
| 656 | if (CTK_ORIENTATION_VERTICAL == palette->priv->orientation) |
| 657 | child_allocation.y += child_allocation.height; |
| 658 | else |
| 659 | x += child_allocation.width; |
| 660 | } |
| 661 | else |
| 662 | ctk_widget_hide (CTK_WIDGET (group->widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group->widget)), ((ctk_widget_get_type ()))))))); |
| 663 | } |
| 664 | |
| 665 | if (CTK_ORIENTATION_VERTICAL == palette->priv->orientation) |
| 666 | { |
| 667 | child_allocation.y += border_width; |
| 668 | child_allocation.y += offset; |
| 669 | |
| 670 | total_size = child_allocation.y; |
| 671 | } |
| 672 | else |
| 673 | { |
| 674 | x += border_width; |
| 675 | x += offset; |
| 676 | |
| 677 | total_size = x; |
| 678 | } |
| 679 | |
| 680 | /* update the scrollbar to match the displayed adjustment */ |
| 681 | if (adjustment) |
| 682 | { |
| 683 | gdouble lower, upper; |
| 684 | |
| 685 | total_size = MAX (0, total_size)(((0) > (total_size)) ? (0) : (total_size)); |
| 686 | page_size = MIN (total_size, page_size)(((total_size) < (page_size)) ? (total_size) : (page_size) ); |
| 687 | |
| 688 | if (CTK_ORIENTATION_VERTICAL == palette->priv->orientation || |
| 689 | CTK_TEXT_DIR_LTR == direction) |
| 690 | { |
| 691 | lower = 0; |
| 692 | upper = total_size; |
| 693 | } |
| 694 | else |
| 695 | { |
| 696 | lower = page_size - total_size; |
| 697 | upper = page_size; |
| 698 | |
| 699 | offset = -offset; |
| 700 | } |
| 701 | |
| 702 | ctk_adjustment_configure (adjustment, |
| 703 | offset, |
| 704 | lower, |
| 705 | upper, |
| 706 | page_size * 0.1, |
| 707 | page_size * 0.9, |
| 708 | page_size); |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | static void |
| 713 | ctk_tool_palette_realize (CtkWidget *widget) |
| 714 | { |
| 715 | CtkAllocation allocation; |
| 716 | CdkWindow *window; |
| 717 | CdkWindowAttr attributes; |
| 718 | gint attributes_mask; |
| 719 | guint border_width; |
| 720 | |
| 721 | ctk_widget_set_realized (widget, TRUE(!(0))); |
| 722 | |
| 723 | border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ()))))))); |
| 724 | |
| 725 | ctk_widget_get_allocation (widget, &allocation); |
| 726 | |
| 727 | attributes.window_type = CDK_WINDOW_CHILD; |
| 728 | attributes.x = allocation.x + border_width; |
| 729 | attributes.y = allocation.y + border_width; |
| 730 | attributes.width = allocation.width - border_width * 2; |
| 731 | attributes.height = allocation.height - border_width * 2; |
| 732 | attributes.wclass = CDK_INPUT_OUTPUT; |
| 733 | attributes.visual = ctk_widget_get_visual (widget); |
| 734 | attributes.event_mask = ctk_widget_get_events (widget) |
| 735 | | CDK_VISIBILITY_NOTIFY_MASK |
| 736 | | CDK_BUTTON_PRESS_MASK | CDK_BUTTON_RELEASE_MASK |
| 737 | | CDK_BUTTON_MOTION_MASK |
| 738 | | CDK_SCROLL_MASK | CDK_SMOOTH_SCROLL_MASK |
| 739 | | CDK_TOUCH_MASK; |
| 740 | attributes_mask = CDK_WA_X | CDK_WA_Y | CDK_WA_VISUAL; |
| 741 | |
| 742 | window = cdk_window_new (ctk_widget_get_parent_window (widget), |
| 743 | &attributes, attributes_mask); |
| 744 | ctk_widget_set_window (widget, window); |
| 745 | ctk_widget_register_window (widget, window); |
| 746 | |
| 747 | ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))), |
| 748 | (CtkCallback) ctk_widget_set_parent_window, |
| 749 | window); |
| 750 | |
| 751 | ctk_widget_queue_resize_no_redraw (widget); |
| 752 | } |
| 753 | |
| 754 | static void |
| 755 | ctk_tool_palette_adjustment_value_changed (CtkAdjustment *adjustment G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 756 | gpointer data) |
| 757 | { |
| 758 | CtkAllocation allocation; |
| 759 | CtkWidget *widget = CTK_WIDGET (data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_widget_get_type ())))))); |
| 760 | |
| 761 | ctk_widget_get_allocation (widget, &allocation); |
| 762 | ctk_tool_palette_size_allocate (widget, &allocation); |
| 763 | } |
| 764 | |
| 765 | static gboolean |
| 766 | ctk_tool_palette_draw (CtkWidget *widget, |
| 767 | cairo_t *cr) |
| 768 | { |
| 769 | ctk_render_background (ctk_widget_get_style_context (widget), cr, |
| 770 | 0, 0, |
| 771 | ctk_widget_get_allocated_width (widget), |
| 772 | ctk_widget_get_allocated_height (widget)); |
| 773 | |
| 774 | return CTK_WIDGET_CLASS (ctk_tool_palette_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_tool_palette_parent_class)), ((ctk_widget_get_type ( )))))))->draw (widget, cr); |
| 775 | } |
| 776 | |
| 777 | static void |
| 778 | ctk_tool_palette_add (CtkContainer *container, |
| 779 | CtkWidget *child) |
| 780 | { |
| 781 | CtkToolPalette *palette; |
| 782 | CtkToolItemGroupInfo *info = g_new0(CtkToolItemGroupInfo, 1)((CtkToolItemGroupInfo *) g_malloc0_n ((1), sizeof (CtkToolItemGroupInfo ))); |
| 783 | |
| 784 | g_return_if_fail (CTK_IS_TOOL_PALETTE (container))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (container); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_TOOL_PALETTE (container)"); return; } } while (0); |
| 785 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (child); GType __t = ((ctk_tool_item_group_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (child)"); return; } } while (0); |
| 786 | |
| 787 | palette = CTK_TOOL_PALETTE (container)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (container), ((ctk_tool_palette_get_type ())))))); |
| 788 | |
| 789 | g_ptr_array_add (palette->priv->groups, info); |
| 790 | info->pos = palette->priv->groups->len - 1; |
| 791 | info->widget = (CtkToolItemGroup *) g_object_ref_sink (child)((__typeof__ (child)) (g_object_ref_sink) (child)); |
| 792 | |
| 793 | ctk_widget_set_parent (child, CTK_WIDGET (palette)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_widget_get_type ()))))))); |
| 794 | } |
| 795 | |
| 796 | static void |
| 797 | ctk_tool_palette_remove (CtkContainer *container, |
| 798 | CtkWidget *child) |
| 799 | { |
| 800 | CtkToolPalette *palette; |
| 801 | guint i; |
| 802 | |
| 803 | g_return_if_fail (CTK_IS_TOOL_PALETTE (container))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (container); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_TOOL_PALETTE (container)"); return; } } while (0); |
| 804 | palette = CTK_TOOL_PALETTE (container)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (container), ((ctk_tool_palette_get_type ())))))); |
| 805 | |
| 806 | for (i = 0; i < palette->priv->groups->len; ++i) |
| 807 | { |
| 808 | CtkToolItemGroupInfo *info = g_ptr_array_index (palette->priv->groups, i)((palette->priv->groups)->pdata)[i]; |
| 809 | if (CTK_WIDGET(info->widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((info->widget)), ((ctk_widget_get_type ())))))) == child) |
| 810 | { |
| 811 | g_object_unref (child); |
| 812 | ctk_widget_unparent (child); |
| 813 | |
| 814 | g_ptr_array_remove_index (palette->priv->groups, i); |
| 815 | } |
| 816 | } |
| 817 | } |
| 818 | |
| 819 | static void |
| 820 | ctk_tool_palette_forall (CtkContainer *container, |
| 821 | gboolean internals G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 822 | CtkCallback callback, |
| 823 | gpointer callback_data) |
| 824 | { |
| 825 | CtkToolPalette *palette = CTK_TOOL_PALETTE (container)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (container), ((ctk_tool_palette_get_type ())))))); |
| 826 | guint i, len; |
| 827 | |
| 828 | for (i = 0; i < palette->priv->groups->len; ++i) |
| 829 | { |
| 830 | CtkToolItemGroupInfo *info = g_ptr_array_index (palette->priv->groups, i)((palette->priv->groups)->pdata)[i]; |
| 831 | |
| 832 | len = palette->priv->groups->len; |
| 833 | |
| 834 | if (info->widget) |
| 835 | callback (CTK_WIDGET (info->widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((info->widget)), ((ctk_widget_get_type ())))))), |
| 836 | callback_data); |
| 837 | |
| 838 | /* At destroy time, 'callback' results in removing a widget, |
| 839 | * here we just reset the current index to account for the removed widget. */ |
| 840 | i -= (len - palette->priv->groups->len); |
| 841 | } |
| 842 | } |
| 843 | |
| 844 | static GType |
| 845 | ctk_tool_palette_child_type (CtkContainer *container G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 846 | { |
| 847 | return CTK_TYPE_TOOL_ITEM_GROUP(ctk_tool_item_group_get_type ()); |
| 848 | } |
| 849 | |
| 850 | static void |
| 851 | ctk_tool_palette_set_child_property (CtkContainer *container, |
| 852 | CtkWidget *child, |
| 853 | guint prop_id, |
| 854 | const GValue *value, |
| 855 | GParamSpec *pspec) |
| 856 | { |
| 857 | CtkToolPalette *palette = CTK_TOOL_PALETTE (container)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (container), ((ctk_tool_palette_get_type ())))))); |
| 858 | |
| 859 | switch (prop_id) |
| 860 | { |
| 861 | case CHILD_PROP_EXCLUSIVE: |
| 862 | ctk_tool_palette_set_exclusive (palette, CTK_TOOL_ITEM_GROUP (child)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (child), ((ctk_tool_item_group_get_type ()))) ))), |
| 863 | g_value_get_boolean (value)); |
| 864 | break; |
| 865 | |
| 866 | case CHILD_PROP_EXPAND: |
| 867 | ctk_tool_palette_set_expand (palette, CTK_TOOL_ITEM_GROUP (child)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (child), ((ctk_tool_item_group_get_type ()))) ))), |
| 868 | g_value_get_boolean (value)); |
| 869 | break; |
| 870 | |
| 871 | default: |
| 872 | CTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((container)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctktoolpalette.c", 872, ("child property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
| 873 | break; |
| 874 | } |
| 875 | } |
| 876 | |
| 877 | static void |
| 878 | ctk_tool_palette_get_child_property (CtkContainer *container, |
| 879 | CtkWidget *child, |
| 880 | guint prop_id, |
| 881 | GValue *value, |
| 882 | GParamSpec *pspec) |
| 883 | { |
| 884 | CtkToolPalette *palette = CTK_TOOL_PALETTE (container)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (container), ((ctk_tool_palette_get_type ())))))); |
| 885 | |
| 886 | switch (prop_id) |
| 887 | { |
| 888 | case CHILD_PROP_EXCLUSIVE: |
| 889 | g_value_set_boolean (value, |
| 890 | ctk_tool_palette_get_exclusive (palette, CTK_TOOL_ITEM_GROUP (child)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (child), ((ctk_tool_item_group_get_type ()))) ))))); |
| 891 | break; |
| 892 | |
| 893 | case CHILD_PROP_EXPAND: |
| 894 | g_value_set_boolean (value, |
| 895 | ctk_tool_palette_get_expand (palette, CTK_TOOL_ITEM_GROUP (child)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (child), ((ctk_tool_item_group_get_type ()))) ))))); |
| 896 | break; |
| 897 | |
| 898 | default: |
| 899 | CTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((container)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctktoolpalette.c", 899, ("child property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
| 900 | break; |
| 901 | } |
| 902 | } |
| 903 | |
| 904 | static void |
| 905 | ctk_tool_palette_screen_changed (CtkWidget *widget, |
| 906 | CdkScreen *previous_screen G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 907 | { |
| 908 | CtkToolPalette *palette = CTK_TOOL_PALETTE (widget)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (widget), ((ctk_tool_palette_get_type ())))))); |
| 909 | |
| 910 | ctk_tool_palette_reconfigured (palette); |
| 911 | } |
| 912 | |
| 913 | |
| 914 | static void |
| 915 | ctk_tool_palette_class_init (CtkToolPaletteClass *cls) |
| 916 | { |
| 917 | GObjectClass *oclass = G_OBJECT_CLASS (cls)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((cls)), (((GType) ((20) << (2)))))))); |
| 918 | CtkWidgetClass *wclass = CTK_WIDGET_CLASS (cls)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((cls)), ((ctk_widget_get_type ())))))); |
| 919 | CtkContainerClass *cclass = CTK_CONTAINER_CLASS (cls)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((cls)), ((ctk_container_get_type ())))))); |
| 920 | |
| 921 | oclass->set_property = ctk_tool_palette_set_property; |
| 922 | oclass->get_property = ctk_tool_palette_get_property; |
| 923 | oclass->dispose = ctk_tool_palette_dispose; |
| 924 | oclass->finalize = ctk_tool_palette_finalize; |
| 925 | |
| 926 | wclass->get_preferred_width = ctk_tool_palette_get_preferred_width; |
| 927 | wclass->get_preferred_height= ctk_tool_palette_get_preferred_height; |
| 928 | wclass->size_allocate = ctk_tool_palette_size_allocate; |
| 929 | wclass->realize = ctk_tool_palette_realize; |
| 930 | wclass->draw = ctk_tool_palette_draw; |
| 931 | |
| 932 | cclass->add = ctk_tool_palette_add; |
| 933 | cclass->remove = ctk_tool_palette_remove; |
| 934 | cclass->forall = ctk_tool_palette_forall; |
| 935 | cclass->child_type = ctk_tool_palette_child_type; |
| 936 | cclass->set_child_property = ctk_tool_palette_set_child_property; |
| 937 | cclass->get_child_property = ctk_tool_palette_get_child_property; |
| 938 | |
| 939 | /* Handle screen-changed so we can update our configuration. |
| 940 | */ |
| 941 | wclass->screen_changed = ctk_tool_palette_screen_changed; |
| 942 | |
| 943 | g_object_class_override_property (oclass, PROP_ORIENTATION, "orientation"); |
| 944 | |
| 945 | g_object_class_override_property (oclass, PROP_HADJUSTMENT, "hadjustment"); |
| 946 | g_object_class_override_property (oclass, PROP_VADJUSTMENT, "vadjustment"); |
| 947 | g_object_class_override_property (oclass, PROP_HSCROLL_POLICY, "hscroll-policy"); |
| 948 | g_object_class_override_property (oclass, PROP_VSCROLL_POLICY, "vscroll-policy"); |
| 949 | |
| 950 | /** |
| 951 | * CtkToolPalette:icon-size: |
| 952 | * |
| 953 | * The size of the icons in a tool palette. When this property is set, |
| 954 | * it overrides the default setting. |
| 955 | * |
| 956 | * This should only be used for special-purpose tool palettes, normal |
| 957 | * application tool palettes should respect the user preferences for the |
| 958 | * size of icons. |
| 959 | * |
| 960 | * Since: 2.20 |
| 961 | */ |
| 962 | g_object_class_install_property (oclass, |
| 963 | PROP_ICON_SIZE, |
| 964 | g_param_spec_enum ("icon-size", |
| 965 | P_("Icon size")g_dgettext("ctk30" "-properties","Icon size"), |
| 966 | P_("Size of icons in this tool palette")g_dgettext("ctk30" "-properties","Size of icons in this tool palette" ), |
| 967 | CTK_TYPE_ICON_SIZE(ctk_icon_size_get_type ()), |
| 968 | DEFAULT_ICON_SIZECTK_ICON_SIZE_SMALL_TOOLBAR, |
| 969 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); |
| 970 | |
| 971 | /** |
| 972 | * CtkToolPalette:icon-size-set: |
| 973 | * |
| 974 | * Is %TRUE if the #CtkToolPalette:icon-size property has been set. |
| 975 | * |
| 976 | * Since: 2.20 |
| 977 | */ |
| 978 | g_object_class_install_property (oclass, |
| 979 | PROP_ICON_SIZE_SET, |
| 980 | g_param_spec_boolean ("icon-size-set", |
| 981 | P_("Icon size set")g_dgettext("ctk30" "-properties","Icon size set"), |
| 982 | P_("Whether the icon-size property has been set")g_dgettext("ctk30" "-properties","Whether the icon-size property has been set" ), |
| 983 | FALSE(0), |
| 984 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); |
| 985 | |
| 986 | /** |
| 987 | * CtkToolPalette:toolbar-style: |
| 988 | * |
| 989 | * The style of items in the tool palette. |
| 990 | * |
| 991 | * Since: 2.20 |
| 992 | */ |
| 993 | g_object_class_install_property (oclass, PROP_TOOLBAR_STYLE, |
| 994 | g_param_spec_enum ("toolbar-style", |
| 995 | P_("Toolbar Style")g_dgettext("ctk30" "-properties","Toolbar Style"), |
| 996 | P_("Style of items in the tool palette")g_dgettext("ctk30" "-properties","Style of items in the tool palette" ), |
| 997 | CTK_TYPE_TOOLBAR_STYLE(ctk_toolbar_style_get_type ()), |
| 998 | DEFAULT_TOOLBAR_STYLECTK_TOOLBAR_ICONS, |
| 999 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); |
| 1000 | |
| 1001 | |
| 1002 | /** |
| 1003 | * CtkToolPalette:exclusive: |
| 1004 | * |
| 1005 | * Whether the item group should be the only one that is expanded |
| 1006 | * at a given time. |
| 1007 | * |
| 1008 | * Since: 2.20 |
| 1009 | */ |
| 1010 | ctk_container_class_install_child_property (cclass, CHILD_PROP_EXCLUSIVE, |
| 1011 | g_param_spec_boolean ("exclusive", |
| 1012 | P_("Exclusive")g_dgettext("ctk30" "-properties","Exclusive"), |
| 1013 | P_("Whether the item group should be the only expanded at a given time")g_dgettext("ctk30" "-properties","Whether the item group should be the only expanded at a given time" ), |
| 1014 | DEFAULT_CHILD_EXCLUSIVE(0), |
| 1015 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
| 1016 | |
| 1017 | /** |
| 1018 | * CtkToolPalette:expand: |
| 1019 | * |
| 1020 | * Whether the item group should receive extra space when the palette grows. |
| 1021 | * at a given time. |
| 1022 | * |
| 1023 | * Since: 2.20 |
| 1024 | */ |
| 1025 | ctk_container_class_install_child_property (cclass, CHILD_PROP_EXPAND, |
| 1026 | g_param_spec_boolean ("expand", |
| 1027 | P_("Expand")g_dgettext("ctk30" "-properties","Expand"), |
| 1028 | P_("Whether the item group should receive extra space when the palette grows")g_dgettext("ctk30" "-properties","Whether the item group should receive extra space when the palette grows" ), |
| 1029 | DEFAULT_CHILD_EXPAND(0), |
| 1030 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
| 1031 | |
| 1032 | ctk_widget_class_set_css_name (wclass, "toolpalette"); |
| 1033 | } |
| 1034 | |
| 1035 | /** |
| 1036 | * ctk_tool_palette_new: |
| 1037 | * |
| 1038 | * Creates a new tool palette. |
| 1039 | * |
| 1040 | * Returns: a new #CtkToolPalette |
| 1041 | * |
| 1042 | * Since: 2.20 |
| 1043 | */ |
| 1044 | CtkWidget* |
| 1045 | ctk_tool_palette_new (void) |
| 1046 | { |
| 1047 | return g_object_new (CTK_TYPE_TOOL_PALETTE(ctk_tool_palette_get_type ()), NULL((void*)0)); |
| 1048 | } |
| 1049 | |
| 1050 | /** |
| 1051 | * ctk_tool_palette_set_icon_size: |
| 1052 | * @palette: a #CtkToolPalette |
| 1053 | * @icon_size: (type int): the #CtkIconSize that icons in the tool |
| 1054 | * palette shall have |
| 1055 | * |
| 1056 | * Sets the size of icons in the tool palette. |
| 1057 | * |
| 1058 | * Since: 2.20 |
| 1059 | */ |
| 1060 | void |
| 1061 | ctk_tool_palette_set_icon_size (CtkToolPalette *palette, |
| 1062 | CtkIconSize icon_size) |
| 1063 | { |
| 1064 | CtkToolPalettePrivate *priv; |
| 1065 | |
| 1066 | g_return_if_fail (CTK_IS_TOOL_PALETTE (palette))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return; } } while (0); |
| 1067 | g_return_if_fail (icon_size != CTK_ICON_SIZE_INVALID)do { if ((icon_size != CTK_ICON_SIZE_INVALID)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "icon_size != CTK_ICON_SIZE_INVALID" ); return; } } while (0); |
| 1068 | |
| 1069 | priv = palette->priv; |
| 1070 | |
| 1071 | if (!priv->icon_size_set) |
| 1072 | { |
| 1073 | priv->icon_size_set = TRUE(!(0)); |
| 1074 | g_object_notify (G_OBJECT (palette)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), (((GType) ((20) << (2)))))))), "icon-size-set"); |
| 1075 | } |
| 1076 | |
| 1077 | if (priv->icon_size == icon_size) |
| 1078 | return; |
| 1079 | |
| 1080 | priv->icon_size = icon_size; |
| 1081 | g_object_notify (G_OBJECT (palette)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), (((GType) ((20) << (2)))))))), "icon-size"); |
| 1082 | |
| 1083 | ctk_tool_palette_reconfigured (palette); |
| 1084 | |
| 1085 | ctk_widget_queue_resize (CTK_WIDGET (palette)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_widget_get_type ()))))))); |
| 1086 | } |
| 1087 | |
| 1088 | /** |
| 1089 | * ctk_tool_palette_unset_icon_size: |
| 1090 | * @palette: a #CtkToolPalette |
| 1091 | * |
| 1092 | * Unsets the tool palette icon size set with ctk_tool_palette_set_icon_size(), |
| 1093 | * so that user preferences will be used to determine the icon size. |
| 1094 | * |
| 1095 | * Since: 2.20 |
| 1096 | */ |
| 1097 | void |
| 1098 | ctk_tool_palette_unset_icon_size (CtkToolPalette *palette) |
| 1099 | { |
| 1100 | CtkToolPalettePrivate* priv = palette->priv; |
| 1101 | CtkIconSize size; |
| 1102 | |
| 1103 | g_return_if_fail (CTK_IS_TOOL_PALETTE (palette))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return; } } while (0); |
| 1104 | |
| 1105 | if (palette->priv->icon_size_set) |
| 1106 | { |
| 1107 | size = DEFAULT_ICON_SIZECTK_ICON_SIZE_SMALL_TOOLBAR; |
| 1108 | |
| 1109 | if (size != palette->priv->icon_size) |
| 1110 | { |
| 1111 | ctk_tool_palette_set_icon_size (palette, size); |
| 1112 | g_object_notify (G_OBJECT (palette)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), (((GType) ((20) << (2)))))))), "icon-size"); |
| 1113 | } |
| 1114 | |
| 1115 | priv->icon_size_set = FALSE(0); |
| 1116 | g_object_notify (G_OBJECT (palette)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), (((GType) ((20) << (2)))))))), "icon-size-set"); |
| 1117 | } |
| 1118 | } |
| 1119 | |
| 1120 | /* Set the "toolbar-style" property and do appropriate things. |
| 1121 | * CtkToolbar does this by emitting a signal instead of just |
| 1122 | * calling a function... |
| 1123 | */ |
| 1124 | static void |
| 1125 | ctk_tool_palette_change_style (CtkToolPalette *palette, |
| 1126 | CtkToolbarStyle style) |
| 1127 | { |
| 1128 | CtkToolPalettePrivate* priv = palette->priv; |
| 1129 | |
| 1130 | if (priv->style != style) |
| 1131 | { |
| 1132 | priv->style = style; |
| 1133 | |
| 1134 | ctk_tool_palette_reconfigured (palette); |
| 1135 | |
| 1136 | ctk_widget_queue_resize (CTK_WIDGET (palette)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_widget_get_type ()))))))); |
| 1137 | g_object_notify (G_OBJECT (palette)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), (((GType) ((20) << (2)))))))), "toolbar-style"); |
| 1138 | } |
| 1139 | } |
| 1140 | |
| 1141 | |
| 1142 | /** |
| 1143 | * ctk_tool_palette_set_style: |
| 1144 | * @palette: a #CtkToolPalette |
| 1145 | * @style: the #CtkToolbarStyle that items in the tool palette shall have |
| 1146 | * |
| 1147 | * Sets the style (text, icons or both) of items in the tool palette. |
| 1148 | * |
| 1149 | * Since: 2.20 |
| 1150 | */ |
| 1151 | void |
| 1152 | ctk_tool_palette_set_style (CtkToolPalette *palette, |
| 1153 | CtkToolbarStyle style) |
| 1154 | { |
| 1155 | g_return_if_fail (CTK_IS_TOOL_PALETTE (palette))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return; } } while (0); |
| 1156 | |
| 1157 | palette->priv->style_set = TRUE(!(0)); |
| 1158 | ctk_tool_palette_change_style (palette, style); |
| 1159 | } |
| 1160 | |
| 1161 | |
| 1162 | /** |
| 1163 | * ctk_tool_palette_unset_style: |
| 1164 | * @palette: a #CtkToolPalette |
| 1165 | * |
| 1166 | * Unsets a toolbar style set with ctk_tool_palette_set_style(), |
| 1167 | * so that user preferences will be used to determine the toolbar style. |
| 1168 | * |
| 1169 | * Since: 2.20 |
| 1170 | */ |
| 1171 | void |
| 1172 | ctk_tool_palette_unset_style (CtkToolPalette *palette) |
| 1173 | { |
| 1174 | CtkToolPalettePrivate* priv = palette->priv; |
| 1175 | CtkToolbarStyle style; |
| 1176 | |
| 1177 | g_return_if_fail (CTK_IS_TOOL_PALETTE (palette))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return; } } while (0); |
| 1178 | |
| 1179 | if (priv->style_set) |
| 1180 | { |
| 1181 | style = DEFAULT_TOOLBAR_STYLECTK_TOOLBAR_ICONS; |
| 1182 | |
| 1183 | if (style != priv->style) |
| 1184 | ctk_tool_palette_change_style (palette, style); |
| 1185 | |
| 1186 | priv->style_set = FALSE(0); |
| 1187 | } |
| 1188 | } |
| 1189 | |
| 1190 | /** |
| 1191 | * ctk_tool_palette_get_icon_size: |
| 1192 | * @palette: a #CtkToolPalette |
| 1193 | * |
| 1194 | * Gets the size of icons in the tool palette. |
| 1195 | * See ctk_tool_palette_set_icon_size(). |
| 1196 | * |
| 1197 | * Returns: (type int): the #CtkIconSize of icons in the tool palette |
| 1198 | * |
| 1199 | * Since: 2.20 |
| 1200 | */ |
| 1201 | CtkIconSize |
| 1202 | ctk_tool_palette_get_icon_size (CtkToolPalette *palette) |
| 1203 | { |
| 1204 | g_return_val_if_fail (CTK_IS_TOOL_PALETTE (palette), DEFAULT_ICON_SIZE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return (CTK_ICON_SIZE_SMALL_TOOLBAR ); } } while (0); |
| 1205 | |
| 1206 | return palette->priv->icon_size; |
| 1207 | } |
| 1208 | |
| 1209 | /** |
| 1210 | * ctk_tool_palette_get_style: |
| 1211 | * @palette: a #CtkToolPalette |
| 1212 | * |
| 1213 | * Gets the style (icons, text or both) of items in the tool palette. |
| 1214 | * |
| 1215 | * Returns: the #CtkToolbarStyle of items in the tool palette. |
| 1216 | * |
| 1217 | * Since: 2.20 |
| 1218 | */ |
| 1219 | CtkToolbarStyle |
| 1220 | ctk_tool_palette_get_style (CtkToolPalette *palette) |
| 1221 | { |
| 1222 | g_return_val_if_fail (CTK_IS_TOOL_PALETTE (palette), DEFAULT_TOOLBAR_STYLE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return (CTK_TOOLBAR_ICONS ); } } while (0); |
| 1223 | |
| 1224 | return palette->priv->style; |
| 1225 | } |
| 1226 | |
| 1227 | static gint |
| 1228 | ctk_tool_palette_compare_groups (gconstpointer a, |
| 1229 | gconstpointer b) |
| 1230 | { |
| 1231 | const CtkToolItemGroupInfo *group_a = *((CtkToolItemGroupInfo **) a); |
| 1232 | const CtkToolItemGroupInfo *group_b = *((CtkToolItemGroupInfo **) b); |
| 1233 | |
| 1234 | return group_a->pos - group_b->pos; |
| 1235 | } |
| 1236 | |
| 1237 | /** |
| 1238 | * ctk_tool_palette_set_group_position: |
| 1239 | * @palette: a #CtkToolPalette |
| 1240 | * @group: a #CtkToolItemGroup which is a child of palette |
| 1241 | * @position: a new index for group |
| 1242 | * |
| 1243 | * Sets the position of the group as an index of the tool palette. |
| 1244 | * If position is 0 the group will become the first child, if position is |
| 1245 | * -1 it will become the last child. |
| 1246 | * |
| 1247 | * Since: 2.20 |
| 1248 | */ |
| 1249 | void |
| 1250 | ctk_tool_palette_set_group_position (CtkToolPalette *palette, |
| 1251 | CtkToolItemGroup *group, |
| 1252 | gint position) |
| 1253 | { |
| 1254 | CtkToolItemGroupInfo *group_new; |
| 1255 | CtkToolItemGroupInfo *group_old; |
| 1256 | gint old_position; |
| 1257 | |
| 1258 | g_return_if_fail (CTK_IS_TOOL_PALETTE (palette))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return; } } while (0); |
| 1259 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_group_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return; } } while (0); |
| 1260 | g_return_if_fail (position >= -1)do { if ((position >= -1)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "position >= -1"); return ; } } while (0); |
| 1261 | |
| 1262 | if (-1 == position) |
| 1263 | position = palette->priv->groups->len - 1; |
| 1264 | |
| 1265 | g_return_if_fail ((guint) position < palette->priv->groups->len)do { if (((guint) position < palette->priv->groups-> len)) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "(guint) position < palette->priv->groups->len" ); return; } } while (0); |
| 1266 | |
| 1267 | group_new = g_ptr_array_index (palette->priv->groups, position)((palette->priv->groups)->pdata)[position]; |
| 1268 | |
| 1269 | if (CTK_TOOL_ITEM_GROUP (group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (group), ((ctk_tool_item_group_get_type ()))) ))) == group_new->widget) |
| 1270 | return; |
| 1271 | |
| 1272 | old_position = ctk_tool_palette_get_group_position (palette, group); |
| 1273 | g_return_if_fail (old_position >= 0)do { if ((old_position >= 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "old_position >= 0"); return; } } while (0); |
| 1274 | |
| 1275 | group_old = g_ptr_array_index (palette->priv->groups, old_position)((palette->priv->groups)->pdata)[old_position]; |
| 1276 | |
| 1277 | group_new->pos = position; |
| 1278 | group_old->pos = old_position; |
| 1279 | |
| 1280 | g_ptr_array_sort (palette->priv->groups, ctk_tool_palette_compare_groups); |
| 1281 | |
| 1282 | ctk_widget_queue_resize (CTK_WIDGET (palette)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_widget_get_type ()))))))); |
| 1283 | } |
| 1284 | |
| 1285 | static void |
| 1286 | ctk_tool_palette_group_notify_collapsed (CtkToolItemGroup *group, |
| 1287 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 1288 | gpointer data) |
| 1289 | { |
| 1290 | CtkToolPalette *palette = CTK_TOOL_PALETTE (data)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (data), ((ctk_tool_palette_get_type ())))))); |
| 1291 | guint i; |
| 1292 | |
| 1293 | if (ctk_tool_item_group_get_collapsed (group)) |
| 1294 | return; |
| 1295 | |
| 1296 | for (i = 0; i < palette->priv->groups->len; ++i) |
| 1297 | { |
| 1298 | CtkToolItemGroupInfo *info = g_ptr_array_index (palette->priv->groups, i)((palette->priv->groups)->pdata)[i]; |
| 1299 | CtkToolItemGroup *current_group = info->widget; |
| 1300 | |
| 1301 | if (current_group && current_group != group) |
| 1302 | ctk_tool_item_group_set_collapsed (current_group, TRUE(!(0))); |
| 1303 | } |
| 1304 | } |
| 1305 | |
| 1306 | /** |
| 1307 | * ctk_tool_palette_set_exclusive: |
| 1308 | * @palette: a #CtkToolPalette |
| 1309 | * @group: a #CtkToolItemGroup which is a child of palette |
| 1310 | * @exclusive: whether the group should be exclusive or not |
| 1311 | * |
| 1312 | * Sets whether the group should be exclusive or not. |
| 1313 | * If an exclusive group is expanded all other groups are collapsed. |
| 1314 | * |
| 1315 | * Since: 2.20 |
| 1316 | */ |
| 1317 | void |
| 1318 | ctk_tool_palette_set_exclusive (CtkToolPalette *palette, |
| 1319 | CtkToolItemGroup *group, |
| 1320 | gboolean exclusive) |
| 1321 | { |
| 1322 | CtkToolItemGroupInfo *group_info; |
| 1323 | gint position; |
| 1324 | |
| 1325 | g_return_if_fail (CTK_IS_TOOL_PALETTE (palette))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return; } } while (0); |
| 1326 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_group_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return; } } while (0); |
| 1327 | |
| 1328 | position = ctk_tool_palette_get_group_position (palette, group); |
| 1329 | g_return_if_fail (position >= 0)do { if ((position >= 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "position >= 0"); return ; } } while (0); |
| 1330 | |
| 1331 | group_info = g_ptr_array_index (palette->priv->groups, position)((palette->priv->groups)->pdata)[position]; |
| 1332 | |
| 1333 | if (exclusive == group_info->exclusive) |
| 1334 | return; |
| 1335 | |
| 1336 | group_info->exclusive = exclusive; |
| 1337 | |
| 1338 | if (group_info->exclusive != (0 != group_info->notify_collapsed)) |
| 1339 | { |
| 1340 | if (group_info->exclusive) |
| 1341 | { |
| 1342 | group_info->notify_collapsed = |
| 1343 | g_signal_connect (group, "notify::collapsed",g_signal_connect_data ((group), ("notify::collapsed"), (((GCallback ) (ctk_tool_palette_group_notify_collapsed))), (palette), ((void *)0), (GConnectFlags) 0) |
| 1344 | G_CALLBACK (ctk_tool_palette_group_notify_collapsed),g_signal_connect_data ((group), ("notify::collapsed"), (((GCallback ) (ctk_tool_palette_group_notify_collapsed))), (palette), ((void *)0), (GConnectFlags) 0) |
| 1345 | palette)g_signal_connect_data ((group), ("notify::collapsed"), (((GCallback ) (ctk_tool_palette_group_notify_collapsed))), (palette), ((void *)0), (GConnectFlags) 0); |
| 1346 | } |
| 1347 | else |
| 1348 | { |
| 1349 | g_signal_handler_disconnect (group, group_info->notify_collapsed); |
| 1350 | group_info->notify_collapsed = 0; |
| 1351 | } |
| 1352 | } |
| 1353 | |
| 1354 | ctk_tool_palette_group_notify_collapsed (group_info->widget, NULL((void*)0), palette); |
| 1355 | ctk_widget_child_notify (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ())))))), "exclusive"); |
| 1356 | } |
| 1357 | |
| 1358 | /** |
| 1359 | * ctk_tool_palette_set_expand: |
| 1360 | * @palette: a #CtkToolPalette |
| 1361 | * @group: a #CtkToolItemGroup which is a child of palette |
| 1362 | * @expand: whether the group should be given extra space |
| 1363 | * |
| 1364 | * Sets whether the group should be given extra space. |
| 1365 | * |
| 1366 | * Since: 2.20 |
| 1367 | */ |
| 1368 | void |
| 1369 | ctk_tool_palette_set_expand (CtkToolPalette *palette, |
| 1370 | CtkToolItemGroup *group, |
| 1371 | gboolean expand) |
| 1372 | { |
| 1373 | CtkToolItemGroupInfo *group_info; |
| 1374 | gint position; |
| 1375 | |
| 1376 | g_return_if_fail (CTK_IS_TOOL_PALETTE (palette))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return; } } while (0); |
| 1377 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_group_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return; } } while (0); |
| 1378 | |
| 1379 | position = ctk_tool_palette_get_group_position (palette, group); |
| 1380 | g_return_if_fail (position >= 0)do { if ((position >= 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "position >= 0"); return ; } } while (0); |
| 1381 | |
| 1382 | group_info = g_ptr_array_index (palette->priv->groups, position)((palette->priv->groups)->pdata)[position]; |
| 1383 | |
| 1384 | if (expand != group_info->expand) |
| 1385 | { |
| 1386 | group_info->expand = expand; |
| 1387 | ctk_widget_queue_resize (CTK_WIDGET (palette)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_widget_get_type ()))))))); |
| 1388 | ctk_widget_child_notify (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ())))))), "expand"); |
| 1389 | } |
| 1390 | } |
| 1391 | |
| 1392 | /** |
| 1393 | * ctk_tool_palette_get_group_position: |
| 1394 | * @palette: a #CtkToolPalette |
| 1395 | * @group: a #CtkToolItemGroup |
| 1396 | * |
| 1397 | * Gets the position of @group in @palette as index. |
| 1398 | * See ctk_tool_palette_set_group_position(). |
| 1399 | * |
| 1400 | * Returns: the index of group or -1 if @group is not a child of @palette |
| 1401 | * |
| 1402 | * Since: 2.20 |
| 1403 | */ |
| 1404 | gint |
| 1405 | ctk_tool_palette_get_group_position (CtkToolPalette *palette, |
| 1406 | CtkToolItemGroup *group) |
| 1407 | { |
| 1408 | guint i; |
| 1409 | |
| 1410 | g_return_val_if_fail (CTK_IS_TOOL_PALETTE (palette), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return (-1); } } while ( 0); |
| 1411 | g_return_val_if_fail (CTK_IS_TOOL_ITEM_GROUP (group), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_group_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return (-1); } } while (0); |
| 1412 | |
| 1413 | for (i = 0; i < palette->priv->groups->len; ++i) |
| 1414 | { |
| 1415 | CtkToolItemGroupInfo *info = g_ptr_array_index (palette->priv->groups, i)((palette->priv->groups)->pdata)[i]; |
| 1416 | if ((gpointer) group == info->widget) |
| 1417 | return i; |
| 1418 | } |
| 1419 | |
| 1420 | return -1; |
| 1421 | } |
| 1422 | |
| 1423 | /** |
| 1424 | * ctk_tool_palette_get_exclusive: |
| 1425 | * @palette: a #CtkToolPalette |
| 1426 | * @group: a #CtkToolItemGroup which is a child of palette |
| 1427 | * |
| 1428 | * Gets whether @group is exclusive or not. |
| 1429 | * See ctk_tool_palette_set_exclusive(). |
| 1430 | * |
| 1431 | * Returns: %TRUE if @group is exclusive |
| 1432 | * |
| 1433 | * Since: 2.20 |
| 1434 | */ |
| 1435 | gboolean |
| 1436 | ctk_tool_palette_get_exclusive (CtkToolPalette *palette, |
| 1437 | CtkToolItemGroup *group) |
| 1438 | { |
| 1439 | gint position; |
| 1440 | CtkToolItemGroupInfo *info; |
| 1441 | |
| 1442 | g_return_val_if_fail (CTK_IS_TOOL_PALETTE (palette), DEFAULT_CHILD_EXCLUSIVE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return ((0)); } } while (0); |
| 1443 | g_return_val_if_fail (CTK_IS_TOOL_ITEM_GROUP (group), DEFAULT_CHILD_EXCLUSIVE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_group_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return ((0)); } } while (0); |
| 1444 | |
| 1445 | position = ctk_tool_palette_get_group_position (palette, group); |
| 1446 | g_return_val_if_fail (position >= 0, DEFAULT_CHILD_EXCLUSIVE)do { if ((position >= 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "position >= 0"); return ((0)); } } while (0); |
| 1447 | |
| 1448 | info = g_ptr_array_index (palette->priv->groups, position)((palette->priv->groups)->pdata)[position]; |
| 1449 | |
| 1450 | return info->exclusive; |
| 1451 | } |
| 1452 | |
| 1453 | /** |
| 1454 | * ctk_tool_palette_get_expand: |
| 1455 | * @palette: a #CtkToolPalette |
| 1456 | * @group: a #CtkToolItemGroup which is a child of palette |
| 1457 | * |
| 1458 | * Gets whether group should be given extra space. |
| 1459 | * See ctk_tool_palette_set_expand(). |
| 1460 | * |
| 1461 | * Returns: %TRUE if group should be given extra space, %FALSE otherwise |
| 1462 | * |
| 1463 | * Since: 2.20 |
| 1464 | */ |
| 1465 | gboolean |
| 1466 | ctk_tool_palette_get_expand (CtkToolPalette *palette, |
| 1467 | CtkToolItemGroup *group) |
| 1468 | { |
| 1469 | gint position; |
| 1470 | CtkToolItemGroupInfo *info; |
| 1471 | |
| 1472 | g_return_val_if_fail (CTK_IS_TOOL_PALETTE (palette), DEFAULT_CHILD_EXPAND)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return ((0)); } } while (0); |
| 1473 | g_return_val_if_fail (CTK_IS_TOOL_ITEM_GROUP (group), DEFAULT_CHILD_EXPAND)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_group_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return ((0)); } } while (0); |
| 1474 | |
| 1475 | position = ctk_tool_palette_get_group_position (palette, group); |
| 1476 | g_return_val_if_fail (position >= 0, DEFAULT_CHILD_EXPAND)do { if ((position >= 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "position >= 0"); return ((0)); } } while (0); |
| 1477 | |
| 1478 | info = g_ptr_array_index (palette->priv->groups, position)((palette->priv->groups)->pdata)[position]; |
| 1479 | |
| 1480 | return info->expand; |
| 1481 | } |
| 1482 | |
| 1483 | /** |
| 1484 | * ctk_tool_palette_get_drop_item: |
| 1485 | * @palette: a #CtkToolPalette |
| 1486 | * @x: the x position |
| 1487 | * @y: the y position |
| 1488 | * |
| 1489 | * Gets the item at position (x, y). |
| 1490 | * See ctk_tool_palette_get_drop_group(). |
| 1491 | * |
| 1492 | * Returns: (nullable) (transfer none): the #CtkToolItem at position or %NULL if there is no such item |
| 1493 | * |
| 1494 | * Since: 2.20 |
| 1495 | */ |
| 1496 | CtkToolItem* |
| 1497 | ctk_tool_palette_get_drop_item (CtkToolPalette *palette, |
| 1498 | gint x, |
| 1499 | gint y) |
| 1500 | { |
| 1501 | CtkAllocation allocation; |
| 1502 | CtkToolItemGroup *group = ctk_tool_palette_get_drop_group (palette, x, y); |
| 1503 | CtkWidget *widget = CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ())))))); |
| 1504 | |
| 1505 | if (group) |
| 1506 | { |
| 1507 | ctk_widget_get_allocation (widget, &allocation); |
| 1508 | return ctk_tool_item_group_get_drop_item (group, |
| 1509 | x - allocation.x, |
| 1510 | y - allocation.y); |
| 1511 | } |
| 1512 | |
| 1513 | return NULL((void*)0); |
| 1514 | } |
| 1515 | |
| 1516 | /** |
| 1517 | * ctk_tool_palette_get_drop_group: |
| 1518 | * @palette: a #CtkToolPalette |
| 1519 | * @x: the x position |
| 1520 | * @y: the y position |
| 1521 | * |
| 1522 | * Gets the group at position (x, y). |
| 1523 | * |
| 1524 | * Returns: (nullable) (transfer none): the #CtkToolItemGroup at position |
| 1525 | * or %NULL if there is no such group |
| 1526 | * |
| 1527 | * Since: 2.20 |
| 1528 | */ |
| 1529 | CtkToolItemGroup* |
| 1530 | ctk_tool_palette_get_drop_group (CtkToolPalette *palette, |
| 1531 | gint x, |
| 1532 | gint y) |
| 1533 | { |
| 1534 | CtkAllocation allocation; |
| 1535 | guint i; |
| 1536 | |
| 1537 | g_return_val_if_fail (CTK_IS_TOOL_PALETTE (palette), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return (((void*)0)); } } while (0); |
| 1538 | |
| 1539 | ctk_widget_get_allocation (CTK_WIDGET (palette)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_widget_get_type ())))))), &allocation); |
| 1540 | |
| 1541 | g_return_val_if_fail (x >= 0 && x < allocation.width, NULL)do { if ((x >= 0 && x < allocation.width)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "x >= 0 && x < allocation.width"); return (( (void*)0)); } } while (0); |
| 1542 | g_return_val_if_fail (y >= 0 && y < allocation.height, NULL)do { if ((y >= 0 && y < allocation.height)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "y >= 0 && y < allocation.height"); return ( ((void*)0)); } } while (0); |
| 1543 | |
| 1544 | for (i = 0; i < palette->priv->groups->len; ++i) |
| 1545 | { |
| 1546 | CtkToolItemGroupInfo *group = g_ptr_array_index (palette->priv->groups, i)((palette->priv->groups)->pdata)[i]; |
| 1547 | CtkWidget *widget; |
| 1548 | gint x0, y0; |
| 1549 | |
| 1550 | if (!group->widget) |
| 1551 | continue; |
| 1552 | |
| 1553 | widget = CTK_WIDGET (group->widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group->widget)), ((ctk_widget_get_type ())))))); |
| 1554 | ctk_widget_get_allocation (widget, &allocation); |
| 1555 | |
| 1556 | x0 = x - allocation.x; |
| 1557 | y0 = y - allocation.y; |
| 1558 | |
| 1559 | if (x0 >= 0 && x0 < allocation.width && |
| 1560 | y0 >= 0 && y0 < allocation.height) |
| 1561 | return CTK_TOOL_ITEM_GROUP (widget)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (widget), ((ctk_tool_item_group_get_type ())) )))); |
| 1562 | } |
| 1563 | |
| 1564 | return NULL((void*)0); |
| 1565 | } |
| 1566 | |
| 1567 | /** |
| 1568 | * ctk_tool_palette_get_drag_item: |
| 1569 | * @palette: a #CtkToolPalette |
| 1570 | * @selection: a #CtkSelectionData |
| 1571 | * |
| 1572 | * Get the dragged item from the selection. |
| 1573 | * This could be a #CtkToolItem or a #CtkToolItemGroup. |
| 1574 | * |
| 1575 | * Returns: (transfer none): the dragged item in selection |
| 1576 | * |
| 1577 | * Since: 2.20 |
| 1578 | */ |
| 1579 | CtkWidget* |
| 1580 | ctk_tool_palette_get_drag_item (CtkToolPalette *palette, |
| 1581 | const CtkSelectionData *selection) |
| 1582 | { |
| 1583 | CtkToolPaletteDragData *data; |
| 1584 | CdkAtom target; |
| 1585 | |
| 1586 | g_return_val_if_fail (CTK_IS_TOOL_PALETTE (palette), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return (((void*)0)); } } while (0); |
| 1587 | g_return_val_if_fail (NULL != selection, NULL)do { if ((((void*)0) != selection)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "NULL != selection"); return (((void*)0)); } } while (0); |
| 1588 | |
| 1589 | g_return_val_if_fail (ctk_selection_data_get_format (selection) == 8, NULL)do { if ((ctk_selection_data_get_format (selection) == 8)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "ctk_selection_data_get_format (selection) == 8"); return (((void*)0)); } } while (0); |
| 1590 | g_return_val_if_fail (ctk_selection_data_get_length (selection) == sizeof (CtkToolPaletteDragData), NULL)do { if ((ctk_selection_data_get_length (selection) == sizeof (CtkToolPaletteDragData))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "ctk_selection_data_get_length (selection) == sizeof (CtkToolPaletteDragData)" ); return (((void*)0)); } } while (0); |
| 1591 | target = ctk_selection_data_get_target (selection); |
| 1592 | g_return_val_if_fail (target == dnd_target_atom_item ||do { if ((target == dnd_target_atom_item || target == dnd_target_atom_group )) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "target == dnd_target_atom_item || target == dnd_target_atom_group" ); return (((void*)0)); } } while (0) |
| 1593 | target == dnd_target_atom_group,do { if ((target == dnd_target_atom_item || target == dnd_target_atom_group )) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "target == dnd_target_atom_item || target == dnd_target_atom_group" ); return (((void*)0)); } } while (0) |
| 1594 | NULL)do { if ((target == dnd_target_atom_item || target == dnd_target_atom_group )) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "target == dnd_target_atom_item || target == dnd_target_atom_group" ); return (((void*)0)); } } while (0); |
| 1595 | |
| 1596 | data = (CtkToolPaletteDragData*) ctk_selection_data_get_data (selection); |
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption | |
| 1597 | |
| 1598 | g_return_val_if_fail (data->palette == palette, NULL)do { if ((data->palette == palette)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "data->palette == palette" ); return (((void*)0)); } } while (0); |
| 1599 | |
| 1600 | if (dnd_target_atom_item == target) |
| 1601 | g_return_val_if_fail (CTK_IS_TOOL_ITEM (data->item), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((data->item)); GType __t = ((ctk_tool_item_get_type () )); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_TOOL_ITEM (data->item)"); return (((void*)0)); } } while (0); |
| 1602 | else if (dnd_target_atom_group == target) |
| 1603 | g_return_val_if_fail (CTK_IS_TOOL_ITEM_GROUP (data->item), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (data->item); GType __t = ((ctk_tool_item_group_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_TOOL_ITEM_GROUP (data->item)" ); return (((void*)0)); } } while (0); |
| 1604 | |
| 1605 | return data->item; |
| 1606 | } |
| 1607 | |
| 1608 | /** |
| 1609 | * ctk_tool_palette_set_drag_source: |
| 1610 | * @palette: a #CtkToolPalette |
| 1611 | * @targets: the #CtkToolPaletteDragTargets |
| 1612 | * which the widget should support |
| 1613 | * |
| 1614 | * Sets the tool palette as a drag source. |
| 1615 | * Enables all groups and items in the tool palette as drag sources |
| 1616 | * on button 1 and button 3 press with copy and move actions. |
| 1617 | * See ctk_drag_source_set(). |
| 1618 | * |
| 1619 | * Since: 2.20 |
| 1620 | */ |
| 1621 | void |
| 1622 | ctk_tool_palette_set_drag_source (CtkToolPalette *palette, |
| 1623 | CtkToolPaletteDragTargets targets) |
| 1624 | { |
| 1625 | guint i; |
| 1626 | |
| 1627 | g_return_if_fail (CTK_IS_TOOL_PALETTE (palette))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return; } } while (0); |
| 1628 | |
| 1629 | if ((palette->priv->drag_source & targets) == targets) |
| 1630 | return; |
| 1631 | |
| 1632 | palette->priv->drag_source |= targets; |
| 1633 | |
| 1634 | for (i = 0; i < palette->priv->groups->len; ++i) |
| 1635 | { |
| 1636 | CtkToolItemGroupInfo *info = g_ptr_array_index (palette->priv->groups, i)((palette->priv->groups)->pdata)[i]; |
| 1637 | if (info->widget) |
| 1638 | ctk_container_forall (CTK_CONTAINER (info->widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((info->widget)), ((ctk_container_get_type ())))))), |
| 1639 | _ctk_tool_palette_child_set_drag_source, |
| 1640 | palette); |
| 1641 | } |
| 1642 | } |
| 1643 | |
| 1644 | /** |
| 1645 | * ctk_tool_palette_add_drag_dest: |
| 1646 | * @palette: a #CtkToolPalette |
| 1647 | * @widget: a #CtkWidget which should be a drag destination for @palette |
| 1648 | * @flags: the flags that specify what actions CTK+ should take for drops |
| 1649 | * on that widget |
| 1650 | * @targets: the #CtkToolPaletteDragTargets which the widget |
| 1651 | * should support |
| 1652 | * @actions: the #CdkDragActions which the widget should suppport |
| 1653 | * |
| 1654 | * Sets @palette as drag source (see ctk_tool_palette_set_drag_source()) |
| 1655 | * and sets @widget as a drag destination for drags from @palette. |
| 1656 | * See ctk_drag_dest_set(). |
| 1657 | * |
| 1658 | * Since: 2.20 |
| 1659 | */ |
| 1660 | void |
| 1661 | ctk_tool_palette_add_drag_dest (CtkToolPalette *palette, |
| 1662 | CtkWidget *widget, |
| 1663 | CtkDestDefaults flags, |
| 1664 | CtkToolPaletteDragTargets targets, |
| 1665 | CdkDragAction actions) |
| 1666 | { |
| 1667 | CtkTargetEntry entries[G_N_ELEMENTS (dnd_targets)(sizeof (dnd_targets) / sizeof ((dnd_targets)[0]))]; |
| 1668 | gint n_entries = 0; |
| 1669 | |
| 1670 | g_return_if_fail (CTK_IS_TOOL_PALETTE (palette))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return; } } while (0); |
| 1671 | g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_WIDGET (widget)"); return; } } while (0); |
| 1672 | |
| 1673 | ctk_tool_palette_set_drag_source (palette, |
| 1674 | targets); |
| 1675 | |
| 1676 | if (targets & CTK_TOOL_PALETTE_DRAG_ITEMS) |
| 1677 | entries[n_entries++] = dnd_targets[0]; |
| 1678 | if (targets & CTK_TOOL_PALETTE_DRAG_GROUPS) |
| 1679 | entries[n_entries++] = dnd_targets[1]; |
| 1680 | |
| 1681 | ctk_drag_dest_set (widget, flags, entries, n_entries, actions); |
| 1682 | } |
| 1683 | |
| 1684 | void |
| 1685 | _ctk_tool_palette_get_item_size (CtkToolPalette *palette, |
| 1686 | CtkRequisition *item_size, |
| 1687 | gboolean homogeneous_only, |
| 1688 | gint *requested_rows) |
| 1689 | { |
| 1690 | CtkRequisition max_requisition; |
| 1691 | gint max_rows; |
| 1692 | guint i; |
| 1693 | |
| 1694 | g_return_if_fail (CTK_IS_TOOL_PALETTE (palette))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return; } } while (0); |
| 1695 | g_return_if_fail (NULL != item_size)do { if ((((void*)0) != item_size)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "NULL != item_size"); return ; } } while (0); |
| 1696 | |
| 1697 | max_requisition.width = 0; |
| 1698 | max_requisition.height = 0; |
| 1699 | max_rows = 0; |
| 1700 | |
| 1701 | /* iterate over all groups and calculate the max item_size and max row request */ |
| 1702 | for (i = 0; i < palette->priv->groups->len; ++i) |
| 1703 | { |
| 1704 | CtkRequisition requisition; |
| 1705 | gint rows; |
| 1706 | CtkToolItemGroupInfo *group = g_ptr_array_index (palette->priv->groups, i)((palette->priv->groups)->pdata)[i]; |
| 1707 | |
| 1708 | if (!group->widget) |
| 1709 | continue; |
| 1710 | |
| 1711 | _ctk_tool_item_group_item_size_request (group->widget, &requisition, homogeneous_only, &rows); |
| 1712 | |
| 1713 | max_requisition.width = MAX (max_requisition.width, requisition.width)(((max_requisition.width) > (requisition.width)) ? (max_requisition .width) : (requisition.width)); |
| 1714 | max_requisition.height = MAX (max_requisition.height, requisition.height)(((max_requisition.height) > (requisition.height)) ? (max_requisition .height) : (requisition.height)); |
| 1715 | max_rows = MAX (max_rows, rows)(((max_rows) > (rows)) ? (max_rows) : (rows)); |
| 1716 | } |
| 1717 | |
| 1718 | *item_size = max_requisition; |
| 1719 | if (requested_rows) |
| 1720 | *requested_rows = max_rows; |
| 1721 | } |
| 1722 | |
| 1723 | static void |
| 1724 | ctk_tool_palette_item_drag_data_get (CtkWidget *widget, |
| 1725 | CdkDragContext *context G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 1726 | CtkSelectionData *selection, |
| 1727 | guint info G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 1728 | guint time G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 1729 | gpointer data) |
| 1730 | { |
| 1731 | CtkToolPaletteDragData drag_data = { CTK_TOOL_PALETTE (data)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (data), ((ctk_tool_palette_get_type ())))))), NULL((void*)0) }; |
| 1732 | CdkAtom target; |
| 1733 | |
| 1734 | target = ctk_selection_data_get_target (selection); |
| 1735 | |
| 1736 | if (target == dnd_target_atom_item) |
| 1737 | drag_data.item = ctk_widget_get_ancestor (widget, CTK_TYPE_TOOL_ITEM(ctk_tool_item_get_type ())); |
| 1738 | |
| 1739 | if (drag_data.item) |
| 1740 | ctk_selection_data_set (selection, target, 8, |
| 1741 | (guchar*) &drag_data, sizeof (drag_data)); |
| 1742 | } |
| 1743 | |
| 1744 | static void |
| 1745 | ctk_tool_palette_child_drag_data_get (CtkWidget *widget, |
| 1746 | CdkDragContext *context G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 1747 | CtkSelectionData *selection, |
| 1748 | guint info G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 1749 | guint time G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 1750 | gpointer data) |
| 1751 | { |
| 1752 | CtkToolPaletteDragData drag_data = { CTK_TOOL_PALETTE (data)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (data), ((ctk_tool_palette_get_type ())))))), NULL((void*)0) }; |
| 1753 | CdkAtom target; |
| 1754 | |
| 1755 | target = ctk_selection_data_get_target (selection); |
| 1756 | |
| 1757 | if (target == dnd_target_atom_group) |
| 1758 | drag_data.item = ctk_widget_get_ancestor (widget, CTK_TYPE_TOOL_ITEM_GROUP(ctk_tool_item_group_get_type ())); |
| 1759 | |
| 1760 | if (drag_data.item) |
| 1761 | ctk_selection_data_set (selection, target, 8, |
| 1762 | (guchar*) &drag_data, sizeof (drag_data)); |
| 1763 | } |
| 1764 | |
| 1765 | void |
| 1766 | _ctk_tool_palette_child_set_drag_source (CtkWidget *child, |
| 1767 | gpointer data) |
| 1768 | { |
| 1769 | CtkToolPalette *palette = CTK_TOOL_PALETTE (data)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (data), ((ctk_tool_palette_get_type ())))))); |
| 1770 | |
| 1771 | /* Check drag_source, |
| 1772 | * to work properly when called from ctk_tool_item_group_insert(). |
| 1773 | */ |
| 1774 | if (!palette->priv->drag_source) |
| 1775 | return; |
| 1776 | |
| 1777 | if (CTK_IS_TOOL_ITEM (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (child)); GType __t = ((ctk_tool_item_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))) && |
| 1778 | (palette->priv->drag_source & CTK_TOOL_PALETTE_DRAG_ITEMS)) |
| 1779 | { |
| 1780 | /* Connect to child instead of the item itself, |
| 1781 | * to work arround bug 510377. |
| 1782 | */ |
| 1783 | if (CTK_IS_TOOL_BUTTON (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (child)); GType __t = ((ctk_tool_button_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) |
| 1784 | child = ctk_bin_get_child (CTK_BIN (child)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_bin_get_type ()))))))); |
| 1785 | |
| 1786 | if (!child) |
| 1787 | return; |
| 1788 | |
| 1789 | ctk_drag_source_set (child, CDK_BUTTON1_MASK | CDK_BUTTON3_MASK, |
| 1790 | &dnd_targets[0], 1, CDK_ACTION_COPY | CDK_ACTION_MOVE); |
| 1791 | |
| 1792 | g_signal_connect (child, "drag-data-get",g_signal_connect_data ((child), ("drag-data-get"), (((GCallback ) (ctk_tool_palette_item_drag_data_get))), (palette), ((void* )0), (GConnectFlags) 0) |
| 1793 | G_CALLBACK (ctk_tool_palette_item_drag_data_get),g_signal_connect_data ((child), ("drag-data-get"), (((GCallback ) (ctk_tool_palette_item_drag_data_get))), (palette), ((void* )0), (GConnectFlags) 0) |
| 1794 | palette)g_signal_connect_data ((child), ("drag-data-get"), (((GCallback ) (ctk_tool_palette_item_drag_data_get))), (palette), ((void* )0), (GConnectFlags) 0); |
| 1795 | } |
| 1796 | else if (CTK_IS_BUTTON (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (child)); GType __t = ((ctk_button_get_type ())); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))) && |
| 1797 | (palette->priv->drag_source & CTK_TOOL_PALETTE_DRAG_GROUPS)) |
| 1798 | { |
| 1799 | ctk_drag_source_set (child, CDK_BUTTON1_MASK | CDK_BUTTON3_MASK, |
| 1800 | &dnd_targets[1], 1, CDK_ACTION_COPY | CDK_ACTION_MOVE); |
| 1801 | |
| 1802 | g_signal_connect (child, "drag-data-get",g_signal_connect_data ((child), ("drag-data-get"), (((GCallback ) (ctk_tool_palette_child_drag_data_get))), (palette), ((void *)0), (GConnectFlags) 0) |
| 1803 | G_CALLBACK (ctk_tool_palette_child_drag_data_get),g_signal_connect_data ((child), ("drag-data-get"), (((GCallback ) (ctk_tool_palette_child_drag_data_get))), (palette), ((void *)0), (GConnectFlags) 0) |
| 1804 | palette)g_signal_connect_data ((child), ("drag-data-get"), (((GCallback ) (ctk_tool_palette_child_drag_data_get))), (palette), ((void *)0), (GConnectFlags) 0); |
| 1805 | } |
| 1806 | } |
| 1807 | |
| 1808 | /** |
| 1809 | * ctk_tool_palette_get_drag_target_item: |
| 1810 | * |
| 1811 | * Gets the target entry for a dragged #CtkToolItem. |
| 1812 | * |
| 1813 | * Returns: (transfer none): the #CtkTargetEntry for a dragged item. |
| 1814 | * |
| 1815 | * Since: 2.20 |
| 1816 | */ |
| 1817 | const CtkTargetEntry* |
| 1818 | ctk_tool_palette_get_drag_target_item (void) |
| 1819 | { |
| 1820 | return &dnd_targets[0]; |
| 1821 | } |
| 1822 | |
| 1823 | /** |
| 1824 | * ctk_tool_palette_get_drag_target_group: |
| 1825 | * |
| 1826 | * Get the target entry for a dragged #CtkToolItemGroup. |
| 1827 | * |
| 1828 | * Returns: (transfer none): the #CtkTargetEntry for a dragged group |
| 1829 | * |
| 1830 | * Since: 2.20 |
| 1831 | */ |
| 1832 | const CtkTargetEntry* |
| 1833 | ctk_tool_palette_get_drag_target_group (void) |
| 1834 | { |
| 1835 | return &dnd_targets[1]; |
| 1836 | } |
| 1837 | |
| 1838 | void |
| 1839 | _ctk_tool_palette_set_expanding_child (CtkToolPalette *palette, |
| 1840 | CtkWidget *widget) |
| 1841 | { |
| 1842 | g_return_if_fail (CTK_IS_TOOL_PALETTE (palette))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return; } } while (0); |
| 1843 | palette->priv->expanding_child = widget; |
| 1844 | } |
| 1845 | |
| 1846 | /** |
| 1847 | * ctk_tool_palette_get_hadjustment: |
| 1848 | * @palette: a #CtkToolPalette |
| 1849 | * |
| 1850 | * Gets the horizontal adjustment of the tool palette. |
| 1851 | * |
| 1852 | * Returns: (transfer none): the horizontal adjustment of @palette |
| 1853 | * |
| 1854 | * Since: 2.20 |
| 1855 | * |
| 1856 | * Deprecated: 3.0: Use ctk_scrollable_get_hadjustment() |
| 1857 | */ |
| 1858 | CtkAdjustment* |
| 1859 | ctk_tool_palette_get_hadjustment (CtkToolPalette *palette) |
| 1860 | { |
| 1861 | g_return_val_if_fail (CTK_IS_TOOL_PALETTE (palette), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return (((void*)0)); } } while (0); |
| 1862 | |
| 1863 | return palette->priv->hadjustment; |
| 1864 | } |
| 1865 | |
| 1866 | static void |
| 1867 | ctk_tool_palette_set_hadjustment (CtkToolPalette *palette, |
| 1868 | CtkAdjustment *adjustment) |
| 1869 | { |
| 1870 | CtkToolPalettePrivate *priv = palette->priv; |
| 1871 | |
| 1872 | if (adjustment && priv->hadjustment == adjustment) |
| 1873 | return; |
| 1874 | |
| 1875 | if (priv->hadjustment != NULL((void*)0)) |
| 1876 | { |
| 1877 | g_signal_handlers_disconnect_by_func (priv->hadjustment,g_signal_handlers_disconnect_matched ((priv->hadjustment), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_tool_palette_adjustment_value_changed ), (palette)) |
| 1878 | ctk_tool_palette_adjustment_value_changed,g_signal_handlers_disconnect_matched ((priv->hadjustment), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_tool_palette_adjustment_value_changed ), (palette)) |
| 1879 | palette)g_signal_handlers_disconnect_matched ((priv->hadjustment), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_tool_palette_adjustment_value_changed ), (palette)); |
| 1880 | g_object_unref (priv->hadjustment); |
| 1881 | } |
| 1882 | |
| 1883 | if (adjustment == NULL((void*)0)) |
| 1884 | adjustment = ctk_adjustment_new (0.0, 0.0, 0.0, |
| 1885 | 0.0, 0.0, 0.0); |
| 1886 | |
| 1887 | g_signal_connect (adjustment, "value-changed",g_signal_connect_data ((adjustment), ("value-changed"), (((GCallback ) (ctk_tool_palette_adjustment_value_changed))), (palette), ( (void*)0), (GConnectFlags) 0) |
| 1888 | G_CALLBACK (ctk_tool_palette_adjustment_value_changed),g_signal_connect_data ((adjustment), ("value-changed"), (((GCallback ) (ctk_tool_palette_adjustment_value_changed))), (palette), ( (void*)0), (GConnectFlags) 0) |
| 1889 | palette)g_signal_connect_data ((adjustment), ("value-changed"), (((GCallback ) (ctk_tool_palette_adjustment_value_changed))), (palette), ( (void*)0), (GConnectFlags) 0); |
| 1890 | priv->hadjustment = g_object_ref_sink (adjustment)((__typeof__ (adjustment)) (g_object_ref_sink) (adjustment)); |
| 1891 | /* FIXME: Adjustment should probably have its values updated now */ |
| 1892 | g_object_notify (G_OBJECT (palette)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), (((GType) ((20) << (2)))))))), "hadjustment"); |
| 1893 | } |
| 1894 | |
| 1895 | /** |
| 1896 | * ctk_tool_palette_get_vadjustment: |
| 1897 | * @palette: a #CtkToolPalette |
| 1898 | * |
| 1899 | * Gets the vertical adjustment of the tool palette. |
| 1900 | * |
| 1901 | * Returns: (transfer none): the vertical adjustment of @palette |
| 1902 | * |
| 1903 | * Since: 2.20 |
| 1904 | * |
| 1905 | * Deprecated: 3.0: Use ctk_scrollable_get_vadjustment() |
| 1906 | */ |
| 1907 | CtkAdjustment* |
| 1908 | ctk_tool_palette_get_vadjustment (CtkToolPalette *palette) |
| 1909 | { |
| 1910 | g_return_val_if_fail (CTK_IS_TOOL_PALETTE (palette), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return (((void*)0)); } } while (0); |
| 1911 | |
| 1912 | return palette->priv->vadjustment; |
| 1913 | } |
| 1914 | |
| 1915 | static void |
| 1916 | ctk_tool_palette_set_vadjustment (CtkToolPalette *palette, |
| 1917 | CtkAdjustment *adjustment) |
| 1918 | { |
| 1919 | CtkToolPalettePrivate *priv = palette->priv; |
| 1920 | |
| 1921 | if (adjustment && priv->vadjustment == adjustment) |
| 1922 | return; |
| 1923 | |
| 1924 | if (priv->vadjustment != NULL((void*)0)) |
| 1925 | { |
| 1926 | g_signal_handlers_disconnect_by_func (priv->vadjustment,g_signal_handlers_disconnect_matched ((priv->vadjustment), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_tool_palette_adjustment_value_changed ), (palette)) |
| 1927 | ctk_tool_palette_adjustment_value_changed,g_signal_handlers_disconnect_matched ((priv->vadjustment), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_tool_palette_adjustment_value_changed ), (palette)) |
| 1928 | palette)g_signal_handlers_disconnect_matched ((priv->vadjustment), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_tool_palette_adjustment_value_changed ), (palette)); |
| 1929 | g_object_unref (priv->vadjustment); |
| 1930 | } |
| 1931 | |
| 1932 | if (adjustment == NULL((void*)0)) |
| 1933 | adjustment = ctk_adjustment_new (0.0, 0.0, 0.0, |
| 1934 | 0.0, 0.0, 0.0); |
| 1935 | |
| 1936 | g_signal_connect (adjustment, "value-changed",g_signal_connect_data ((adjustment), ("value-changed"), (((GCallback ) (ctk_tool_palette_adjustment_value_changed))), (palette), ( (void*)0), (GConnectFlags) 0) |
| 1937 | G_CALLBACK (ctk_tool_palette_adjustment_value_changed),g_signal_connect_data ((adjustment), ("value-changed"), (((GCallback ) (ctk_tool_palette_adjustment_value_changed))), (palette), ( (void*)0), (GConnectFlags) 0) |
| 1938 | palette)g_signal_connect_data ((adjustment), ("value-changed"), (((GCallback ) (ctk_tool_palette_adjustment_value_changed))), (palette), ( (void*)0), (GConnectFlags) 0); |
| 1939 | priv->vadjustment = g_object_ref_sink (adjustment)((__typeof__ (adjustment)) (g_object_ref_sink) (adjustment)); |
| 1940 | /* FIXME: Adjustment should probably have its values updated now */ |
| 1941 | g_object_notify (G_OBJECT (palette)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), (((GType) ((20) << (2)))))))), "vadjustment"); |
| 1942 | } |
| 1943 | |
| 1944 | CtkSizeGroup * |
| 1945 | _ctk_tool_palette_get_size_group (CtkToolPalette *palette) |
| 1946 | { |
| 1947 | g_return_val_if_fail (CTK_IS_TOOL_PALETTE (palette), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (palette); GType __t = ((ctk_tool_palette_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_PALETTE (palette)"); return (((void*)0)); } } while (0); |
| 1948 | |
| 1949 | return palette->priv->text_size_group; |
| 1950 | } |