JNIEXPORT jboolean JNICALL Java_org_gnome_gtk_GtkToolItem_gtk_1tool_1item_1get_1is_1important ( JNIEnv* env, jclass cls, jlong _self ) { gboolean result; jboolean _result; GtkToolItem* self; // convert parameter self self = (GtkToolItem*) _self; // call function result = gtk_tool_item_get_is_important(self); // cleanup parameter self // translate return value to JNI type _result = (jboolean) result; // and finally return _result; }
/* * Writes the source code needed to create this widget. * You have to output everything necessary to create the widget here, though * there are some convenience functions to help. */ static void gb_tool_item_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data) { if (data->create_widget) { source_add (data, " %s = (GtkWidget*) gtk_tool_item_new ();\n", data->wname); } gb_widget_write_standard_source (widget, data); if (gtk_object_get_data (GTK_OBJECT (widget), VisibleHorz) != NULL) { source_add (data, " gtk_tool_item_set_visible_horizontal (GTK_TOOL_ITEM (%s), FALSE);\n", data->wname); } if (gtk_object_get_data (GTK_OBJECT (widget), VisibleVert) != NULL) { source_add (data, " gtk_tool_item_set_visible_vertical (GTK_TOOL_ITEM (%s), FALSE);\n", data->wname); } if (gtk_tool_item_get_is_important (GTK_TOOL_ITEM (widget))) { source_add (data, " gtk_tool_item_set_is_important (GTK_TOOL_ITEM (%s), TRUE);\n", data->wname); } }
static void set_important_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { GtkToolItem *tool_item; gtk_tree_model_get (model, iter, 0, &tool_item, -1); g_object_set (cell, "active", gtk_tool_item_get_is_important (tool_item), NULL); g_object_unref (tool_item); }
/* * Gets the properties of the widget. This is used for both displaying the * properties in the property editor, and also for saving the properties. */ static void gb_tool_item_get_properties (GtkWidget *widget, GbWidgetGetArgData * data) { gb_widget_output_bool (data, VisibleHorz, gtk_object_get_data (GTK_OBJECT (widget), VisibleHorz) != NULL ? FALSE : TRUE); gb_widget_output_bool (data, VisibleVert, gtk_object_get_data (GTK_OBJECT (widget), VisibleVert) != NULL ? FALSE : TRUE); gb_widget_output_bool (data, IsImportant, gtk_tool_item_get_is_important (GTK_TOOL_ITEM (widget))); }
static void important_toggled(GtkCellRendererToggle *cell, const gchar *path_str, GtkTreeModel *model) { GtkTreePath *path; GtkTreeIter iter; GtkToolItem *tool_item; path = gtk_tree_path_new_from_string (path_str); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, 0, &tool_item, -1); gtk_tool_item_set_is_important (tool_item, !gtk_tool_item_get_is_important (tool_item)); g_object_unref (tool_item); gtk_tree_model_row_changed (model, path, &iter); gtk_tree_path_free (path); }
/* * Writes the source code needed to create this widget. * You have to output everything necessary to create the widget here, though * there are some convenience functions to help. */ static void gb_radio_tool_button_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data) { GladeFindGroupData find_data; GtkWidget *group_widget; gchar *stock_id, *label, *icon_name; gchar buffer[256], *group_name; gboolean translatable, context; gchar *comments; stock_id = gtk_object_get_data (GTK_OBJECT (widget), GladeToolButtonStockIDKey); icon_name = gtk_object_get_data (GTK_OBJECT (widget), GladeToolButtonIconKey); label = (gchar*) gtk_tool_button_get_label (GTK_TOOL_BUTTON (widget)); glade_util_get_translation_properties (widget, Label, &translatable, &comments, &context); find_data.group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (widget)); find_data.found_widget = NULL; gb_widget_children_foreach (widget->parent, (GtkCallback) find_radio_group, &find_data); group_widget = find_data.found_widget; if (!group_widget) { g_warning ("Radiotoolbutton has no group"); group_widget = widget; } group_name = (char*) gtk_widget_get_name (group_widget); group_name = source_create_valid_identifier (group_name); sprintf (buffer, " GSList *%s_group = NULL;\n", group_name); source_ensure_decl (data, buffer); if (data->create_widget) { if (stock_id) { /* Stock Button */ source_add (data, " %s = (GtkWidget*) gtk_radio_tool_button_new_from_stock (NULL, %s);\n", data->wname, source_make_string (stock_id, FALSE)); } else if (icon_name) { /* Icon and Label */ source_add (data, " %s = (GtkWidget*) gtk_radio_tool_button_new (NULL);\n", data->wname); source_add_translator_comments (data, translatable, comments); source_add (data, " gtk_tool_button_set_label (GTK_TOOL_BUTTON (%s), %s);\n", data->wname, label ? source_make_string_full (label, data->use_gettext && translatable, context) : "NULL"); source_ensure_decl (data, " GtkWidget *tmp_image;\n"); if (glade_util_check_is_stock_id (icon_name)) { source_add (data, " tmp_image = gtk_image_new_from_stock (\"%s\", tmp_toolbar_icon_size);\n", icon_name); } else { source_create_pixmap (data, "tmp_image", icon_name); } source_add (data, " gtk_widget_show (tmp_image);\n"); source_add (data, " gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (%s), tmp_image);\n", data->wname); } else { /* Just a Label */ source_add (data, " %s = (GtkWidget*) gtk_radio_tool_button_new (NULL);\n", data->wname); source_add_translator_comments (data, translatable, comments); source_add (data, " gtk_tool_button_set_label (GTK_TOOL_BUTTON (%s), %s);\n", data->wname, label ? source_make_string_full (label, data->use_gettext && translatable, context) : "NULL"); } } gb_widget_write_standard_source (widget, data); source_add (data, " gtk_radio_tool_button_set_group (GTK_RADIO_TOOL_BUTTON (%s), %s_group);\n", data->wname, group_name); source_add (data, " %s_group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (%s));\n", group_name, data->wname); if (data->widget_data->flags & GLADE_ACTIVE) { source_add (data, " gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (%s), TRUE);\n", data->wname); } if (gtk_object_get_data (GTK_OBJECT (widget), VisibleHorz) != NULL) { source_add (data, " gtk_tool_item_set_visible_horizontal (GTK_TOOL_ITEM (%s), FALSE);\n", data->wname); } if (gtk_object_get_data (GTK_OBJECT (widget), VisibleVert) != NULL) { source_add (data, " gtk_tool_item_set_visible_vertical (GTK_TOOL_ITEM (%s), FALSE);\n", data->wname); } if (gtk_tool_item_get_is_important (GTK_TOOL_ITEM (widget))) { source_add (data, " gtk_tool_item_set_is_important (GTK_TOOL_ITEM (%s), TRUE);\n", data->wname); } g_free (group_name); }
/* * Writes the source code needed to create this widget. * You have to output everything necessary to create the widget here, though * there are some convenience functions to help. */ static void gb_toggle_tool_button_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data) { gchar *stock_id, *label, *icon_name; gboolean translatable, context; gchar *comments; stock_id = gtk_object_get_data (GTK_OBJECT (widget), GladeToolButtonStockIDKey); icon_name = gtk_object_get_data (GTK_OBJECT (widget), GladeToolButtonIconKey); label = (gchar*) gtk_tool_button_get_label (GTK_TOOL_BUTTON (widget)); glade_util_get_translation_properties (widget, Label, &translatable, &comments, &context); if (data->create_widget) { if (stock_id) { /* Stock Button */ source_add (data, " %s = (GtkWidget*) gtk_toggle_tool_button_new_from_stock (%s);\n", data->wname, source_make_string (stock_id, FALSE)); } else if (icon_name) { /* Icon and Label */ source_add (data, " %s = (GtkWidget*) gtk_toggle_tool_button_new ();\n", data->wname); source_add_translator_comments (data, translatable, comments); source_add (data, " gtk_tool_button_set_label (GTK_TOOL_BUTTON (%s), %s);\n", data->wname, label ? source_make_string_full (label, data->use_gettext && translatable, context) : "NULL"); source_ensure_decl (data, " GtkWidget *tmp_image;\n"); if (glade_util_check_is_stock_id (icon_name)) { source_add (data, " tmp_image = gtk_image_new_from_stock (\"%s\", tmp_toolbar_icon_size);\n", icon_name); } else { source_create_pixmap (data, "tmp_image", icon_name); } source_add (data, " gtk_widget_show (tmp_image);\n"); source_add (data, " gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (%s), tmp_image);\n", data->wname); } else { /* Just a Label */ source_add (data, " %s = (GtkWidget*) gtk_toggle_tool_button_new ();\n", data->wname); source_add_translator_comments (data, translatable, comments); source_add (data, " gtk_tool_button_set_label (GTK_TOOL_BUTTON (%s), %s);\n", data->wname, label ? source_make_string_full (label, data->use_gettext && translatable, context) : "NULL"); } } gb_widget_write_standard_source (widget, data); if (data->widget_data->flags & GLADE_ACTIVE) { source_add (data, " gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (%s), TRUE);\n", data->wname); } if (gtk_object_get_data (GTK_OBJECT (widget), VisibleHorz) != NULL) { source_add (data, " gtk_tool_item_set_visible_horizontal (GTK_TOOL_ITEM (%s), FALSE);\n", data->wname); } if (gtk_object_get_data (GTK_OBJECT (widget), VisibleVert) != NULL) { source_add (data, " gtk_tool_item_set_visible_vertical (GTK_TOOL_ITEM (%s), FALSE);\n", data->wname); } if (gtk_tool_item_get_is_important (GTK_TOOL_ITEM (widget))) { source_add (data, " gtk_tool_item_set_is_important (GTK_TOOL_ITEM (%s), TRUE);\n", data->wname); } }
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)); }