static void cb_toolbar_reconfigured (GOToolComboPixmaps *tool, GtkAction *a) { GtkOrientation o = gtk_tool_item_get_orientation (GTK_TOOL_ITEM (tool)); GtkReliefStyle relief = gtk_tool_item_get_relief_style (GTK_TOOL_ITEM (tool)); GOActionComboPixmaps *paction = (GOActionComboPixmaps *)a; GOActionComboPixmapsElement const *el = paction->elements; g_object_set (G_OBJECT (tool->combo), "show-arrow", o == GTK_ORIENTATION_HORIZONTAL, NULL); go_combo_pixmaps_clear_elements (tool->combo); for ( ; el->stock_id != NULL ; el++) { GdkPixbuf *icon = make_icon (a, el->stock_id, GTK_WIDGET (tool)); /* * FIXME FIXME FIXME: we must find a better solution for * translating strings not in goffice domain */ go_combo_pixmaps_add_element (tool->combo, icon, el->id, gettext (el->untranslated_tooltip)); } go_combo_pixmaps_select_id (tool->combo, paction->selected_id); go_combo_box_set_relief (GO_COMBO_BOX (tool->combo), relief); }
// helper to create a dropdown menu item void wxToolBarTool::CreateDropDown() { gtk_tool_item_set_homogeneous(m_item, false); GtkWidget* box; GtkWidget* arrow; if (GetToolBar()->HasFlag(wxTB_LEFT | wxTB_RIGHT)) { box = gtk_vbox_new(false, 0); arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE); } else { box = gtk_hbox_new(false, 0); arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE); } GtkWidget* tool_button = GTK_BIN(m_item)->child; gtk_widget_reparent(tool_button, box); GtkWidget* arrow_button = gtk_toggle_button_new(); gtk_button_set_relief(GTK_BUTTON(arrow_button), gtk_tool_item_get_relief_style(GTK_TOOL_ITEM(m_item))); gtk_container_add(GTK_CONTAINER(arrow_button), arrow); gtk_container_add(GTK_CONTAINER(box), arrow_button); gtk_widget_show_all(box); gtk_container_add(GTK_CONTAINER(m_item), box); g_signal_connect(arrow_button, "toggled", G_CALLBACK(arrow_toggled), this); g_signal_connect(arrow_button, "button_press_event", G_CALLBACK(arrow_button_press_event), this); }
// helper to create a dropdown menu item void wxToolBarTool::CreateDropDown() { gtk_tool_item_set_homogeneous(m_item, false); GtkOrientation orient = GTK_ORIENTATION_HORIZONTAL; GtkArrowType arrowType = GTK_ARROW_DOWN; if (GetToolBar()->HasFlag(wxTB_LEFT | wxTB_RIGHT)) { orient = GTK_ORIENTATION_VERTICAL; arrowType = GTK_ARROW_RIGHT; } GtkWidget* box = gtk_box_new(orient, 0); GtkWidget* arrow = gtk_arrow_new(arrowType, GTK_SHADOW_NONE); GtkWidget* tool_button = gtk_bin_get_child(GTK_BIN(m_item)); g_object_ref(tool_button); gtk_container_remove(GTK_CONTAINER(m_item), tool_button); gtk_container_add(GTK_CONTAINER(box), tool_button); g_object_unref(tool_button); GtkWidget* arrow_button = gtk_toggle_button_new(); gtk_button_set_relief(GTK_BUTTON(arrow_button), gtk_tool_item_get_relief_style(GTK_TOOL_ITEM(m_item))); gtk_container_add(GTK_CONTAINER(arrow_button), arrow); gtk_container_add(GTK_CONTAINER(box), arrow_button); gtk_widget_show_all(box); gtk_container_add(GTK_CONTAINER(m_item), box); g_signal_connect(arrow_button, "toggled", G_CALLBACK(arrow_toggled), this); g_signal_connect(arrow_button, "button_press_event", G_CALLBACK(arrow_button_press_event), this); }
JNIEXPORT jint JNICALL Java_org_gnome_gtk_GtkToolItem_gtk_1tool_1item_1get_1relief_1style ( JNIEnv* env, jclass cls, jlong _self ) { GtkReliefStyle result; jint _result; GtkToolItem* self; // convert parameter self self = (GtkToolItem*) _self; // call function result = gtk_tool_item_get_relief_style(self); // cleanup parameter self // translate return value to JNI type _result = (jint) result; // and finally return _result; }
static void gimp_throbber_construct_contents (GtkToolItem *tool_item) { GimpThrobber *button = GIMP_THROBBER (tool_item); GtkWidget *image; GtkToolbarStyle style; if (button->priv->image && gtk_widget_get_parent (button->priv->image)) gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (button->priv->image)), button->priv->image); if (gtk_bin_get_child (GTK_BIN (button->priv->button))) gtk_widget_destroy (gtk_bin_get_child (GTK_BIN (button->priv->button))); style = gtk_tool_item_get_toolbar_style (tool_item); if (style == GTK_TOOLBAR_TEXT) { image = gtk_image_new_from_icon_name (button->priv->icon_name, GTK_ICON_SIZE_MENU); } else if (style == GTK_TOOLBAR_ICONS) { image = gtk_image_new_from_icon_name (button->priv->icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR); } else if (button->priv->image) { image = button->priv->image; } else { image = gtk_image_new_from_icon_name (button->priv->icon_name, GTK_ICON_SIZE_DND); } gtk_container_add (GTK_CONTAINER (button->priv->button), image); gtk_widget_show (image); gtk_button_set_relief (GTK_BUTTON (button->priv->button), gtk_tool_item_get_relief_style (tool_item)); gtk_widget_queue_resize (GTK_WIDGET (button)); }
static VALUE rg_relief_style(VALUE self) { return GTKRELIEFSTYLE2RVAL(gtk_tool_item_get_relief_style(_SELF(self))); }
static void gtk_tool_button_construct_contents (GtkToolItem *tool_item) { GtkToolButton *button = GTK_TOOL_BUTTON (tool_item); GtkWidget *label = NULL; GtkWidget *icon = NULL; GtkToolbarStyle style; gboolean need_label = FALSE; gboolean need_icon = FALSE; GtkIconSize icon_size; GtkWidget *box = NULL; guint icon_spacing; GtkOrientation text_orientation = GTK_ORIENTATION_HORIZONTAL; GtkSizeGroup *size_group = NULL; button->priv->contents_invalid = FALSE; gtk_widget_style_get (GTK_WIDGET (tool_item), "icon-spacing", &icon_spacing, NULL); if (button->priv->icon_widget && button->priv->icon_widget->parent) { gtk_container_remove (GTK_CONTAINER (button->priv->icon_widget->parent), button->priv->icon_widget); } if (button->priv->label_widget && button->priv->label_widget->parent) { gtk_container_remove (GTK_CONTAINER (button->priv->label_widget->parent), button->priv->label_widget); } if (GTK_BIN (button->priv->button)->child) { /* Note: we are not destroying the label_widget or icon_widget * here because they were removed from their containers above */ gtk_widget_destroy (GTK_BIN (button->priv->button)->child); } style = gtk_tool_item_get_toolbar_style (GTK_TOOL_ITEM (button)); if (style != GTK_TOOLBAR_TEXT) need_icon = TRUE; if (style != GTK_TOOLBAR_ICONS && style != GTK_TOOLBAR_BOTH_HORIZ) need_label = TRUE; if (style == GTK_TOOLBAR_BOTH_HORIZ && (gtk_tool_item_get_is_important (GTK_TOOL_ITEM (button)) || gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button)) == GTK_ORIENTATION_VERTICAL || gtk_tool_item_get_text_orientation (GTK_TOOL_ITEM (button)) == GTK_ORIENTATION_VERTICAL)) { need_label = TRUE; } if (style == GTK_TOOLBAR_ICONS && button->priv->icon_widget == NULL && button->priv->stock_id == NULL && button->priv->icon_name == NULL) { need_label = TRUE; need_icon = FALSE; style = GTK_TOOLBAR_TEXT; } if (style == GTK_TOOLBAR_TEXT && button->priv->label_widget == NULL && button->priv->stock_id == NULL && button->priv->label_text == NULL) { need_label = FALSE; need_icon = TRUE; style = GTK_TOOLBAR_ICONS; } if (need_label) { if (button->priv->label_widget) { label = button->priv->label_widget; } else { GtkStockItem stock_item; gboolean elide; gchar *label_text; if (button->priv->label_text) { label_text = button->priv->label_text; elide = button->priv->use_underline; } else if (button->priv->stock_id && gtk_stock_lookup (button->priv->stock_id, &stock_item)) { label_text = stock_item.label; elide = TRUE; } else { label_text = ""; elide = FALSE; } if (elide) label_text = _gtk_toolbar_elide_underscores (label_text); else label_text = g_strdup (label_text); label = gtk_label_new (label_text); g_free (label_text); gtk_widget_show (label); } gtk_label_set_ellipsize (GTK_LABEL (label), gtk_tool_item_get_ellipsize_mode (GTK_TOOL_ITEM (button))); text_orientation = gtk_tool_item_get_text_orientation (GTK_TOOL_ITEM (button)); if (text_orientation == GTK_ORIENTATION_HORIZONTAL) { gtk_label_set_angle (GTK_LABEL (label), 0); gtk_misc_set_alignment (GTK_MISC (label), gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button)), 0.5); } else { gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_NONE); if (gtk_widget_get_direction (GTK_WIDGET (tool_item)) == GTK_TEXT_DIR_RTL) gtk_label_set_angle (GTK_LABEL (label), -90); else gtk_label_set_angle (GTK_LABEL (label), 90); gtk_misc_set_alignment (GTK_MISC (label), 0.5, 1 - gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button))); } } icon_size = gtk_tool_item_get_icon_size (GTK_TOOL_ITEM (button)); if (need_icon) { if (button->priv->icon_widget) { icon = button->priv->icon_widget; if (GTK_IS_IMAGE (icon)) { g_object_set (button->priv->icon_widget, "icon-size", icon_size, NULL); } } else if (button->priv->stock_id && gtk_icon_factory_lookup_default (button->priv->stock_id)) { icon = gtk_image_new_from_stock (button->priv->stock_id, icon_size); gtk_widget_show (icon); } else if (button->priv->icon_name) { icon = gtk_image_new_from_icon_name (button->priv->icon_name, icon_size); gtk_widget_show (icon); } if (icon && text_orientation == GTK_ORIENTATION_HORIZONTAL) gtk_misc_set_alignment (GTK_MISC (icon), 1.0 - gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button)), 0.5); else if (icon) gtk_misc_set_alignment (GTK_MISC (icon), 0.5, gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button))); if (icon) { size_group = gtk_tool_item_get_text_size_group (GTK_TOOL_ITEM (button)); if (size_group != NULL) gtk_size_group_add_widget (size_group, icon); } } switch (style) { case GTK_TOOLBAR_ICONS: if (icon) gtk_container_add (GTK_CONTAINER (button->priv->button), icon); break; case GTK_TOOLBAR_BOTH: if (text_orientation == GTK_ORIENTATION_HORIZONTAL) box = gtk_vbox_new (FALSE, icon_spacing); else box = gtk_hbox_new (FALSE, icon_spacing); if (icon) gtk_box_pack_start (GTK_BOX (box), icon, TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (box), label, FALSE, TRUE, 0); gtk_container_add (GTK_CONTAINER (button->priv->button), box); break; case GTK_TOOLBAR_BOTH_HORIZ: if (text_orientation == GTK_ORIENTATION_HORIZONTAL) { box = gtk_hbox_new (FALSE, icon_spacing); if (icon) gtk_box_pack_start (GTK_BOX (box), icon, label? FALSE : TRUE, TRUE, 0); if (label) gtk_box_pack_end (GTK_BOX (box), label, TRUE, TRUE, 0); } else { box = gtk_vbox_new (FALSE, icon_spacing); if (icon) gtk_box_pack_end (GTK_BOX (box), icon, label ? FALSE : TRUE, TRUE, 0); if (label) gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0); } gtk_container_add (GTK_CONTAINER (button->priv->button), box); break; case GTK_TOOLBAR_TEXT: gtk_container_add (GTK_CONTAINER (button->priv->button), label); break; } if (box) gtk_widget_show (box); gtk_button_set_relief (GTK_BUTTON (button->priv->button), gtk_tool_item_get_relief_style (GTK_TOOL_ITEM (button))); gtk_tool_item_rebuild_menu (tool_item); gtk_widget_queue_resize (GTK_WIDGET (button)); }