language-support-js: Fixed bgo#665082 - Crash in javascript autocompletion
[anjuta.git] / libanjuta / anjuta-tabber.c
blob7e7a7cf61af4b52405c258b436fa6c76bcc809b1
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta-notebook-tabber
4 * Copyright (C) Johannes Schmid 2010 <jhs@gnome.org>
5 *
6 * anjuta-notebook-tabber is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * anjuta-notebook-tabber is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "anjuta-tabber.h"
22 struct _AnjutaTabberPriv
24 GtkNotebook* notebook;
25 GList* children;
26 gint active_page;
28 /* Style information (taken from GtkNotebook) */
29 gint tab_hborder;
30 gint tab_vborder;
32 GdkWindow* event_window;
35 enum
37 PROP_0,
38 PROP_NOTEBOOK
41 #define ANJUTA_TABBER_GET_PRIVATE(o) \
42 (G_TYPE_INSTANCE_GET_PRIVATE ((o), ANJUTA_TYPE_TABBER, AnjutaTabberPriv))
45 G_DEFINE_TYPE (AnjutaTabber, anjuta_tabber, GTK_TYPE_CONTAINER);
47 static void
48 anjuta_tabber_init (AnjutaTabber *object)
50 AnjutaTabber* tabber = ANJUTA_TABBER (object);
51 AnjutaTabberPriv* priv;
53 tabber->priv = ANJUTA_TABBER_GET_PRIVATE (tabber);
54 priv = tabber->priv;
56 priv->children = NULL;
57 priv->active_page = 0;
59 priv->tab_hborder = 2;
60 priv->tab_vborder = 2;
62 gtk_widget_set_has_window (GTK_WIDGET(tabber), FALSE);
65 /**
66 * anjuta_tabber_notebook_page_removed:
68 * Called when a page is removed from the associated notebook. Removes
69 * the tab for this page
71 static void
72 anjuta_tabber_notebook_page_removed (GtkNotebook* notebook,
73 GtkWidget* notebook_child,
74 gint page_num,
75 AnjutaTabber* tabber)
77 GtkWidget* child = g_list_nth_data (tabber->priv->children, page_num);
78 gtk_container_remove (GTK_CONTAINER (tabber), child);
81 static void
82 anjuta_tabber_notebook_switch_page (GtkNotebook* notebook,
83 GtkWidget* page,
84 guint page_num,
85 AnjutaTabber* tabber)
87 tabber->priv->active_page = page_num;
88 gtk_widget_queue_draw (GTK_WIDGET (tabber));
91 static void
92 anjuta_tabber_finalize (GObject *object)
94 G_OBJECT_CLASS (anjuta_tabber_parent_class)->finalize (object);
97 static void
98 anjuta_tabber_dispose (GObject *object)
100 AnjutaTabber* tabber = ANJUTA_TABBER (object);
101 g_signal_handlers_disconnect_by_func (tabber->priv->notebook,
102 anjuta_tabber_notebook_page_removed,
103 object);
104 g_signal_handlers_disconnect_by_func (tabber->priv->notebook,
105 anjuta_tabber_notebook_switch_page,
106 object);
108 G_OBJECT_CLASS (anjuta_tabber_parent_class)->dispose (object);
112 * anjuta_tabber_connect_notebook:
114 * Connect signals to associated notebook
117 static void
118 anjuta_tabber_connect_notebook (AnjutaTabber* tabber)
120 g_signal_connect (tabber->priv->notebook, "page-removed",
121 G_CALLBACK(anjuta_tabber_notebook_page_removed), tabber);
122 g_signal_connect (tabber->priv->notebook, "switch-page",
123 G_CALLBACK(anjuta_tabber_notebook_switch_page), tabber);
126 static void
127 anjuta_tabber_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
129 g_return_if_fail (ANJUTA_IS_TABBER (object));
131 AnjutaTabber* tabber = ANJUTA_TABBER (object);
133 switch (prop_id)
135 case PROP_NOTEBOOK:
136 tabber->priv->notebook = g_value_get_object (value);
137 anjuta_tabber_connect_notebook (tabber);
138 break;
139 default:
140 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
141 break;
145 static void
146 anjuta_tabber_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
148 g_return_if_fail (ANJUTA_IS_TABBER (object));
150 switch (prop_id)
152 case PROP_NOTEBOOK:
153 g_value_set_object (value, object);
154 break;
155 default:
156 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
157 break;
161 static void
162 anjuta_tabber_get_preferred_width (GtkWidget* widget,
163 gint* minimum,
164 gint* preferred)
166 g_return_if_fail (ANJUTA_IS_TABBER (widget));
168 AnjutaTabber* tabber = ANJUTA_TABBER (widget);
169 GList* child;
170 gint xthickness;
171 gint focus_width;
172 gint tab_curvature;
173 gint tab_overlap;
174 gint padding;
176 GtkStyle* style = gtk_widget_get_style (widget);
178 xthickness = style->xthickness;
180 *minimum = 0;
181 *preferred = 0;
183 gtk_widget_style_get (GTK_WIDGET (tabber->priv->notebook),
184 "focus-line-width", &focus_width,
185 "tab-curvature", &tab_curvature,
186 "tab-overlap", &tab_overlap,
187 NULL);
189 padding = xthickness + focus_width + tabber->priv->tab_hborder;
191 for (child = tabber->priv->children; child != NULL; child = g_list_next (child))
193 gint child_min;
194 gint child_preferred;
195 gint extra_space = 2 * (tab_curvature - tab_overlap);
197 if (child == g_list_first (tabber->priv->children))
198 extra_space += tab_overlap;
199 if (child == g_list_last (tabber->priv->children))
200 extra_space += tab_overlap;
202 gtk_widget_get_preferred_width (GTK_WIDGET (child->data), &child_min, &child_preferred);
203 if (minimum)
205 *minimum += child_min + 2 * padding + extra_space;
207 if (preferred)
209 *preferred += child_preferred + 2 * padding + extra_space;
214 static void
215 anjuta_tabber_get_preferred_height (GtkWidget* widget,
216 gint* minimum,
217 gint* preferred)
219 g_return_if_fail (ANJUTA_IS_TABBER (widget));
221 AnjutaTabber* tabber = ANJUTA_TABBER (widget);
222 GList* child;
223 gint ythickness;
224 gint focus_width;
225 GtkStyle* style = gtk_widget_get_style (widget);
227 ythickness = style->ythickness;
229 gtk_widget_style_get (GTK_WIDGET (tabber->priv->notebook),
230 "focus-line-width", &focus_width,
231 NULL);
234 for (child = tabber->priv->children; child != NULL; child = g_list_next (child))
236 gint child_min;
237 gint child_preferred;
239 gtk_widget_get_preferred_height (GTK_WIDGET (child->data), &child_min, &child_preferred);
240 if (minimum)
242 *minimum = MAX(*minimum, child_min +
243 2 * (ythickness + focus_width + tabber->priv->tab_vborder));
245 if (preferred)
247 *preferred = MAX(*preferred, child_preferred +
248 2 * (ythickness + focus_width + tabber->priv->tab_vborder));
254 static void
255 anjuta_tabber_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
257 g_return_if_fail (ANJUTA_IS_TABBER (widget));
258 AnjutaTabber* tabber = ANJUTA_TABBER (widget);
260 GList* child;
261 gint focus_width;
262 gint tab_curvature;
263 gint tab_overlap;
264 gint n_children = g_list_length (tabber->priv->children);
265 gint xthickness;
266 gint ythickness;
267 gint x;
268 gint padding;
269 gint tab_space;
270 GtkStyle* style = gtk_widget_get_style (widget);
272 xthickness = style->xthickness;
273 ythickness = style->ythickness;
275 gtk_widget_style_get (GTK_WIDGET (tabber->priv->notebook),
276 "focus-line-width", &focus_width,
277 "tab-curvature", &tab_curvature,
278 "tab-overlap", &tab_overlap,
279 NULL);
281 padding = xthickness + focus_width + tabber->priv->tab_hborder;
282 tab_space = tab_curvature - tab_overlap;
284 gtk_widget_set_allocation (widget, allocation);
286 switch (gtk_widget_get_direction (widget))
288 case GTK_TEXT_DIR_RTL:
289 x = allocation->x + allocation->width;
290 break;
291 case GTK_TEXT_DIR_LTR:
292 default:
293 x = allocation->x;
296 if (gtk_widget_get_realized (widget))
298 gdk_window_move_resize (tabber->priv->event_window,
299 allocation->x, allocation->y,
300 allocation->width, allocation->height);
301 if (gtk_widget_get_mapped (widget))
302 gdk_window_show_unraised (tabber->priv->event_window);
305 if (n_children > 0)
307 gint total_width = 2 * tab_overlap;
308 gboolean use_natural = FALSE;
309 gint child_equal;
310 gint extra_space = 0;
311 gint real_width = allocation->width;
313 /* Check if we have enough space for all widgets natural size */
314 child_equal = real_width / n_children -
315 n_children * 2 * (padding + tab_space) - 2 * tab_overlap;
317 if (child_equal < 0)
318 return;
320 for (child = tabber->priv->children; child != NULL; child = g_list_next (child))
322 GtkWidget* child_widget = GTK_WIDGET (child->data);
323 gint natural;
324 gtk_widget_get_preferred_width (child_widget, NULL,
325 &natural);
327 total_width += natural + 2 * (padding + tab_space);
328 if (natural < child_equal)
329 extra_space += child_equal - natural;
331 use_natural = (total_width <= real_width);
332 child_equal += extra_space / n_children;
334 for (child = tabber->priv->children; child != NULL; child = g_list_next (child))
336 GtkWidget* child_widget = GTK_WIDGET (child->data);
337 GtkAllocation child_alloc;
338 gint natural;
339 gint minimal;
340 gint begin_tab = tab_space;
341 gint end_tab = tab_space;
343 if (child == g_list_first (tabber->priv->children))
344 begin_tab += tab_overlap;
345 if (child == g_list_last (tabber->priv->children))
346 end_tab += tab_overlap;
348 gtk_widget_get_preferred_width (child_widget, &minimal,
349 &natural);
351 if (use_natural)
353 child_alloc.width = natural;
355 else
357 if (natural < child_equal)
358 child_alloc.width = natural;
359 else
360 child_alloc.width = child_equal;
362 child_alloc.height = allocation->height
363 - 2 * (ythickness + focus_width + tabber->priv->tab_vborder);
364 switch (gtk_widget_get_direction (widget))
366 case GTK_TEXT_DIR_RTL:
367 child_alloc.x = x - padding - begin_tab - child_alloc.width;
368 x = child_alloc.x - padding - end_tab;
369 break;
370 case GTK_TEXT_DIR_LTR:
371 default:
372 child_alloc.x = x + padding + begin_tab;
373 x = child_alloc.x + child_alloc.width + padding + end_tab;
375 child_alloc.y = allocation->y +
376 tabber->priv->tab_vborder + focus_width + ythickness;
378 gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_alloc);
383 static void
384 anjuta_tabber_render_tab (GtkWidget* widget,
385 GtkWidget* tab,
386 cairo_t* cr,
387 gboolean current,
388 GtkRegionFlags region_flags)
390 AnjutaTabber* tabber = ANJUTA_TABBER (widget);
391 GtkAllocation alloc;
392 GtkAllocation widget_alloc;
394 gint focus_width;
395 gint xthickness;
396 gint ythickness;
397 gint tab_curvature;
398 gint tab_overlap;
399 gint tab_begin;
400 gint tab_end;
402 gint xpadding;
403 gint ypadding;
404 GtkStyle* style = gtk_widget_get_style (GTK_WIDGET (tabber));
405 GtkStyleContext* context = gtk_widget_get_style_context (GTK_WIDGET (tabber->priv->notebook));
407 if (current)
408 gtk_widget_set_state_flags (tab, GTK_STATE_FLAG_ACTIVE, TRUE);
409 else
410 gtk_widget_unset_state_flags (tab, GTK_STATE_FLAG_ACTIVE);
412 xthickness = style->xthickness;
413 ythickness = style->ythickness;
415 gtk_widget_style_get (GTK_WIDGET (tabber->priv->notebook),
416 "focus-line-width", &focus_width,
417 "tab-curvature", &tab_curvature,
418 "tab-overlap", &tab_overlap,
419 NULL);
421 /* Get border/padding for tab */
422 gtk_style_context_save (context);
423 gtk_style_context_add_class (context, GTK_STYLE_CLASS_NOTEBOOK);
424 gtk_style_context_add_region (context, GTK_STYLE_REGION_TAB,
425 region_flags);
426 if (current)
427 gtk_style_context_set_state (context, GTK_STATE_FLAG_ACTIVE);
428 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
429 gtk_style_context_set_junction_sides (context,
430 GTK_JUNCTION_CORNER_TOPLEFT);
431 else
432 gtk_style_context_set_junction_sides (context,
433 GTK_JUNCTION_CORNER_TOPRIGHT);
435 gtk_widget_get_allocation (widget, &widget_alloc);
436 gtk_widget_get_allocation (tab, &alloc);
438 xpadding = xthickness + focus_width + tabber->priv->tab_hborder;
439 ypadding = ythickness + focus_width + tabber->priv->tab_vborder;
441 tab_begin = tab_curvature - tab_overlap;
442 tab_end = tab_curvature - tab_overlap;
444 if (region_flags | GTK_REGION_FIRST)
445 tab_begin += tab_overlap;
446 if (region_flags | GTK_REGION_LAST)
447 tab_end += tab_overlap;
449 alloc.x -= widget_alloc.x;
450 alloc.x -= tab_begin;
451 alloc.x -= xpadding;
452 alloc.y -= widget_alloc.y;
453 alloc.y -= ypadding;
454 alloc.width += 2 * (xpadding) + tab_begin + tab_end;
455 alloc.height += 2 * ypadding;
457 gtk_render_extension (context,
459 alloc.x,
460 alloc.y,
461 alloc.width,
462 alloc.height,
463 GTK_POS_BOTTOM);
465 if (gtk_widget_has_focus (widget) &&
466 current)
468 GtkAllocation allocation;
470 gtk_widget_get_allocation (tab, &allocation);
472 gtk_render_focus (context, cr,
473 allocation.x - focus_width,
474 allocation.y - focus_width,
475 allocation.width + 2 * focus_width,
476 allocation.height + 2 * focus_width);
479 gtk_style_context_restore (context);
482 static GtkRegionFlags
483 anjuta_tabber_get_region_flags (gint page_num, gboolean is_last)
485 GtkRegionFlags flags = 0;
486 if ((page_num) % 2 == 0)
487 flags |= GTK_REGION_EVEN;
488 else
489 flags |= GTK_REGION_ODD;
491 if (page_num == 0)
492 flags |= GTK_REGION_FIRST;
494 if (is_last)
495 flags |= GTK_REGION_LAST;
497 return flags;
500 static void
501 anjuta_tabber_draw_tab (AnjutaTabber* tabber,
502 cairo_t* cr,
503 GList* child,
504 gboolean current)
506 GtkWidget* tab = GTK_WIDGET (child->data);
507 gint nth = g_list_index (tabber->priv->children,
508 child->data) + 1;
509 gboolean last = (child->next == NULL);
510 anjuta_tabber_render_tab (GTK_WIDGET (tabber), tab, cr, current,
511 anjuta_tabber_get_region_flags (nth, last));
514 static gboolean
515 anjuta_tabber_draw (GtkWidget* widget, cairo_t* cr)
517 AnjutaTabber* tabber;
518 GList* current_tab;
519 GList* child;
521 g_return_val_if_fail (ANJUTA_IS_TABBER (widget), FALSE);
523 tabber = ANJUTA_TABBER (widget);
525 if (!tabber->priv->children)
526 return TRUE;
528 current_tab = g_list_nth (tabber->priv->children, tabber->priv->active_page);
530 for (child = tabber->priv->children; child != current_tab; child = g_list_next (child))
532 anjuta_tabber_draw_tab (tabber, cr, child, FALSE);
534 for (child = g_list_last (tabber->priv->children); child != current_tab; child = g_list_previous (child))
536 anjuta_tabber_draw_tab (tabber, cr, child, FALSE);
538 anjuta_tabber_draw_tab (tabber, cr, current_tab, TRUE);
539 return GTK_WIDGET_CLASS (anjuta_tabber_parent_class)->draw (widget, cr);
543 * anjuta_tabber_get_widget_coordintes
544 * @widget: widget for the coordinates
545 * @event: event to get coordinates from
546 * @x: return location for x coordinate
547 * @y: return location for y coordinate
549 * Returns: TRUE if coordinates were set, FALSE otherwise
551 static gboolean
552 anjuta_tabber_get_widget_coordinates (GtkWidget *widget,
553 GdkEvent *event,
554 gint *x,
555 gint *y)
557 GdkWindow *window = ((GdkEventAny *)event)->window;
558 gdouble tx, ty;
560 if (!gdk_event_get_coords (event, &tx, &ty))
561 return FALSE;
563 while (window && window != gtk_widget_get_window (widget))
565 gint window_x, window_y;
567 gdk_window_get_position (window, &window_x, &window_y);
568 tx += window_x;
569 ty += window_y;
571 window = gdk_window_get_parent (window);
574 if (window)
576 *x = tx;
577 *y = ty;
579 return TRUE;
581 else
582 return FALSE;
585 static gboolean
586 anjuta_tabber_button_press_event (GtkWidget* widget, GdkEventButton* event)
588 AnjutaTabber* tabber = ANJUTA_TABBER (widget);
589 GList* child;
591 if (event->button == 1)
593 gint x, y;
594 if (!anjuta_tabber_get_widget_coordinates (widget, (GdkEvent*) event, &x, &y))
595 return FALSE;
597 for (child = tabber->priv->children; child != NULL; child = g_list_next (child))
599 GtkAllocation alloc;
600 gtk_widget_get_allocation (GTK_WIDGET (child->data), &alloc);
602 if (alloc.x <= x && (alloc.x + alloc.width) >= x &&
603 alloc.y <= y && (alloc.y + alloc.height) >= y)
605 gint page = g_list_position (tabber->priv->children, child);
606 gtk_notebook_set_current_page (tabber->priv->notebook, page);
607 return TRUE;
612 return FALSE;
615 static void
616 anjuta_tabber_realize (GtkWidget *widget)
618 GdkWindow* window;
619 GdkWindowAttr attributes;
620 GtkAllocation allocation;
621 AnjutaTabber* tabber = ANJUTA_TABBER (widget);
623 gtk_widget_set_realized (widget, TRUE);
625 window = gtk_widget_get_parent_window (widget);
626 gtk_widget_set_window (widget, window);
627 g_object_ref (window);
629 gtk_widget_get_allocation (widget, &allocation);
631 attributes.window_type = GDK_WINDOW_CHILD;
632 attributes.x = allocation.x;
633 attributes.y = allocation.y;
634 attributes.width = allocation.width;
635 attributes.height = allocation.height;
636 attributes.wclass = GDK_INPUT_ONLY;
637 attributes.event_mask = gtk_widget_get_events (widget);
638 attributes.event_mask |= (GDK_BUTTON_PRESS_MASK);
640 tabber->priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
641 &attributes, GDK_WA_X | GDK_WA_Y);
642 gdk_window_set_user_data (tabber->priv->event_window, tabber);
644 gtk_widget_style_attach (widget);
647 static void
648 anjuta_tabber_unrealize (GtkWidget *widget)
650 AnjutaTabber* tabber = ANJUTA_TABBER (widget);
651 gdk_window_set_user_data (tabber->priv->event_window, NULL);
652 gdk_window_destroy (tabber->priv->event_window);
653 tabber->priv->event_window = NULL;
655 GTK_WIDGET_CLASS (anjuta_tabber_parent_class)->unrealize (widget);
658 static void
659 anjuta_tabber_map (GtkWidget* widget)
661 AnjutaTabber* tabber = ANJUTA_TABBER (widget);
662 gtk_widget_set_mapped (widget, TRUE);
664 gdk_window_show_unraised (tabber->priv->event_window);
666 GTK_WIDGET_CLASS (anjuta_tabber_parent_class)->map (widget);
669 static void
670 anjuta_tabber_unmap (GtkWidget* widget)
672 AnjutaTabber* tabber = ANJUTA_TABBER (widget);
674 gtk_widget_set_mapped (widget, FALSE);
675 gdk_window_hide (tabber->priv->event_window);
677 GTK_WIDGET_CLASS (anjuta_tabber_parent_class)->unmap (widget);
681 static void
682 anjuta_tabber_add (GtkContainer* container, GtkWidget* widget)
684 g_return_if_fail (ANJUTA_IS_TABBER (container));
685 g_return_if_fail (GTK_IS_WIDGET (widget));
687 AnjutaTabber* tabber = ANJUTA_TABBER (container);
688 gboolean visible = gtk_widget_get_visible (widget);
690 tabber->priv->children = g_list_append (tabber->priv->children, widget);
691 gtk_widget_set_parent (widget, GTK_WIDGET (tabber));
692 if (visible)
694 gtk_container_resize_children (GTK_CONTAINER (tabber));
695 gtk_widget_queue_resize (widget);
699 static void
700 anjuta_tabber_remove (GtkContainer* container, GtkWidget* widget)
702 g_return_if_fail (ANJUTA_IS_TABBER (container));
703 g_return_if_fail (GTK_IS_WIDGET (widget));
705 AnjutaTabber* tabber = ANJUTA_TABBER (container);
706 gboolean visible = gtk_widget_get_visible (widget);
708 gtk_widget_unparent (widget);
709 tabber->priv->children = g_list_remove (tabber->priv->children, widget);
711 if (tabber->priv->active_page > 0)
712 tabber->priv->active_page--;
714 if (visible)
715 gtk_widget_queue_resize (GTK_WIDGET (tabber));
718 static void
719 anjuta_tabber_forall (GtkContainer* container,
720 gboolean include_internals,
721 GtkCallback callback,
722 gpointer callback_data)
724 g_return_if_fail (ANJUTA_IS_TABBER (container));
725 AnjutaTabber* tabber = ANJUTA_TABBER (container);
726 GList* child;
727 for (child = tabber->priv->children; child != NULL; child = g_list_next (child))
729 (* callback) (GTK_WIDGET(child->data), callback_data);
733 static void
734 anjuta_tabber_class_init (AnjutaTabberClass *klass)
736 GObjectClass* object_class = G_OBJECT_CLASS (klass);
737 GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
738 GtkContainerClass* container_class = GTK_CONTAINER_CLASS (klass);
740 object_class->finalize = anjuta_tabber_finalize;
741 object_class->dispose = anjuta_tabber_dispose;
742 object_class->set_property = anjuta_tabber_set_property;
743 object_class->get_property = anjuta_tabber_get_property;
745 widget_class->get_preferred_height = anjuta_tabber_get_preferred_height;
746 widget_class->get_preferred_width = anjuta_tabber_get_preferred_width;
747 widget_class->size_allocate = anjuta_tabber_size_allocate;
748 widget_class->draw = anjuta_tabber_draw;
749 widget_class->button_press_event = anjuta_tabber_button_press_event;
750 widget_class->realize = anjuta_tabber_realize;
751 widget_class->unrealize = anjuta_tabber_unrealize;
752 widget_class->map = anjuta_tabber_map;
753 widget_class->unmap = anjuta_tabber_unmap;
755 container_class->add = anjuta_tabber_add;
756 container_class->remove = anjuta_tabber_remove;
757 container_class->forall = anjuta_tabber_forall;
759 g_object_class_install_property (object_class,
760 PROP_NOTEBOOK,
761 g_param_spec_object ("notebook",
762 "a GtkNotebook",
763 "GtkNotebook the tabber is associated with",
764 G_TYPE_OBJECT,
765 G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
767 g_type_class_add_private (klass, sizeof (AnjutaTabberPriv));
771 * anjuta_tabber_new:
772 * @notebook: the GtkNotebook the tabber should be associated with
774 * Creates a new AnjutaTabber widget
776 * Returns: newly created AnjutaTabber widget
778 GtkWidget* anjuta_tabber_new (GtkNotebook* notebook)
780 GtkWidget* tabber;
781 tabber = GTK_WIDGET (g_object_new (ANJUTA_TYPE_TABBER, "notebook", notebook, NULL));
783 return tabber;
787 * anjuta_tabber_add_tab:
788 * @tabber: a AnjutaTabber widget
789 * @tab_label: widget used as tab label
791 * Adds a tab to the AnjutaTabber widget
793 void anjuta_tabber_add_tab (AnjutaTabber* tabber, GtkWidget* tab_label)
795 gtk_container_add (GTK_CONTAINER (tabber), tab_label);