| File: | demos/ctk-demo/toolpalette.c |
| Warning: | line 317, column 7 This statement is never executed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* Tool Palette |
| 2 | * |
| 3 | * A tool palette widget shows groups of toolbar items as a grid of icons |
| 4 | * or a list of names. |
| 5 | */ |
| 6 | |
| 7 | #include <string.h> |
| 8 | #include <ctk/ctk.h> |
| 9 | |
| 10 | static CtkWidget *window = NULL((void*)0); |
| 11 | |
| 12 | static void load_icon_items (CtkToolPalette *palette); |
| 13 | static void load_toggle_items (CtkToolPalette *palette); |
| 14 | static void load_special_items (CtkToolPalette *palette); |
| 15 | |
| 16 | typedef struct _CanvasItem CanvasItem; |
| 17 | |
| 18 | struct _CanvasItem |
| 19 | { |
| 20 | GdkPixbuf *pixbuf; |
| 21 | gdouble x, y; |
| 22 | }; |
| 23 | |
| 24 | static gboolean drag_data_requested_for_drop = FALSE(0); |
| 25 | static CanvasItem *drop_item = NULL((void*)0); |
| 26 | static GList *canvas_items = NULL((void*)0); |
| 27 | |
| 28 | /********************************/ |
| 29 | /* ====== Canvas drawing ====== */ |
| 30 | /********************************/ |
| 31 | |
| 32 | static CanvasItem* |
| 33 | canvas_item_new (CtkWidget *widget, |
| 34 | CtkToolButton *button, |
| 35 | gdouble x, |
| 36 | gdouble y) |
| 37 | { |
| 38 | CanvasItem *item = NULL((void*)0); |
| 39 | const gchar *icon_name; |
| 40 | GdkPixbuf *pixbuf; |
| 41 | CtkIconTheme *icon_theme; |
| 42 | int width; |
| 43 | |
| 44 | icon_name = ctk_tool_button_get_icon_name (button); |
| 45 | icon_theme = ctk_icon_theme_get_for_screen (ctk_widget_get_screen (widget)); |
| 46 | ctk_icon_size_lookup (CTK_ICON_SIZE_DIALOG, &width, NULL((void*)0)); |
| 47 | pixbuf = ctk_icon_theme_load_icon (icon_theme, |
| 48 | icon_name, |
| 49 | width, |
| 50 | CTK_ICON_LOOKUP_GENERIC_FALLBACK, |
| 51 | NULL((void*)0)); |
| 52 | |
| 53 | if (pixbuf) |
| 54 | { |
| 55 | item = g_slice_new0 (CanvasItem)((CanvasItem*) g_slice_alloc0 ((sizeof (CanvasItem) > 0 ? sizeof (CanvasItem) : 1))); |
| 56 | item->pixbuf = pixbuf; |
| 57 | item->x = x; |
| 58 | item->y = y; |
| 59 | } |
| 60 | |
| 61 | return item; |
| 62 | } |
| 63 | |
| 64 | static void |
| 65 | canvas_item_free (CanvasItem *item) |
| 66 | { |
| 67 | g_object_unref (item->pixbuf); |
| 68 | g_slice_free (CanvasItem, item)do { if (1) g_slice_free1 (sizeof (CanvasItem), (item)); else (void) ((CanvasItem*) 0 == (item)); } while (0); |
| 69 | } |
| 70 | |
| 71 | static void |
| 72 | canvas_item_draw (const CanvasItem *item, |
| 73 | cairo_t *cr, |
| 74 | gboolean preview) |
| 75 | { |
| 76 | gdouble cx = gdk_pixbuf_get_width (item->pixbuf); |
| 77 | gdouble cy = gdk_pixbuf_get_height (item->pixbuf); |
| 78 | |
| 79 | cdk_cairo_set_source_pixbuf (cr, |
| 80 | item->pixbuf, |
| 81 | item->x - cx * 0.5, |
| 82 | item->y - cy * 0.5); |
| 83 | |
| 84 | if (preview) |
| 85 | cairo_paint_with_alpha (cr, 0.6); |
| 86 | else |
| 87 | cairo_paint (cr); |
| 88 | } |
| 89 | |
| 90 | static gboolean |
| 91 | canvas_draw (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 92 | cairo_t *cr) |
| 93 | { |
| 94 | GList *iter; |
| 95 | |
| 96 | cairo_set_source_rgb (cr, 1, 1, 1); |
| 97 | cairo_paint (cr); |
| 98 | |
| 99 | for (iter = canvas_items; iter; iter = iter->next) |
| 100 | canvas_item_draw (iter->data, cr, FALSE(0)); |
| 101 | |
| 102 | if (drop_item) |
| 103 | canvas_item_draw (drop_item, cr, TRUE(!(0))); |
| 104 | |
| 105 | return TRUE(!(0)); |
| 106 | } |
| 107 | |
| 108 | /*****************************/ |
| 109 | /* ====== Palette DnD ====== */ |
| 110 | /*****************************/ |
| 111 | |
| 112 | static void |
| 113 | palette_drop_item (CtkToolItem *drag_item, |
| 114 | CtkToolItemGroup *drop_group, |
| 115 | gint x, |
| 116 | gint y) |
| 117 | { |
| 118 | CtkWidget *drag_group = ctk_widget_get_parent (CTK_WIDGET (drag_item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drag_item)), ((ctk_widget_get_type ()))))))); |
| 119 | CtkToolItem *drop_item = ctk_tool_item_group_get_drop_item (drop_group, x, y); |
| 120 | gint drop_position = -1; |
| 121 | |
| 122 | if (drop_item) |
| 123 | drop_position = ctk_tool_item_group_get_item_position (CTK_TOOL_ITEM_GROUP (drop_group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (drop_group), ((ctk_tool_item_group_get_type ( ))))))), drop_item); |
| 124 | |
| 125 | if (CTK_TOOL_ITEM_GROUP (drag_group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (drag_group), ((ctk_tool_item_group_get_type ( ))))))) != drop_group) |
| 126 | { |
| 127 | gboolean homogeneous, expand, fill, new_row; |
| 128 | |
| 129 | g_object_ref (drag_item)((__typeof__ (drag_item)) (g_object_ref) (drag_item)); |
| 130 | ctk_container_child_get (CTK_CONTAINER (drag_group)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drag_group)), ((ctk_container_get_type ())))))), CTK_WIDGET (drag_item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drag_item)), ((ctk_widget_get_type ())))))), |
| 131 | "homogeneous", &homogeneous, |
| 132 | "expand", &expand, |
| 133 | "fill", &fill, |
| 134 | "new-row", &new_row, |
| 135 | NULL((void*)0)); |
| 136 | ctk_container_remove (CTK_CONTAINER (drag_group)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drag_group)), ((ctk_container_get_type ())))))), CTK_WIDGET (drag_item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drag_item)), ((ctk_widget_get_type ()))))))); |
| 137 | ctk_tool_item_group_insert (CTK_TOOL_ITEM_GROUP (drop_group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (drop_group), ((ctk_tool_item_group_get_type ( ))))))), |
| 138 | drag_item, drop_position); |
| 139 | ctk_container_child_set (CTK_CONTAINER (drop_group)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drop_group)), ((ctk_container_get_type ())))))), CTK_WIDGET (drag_item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drag_item)), ((ctk_widget_get_type ())))))), |
| 140 | "homogeneous", homogeneous, |
| 141 | "expand", expand, |
| 142 | "fill", fill, |
| 143 | "new-row", new_row, |
| 144 | NULL((void*)0)); |
| 145 | g_object_unref (drag_item); |
| 146 | } |
| 147 | else |
| 148 | ctk_tool_item_group_set_item_position (CTK_TOOL_ITEM_GROUP (drop_group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (drop_group), ((ctk_tool_item_group_get_type ( ))))))), |
| 149 | drag_item, drop_position); |
| 150 | } |
| 151 | |
| 152 | static void |
| 153 | palette_drop_group (CtkToolPalette *palette, |
| 154 | CtkToolItemGroup *drag_group, |
| 155 | CtkToolItemGroup *drop_group) |
| 156 | { |
| 157 | gint drop_position = -1; |
| 158 | |
| 159 | if (drop_group) |
| 160 | drop_position = ctk_tool_palette_get_group_position (palette, drop_group); |
| 161 | |
| 162 | ctk_tool_palette_set_group_position (palette, drag_group, drop_position); |
| 163 | } |
| 164 | |
| 165 | static void |
| 166 | palette_drag_data_received (CtkWidget *widget, |
| 167 | CdkDragContext *context, |
| 168 | gint x, |
| 169 | gint y, |
| 170 | CtkSelectionData *selection, |
| 171 | guint info G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 172 | guint time G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 173 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 174 | { |
| 175 | CtkAllocation allocation; |
| 176 | CtkToolItemGroup *drop_group = NULL((void*)0); |
| 177 | CtkWidget *drag_palette = ctk_drag_get_source_widget (context); |
| 178 | CtkWidget *drag_item = NULL((void*)0); |
| 179 | |
| 180 | while (drag_palette && !CTK_IS_TOOL_PALETTE (drag_palette)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( drag_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; }))))) |
| 181 | drag_palette = ctk_widget_get_parent (drag_palette); |
| 182 | |
| 183 | if (drag_palette) |
| 184 | { |
| 185 | drag_item = ctk_tool_palette_get_drag_item (CTK_TOOL_PALETTE (drag_palette)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (drag_palette), ((ctk_tool_palette_get_type ())))))), |
| 186 | selection); |
| 187 | drop_group = ctk_tool_palette_get_drop_group (CTK_TOOL_PALETTE (widget)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (widget), ((ctk_tool_palette_get_type ())))))), |
| 188 | x, y); |
| 189 | } |
| 190 | |
| 191 | if (CTK_IS_TOOL_ITEM_GROUP (drag_item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( drag_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; }))))) |
| 192 | palette_drop_group (CTK_TOOL_PALETTE (drag_palette)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (drag_palette), ((ctk_tool_palette_get_type ())))))), |
| 193 | CTK_TOOL_ITEM_GROUP (drag_item)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (drag_item), ((ctk_tool_item_group_get_type ( ))))))), |
| 194 | drop_group); |
| 195 | else if (CTK_IS_TOOL_ITEM (drag_item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (drag_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; })))) && drop_group) |
| 196 | { |
| 197 | ctk_widget_get_allocation (CTK_WIDGET (drop_group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drop_group)), ((ctk_widget_get_type ())))))), &allocation); |
| 198 | palette_drop_item (CTK_TOOL_ITEM (drag_item)((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drag_item)), ((ctk_tool_item_get_type ())))))), |
| 199 | drop_group, |
| 200 | x - allocation.x, |
| 201 | y - allocation.y); |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | /********************************/ |
| 206 | /* ====== Passive Canvas ====== */ |
| 207 | /********************************/ |
| 208 | |
| 209 | static void |
| 210 | passive_canvas_drag_data_received (CtkWidget *widget, |
| 211 | CdkDragContext *context, |
| 212 | gint x, |
| 213 | gint y, |
| 214 | CtkSelectionData *selection, |
| 215 | guint info G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 216 | guint time G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 217 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 218 | { |
| 219 | /* find the tool button, which is the source of this DnD operation */ |
| 220 | |
| 221 | CtkWidget *palette = ctk_drag_get_source_widget (context); |
| 222 | CanvasItem *canvas_item = NULL((void*)0); |
| 223 | CtkWidget *tool_item = NULL((void*)0); |
| 224 | |
| 225 | while (palette && !CTK_IS_TOOL_PALETTE (palette)(((__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; }))))) |
| 226 | palette = ctk_widget_get_parent (palette); |
| 227 | |
| 228 | if (palette) |
| 229 | tool_item = ctk_tool_palette_get_drag_item (CTK_TOOL_PALETTE (palette)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (palette), ((ctk_tool_palette_get_type ())))))), |
| 230 | selection); |
| 231 | |
| 232 | g_assert (NULL == drop_item)do { if (((void*)0) == drop_item) ; else g_assertion_message_expr (((gchar*) 0), "toolpalette.c", 232, ((const char*) (__func__ )), "NULL == drop_item"); } while (0); |
| 233 | |
| 234 | /* append a new canvas item when a tool button was found */ |
| 235 | |
| 236 | if (CTK_IS_TOOL_ITEM (tool_item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (tool_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; }))))) |
| 237 | canvas_item = canvas_item_new (widget, CTK_TOOL_BUTTON (tool_item)((((CtkToolButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tool_item)), ((ctk_tool_button_get_type ())))))), x, y); |
| 238 | |
| 239 | if (canvas_item) |
| 240 | { |
| 241 | canvas_items = g_list_append (canvas_items, canvas_item); |
| 242 | ctk_widget_queue_draw (widget); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | /************************************/ |
| 247 | /* ====== Interactive Canvas ====== */ |
| 248 | /************************************/ |
| 249 | |
| 250 | static gboolean |
| 251 | interactive_canvas_drag_motion (CtkWidget *widget, |
| 252 | CdkDragContext *context, |
| 253 | gint x, |
| 254 | gint y, |
| 255 | guint time, |
| 256 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 257 | { |
| 258 | if (drop_item) |
| 259 | { |
| 260 | /* already have a drop indicator - just update position */ |
| 261 | |
| 262 | drop_item->x = x; |
| 263 | drop_item->y = y; |
| 264 | |
| 265 | ctk_widget_queue_draw (widget); |
| 266 | cdk_drag_status (context, CDK_ACTION_COPY, time); |
| 267 | } |
| 268 | else |
| 269 | { |
| 270 | /* request DnD data for creating a drop indicator */ |
| 271 | |
| 272 | CdkAtom target = ctk_drag_dest_find_target (widget, context, NULL((void*)0)); |
| 273 | |
| 274 | if (!target) |
| 275 | return FALSE(0); |
| 276 | |
| 277 | drag_data_requested_for_drop = FALSE(0); |
| 278 | ctk_drag_get_data (widget, context, target, time); |
| 279 | } |
| 280 | |
| 281 | return TRUE(!(0)); |
| 282 | } |
| 283 | |
| 284 | static void |
| 285 | interactive_canvas_drag_data_received (CtkWidget *widget, |
| 286 | CdkDragContext *context, |
| 287 | gint x, |
| 288 | gint y, |
| 289 | CtkSelectionData *selection, |
| 290 | guint info G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 291 | guint time, |
| 292 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 293 | |
| 294 | { |
| 295 | /* find the tool button which is the source of this DnD operation */ |
| 296 | |
| 297 | CtkWidget *palette = ctk_drag_get_source_widget (context); |
| 298 | CtkWidget *tool_item = NULL((void*)0); |
| 299 | CanvasItem *item; |
| 300 | |
| 301 | while (palette && !CTK_IS_TOOL_PALETTE (palette)(((__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; }))))) |
| 302 | palette = ctk_widget_get_parent (palette); |
| 303 | |
| 304 | if (palette) |
| 305 | tool_item = ctk_tool_palette_get_drag_item (CTK_TOOL_PALETTE (palette)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (palette), ((ctk_tool_palette_get_type ())))))), |
| 306 | selection); |
| 307 | |
| 308 | /* create a canvas item when a tool button was found */ |
| 309 | |
| 310 | g_assert (NULL == drop_item)do { if (((void*)0) == drop_item) ; else g_assertion_message_expr (((gchar*) 0), "toolpalette.c", 310, ((const char*) (__func__ )), "NULL == drop_item"); } while (0); |
| 311 | |
| 312 | if (!CTK_IS_TOOL_ITEM (tool_item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (tool_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; }))))) |
| 313 | return; |
| 314 | |
| 315 | if (drop_item) |
| 316 | { |
| 317 | canvas_item_free (drop_item); |
This statement is never executed | |
| 318 | drop_item = NULL((void*)0); |
| 319 | } |
| 320 | |
| 321 | item = canvas_item_new (widget, CTK_TOOL_BUTTON (tool_item)((((CtkToolButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tool_item)), ((ctk_tool_button_get_type ())))))), x, y); |
| 322 | |
| 323 | /* Either create a new item or just create a preview item, |
| 324 | depending on why the drag data was requested. */ |
| 325 | if(drag_data_requested_for_drop) |
| 326 | { |
| 327 | canvas_items = g_list_append (canvas_items, item); |
| 328 | drop_item = NULL((void*)0); |
| 329 | |
| 330 | ctk_drag_finish (context, TRUE(!(0)), FALSE(0), time); |
| 331 | } else |
| 332 | { |
| 333 | drop_item = item; |
| 334 | cdk_drag_status (context, CDK_ACTION_COPY, time); |
| 335 | } |
| 336 | |
| 337 | ctk_widget_queue_draw (widget); |
| 338 | } |
| 339 | |
| 340 | static gboolean |
| 341 | interactive_canvas_drag_drop (CtkWidget *widget, |
| 342 | CdkDragContext *context, |
| 343 | gint x G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 344 | gint y G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 345 | guint time, |
| 346 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 347 | { |
| 348 | CdkAtom target = ctk_drag_dest_find_target (widget, context, NULL((void*)0)); |
| 349 | |
| 350 | if (!target) |
| 351 | return FALSE(0); |
| 352 | |
| 353 | drag_data_requested_for_drop = TRUE(!(0)); |
| 354 | ctk_drag_get_data (widget, context, target, time); |
| 355 | |
| 356 | return FALSE(0); |
| 357 | } |
| 358 | |
| 359 | static void |
| 360 | interactive_canvas_drag_leave (gpointer data) |
| 361 | { |
| 362 | if (drop_item) |
| 363 | { |
| 364 | CtkWidget *widget = CTK_WIDGET (data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_widget_get_type ())))))); |
| 365 | |
| 366 | canvas_item_free (drop_item); |
| 367 | drop_item = NULL((void*)0); |
| 368 | |
| 369 | if (widget) |
| 370 | ctk_widget_queue_draw (widget); |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | static void |
| 375 | on_combo_orientation_changed (CtkComboBox *combo_box, |
| 376 | gpointer user_data) |
| 377 | { |
| 378 | CtkToolPalette *palette = CTK_TOOL_PALETTE (user_data)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (user_data), ((ctk_tool_palette_get_type ())))))); |
| 379 | CtkScrolledWindow *sw; |
| 380 | CtkTreeModel *model = ctk_combo_box_get_model (combo_box); |
| 381 | CtkTreeIter iter; |
| 382 | gint val = 0; |
| 383 | |
| 384 | sw = CTK_SCROLLED_WINDOW (ctk_widget_get_parent (CTK_WIDGET (palette)))((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((ctk_widget_get_parent (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((palette)), ((ctk_widget_get_type ()))))))))), ((ctk_scrolled_window_get_type ())))))); |
| 385 | |
| 386 | if (!ctk_combo_box_get_active_iter (combo_box, &iter)) |
| 387 | return; |
| 388 | |
| 389 | ctk_tree_model_get (model, &iter, 1, &val, -1); |
| 390 | |
| 391 | ctk_orientable_set_orientation (CTK_ORIENTABLE (palette)((((CtkOrientable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_orientable_get_type ())))))), val); |
| 392 | |
| 393 | if (val == CTK_ORIENTATION_HORIZONTAL) |
| 394 | ctk_scrolled_window_set_policy (sw, CTK_POLICY_AUTOMATIC, CTK_POLICY_NEVER); |
| 395 | else |
| 396 | ctk_scrolled_window_set_policy (sw, CTK_POLICY_NEVER, CTK_POLICY_AUTOMATIC); |
| 397 | } |
| 398 | |
| 399 | static void |
| 400 | on_combo_style_changed (CtkComboBox *combo_box, |
| 401 | gpointer user_data) |
| 402 | { |
| 403 | CtkToolPalette *palette = CTK_TOOL_PALETTE (user_data)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (user_data), ((ctk_tool_palette_get_type ())))))); |
| 404 | CtkTreeModel *model = ctk_combo_box_get_model (combo_box); |
| 405 | CtkTreeIter iter; |
| 406 | gint val = 0; |
| 407 | |
| 408 | if (!ctk_combo_box_get_active_iter (combo_box, &iter)) |
| 409 | return; |
| 410 | |
| 411 | ctk_tree_model_get (model, &iter, 1, &val, -1); |
| 412 | |
| 413 | if (val == -1) |
| 414 | ctk_tool_palette_unset_style (palette); |
| 415 | else |
| 416 | ctk_tool_palette_set_style (palette, val); |
| 417 | } |
| 418 | |
| 419 | CtkWidget * |
| 420 | do_toolpalette (CtkWidget *do_widget) |
| 421 | { |
| 422 | CtkWidget *box = NULL((void*)0); |
| 423 | CtkWidget *hbox = NULL((void*)0); |
| 424 | CtkWidget *combo_orientation = NULL((void*)0); |
| 425 | CtkListStore *orientation_model = NULL((void*)0); |
| 426 | CtkWidget *combo_style = NULL((void*)0); |
| 427 | CtkListStore *style_model = NULL((void*)0); |
| 428 | CtkCellRenderer *cell_renderer = NULL((void*)0); |
| 429 | CtkTreeIter iter; |
| 430 | CtkWidget *palette = NULL((void*)0); |
| 431 | CtkWidget *palette_scroller = NULL((void*)0); |
| 432 | CtkWidget *notebook = NULL((void*)0); |
| 433 | CtkWidget *contents = NULL((void*)0); |
| 434 | CtkWidget *contents_scroller = NULL((void*)0); |
| 435 | |
| 436 | if (!window) |
| 437 | { |
| 438 | window = ctk_window_new (CTK_WINDOW_TOPLEVEL); |
| 439 | ctk_window_set_screen (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), |
| 440 | ctk_widget_get_screen (do_widget)); |
| 441 | ctk_window_set_title (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), "Tool Palette"); |
| 442 | ctk_window_set_default_size (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), 200, 600); |
| 443 | |
| 444 | g_signal_connect (window, "destroy",g_signal_connect_data ((window), ("destroy"), (((GCallback) ( ctk_widget_destroyed))), (&window), ((void*)0), (GConnectFlags ) 0) |
| 445 | G_CALLBACK (ctk_widget_destroyed), &window)g_signal_connect_data ((window), ("destroy"), (((GCallback) ( ctk_widget_destroyed))), (&window), ((void*)0), (GConnectFlags ) 0); |
| 446 | ctk_container_set_border_width (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ())))))), 8); |
| 447 | |
| 448 | /* Add widgets to control the ToolPalette appearance: */ |
| 449 | box = ctk_box_new (CTK_ORIENTATION_VERTICAL, 6); |
| 450 | ctk_container_add (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ())))))), box); |
| 451 | |
| 452 | /* Orientation combo box: */ |
| 453 | orientation_model = ctk_list_store_new (2, G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_INT((GType) ((6) << (2)))); |
| 454 | ctk_list_store_append (orientation_model, &iter); |
| 455 | ctk_list_store_set (orientation_model, &iter, |
| 456 | 0, "Horizontal", |
| 457 | 1, CTK_ORIENTATION_HORIZONTAL, |
| 458 | -1); |
| 459 | ctk_list_store_append (orientation_model, &iter); |
| 460 | ctk_list_store_set (orientation_model, &iter, |
| 461 | 0, "Vertical", |
| 462 | 1, CTK_ORIENTATION_VERTICAL, |
| 463 | -1); |
| 464 | |
| 465 | combo_orientation = |
| 466 | ctk_combo_box_new_with_model (CTK_TREE_MODEL (orientation_model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((orientation_model)), ((ctk_tree_model_get_type ()))))))); |
| 467 | cell_renderer = ctk_cell_renderer_text_new (); |
| 468 | ctk_cell_layout_pack_start (CTK_CELL_LAYOUT (combo_orientation)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo_orientation)), ((ctk_cell_layout_get_type ())))))), |
| 469 | cell_renderer, |
| 470 | TRUE(!(0))); |
| 471 | ctk_cell_layout_set_attributes (CTK_CELL_LAYOUT (combo_orientation)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo_orientation)), ((ctk_cell_layout_get_type ())))))), |
| 472 | cell_renderer, |
| 473 | "text", 0, |
| 474 | NULL((void*)0)); |
| 475 | ctk_combo_box_set_active_iter (CTK_COMBO_BOX (combo_orientation)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo_orientation)), ((ctk_combo_box_get_type ())))))), &iter); |
| 476 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), combo_orientation, FALSE(0), FALSE(0), 0); |
| 477 | |
| 478 | /* Style combo box: */ |
| 479 | style_model = ctk_list_store_new (2, G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_INT((GType) ((6) << (2)))); |
| 480 | ctk_list_store_append (style_model, &iter); |
| 481 | ctk_list_store_set (style_model, &iter, |
| 482 | 0, "Text", |
| 483 | 1, CTK_TOOLBAR_TEXT, |
| 484 | -1); |
| 485 | ctk_list_store_append (style_model, &iter); |
| 486 | ctk_list_store_set (style_model, &iter, |
| 487 | 0, "Both", |
| 488 | 1, CTK_TOOLBAR_BOTH, |
| 489 | -1); |
| 490 | ctk_list_store_append (style_model, &iter); |
| 491 | ctk_list_store_set (style_model, &iter, |
| 492 | 0, "Both: Horizontal", |
| 493 | 1, CTK_TOOLBAR_BOTH_HORIZ, |
| 494 | -1); |
| 495 | ctk_list_store_append (style_model, &iter); |
| 496 | ctk_list_store_set (style_model, &iter, |
| 497 | 0, "Icons", |
| 498 | 1, CTK_TOOLBAR_ICONS, |
| 499 | -1); |
| 500 | ctk_list_store_append (style_model, &iter); |
| 501 | ctk_list_store_set (style_model, &iter, |
| 502 | 0, "Default", |
| 503 | 1, -1, /* A custom meaning for this demo. */ |
| 504 | -1); |
| 505 | combo_style = ctk_combo_box_new_with_model (CTK_TREE_MODEL (style_model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((style_model)), ((ctk_tree_model_get_type ()))))))); |
| 506 | cell_renderer = ctk_cell_renderer_text_new (); |
| 507 | ctk_cell_layout_pack_start (CTK_CELL_LAYOUT (combo_style)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo_style)), ((ctk_cell_layout_get_type ())))))), |
| 508 | cell_renderer, |
| 509 | TRUE(!(0))); |
| 510 | ctk_cell_layout_set_attributes (CTK_CELL_LAYOUT (combo_style)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo_style)), ((ctk_cell_layout_get_type ())))))), |
| 511 | cell_renderer, |
| 512 | "text", 0, |
| 513 | NULL((void*)0)); |
| 514 | ctk_combo_box_set_active_iter (CTK_COMBO_BOX (combo_style)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo_style)), ((ctk_combo_box_get_type ())))))), &iter); |
| 515 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), combo_style, FALSE(0), FALSE(0), 0); |
| 516 | |
| 517 | /* Add hbox */ |
| 518 | hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 5); |
| 519 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), hbox, TRUE(!(0)), TRUE(!(0)), 0); |
| 520 | |
| 521 | /* Add and fill the ToolPalette: */ |
| 522 | palette = ctk_tool_palette_new (); |
| 523 | |
| 524 | load_icon_items (CTK_TOOL_PALETTE (palette)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (palette), ((ctk_tool_palette_get_type ()))))))); |
| 525 | load_toggle_items (CTK_TOOL_PALETTE (palette)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (palette), ((ctk_tool_palette_get_type ()))))))); |
| 526 | load_special_items (CTK_TOOL_PALETTE (palette)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (palette), ((ctk_tool_palette_get_type ()))))))); |
| 527 | |
| 528 | palette_scroller = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0)); |
| 529 | ctk_scrolled_window_set_policy (CTK_SCROLLED_WINDOW (palette_scroller)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((palette_scroller)), ((ctk_scrolled_window_get_type ())))))), |
| 530 | CTK_POLICY_NEVER, |
| 531 | CTK_POLICY_AUTOMATIC); |
| 532 | ctk_container_set_border_width (CTK_CONTAINER (palette_scroller)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette_scroller)), ((ctk_container_get_type ())))))), 6); |
| 533 | ctk_widget_set_hexpand (palette_scroller, TRUE(!(0))); |
| 534 | |
| 535 | ctk_container_add (CTK_CONTAINER (palette_scroller)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette_scroller)), ((ctk_container_get_type ())))))), palette); |
| 536 | ctk_container_add (CTK_CONTAINER (hbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_container_get_type ())))))), palette_scroller); |
| 537 | |
| 538 | ctk_widget_show_all (box); |
| 539 | |
| 540 | /* Connect signals: */ |
| 541 | g_signal_connect (combo_orientation, "changed",g_signal_connect_data ((combo_orientation), ("changed"), (((GCallback ) (on_combo_orientation_changed))), (palette), ((void*)0), (GConnectFlags ) 0) |
| 542 | G_CALLBACK (on_combo_orientation_changed), palette)g_signal_connect_data ((combo_orientation), ("changed"), (((GCallback ) (on_combo_orientation_changed))), (palette), ((void*)0), (GConnectFlags ) 0); |
| 543 | g_signal_connect (combo_style, "changed",g_signal_connect_data ((combo_style), ("changed"), (((GCallback ) (on_combo_style_changed))), (palette), ((void*)0), (GConnectFlags ) 0) |
| 544 | G_CALLBACK (on_combo_style_changed), palette)g_signal_connect_data ((combo_style), ("changed"), (((GCallback ) (on_combo_style_changed))), (palette), ((void*)0), (GConnectFlags ) 0); |
| 545 | |
| 546 | /* Keep the widgets in sync: */ |
| 547 | on_combo_orientation_changed (CTK_COMBO_BOX (combo_orientation)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo_orientation)), ((ctk_combo_box_get_type ())))))), palette); |
| 548 | |
| 549 | /* ===== notebook ===== */ |
| 550 | |
| 551 | notebook = ctk_notebook_new (); |
| 552 | ctk_container_set_border_width (CTK_CONTAINER (notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_container_get_type ())))))), 6); |
| 553 | ctk_box_pack_end (CTK_BOX(hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), notebook, FALSE(0), FALSE(0), 0); |
| 554 | |
| 555 | /* ===== DnD for tool items ===== */ |
| 556 | |
| 557 | g_signal_connect (palette, "drag-data-received",g_signal_connect_data ((palette), ("drag-data-received"), ((( GCallback) (palette_drag_data_received))), (((void*)0)), ((void *)0), (GConnectFlags) 0) |
| 558 | G_CALLBACK (palette_drag_data_received), NULL)g_signal_connect_data ((palette), ("drag-data-received"), ((( GCallback) (palette_drag_data_received))), (((void*)0)), ((void *)0), (GConnectFlags) 0); |
| 559 | |
| 560 | ctk_tool_palette_add_drag_dest (CTK_TOOL_PALETTE (palette)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (palette), ((ctk_tool_palette_get_type ())))))), |
| 561 | palette, |
| 562 | CTK_DEST_DEFAULT_ALL, |
| 563 | CTK_TOOL_PALETTE_DRAG_ITEMS | |
| 564 | CTK_TOOL_PALETTE_DRAG_GROUPS, |
| 565 | CDK_ACTION_MOVE); |
| 566 | |
| 567 | /* ===== passive DnD dest ===== */ |
| 568 | |
| 569 | contents = ctk_drawing_area_new (); |
| 570 | ctk_widget_set_app_paintable (contents, TRUE(!(0))); |
| 571 | |
| 572 | g_object_connect (contents, |
| 573 | "signal::draw", canvas_draw, NULL((void*)0), |
| 574 | "signal::drag-data-received", passive_canvas_drag_data_received, NULL((void*)0), |
| 575 | NULL((void*)0)); |
| 576 | |
| 577 | ctk_tool_palette_add_drag_dest (CTK_TOOL_PALETTE (palette)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (palette), ((ctk_tool_palette_get_type ())))))), |
| 578 | contents, |
| 579 | CTK_DEST_DEFAULT_ALL, |
| 580 | CTK_TOOL_PALETTE_DRAG_ITEMS, |
| 581 | CDK_ACTION_COPY); |
| 582 | |
| 583 | contents_scroller = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0)); |
| 584 | ctk_scrolled_window_set_policy (CTK_SCROLLED_WINDOW (contents_scroller)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((contents_scroller)), ((ctk_scrolled_window_get_type ())))))), |
| 585 | CTK_POLICY_AUTOMATIC, |
| 586 | CTK_POLICY_ALWAYS); |
| 587 | ctk_container_add (CTK_CONTAINER (contents_scroller)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((contents_scroller)), ((ctk_container_get_type ())))))), contents); |
| 588 | ctk_container_set_border_width (CTK_CONTAINER (contents_scroller)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((contents_scroller)), ((ctk_container_get_type ())))))), 6); |
| 589 | |
| 590 | ctk_notebook_append_page (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ())))))), |
| 591 | contents_scroller, |
| 592 | ctk_label_new ("Passive DnD Mode")); |
| 593 | |
| 594 | /* ===== interactive DnD dest ===== */ |
| 595 | |
| 596 | contents = ctk_drawing_area_new (); |
| 597 | ctk_widget_set_app_paintable (contents, TRUE(!(0))); |
| 598 | |
| 599 | g_object_connect (contents, |
| 600 | "signal::draw", canvas_draw, NULL((void*)0), |
| 601 | "signal::drag-motion", interactive_canvas_drag_motion, NULL((void*)0), |
| 602 | "signal::drag-data-received", interactive_canvas_drag_data_received, NULL((void*)0), |
| 603 | "signal::drag-leave", interactive_canvas_drag_leave, contents, |
| 604 | "signal::drag-drop", interactive_canvas_drag_drop, NULL((void*)0), |
| 605 | NULL((void*)0)); |
| 606 | |
| 607 | ctk_tool_palette_add_drag_dest (CTK_TOOL_PALETTE (palette)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (palette), ((ctk_tool_palette_get_type ())))))), |
| 608 | contents, |
| 609 | CTK_DEST_DEFAULT_HIGHLIGHT, |
| 610 | CTK_TOOL_PALETTE_DRAG_ITEMS, |
| 611 | CDK_ACTION_COPY); |
| 612 | |
| 613 | contents_scroller = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0)); |
| 614 | ctk_scrolled_window_set_policy (CTK_SCROLLED_WINDOW (contents_scroller)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((contents_scroller)), ((ctk_scrolled_window_get_type ())))))), |
| 615 | CTK_POLICY_AUTOMATIC, |
| 616 | CTK_POLICY_ALWAYS); |
| 617 | ctk_container_add (CTK_CONTAINER (contents_scroller)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((contents_scroller)), ((ctk_container_get_type ())))))), contents); |
| 618 | ctk_container_set_border_width (CTK_CONTAINER (contents_scroller)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((contents_scroller)), ((ctk_container_get_type ())))))), 6); |
| 619 | |
| 620 | ctk_notebook_append_page (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ())))))), contents_scroller, |
| 621 | ctk_label_new ("Interactive DnD Mode")); |
| 622 | } |
| 623 | |
| 624 | if (!ctk_widget_get_visible (window)) |
| 625 | { |
| 626 | ctk_widget_show_all (window); |
| 627 | } |
| 628 | else |
| 629 | { |
| 630 | ctk_widget_destroy (window); |
| 631 | window = NULL((void*)0); |
| 632 | } |
| 633 | |
| 634 | return window; |
| 635 | } |
| 636 | |
| 637 | |
| 638 | static void |
| 639 | load_icon_items (CtkToolPalette *palette) |
| 640 | { |
| 641 | GList *contexts; |
| 642 | GList *l; |
| 643 | CtkIconTheme *icon_theme; |
| 644 | |
| 645 | icon_theme = ctk_icon_theme_get_for_screen (ctk_widget_get_screen (CTK_WIDGET (palette)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_widget_get_type ())))))))); |
| 646 | |
| 647 | contexts = ctk_icon_theme_list_contexts (icon_theme); |
| 648 | for (l = contexts; l; l = l->next) |
| 649 | { |
| 650 | gchar *context = l->data; |
| 651 | GList *icon_names; |
| 652 | GList *ll; |
| 653 | const guint max_icons = 10; |
| 654 | guint icons_count = 0; |
| 655 | |
| 656 | CtkWidget *group = ctk_tool_item_group_new (context); |
| 657 | ctk_container_add (CTK_CONTAINER (palette)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_container_get_type ())))))), group); |
| 658 | |
| 659 | if (g_strcmp0 (context, "Animations") == 0) |
| 660 | continue; |
| 661 | |
| 662 | g_message ("Got context '%s'", context); |
| 663 | icon_names = ctk_icon_theme_list_icons (icon_theme, context); |
| 664 | icon_names = g_list_sort (icon_names, (GCompareFunc) strcmp); |
| 665 | |
| 666 | for (ll = icon_names; ll; ll = ll->next) |
| 667 | { |
| 668 | CtkToolItem *item; |
| 669 | gchar *id = ll->data; |
| 670 | |
| 671 | if (g_str_equal (id, "emblem-desktop")(strcmp ((const char *) (id), (const char *) ("emblem-desktop" )) == 0)) |
| 672 | continue; |
| 673 | |
| 674 | if (g_str_has_suffix (id, "-symbolic")(__builtin_constant_p ("-symbolic")? __extension__ ({ const char * const __str = (id); const char * const __suffix = ("-symbolic" ); gboolean __result = (0); if (__str == ((void*)0) || __suffix == ((void*)0)) __result = (g_str_has_suffix) (__str, __suffix ); else { const size_t __str_len = strlen (((__str) + !(__str ))); const size_t __suffix_len = strlen (((__suffix) + !(__suffix ))); if (__str_len >= __suffix_len) __result = memcmp (__str + __str_len - __suffix_len, ((__suffix) + !(__suffix)), __suffix_len ) == 0; } __result; }) : (g_str_has_suffix) (id, "-symbolic") )) |
| 675 | continue; |
| 676 | |
| 677 | g_message ("Got id '%s'", id); |
| 678 | |
| 679 | item = ctk_tool_button_new (NULL((void*)0), NULL((void*)0)); |
| 680 | ctk_tool_button_set_icon_name (CTK_TOOL_BUTTON (item)((((CtkToolButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_tool_button_get_type ())))))), id); |
| 681 | ctk_tool_item_set_tooltip_text (CTK_TOOL_ITEM (item)((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_tool_item_get_type ())))))), id); |
| 682 | ctk_tool_item_group_insert (CTK_TOOL_ITEM_GROUP (group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (group), ((ctk_tool_item_group_get_type ()))) ))), item, -1); |
| 683 | |
| 684 | /* Prevent us having an insane number of icons: */ |
| 685 | ++icons_count; |
| 686 | if(icons_count >= max_icons) |
| 687 | break; |
| 688 | } |
| 689 | |
| 690 | g_list_free_full (icon_names, g_free); |
| 691 | } |
| 692 | |
| 693 | g_list_free_full (contexts, g_free); |
| 694 | } |
| 695 | |
| 696 | static void |
| 697 | load_toggle_items (CtkToolPalette *palette) |
| 698 | { |
| 699 | GSList *toggle_group = NULL((void*)0); |
| 700 | CtkWidget *group; |
| 701 | int i; |
| 702 | |
| 703 | group = ctk_tool_item_group_new ("Radio Item"); |
| 704 | ctk_container_add (CTK_CONTAINER (palette)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_container_get_type ())))))), group); |
| 705 | |
| 706 | for (i = 1; i <= 10; ++i) |
| 707 | { |
| 708 | CtkToolItem *item; |
| 709 | char *label; |
| 710 | |
| 711 | label = g_strdup_printf ("#%d", i); |
| 712 | item = ctk_radio_tool_button_new (toggle_group); |
| 713 | ctk_tool_button_set_label (CTK_TOOL_BUTTON (item)((((CtkToolButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_tool_button_get_type ())))))), label); |
| 714 | g_free (label); |
| 715 | |
| 716 | ctk_tool_item_group_insert (CTK_TOOL_ITEM_GROUP (group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (group), ((ctk_tool_item_group_get_type ()))) ))), item, -1); |
| 717 | toggle_group = ctk_radio_tool_button_get_group (CTK_RADIO_TOOL_BUTTON (item)((((CtkRadioToolButton*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((item)), ((ctk_radio_tool_button_get_type ( )))))))); |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | static CtkToolItem * |
| 722 | create_entry_item (const char *text) |
| 723 | { |
| 724 | CtkToolItem *item; |
| 725 | CtkWidget *entry; |
| 726 | |
| 727 | entry = ctk_entry_new (); |
| 728 | ctk_entry_set_text (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry)), ((ctk_entry_get_type ())))))), text); |
| 729 | ctk_entry_set_width_chars (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry)), ((ctk_entry_get_type ())))))), 5); |
| 730 | |
| 731 | item = ctk_tool_item_new (); |
| 732 | ctk_container_add (CTK_CONTAINER (item)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_container_get_type ())))))), entry); |
| 733 | |
| 734 | return item; |
| 735 | } |
| 736 | |
| 737 | static void |
| 738 | load_special_items (CtkToolPalette *palette) |
| 739 | { |
| 740 | CtkToolItem *item; |
| 741 | CtkWidget *group; |
| 742 | CtkWidget *label_button; |
| 743 | |
| 744 | group = ctk_tool_item_group_new (NULL((void*)0)); |
| 745 | label_button = ctk_button_new_with_label ("Advanced Features"); |
| 746 | ctk_widget_show (label_button); |
| 747 | ctk_tool_item_group_set_label_widget (CTK_TOOL_ITEM_GROUP (group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (group), ((ctk_tool_item_group_get_type ()))) ))), |
| 748 | label_button); |
| 749 | ctk_container_add (CTK_CONTAINER (palette)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((palette)), ((ctk_container_get_type ())))))), group); |
| 750 | |
| 751 | item = create_entry_item ("homogeneous=FALSE"); |
| 752 | ctk_tool_item_group_insert (CTK_TOOL_ITEM_GROUP (group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (group), ((ctk_tool_item_group_get_type ()))) ))), item, -1); |
| 753 | ctk_container_child_set (CTK_CONTAINER (group)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_container_get_type ())))))), CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))), |
| 754 | "homogeneous", FALSE(0), NULL((void*)0)); |
| 755 | |
| 756 | item = create_entry_item ("homogeneous=FALSE, expand=TRUE"); |
| 757 | ctk_tool_item_group_insert (CTK_TOOL_ITEM_GROUP (group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (group), ((ctk_tool_item_group_get_type ()))) ))), item, -1); |
| 758 | ctk_container_child_set (CTK_CONTAINER (group)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_container_get_type ())))))), CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))), |
| 759 | "homogeneous", FALSE(0), "expand", TRUE(!(0)), |
| 760 | NULL((void*)0)); |
| 761 | |
| 762 | item = create_entry_item ("homogeneous=FALSE, expand=TRUE, fill=FALSE"); |
| 763 | ctk_tool_item_group_insert (CTK_TOOL_ITEM_GROUP (group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (group), ((ctk_tool_item_group_get_type ()))) ))), item, -1); |
| 764 | ctk_container_child_set (CTK_CONTAINER (group)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_container_get_type ())))))), CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))), |
| 765 | "homogeneous", FALSE(0), "expand", TRUE(!(0)), |
| 766 | "fill", FALSE(0), NULL((void*)0)); |
| 767 | |
| 768 | item = create_entry_item ("homogeneous=FALSE, expand=TRUE, new-row=TRUE"); |
| 769 | ctk_tool_item_group_insert (CTK_TOOL_ITEM_GROUP (group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (group), ((ctk_tool_item_group_get_type ()))) ))), item, -1); |
| 770 | ctk_container_child_set (CTK_CONTAINER (group)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_container_get_type ())))))), CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))), |
| 771 | "homogeneous", FALSE(0), "expand", TRUE(!(0)), |
| 772 | "new-row", TRUE(!(0)), NULL((void*)0)); |
| 773 | |
| 774 | item = ctk_tool_button_new (NULL((void*)0), NULL((void*)0)); |
| 775 | ctk_tool_button_set_icon_name (CTK_TOOL_BUTTON (item)((((CtkToolButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_tool_button_get_type ())))))), "go-up"); |
| 776 | ctk_tool_item_set_tooltip_text (item, "Show on vertical palettes only"); |
| 777 | ctk_tool_item_group_insert (CTK_TOOL_ITEM_GROUP (group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (group), ((ctk_tool_item_group_get_type ()))) ))), item, -1); |
| 778 | ctk_tool_item_set_visible_horizontal (item, FALSE(0)); |
| 779 | |
| 780 | item = ctk_tool_button_new (NULL((void*)0), NULL((void*)0)); |
| 781 | ctk_tool_button_set_icon_name (CTK_TOOL_BUTTON (item)((((CtkToolButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_tool_button_get_type ())))))), "go-next"); |
| 782 | ctk_tool_item_set_tooltip_text (item, "Show on horizontal palettes only"); |
| 783 | ctk_tool_item_group_insert (CTK_TOOL_ITEM_GROUP (group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (group), ((ctk_tool_item_group_get_type ()))) ))), item, -1); |
| 784 | ctk_tool_item_set_visible_vertical (item, FALSE(0)); |
| 785 | |
| 786 | item = ctk_tool_button_new (NULL((void*)0), NULL((void*)0)); |
| 787 | ctk_tool_button_set_icon_name (CTK_TOOL_BUTTON (item)((((CtkToolButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_tool_button_get_type ())))))), "edit-delete"); |
| 788 | ctk_tool_item_set_tooltip_text (item, "Do not show at all"); |
| 789 | ctk_tool_item_group_insert (CTK_TOOL_ITEM_GROUP (group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (group), ((ctk_tool_item_group_get_type ()))) ))), item, -1); |
| 790 | ctk_widget_set_no_show_all (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))), TRUE(!(0))); |
| 791 | |
| 792 | item = ctk_tool_button_new (NULL((void*)0), NULL((void*)0)); |
| 793 | ctk_tool_button_set_icon_name (CTK_TOOL_BUTTON (item)((((CtkToolButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_tool_button_get_type ())))))), "view-fullscreen"); |
| 794 | ctk_tool_item_set_tooltip_text (item, "Expanded this item"); |
| 795 | ctk_tool_item_group_insert (CTK_TOOL_ITEM_GROUP (group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (group), ((ctk_tool_item_group_get_type ()))) ))), item, -1); |
| 796 | ctk_container_child_set (CTK_CONTAINER (group)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_container_get_type ())))))), CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))), |
| 797 | "homogeneous", FALSE(0), |
| 798 | "expand", TRUE(!(0)), |
| 799 | NULL((void*)0)); |
| 800 | |
| 801 | item = ctk_tool_button_new (NULL((void*)0), NULL((void*)0)); |
| 802 | ctk_tool_button_set_icon_name (CTK_TOOL_BUTTON (item)((((CtkToolButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_tool_button_get_type ())))))), "help-browser"); |
| 803 | ctk_tool_item_set_tooltip_text (item, "A regular item"); |
| 804 | ctk_tool_item_group_insert (CTK_TOOL_ITEM_GROUP (group)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (group), ((ctk_tool_item_group_get_type ()))) ))), item, -1); |
| 805 | } |