/* * 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_scrolled_window_get_properties (GtkWidget * widget, GbWidgetGetArgData * data) { gint i; for (i = 0; i < sizeof (GbPolicyValues) / sizeof (GbPolicyValues[0]); i++) { if (GbPolicyValues[i] == GTK_SCROLLED_WINDOW (widget)->hscrollbar_policy) gb_widget_output_choice (data, HPolicy, i, GbPolicySymbols[i]); } for (i = 0; i < sizeof (GbPolicyValues) / sizeof (GbPolicyValues[0]); i++) { if (GbPolicyValues[i] == GTK_SCROLLED_WINDOW (widget)->vscrollbar_policy) gb_widget_output_choice (data, VPolicy, i, GbPolicySymbols[i]); } for (i = 0; i < GladeShadowChoicesSize; i++) { if (GladeShadowValues[i] == GTK_SCROLLED_WINDOW (widget)->shadow_type) gb_widget_output_choice (data, ShadowType, i, GladeShadowSymbols[i]); } for (i = 0; i < GladeCornerChoicesSize; i++) { if (GladeCornerValues[i] == GTK_SCROLLED_WINDOW (widget)->window_placement) gb_widget_output_choice (data, WindowPlacement, i, GladeCornerSymbols[i]); } }
/* * 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_handle_box_get_properties(GtkWidget *widget, GbWidgetGetArgData *data) { gint i; for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]); i++) { if (GbShadowValues[i] == GTK_HANDLE_BOX (widget)->shadow_type) gb_widget_output_choice (data, Shadow, i, GbShadowSymbols[i]); } for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]); i++) { if (GbPositionValues[i] == GTK_HANDLE_BOX (widget)->handle_position) gb_widget_output_choice (data, Position, i, GbPositionSymbols[i]); } for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]); i++) { if (GbPositionValues[i] == GTK_HANDLE_BOX (widget)->snap_edge) gb_widget_output_choice (data, SnapEdge, i, GbPositionSymbols[i]); } }
/* * 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_tclist_get_properties (GtkWidget * widget, GtkWidget *child, GbWidgetGetArgData * data) { gchar buffer[1024]; gchar *pos; gboolean buffer_overrun = FALSE; gint i; if (data->action == GB_SAVING) { gb_widget_output_int (data, Cols, GTK_CLIST (widget)->columns); pos = buffer; for (i = 0; i < GTK_CLIST (widget)->columns; i++) { if (i == 0) sprintf (pos, "%i", GTK_CLIST (widget)->column[i].width); else sprintf (pos, ",%i", GTK_CLIST (widget)->column[i].width); pos += strlen (pos); /* Extra check to make sure we don't overrun the buffer. */ if (pos - buffer > 1000) { g_warning ("Buffer overflow"); buffer_overrun = TRUE; break; } } if (!buffer_overrun) gb_widget_output_string (data, ColumnWidths, buffer); } for (i = 0; i < sizeof (GbModeValues) / sizeof (GbModeValues[0]); i++) { if (GbModeValues[i] == GTK_CLIST (widget)->selection_mode) gb_widget_output_choice (data, Mode, i, GbModeSymbols[i]); } gb_widget_output_bool (data, Titles, GTK_CLIST_SHOW_TITLES (widget)); for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]); i++) { if (GbShadowValues[i] == GTK_CLIST (widget)->shadow_type) gb_widget_output_choice (data, Shadow, i, GbShadowSymbols[i]); } #ifndef GTK_HAVE_FEATURES_1_1_4 for (i = 0; i < sizeof (GbPolicyValues) / sizeof (GbPolicyValues[0]); i++) { if (GbPolicyValues[i] == GTK_CLIST (widget)->hscrollbar_policy) gb_widget_output_choice (data, HPolicy, i, GbPolicySymbols[i]); } for (i = 0; i < sizeof (GbPolicyValues) / sizeof (GbPolicyValues[0]); i++) { if (GbPolicyValues[i] == GTK_CLIST (widget)->vscrollbar_policy) gb_widget_output_choice (data, VPolicy, i, GbPolicySymbols[i]); } #endif }
/* * 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); } }
/* * 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_file_chooser_button_get_properties (GtkWidget *widget, GbWidgetGetArgData * data) { gchar *title; GtkFileChooserAction action; gboolean local_only, show_hidden, confirm; gint i, width_chars; g_object_get (widget, "title", &title, "action", &action, "local_only", &local_only, "show_hidden", &show_hidden, "do_overwrite_confirmation", &confirm, "width_chars", &width_chars, NULL); gb_widget_output_translatable_string (data, Title, title); g_free (title); for (i = 0; i < sizeof (GbActionValues) / sizeof (GbActionValues[0]); i++) { if (GbActionValues[i] == action) gb_widget_output_choice (data, Action, i, GbActionSymbols[i]); } gb_widget_output_bool (data, LocalOnly, local_only); gb_widget_output_bool (data, ShowHidden, show_hidden); gb_widget_output_bool (data, Confirm, confirm); gb_widget_output_int (data, WidthChars, width_chars); }
/* * 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_gnome_message_box_get_properties (GtkWidget *widget, GbWidgetGetArgData * data) { GtkWidget *pixmap, *label; gchar *label_text; gint type_index; get_message_box_widgets (widget, &pixmap, &label); g_return_if_fail (pixmap != NULL); g_return_if_fail (label != NULL); type_index = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), MessageBoxType)); gb_widget_output_choice (data, MessageBoxType, type_index, GbMessageBoxTypeSymbols[type_index]); gtk_label_get (GTK_LABEL (label), &label_text); gb_widget_output_translatable_text (data, Message, label_text); gb_window_get_standard_properties (widget, data, Title, NULL, Position, Modal, DefaultWidth, DefaultHeight, Shrink, Grow, AutoShrink, WMName, WMClass); gb_widget_output_bool (data, AutoClose, GNOME_DIALOG (widget)->click_closes); gb_widget_output_bool (data, HideOnClose, GNOME_DIALOG (widget)->just_hide); }
/* * 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_spin_button_get_properties (GtkWidget * widget, GbWidgetGetArgData * data) { gint i, update_policy; gb_widget_output_float (data, ClimbRate, GTK_SPIN_BUTTON (widget)->climb_rate); gb_widget_output_int (data, Digits, GTK_SPIN_BUTTON (widget)->digits); gb_widget_output_bool (data, Numeric, GTK_SPIN_BUTTON (widget)->numeric); /* This is a slight kludge since the spin_button's update policy is a set of flags rather than integer values */ update_policy = GTK_SPIN_BUTTON (widget)->update_policy & (GTK_UPDATE_ALWAYS | GTK_UPDATE_IF_VALID); for (i = 0; i < sizeof (GbPolicyValues) / sizeof (GbPolicyValues[0]); i++) { if (GbPolicyValues[i] == update_policy) gb_widget_output_choice (data, Policy, i, GbPolicySymbols[i]); } /* In GTK 1.1 snap_to_ticks is given its own variable. */ gb_widget_output_bool (data, Snap, GTK_SPIN_BUTTON (widget)->snap_to_ticks); gb_widget_output_bool (data, Wrap, GTK_SPIN_BUTTON (widget)->wrap); gb_widget_output_adjustment (data, Values, GTK_SPIN_BUTTON (widget)->adjustment, "adjustment"); }
/* * 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_bonobo_dock_item_get_properties (GtkWidget *widget, GbWidgetGetArgData * data) { gint i; if (BONOBO_DOCK_ITEM (widget)->is_floating) { /* Orientation is only relevant when floating. */ for (i = 0; i < GladeOrientationSize; i++) { if (GladeOrientationValues[i] == BONOBO_DOCK_ITEM (widget)->orientation) { gb_widget_output_choice (data, Orientation, i, GladeOrientationSymbols[i]); } } } if (data->action == GB_SHOWING) { gb_widget_output_bool (data, Locked, BONOBO_DOCK_ITEM (widget)->behavior & BONOBO_DOCK_ITEM_BEH_LOCKED); gb_widget_output_bool (data, Exclusive, BONOBO_DOCK_ITEM (widget)->behavior & BONOBO_DOCK_ITEM_BEH_EXCLUSIVE); gb_widget_output_bool (data, NeverFloating, BONOBO_DOCK_ITEM (widget)->behavior & BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING); gb_widget_output_bool (data, NeverVertical, BONOBO_DOCK_ITEM (widget)->behavior & BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL); gb_widget_output_bool (data, NeverHorizontal, BONOBO_DOCK_ITEM (widget)->behavior & BONOBO_DOCK_ITEM_BEH_NEVER_HORIZONTAL); } for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]); i++) { if (GbShadowValues[i] == BONOBO_DOCK_ITEM (widget)->shadow_type) gb_widget_output_choice (data, ShadowType, i, GbShadowSymbols[i]); } if (data->action == GB_SHOWING) { /* The orientation is only useful for floating items. */ property_set_sensitive (Orientation, BONOBO_DOCK_ITEM (widget)->is_floating); } }
/* * 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_viewport_get_properties (GtkWidget * widget, GbWidgetGetArgData * data) { gint i; for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]); i++) { if (GbShadowValues[i] == GTK_VIEWPORT (widget)->shadow_type) gb_widget_output_choice (data, Shadow, i, GbShadowSymbols[i]); } /* gb_widget_output_adjustment(data, HValues, GTK_VIEWPORT(widget)->hadjustment); gb_widget_output_adjustment(data, VValues, GTK_VIEWPORT(widget)->vadjustment); */ }
/* * 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, min_width, min_height, ipad_x, ipad_y; gint default_spacing; gint default_min_width, default_min_height, default_ipad_x, default_ipad_y; 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_button_box_get_spacing (GTK_BUTTON_BOX (widget)); default_spacing = gtk_vbutton_box_get_spacing_default (); if (spacing == GTK_BUTTONBOX_DEFAULT) spacing = default_spacing; gb_widget_output_int (data, Spacing, spacing); gtk_button_box_get_child_size_default (&default_min_width, &default_min_height); gtk_button_box_get_child_size (GTK_BUTTON_BOX (widget), &min_width, &min_height); if (min_width == GTK_BUTTONBOX_DEFAULT) min_width = default_min_width; if (min_height == GTK_BUTTONBOX_DEFAULT) min_height = default_min_height; gb_widget_output_int (data, Width, min_width); gb_widget_output_int (data, Height, min_height); gtk_button_box_get_child_ipadding_default (&default_ipad_x, &default_ipad_y); gtk_button_box_get_child_ipadding (GTK_BUTTON_BOX (widget), &ipad_x, &ipad_y); if (ipad_x == GTK_BUTTONBOX_DEFAULT) ipad_x = default_ipad_x; if (ipad_y == GTK_BUTTONBOX_DEFAULT) ipad_y = default_ipad_y; gb_widget_output_int (data, XPad, ipad_x); gb_widget_output_int (data, YPad, ipad_y); }
/* * 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); }
void gb_label_get_standard_properties (GtkWidget * widget, GbWidgetGetArgData * data, const char *label_p, const char *use_underline_p, const char *use_markup_p, const char *justify_p, const char *wrap_p, const char *selectable_p, const char *xalign_p, const char *yalign_p, const char *xpad_p, const char *ypad_p, const char *focus_target_p) { const gchar *label_text; gint i; label_text = gtk_label_get_label (GTK_LABEL (widget)); gb_widget_output_translatable_text (data, label_p, label_text); gb_widget_output_bool (data, use_underline_p, gtk_label_get_use_underline (GTK_LABEL (widget))); gb_widget_output_bool (data, use_markup_p, GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), use_markup_p))); for (i = 0; i < sizeof (GbJustifyValues) / sizeof (GbJustifyValues[0]); i++) { if (GbJustifyValues[i] == GTK_LABEL (widget)->jtype) gb_widget_output_choice (data, justify_p, i, GbJustifySymbols[i]); } gb_widget_output_bool (data, wrap_p, GTK_LABEL (widget)->wrap); gb_widget_output_bool (data, selectable_p, gtk_label_get_selectable (GTK_LABEL (widget))); gb_widget_output_float (data, xalign_p, GTK_MISC (widget)->xalign); gb_widget_output_float (data, yalign_p, GTK_MISC (widget)->yalign); gb_widget_output_int (data, xpad_p, GTK_MISC (widget)->xpad); gb_widget_output_int (data, ypad_p, GTK_MISC (widget)->ypad); /* Labels not in buttons may have a focus target widget. */ if (!gb_label_find_mnemonic_widget (widget)) { gchar *accel_target; accel_target = gtk_object_get_data (GTK_OBJECT (widget), focus_target_p); /* If we're showing we need to display the list of possible focus target widgets. We walk the tree of widgets in this component, and if a widget has CAN_FOCUS set, we add it to the list. */ if (data->action == GB_SHOWING) { GList *focus_targets = NULL, *standard_items = NULL; GtkWidget *item, *combo; property_set_visible (focus_target_p, TRUE); gb_label_get_focus_targets (gtk_widget_get_toplevel (widget), &focus_targets); property_set_combo_strings (focus_target_p, focus_targets); g_list_free (focus_targets); combo = property_get_value_widget (focus_target_p); item = gtk_list_item_new_with_label (_("Auto")); gtk_widget_show (item); standard_items = g_list_append (standard_items, item); item = gtk_list_item_new (); gtk_widget_set_sensitive (item, FALSE); gtk_widget_show (item); standard_items = g_list_append (standard_items, item); gtk_combo_set_item_string (GTK_COMBO (combo), GTK_ITEM (item), ""); gtk_list_prepend_items (GTK_LIST (GTK_COMBO (combo)->list), standard_items); if (!accel_target) { accel_target = _("Auto"); } gb_widget_output_combo (data, focus_target_p, accel_target); } else { /* When saving, we only save the property if it has been set. */ if (accel_target) { /* First check that the widget is still there, and if it isn't just skip it. */ if (glade_util_find_widget (gtk_widget_get_toplevel (widget), accel_target)) { gb_widget_output_combo (data, focus_target_p, accel_target); } } else { /* If no target has been set, and the label has an underlined key, we try to find a default target and save that. */ if (gtk_label_get_use_underline (GTK_LABEL (widget))) { GtkWidget *accel_target; accel_target = glade_util_find_default_accelerator_target (widget); if (accel_target) { gb_widget_output_string (data, focus_target_p, gtk_widget_get_name (accel_target)); } } } } } else { if (data->action == GB_SHOWING) { property_set_visible (focus_target_p, FALSE); } } }
/* * 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_image_get_properties (GtkWidget * widget, GbWidgetGetArgData * data) { gchar *icon = gtk_object_get_data (GTK_OBJECT (widget), GladeIconKey); gchar *icon_name = NULL; gboolean is_stock_icon, is_named_icon = FALSE; gint i, pixel_size; GtkImageType storage_type; storage_type = gtk_image_get_storage_type (GTK_IMAGE (widget)); pixel_size = gtk_image_get_pixel_size (GTK_IMAGE (widget)); is_stock_icon = glade_util_check_is_stock_id (icon); if (storage_type == GTK_IMAGE_ICON_NAME) { g_object_get (widget, "icon_name", &icon_name, NULL); if (icon_name && *icon_name) is_named_icon = TRUE; } if (data->action == GB_SAVING) { /* When saving we want to use "stock" or "pixbuf", depending on whether it is a stock icon or an oridinary pixmap file. */ if (is_stock_icon) gb_widget_output_icon (data, "stock", icon); else gb_widget_output_icon (data, "pixbuf", icon); } else { gb_widget_output_icon (data, Icon, icon); } if (is_stock_icon || is_named_icon) { if (data->action == GB_SHOWING) { for (i = 0; i < GladeIconSizeChoicesSize; i++) { if (GladeIconSizeValues[i] == GTK_IMAGE (widget)->icon_size) gb_widget_output_choice (data, IconSize, i, GladeIconSizeSymbols[i]); } check_visible_sizes (icon, is_named_icon); } else { /* We have to save the size as an integer, which sucks a bit. The integer is the GtkIconSize enum value, not the actual size.*/ if (is_stock_icon || pixel_size == -1) gb_widget_output_int (data, IconSize, GTK_IMAGE (widget)->icon_size); } } gb_widget_output_named_icon (data, IconName, icon_name); /* The icon size only applies to stock icons or named icons. The pixel size only applies to named icons. */ if (data->action == GB_SHOWING) { property_set_sensitive (IconSize, is_stock_icon || is_named_icon); property_set_sensitive (PixelSize, is_named_icon); } /* We only want to save the pixel size for named icons, and only if it is not -1. */ if (data->action == GB_SHOWING || (storage_type == GTK_IMAGE_ICON_NAME && pixel_size != -1)) gb_widget_output_int (data, PixelSize, pixel_size); gb_widget_output_float (data, XAlign, GTK_MISC (widget)->xalign); gb_widget_output_float (data, YAlign, GTK_MISC (widget)->yalign); gb_widget_output_int (data, XPad, GTK_MISC (widget)->xpad); gb_widget_output_int (data, YPad, GTK_MISC (widget)->ypad); }
void gb_window_get_standard_properties (GtkWidget * widget, GbWidgetGetArgData * data, gchar *title_p, gchar *type_p, gchar *position_p, gchar *modal_p, gchar *default_width_p, gchar *default_height_p, gchar *shrink_p, gchar *grow_p, gchar *auto_shrink_p, gchar *wmname_p, gchar *wmclass_p, gchar *resizable_p, gchar *destroy_with_parent_p, gchar *icon_p) { gint type, position, default_width, default_height; if (title_p) gb_widget_output_translatable_string (data, title_p, GTK_WINDOW (widget)->title); /* The type is stored in the object datalist as we can't change it after the window is realized. It will default to 0, which is OK. */ if (type_p) { type = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), type_p)); gb_widget_output_choice (data, type_p, type, GbTypeSymbols[type]); } /* The position is stored in the object datalist so that it doesn't affect the displaying of the window within Glade. It will default to 0, i.e. GTK_WIN_POS_NONE, which is OK. */ if (position_p) { position = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), position_p)); gb_widget_output_choice (data, position_p, position, GbPositionSymbols[position]); } if (modal_p) { gb_widget_output_bool (data, modal_p, gtk_object_get_data (GTK_OBJECT (widget), modal_p) != NULL ? TRUE : FALSE); } if (default_width_p && default_height_p) { default_width = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), DefaultWidth)); gb_widget_output_optional_int (data, default_width_p, default_width, default_width != 0 ? TRUE : FALSE); default_height = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), DefaultHeight)); gb_widget_output_optional_int (data, default_height_p, default_height, default_height != 0 ? TRUE : FALSE); } #if 0 /* These are deprecated. */ if (grow_p && shrink_p) { gb_widget_output_bool (data, grow_p, GTK_WINDOW (widget)->allow_grow); gb_widget_output_bool (data, shrink_p, GTK_WINDOW (widget)->allow_shrink); } #endif /* These are stored in the object hash since we can't set them after the window is realized. */ #if 0 /* These aren't necessary, and have been used incorrectly for ages. */ if (wmname_p) gb_widget_output_string (data, wmname_p, gtk_object_get_data (GTK_OBJECT (widget), wmname_p)); if (wmclass_p) gb_widget_output_string (data, wmclass_p, gtk_object_get_data (GTK_OBJECT (widget), wmclass_p)); #endif if (resizable_p) gb_widget_output_bool (data, resizable_p, gtk_window_get_resizable (GTK_WINDOW (widget))); if (destroy_with_parent_p) gb_widget_output_bool (data, destroy_with_parent_p, gtk_window_get_destroy_with_parent (GTK_WINDOW (widget))); if (icon_p) gb_widget_output_pixmap_filename (data, icon_p, gtk_object_get_data (GTK_OBJECT (widget), icon_p)); }