/* * 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_vbutton_box_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data) { GtkButtonBoxStyle layout_style; gint spacing, i; if (data->create_widget) { source_add (data, " %s = gtk_vbutton_box_new ();\n", data->wname); } gb_widget_write_standard_source (widget, data); layout_style = GTK_BUTTON_BOX (widget)->layout_style; if (layout_style != GTK_BUTTONBOX_DEFAULT_STYLE) { for (i = 0; i < sizeof (GbLayoutValues) / sizeof (GbLayoutValues[0]); i ++) { if (GbLayoutValues[i] == layout_style) source_add (data, " gtk_button_box_set_layout (GTK_BUTTON_BOX (%s), %s);\n", data->wname, GbLayoutSymbols[i]); } } spacing = gtk_box_get_spacing (GTK_BOX (widget)); if (spacing != 0) { source_add (data, " gtk_box_set_spacing (GTK_BOX (%s), %i);\n", data->wname, spacing); } }
/* * 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_hbutton_box_get_properties (GtkWidget * widget, GbWidgetGetArgData * data) { GtkButtonBoxStyle layout; gint i, spacing; gboolean spacing_visible = FALSE; if (data->action != GB_SAVING) gb_widget_output_int (data, Size, g_list_length (GTK_BOX (widget)->children)); layout = gtk_button_box_get_layout (GTK_BUTTON_BOX (widget)); for (i = 0; i < sizeof (GbLayoutValues) / sizeof (GbLayoutValues[0]); i++) { if (GbLayoutValues[i] == layout) gb_widget_output_choice (data, Layout, i, GbLayoutSymbols[i]); } if (!gb_hbutton_box_is_dialog_action_area (widget)) { spacing_visible = TRUE; spacing = gtk_box_get_spacing (GTK_BOX (widget)); gb_widget_output_int (data, Spacing, spacing); } if (data->action == GB_SHOWING) { property_set_visible (Spacing, spacing_visible); } }
JNIEXPORT jint JNICALL Java_org_gnome_gtk_GtkBox_gtk_1box_1get_1spacing ( JNIEnv* env, jclass cls, jlong _self ) { gint result; jint _result; GtkBox* self; // convert parameter self self = (GtkBox*) _self; // call function result = gtk_box_get_spacing(self); // cleanup parameter self // translate return value to JNI type _result = (jint) result; // and finally return _result; }
/* * 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_vbutton_box_get_properties (GtkWidget * widget, GbWidgetGetArgData * data) { GtkButtonBoxStyle layout; gint i, spacing; if (data->action != GB_SAVING) gb_widget_output_int (data, Size, g_list_length (GTK_BOX (widget)->children)); layout = gtk_button_box_get_layout (GTK_BUTTON_BOX (widget)); for (i = 0; i < sizeof (GbLayoutValues) / sizeof (GbLayoutValues[0]); i++) { if (GbLayoutValues[i] == layout) gb_widget_output_choice (data, Layout, i, GbLayoutSymbols[i]); } spacing = gtk_box_get_spacing (GTK_BOX (widget)); gb_widget_output_int (data, Spacing, spacing); }
static gint luaH_box_index(lua_State *L, widget_t *w, luakit_token_t token) { switch(token) { LUAKIT_WIDGET_INDEX_COMMON(w) LUAKIT_WIDGET_CONTAINER_INDEX_COMMON(w) /* push class methods */ PF_CASE(PACK, luaH_box_pack) PF_CASE(REORDER, luaH_box_reorder_child) /* push boolean properties */ PB_CASE(HOMOGENEOUS, gtk_box_get_homogeneous(GTK_BOX(w->widget))) /* push string properties */ PN_CASE(SPACING, gtk_box_get_spacing(GTK_BOX(w->widget))) PS_CASE(BG, g_object_get_data(G_OBJECT(w->widget), "bg")) default: break; } return 0; }
static void fr_file_selector_dialog_get_default_size (FrFileSelectorDialog *self, int *default_width, int *default_height) { int width, height; g_settings_get (self->priv->settings, PREF_FILE_SELECTOR_WINDOW_SIZE, "(ii)", &width, &height); if ((width > 0) && (height > 0)) { *default_width = width; *default_height = height; return; } find_good_window_size_from_style (GTK_WIDGET (self), default_width, default_height); if ((self->priv->extra_widget != NULL) && gtk_widget_get_visible (self->priv->extra_widget)) { GtkRequisition req; gtk_widget_get_preferred_size (GET_WIDGET ("extra_widget_container"), &req, NULL); *default_height += gtk_box_get_spacing (GTK_BOX (GET_WIDGET ("content"))) + req.height; } }
static gint luaH_box_index(lua_State *L, luapdf_token_t token) { widget_t *w = luaH_checkwidget(L, 1); switch(token) { LUAPDF_WIDGET_INDEX_COMMON LUAPDF_WIDGET_CONTAINER_INDEX_COMMON(w) /* push class methods */ PF_CASE(PACK, luaH_box_pack) PF_CASE(REORDER, luaH_box_reorder_child) /* push boolean properties */ PB_CASE(HOMOGENEOUS, gtk_box_get_homogeneous(GTK_BOX(w->widget))) /* push string properties */ PN_CASE(SPACING, gtk_box_get_spacing(GTK_BOX(w->widget))) default: break; } return 0; }
GtkWidget * gimp_text_options_gui (GimpToolOptions *tool_options) { GObject *config = G_OBJECT (tool_options); GimpTextOptions *options = GIMP_TEXT_OPTIONS (tool_options); GtkWidget *main_vbox = gimp_tool_options_gui (tool_options); GimpAsyncSet *async_set; GtkWidget *options_vbox; GtkWidget *grid; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *button; GtkWidget *entry; GtkWidget *box; GtkWidget *spinbutton; GtkWidget *combo; GtkSizeGroup *size_group; gint row = 0; async_set = gimp_data_factory_get_async_set (tool_options->tool_info->gimp->font_factory); box = gimp_busy_box_new (_("Loading fonts (this may take a while...)")); gtk_container_set_border_width (GTK_CONTAINER (box), 8); gtk_box_pack_start (GTK_BOX (main_vbox), box, FALSE, FALSE, 0); g_object_bind_property (async_set, "empty", box, "visible", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN); options_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, gtk_box_get_spacing (GTK_BOX (main_vbox))); gtk_box_pack_start (GTK_BOX (main_vbox), options_vbox, FALSE, FALSE, 0); gtk_widget_show (options_vbox); g_object_bind_property (async_set, "empty", options_vbox, "sensitive", G_BINDING_SYNC_CREATE); hbox = gimp_prop_font_box_new (NULL, GIMP_CONTEXT (tool_options), _("Font"), 2, "font-view-type", "font-view-size"); gtk_box_pack_start (GTK_BOX (options_vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); grid = gtk_grid_new (); gtk_grid_set_column_spacing (GTK_GRID (grid), 2); gtk_grid_set_row_spacing (GTK_GRID (grid), 2); gtk_box_pack_start (GTK_BOX (options_vbox), grid, FALSE, FALSE, 0); gtk_widget_show (grid); entry = gimp_prop_size_entry_new (config, "font-size", FALSE, "font-size-unit", "%p", GIMP_SIZE_ENTRY_UPDATE_SIZE, 72.0); gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++, _("Size:"), 0.0, 0.5, entry, 2); options->size_entry = entry; vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_box_pack_start (GTK_BOX (options_vbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); button = gimp_prop_check_button_new (config, "use-editor", NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_prop_check_button_new (config, "antialias", NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); grid = gtk_grid_new (); gtk_grid_set_column_spacing (GTK_GRID (grid), 2); gtk_grid_set_row_spacing (GTK_GRID (grid), 2); gtk_box_pack_start (GTK_BOX (options_vbox), grid, FALSE, FALSE, 0); gtk_widget_show (grid); row = 0; size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); button = gimp_prop_enum_combo_box_new (config, "hint-style", -1, -1); gtk_widget_set_halign (button, GTK_ALIGN_START); gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++, _("Hinting:"), 0.0, 0.5, button, 1); gtk_size_group_add_widget (size_group, button); button = gimp_prop_color_button_new (config, "foreground", _("Text Color"), 40, 24, GIMP_COLOR_AREA_FLAT); gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), GIMP_CONTEXT (options)); gtk_widget_set_halign (button, GTK_ALIGN_START); gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++, _("Color:"), 0.0, 0.5, button, 1); gtk_size_group_add_widget (size_group, button); box = gimp_prop_enum_icon_box_new (config, "justify", "format-justify", 0, 0); gtk_widget_set_halign (box, GTK_ALIGN_START); gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++, _("Justify:"), 0.0, 0.5, box, 2); gtk_size_group_add_widget (size_group, box); g_object_unref (size_group); spinbutton = gimp_prop_spin_button_new (config, "indent", 1.0, 10.0, 1); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5); gtk_widget_set_halign (spinbutton, GTK_ALIGN_START); gimp_grid_attach_icon (GTK_GRID (grid), row++, GIMP_ICON_FORMAT_INDENT_MORE, spinbutton, 1); spinbutton = gimp_prop_spin_button_new (config, "line-spacing", 1.0, 10.0, 1); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5); gtk_widget_set_halign (spinbutton, GTK_ALIGN_START); gimp_grid_attach_icon (GTK_GRID (grid), row++, GIMP_ICON_FORMAT_TEXT_SPACING_LINE, spinbutton, 1); spinbutton = gimp_prop_spin_button_new (config, "letter-spacing", 1.0, 10.0, 1); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5); gtk_widget_set_halign (spinbutton, GTK_ALIGN_START); gimp_grid_attach_icon (GTK_GRID (grid), row++, GIMP_ICON_FORMAT_TEXT_SPACING_LETTER, spinbutton, 1); combo = gimp_prop_enum_combo_box_new (config, "box-mode", 0, 0); gtk_widget_set_halign (combo, GTK_ALIGN_START); gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++, _("Box:"), 0.0, 0.5, combo, 1); /* Only add the language entry if the iso-codes package is available. */ #ifdef HAVE_ISO_CODES { GtkWidget *label; vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_box_pack_start (GTK_BOX (options_vbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new (_("Language:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); entry = gimp_prop_language_entry_new (config, "language"); gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0); gtk_widget_show (entry); } #endif return main_vbox; }
/* Make the size of dialogs smaller by breaking GNOME HIG * http://library.gnome.org/devel/hig-book/stable/design-window.html.en * According to GNOME HIG, spacings are increased by the multiples of 6. * Change them to the multiples of 1 can greatly reduce the required size * while still keeping some degree of spacing. */ static void break_gnome_hig( GtkWidget* w, gpointer _factor ) { int factor = GPOINTER_TO_INT(_factor); /* g_debug( G_OBJECT_TYPE_NAME(w) ); */ if( GTK_IS_CONTAINER(w) ) { int val; val = gtk_container_get_border_width( (GtkContainer*)w ); /* border of dialog defaults to 12 under gnome */ if( GTK_IS_DIALOG(w) ) { if( val > 0 ) gtk_container_set_border_width( (GtkContainer*)w, val / factor ); } else { if( GTK_IS_BOX(w) ) /* boxes, spacing defaults to 6, 12, 18 under gnome */ { int spacing = gtk_box_get_spacing( (GtkBox*)w ); gtk_box_set_spacing( (GtkBox*)w, spacing / factor ); } else if( GTK_IS_TABLE(w) ) /* tables, spacing defaults to 6, 12, 18 under gnome */ { int spacing; int col, row; g_object_get( w, "n-columns", &col, "n-rows", &row, NULL ); if( col > 1 ) { --col; while( --col >= 0 ) { spacing = gtk_table_get_col_spacing( (GtkTable*)w, col ); if( spacing > 0 ) gtk_table_set_col_spacing( (GtkTable*)w, col, spacing / factor ); } } if( row > 1 ) { --row; while( --row >= 0 ) { spacing = gtk_table_get_row_spacing( (GtkTable*)w, row ); if( spacing > 0 ) gtk_table_set_row_spacing( (GtkTable*)w, row, spacing / factor ); } } /* FIXME: handle default spacings */ } else if( GTK_IS_ALIGNMENT(w) ) /* groups, has 12 px indent by default */ { int t, b, l, r; gtk_alignment_get_padding( (GtkAlignment*)w, &t, &b, &l, &r ); if( l > 0 ) { l /= (factor / 2); /* groups still need proper indent not to hurt usability */ gtk_alignment_set_padding( (GtkAlignment*)w, t, b, l, r ); } } if( val > 0 ) gtk_container_set_border_width( (GtkContainer*)w, val * 2 / factor ); } gtk_container_foreach( (GtkContainer*)w, break_gnome_hig, GINT_TO_POINTER(factor) ); } }