/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_tool_item_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean visible_horz, visible_vert, is_important; visible_horz = gb_widget_input_bool (data, VisibleHorz); if (data->apply) { gtk_object_set_data (GTK_OBJECT (widget), VisibleHorz, visible_horz ? NULL : "FALSE"); } visible_vert = gb_widget_input_bool (data, VisibleVert); if (data->apply) { gtk_object_set_data (GTK_OBJECT (widget), VisibleVert, visible_vert ? NULL : "FALSE"); } is_important = gb_widget_input_bool (data, IsImportant); if (data->apply) { gtk_tool_item_set_is_important (GTK_TOOL_ITEM (widget), is_important); } }
/* Applies or loads the child properties of a child of a hbox/vbox. */ void gb_box_set_child_properties (GtkWidget *widget, GtkWidget *child, GbWidgetSetArgData *data) { gint position, padding; guint old_padding; gboolean expand, fill, pack, set_child_packing = FALSE; gboolean old_expand, old_fill; GtkPackType old_pack_type; position = gb_widget_input_int (data, GbPosition); if (data->apply) { gtk_box_reorder_child (GTK_BOX (widget), child, position); } gtk_box_query_child_packing (GTK_BOX (widget), child, &old_expand, &old_fill, &old_padding, &old_pack_type); padding = gb_widget_input_int (data, GbPadding); if (data->apply) set_child_packing = TRUE; else padding = old_padding; expand = gb_widget_input_bool (data, GbExpand); if (data->apply) set_child_packing = TRUE; else expand = old_expand; fill = gb_widget_input_bool (data, GbFill); if (data->apply) set_child_packing = TRUE; else fill = old_fill; if (data->action == GB_APPLYING) { pack = gb_widget_input_bool (data, GbPack); } else { gchar *pack_symbol = gb_widget_input_string (data, GbPack); pack = pack_symbol && !strcmp (pack_symbol, "GTK_PACK_START"); } if (data->apply) set_child_packing = TRUE; else pack = (old_pack_type == GTK_PACK_START) ? TRUE : FALSE; if (set_child_packing) gtk_box_set_child_packing (GTK_BOX (widget), child, expand, fill, padding, pack ? GTK_PACK_START : GTK_PACK_END); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_combo_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean value_in_list, ok_if_empty, case_sensitive, arrows, arrows_always; gchar *items; GList *item_list = NULL; value_in_list = gb_widget_input_bool (data, ValueInList); if (data->apply) { gtk_object_set_data (GTK_OBJECT (widget), ValueInList, value_in_list ? "TRUE" : NULL); } ok_if_empty = gb_widget_input_bool (data, OKIfEmpty); if (data->apply) { gtk_object_set_data (GTK_OBJECT (widget), OKIfEmpty, ok_if_empty ? "TRUE" : NULL); } case_sensitive = gb_widget_input_bool (data, Case); if (data->apply) gtk_combo_set_case_sensitive (GTK_COMBO (widget), case_sensitive); arrows = gb_widget_input_bool (data, Arrows); if (data->apply) gtk_combo_set_use_arrows (GTK_COMBO (widget), arrows); arrows_always = gb_widget_input_bool (data, Always); if (data->apply) gtk_combo_set_use_arrows_always (GTK_COMBO (widget), arrows_always); items = gb_widget_input_text (data, Items); if (data->apply) { gchar *pos = items; gchar *items_end = &items[strlen (items)]; while (pos < items_end) { gchar *item_end = strchr (pos, '\n'); if (item_end == NULL) item_end = items_end; *item_end = '\0'; item_list = g_list_append (item_list, pos); pos = item_end + 1; } if (item_list) gtk_combo_set_popdown_strings (GTK_COMBO (widget), item_list); else gtk_list_clear_items (GTK_LIST (GTK_COMBO (widget)->list), 0, -1); g_list_free (item_list); } if (data->action == GB_APPLYING) g_free (items); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_gnome_app_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean statusbar, enable_layout_config; gb_window_set_standard_properties (widget, data, Title, Type, Position, Modal, DefaultWidth, DefaultHeight, Shrink, Grow, AutoShrink, IconName, FocusOnMap, Resizable, DestroyWithParent, Icon, Role, TypeHint, SkipTaskbar, SkipPager, Decorated, Gravity, Urgency); if (data->action == GB_APPLYING) { statusbar = gb_widget_input_bool (data, StatusBar); if (data->apply) { if (statusbar) { if (!GNOME_APP (widget)->statusbar) { gnome_app_set_statusbar (GNOME_APP (widget), gb_widget_new ("GnomeAppBar", widget)); gb_widget_set_child_name (GNOME_APP (widget)->statusbar, GladeChildGnomeAppBar); tree_add_widget (GNOME_APP (widget)->statusbar); } } else { if (GNOME_APP (widget)->statusbar) { /* This is not very clean, but there's no proper way to remove the statusbar. The statusbar has an hbox inserted above it which is added to the GnomeApp's vbox, so we remove the hbox. */ GtkWidget *hbox = GNOME_APP (widget)->statusbar->parent; gtk_container_remove (GTK_CONTAINER (hbox->parent), hbox); GNOME_APP (widget)->statusbar = NULL; } } } } enable_layout_config = gb_widget_input_bool (data, EnableLayoutConfig); if (data->apply) { gtk_object_set_data (GTK_OBJECT (widget), EnableLayoutConfig, GINT_TO_POINTER (enable_layout_config)); } }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_spin_button_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gfloat climb_rate; gint digits, policy_value = GTK_UPDATE_ALWAYS, i; gchar *policy; gboolean numeric, snap, wrap; GtkAdjustment *adj; climb_rate = gb_widget_input_float (data, ClimbRate); /* No set function for this */ if (data->apply) GTK_SPIN_BUTTON (widget)->climb_rate = climb_rate; digits = gb_widget_input_int (data, Digits); if (data->apply) gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), digits); numeric = gb_widget_input_bool (data, Numeric); if (data->apply) gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (widget), numeric); snap = gb_widget_input_bool (data, Snap); if (data->apply) gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (widget), snap); policy = gb_widget_input_choice (data, Policy); for (i = 0; i < sizeof (GbPolicyValues) / sizeof (GbPolicyValues[0]); i++) { if (!strcmp (policy, GbPolicyChoices[i]) || !strcmp (policy, GbPolicySymbols[i])) { policy_value = GbPolicyValues[i]; break; } } if (data->apply) gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (widget), policy_value); wrap = gb_widget_input_bool (data, Wrap); if (data->apply) gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (widget), wrap); adj = GTK_SPIN_BUTTON (widget)->adjustment; if (gb_widget_input_adjustment (data, Values, adj, "adjustment")) { gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed"); } }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_combo_box_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gchar *items; gboolean add_tearoffs, focus_on_click; items = gb_widget_input_text (data, Items); if (data->apply) { GtkTreeModel *model; gchar *pos = items; gchar *items_end = &items[strlen (items)]; /* Save a copy so it is easy to get out later. */ gtk_object_set_data_full (GTK_OBJECT (widget), Items, g_strdup (items), g_free); /* Clear the list. */ model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); gtk_list_store_clear (GTK_LIST_STORE (model)); /* Now add the items one at a time. */ while (pos < items_end) { gchar *item_end = strchr (pos, '\n'); if (item_end == NULL) item_end = items_end; *item_end = '\0'; gtk_combo_box_append_text (GTK_COMBO_BOX (widget), pos); if (item_end != items_end) *item_end = '\n'; pos = item_end + 1; } } if (data->action == GB_APPLYING) g_free (items); add_tearoffs = gb_widget_input_bool (data, AddTearoffs); if (data->apply) gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (widget), add_tearoffs); focus_on_click = gb_widget_input_bool (data, FocusOnClick); if (data->apply) gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (widget), focus_on_click); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_gnome_druid_set_properties (GtkWidget *widget, GbWidgetSetArgData *data) { gboolean show_help; show_help = gb_widget_input_bool (data, ShowHelp); if (data->apply) g_object_set (G_OBJECT (widget), "show-help", show_help, NULL); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_file_chooser_button_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gchar *title, *action; gboolean local_only, show_hidden, confirm; gint i, width_chars; title = gb_widget_input_string (data, Title); if (data->apply) g_object_set (widget, "title", title, NULL); action = gb_widget_input_choice (data, Action); if (data->apply) { for (i = 0; i < sizeof (GbActionValues) / sizeof (GbActionValues[0]); i++) { if (!strcmp (action, GbActionChoices[i]) || !strcmp (action, GbActionSymbols[i])) { g_object_set (widget, "action", GbActionValues[i], NULL); break; } } } local_only = gb_widget_input_bool (data, LocalOnly); if (data->apply) g_object_set (widget, "local_only", local_only, NULL); show_hidden = gb_widget_input_bool (data, ShowHidden); if (data->apply) g_object_set (widget, "show_hidden", show_hidden, NULL); confirm = gb_widget_input_bool (data, Confirm); if (data->apply) g_object_set (widget, "do_overwrite_confirmation", confirm, NULL); width_chars = gb_widget_input_int (data, WidthChars); if (data->apply) g_object_set (widget, "width_chars", width_chars, NULL); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_statusbar_set_properties(GtkWidget *widget, GbWidgetSetArgData *data) { gboolean resize_grip; resize_grip = gb_widget_input_bool (data, ResizeGrip); if (data->apply) { gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (widget), resize_grip); } }
/* Applies or loads the child properties of a child of a hbox/vbox. */ void gb_paned_set_child_properties (GtkWidget *widget, GtkWidget *child, GbWidgetSetArgData *data) { gboolean shrink, resize, is_child1, need_resize = FALSE; if (child == GTK_PANED (widget)->child1) is_child1 = TRUE; else if (child == GTK_PANED (widget)->child2) is_child1 = FALSE; else { /* This shouldn't happen. */ g_warning ("Couldn't find child of GtkPaned container"); return; } shrink = gb_widget_input_bool (data, Shrink); if (data->apply) { if (is_child1) GTK_PANED (widget)->child1_shrink = shrink; else GTK_PANED (widget)->child2_shrink = shrink; need_resize = TRUE; } resize = gb_widget_input_bool (data, Resize); if (data->apply) { if (is_child1) GTK_PANED (widget)->child1_resize = resize; else GTK_PANED (widget)->child2_resize = resize; need_resize = TRUE; } if (need_resize) gtk_widget_queue_resize (widget); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_gnome_message_box_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { GtkWidget *pixmap, *label; gchar *message, *type_name; gboolean auto_close, hide_on_close; get_message_box_widgets (widget, &pixmap, &label); g_return_if_fail (pixmap != NULL); g_return_if_fail (label != NULL); type_name = gb_widget_input_choice (data, MessageBoxType); if (data->apply) { set_message_box_type (widget, pixmap, type_name); } message = gb_widget_input_text (data, Message); if (data->apply) { gtk_label_set_text (GTK_LABEL (label), message); } if (data->action == GB_APPLYING) g_free (message); gb_window_set_standard_properties (widget, data, Title, NULL, Position, Modal, DefaultWidth, DefaultHeight, Shrink, Grow, AutoShrink, WMName, WMClass); auto_close = gb_widget_input_bool (data, AutoClose); if (data->apply) gnome_dialog_set_close (GNOME_DIALOG (widget), auto_close); hide_on_close = gb_widget_input_bool (data, HideOnClose); if (data->apply) gnome_dialog_close_hides (GNOME_DIALOG (widget), hide_on_close); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_gnome_color_picker_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean dither, use_alpha, focus_on_click; gchar *title; dither = gb_widget_input_bool (data, Dither); if (data->apply) gnome_color_picker_set_dither (GNOME_COLOR_PICKER (widget), dither); use_alpha = gb_widget_input_bool (data, UseAlpha); if (data->apply) gnome_color_picker_set_use_alpha (GNOME_COLOR_PICKER (widget), use_alpha); title = gb_widget_input_string (data, Title); if (data->apply) gnome_color_picker_set_title (GNOME_COLOR_PICKER (widget), title); focus_on_click = gb_widget_input_bool (data, FocusOnClick); if (data->apply) gtk_button_set_focus_on_click (GTK_BUTTON (widget), focus_on_click); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_gnome_dialog_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean auto_close, hide_on_close; gb_window_set_standard_properties (widget, data, Title, Type, Position, Modal, DefaultWidth, DefaultHeight, Shrink, Grow, AutoShrink, IconName, FocusOnMap, Resizable, DestroyWithParent, Icon, Role, TypeHint, SkipTaskbar, SkipPager, Decorated, Gravity, Urgency); auto_close = gb_widget_input_bool (data, AutoClose); if (data->apply) gnome_dialog_set_close (GNOME_DIALOG (widget), auto_close); hide_on_close = gb_widget_input_bool (data, HideOnClose); if (data->apply) gnome_dialog_close_hides (GNOME_DIALOG (widget), hide_on_close); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_toggle_button_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean state, inconsistent; gb_button_set_standard_properties (widget, data, StockButton, Label, Icon, Relief, FocusOnClick); state = gb_widget_input_bool (data, State); if (data->apply) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), state); if (state) data->widget_data->flags |= GLADE_ACTIVE; else data->widget_data->flags &= ~GLADE_ACTIVE; } inconsistent = gb_widget_input_bool (data, Inconsistent); if (data->apply) gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (widget), inconsistent); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_vbox_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean homogeneous; gint spacing, size; size = gb_widget_input_int (data, Size); if (data->apply) gb_box_set_size (widget, size); homogeneous = gb_widget_input_bool (data, Homogeneous); if (data->apply) gtk_box_set_homogeneous (GTK_BOX (widget), homogeneous); spacing = gb_widget_input_int (data, Spacing); if (data->apply) gtk_box_set_spacing (GTK_BOX (widget), spacing); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_toggle_tool_button_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean active; gb_tool_button_set_standard_properties (widget, data, StockButton, Label, Icon, VisibleHorz, VisibleVert, IsImportant); active = gb_widget_input_bool (data, Active); if (data->apply) { gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (widget), active); if (active) data->widget_data->flags |= GLADE_ACTIVE; else data->widget_data->flags &= ~GLADE_ACTIVE; } }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_file_selection_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean show_fileops; gb_window_set_standard_properties (widget, data, Title, Type, Position, Modal, DefaultWidth, DefaultHeight, Shrink, Grow, AutoShrink, WMName, WMClass, Resizable, DestroyWithParent, Icon); show_fileops = gb_widget_input_bool (data, FileOps); if (data->apply) { if (show_fileops) gtk_file_selection_show_fileop_buttons (GTK_FILE_SELECTION (widget)); else gtk_file_selection_hide_fileop_buttons (GTK_FILE_SELECTION (widget)); } }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_gnome_href_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gchar *url, *label_text; gboolean focus_on_click; url = gb_widget_input_string (data, HRefURL); if (data->apply) gnome_href_set_url (GNOME_HREF (widget), url && url[0] ? url : ""); label_text = gb_widget_input_text (data, HRefLabel); /* Support the old name we used for the property. */ if (!data->apply && data->action == GB_LOADING) label_text = gb_widget_input_text (data, "label"); if (data->apply) gnome_href_set_text (GNOME_HREF (widget), label_text); if (data->action == GB_APPLYING) g_free (label_text); focus_on_click = gb_widget_input_bool (data, FocusOnClick); if (data->apply) gtk_button_set_focus_on_click (GTK_BUTTON (widget), focus_on_click); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_radio_tool_button_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean active; gchar *group_name; gb_tool_button_set_standard_properties (widget, data, StockButton, Label, Icon, VisibleHorz, VisibleVert, IsImportant); active = gb_widget_input_bool (data, Active); if (data->apply) { gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (widget), active); if (active) data->widget_data->flags |= GLADE_ACTIVE; else data->widget_data->flags &= ~GLADE_ACTIVE; } /* Find any widgets in given group and set this widgets group. If group is NULL try to find radiobuttons with same parent and use their group. If these don't succeed, set group to NULL. */ group_name = gb_widget_input_combo (data, Group); if (data->apply) { GSList *old_group, *new_group = NULL; old_group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (widget)); if (group_name && (group_name[0] == '\0' || !strcmp (group_name, _("New Group")))) group_name = NULL; if (group_name) { GladeFindGroupWidgetData find_data; find_data.name = group_name; find_data.found_widget = NULL; gb_widget_children_foreach (widget->parent, (GtkCallback) find_group_widget, &find_data); if (find_data.found_widget) new_group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (find_data.found_widget)); else if (data->action == GB_LOADING) g_warning ("Invalid radio group: %s\n (Note that forward references are not allowed in Glade files)", group_name); } #if 0 g_print ("New Group: %p Old Group: %p\n", new_group, old_group); #endif if (new_group != old_group) { #if 0 g_print ("##### setting radio group: %s\n", group_name ? group_name : "NULL"); #endif gtk_radio_tool_button_set_group (GTK_RADIO_TOOL_BUTTON (widget), new_group); } } }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_bonobo_control_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { Bonobo_PropertyBag pb = control_get_pb (widget); char *moniker = gtk_object_get_data (GTK_OBJECT (widget), Moniker); GList *key_list, *names; g_assert (moniker); if (!pb) return; key_list = bonobo_pbclient_get_keys (pb, NULL); for (names = key_list; names; names = names->next) { CORBA_TypeCode tc; char *prop = create_prop_name (moniker, names->data); #if 0 g_print ("Checking property: %s\n", prop); #endif tc = bonobo_pbclient_get_type (pb, names->data, NULL); switch (tc->kind) { case CORBA_tk_boolean: { gboolean val; val = gb_widget_input_bool (data, prop); if (data->apply) bonobo_pbclient_set_boolean (pb, names->data, val, NULL); break; } case CORBA_tk_string: { const char *str; str = gb_widget_input_string (data, prop); if (data->apply) bonobo_pbclient_set_string (pb, names->data, str, NULL); break; } case CORBA_tk_float: { gfloat val; val = gb_widget_input_float (data, prop); if (data->apply) bonobo_pbclient_set_float (pb, names->data, val, NULL); break; } case CORBA_tk_double: { gdouble val; val = gb_widget_input_float (data, prop); if (data->apply) bonobo_pbclient_set_double (pb, names->data, val, NULL); break; } case CORBA_tk_long: { glong val; val = gb_widget_input_int (data, prop); if (data->apply) bonobo_pbclient_set_long (pb, names->data, val, NULL); break; } case CORBA_tk_ulong: { glong val; val = gb_widget_input_int (data, prop); if (data->apply) bonobo_pbclient_set_ulong (pb, names->data, val, NULL); break; } case CORBA_tk_short: { glong val; val = gb_widget_input_int (data, prop); if (data->apply) bonobo_pbclient_set_short (pb, names->data, val, NULL); break; } case CORBA_tk_ushort: { glong val; val = gb_widget_input_int (data, prop); if (data->apply) bonobo_pbclient_set_ushort (pb, names->data, val, NULL); break; } default: g_warning ("Unhandled type %d", tc->kind); break; } g_free (prop); } bonobo_pbclient_free_keys (key_list); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_radio_button_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean state, indicator; gchar *group_name; GSList *group = NULL, *current_group; GbFindGroupData find_group_data; if (gb_toolbar_is_toolbar_button (widget)) { gb_toolbar_input_child_label (widget, data, Label); gb_toolbar_input_child_icon (widget, data, Icon); } else { gb_widget_input_child_label (widget, data, Label); } state = gb_widget_input_bool (data, State); if (data->apply) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), state); if (state) data->widget_data->flags |= GLADE_ACTIVE; else data->widget_data->flags &= ~GLADE_ACTIVE; } indicator = gb_widget_input_bool (data, Indicator); if (data->apply) gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (widget), indicator); /* Find any widgets in given group and set this widgets group. If group is NULL try to find radiobuttons with same parent and use their group. If these don't succeed, set group to NULL. */ group_name = gb_widget_input_combo (data, Group); if (data->apply) { if (group_name && group_name[0] == '\0') group_name = NULL; current_group = gtk_radio_button_group (GTK_RADIO_BUTTON (widget)); if (group_name == NULL) gtk_container_foreach (GTK_CONTAINER (widget->parent), (GtkCallback) find_parents_group, &group); else { find_group_data.group_name = group_name; find_group_data.group = NULL; find_group (gtk_widget_get_toplevel (widget), &find_group_data); group = find_group_data.group; } g_free (gtk_object_get_data (GTK_OBJECT (widget), Group)); gtk_object_set_data (GTK_OBJECT (widget), Group, g_strdup (group_name)); /* This crashes if we set the group to NULL, so we have to reset the group ourself. We only set the group if it has changed. */ if (group) { if (group != current_group) { if (current_group->data == widget) current_group = current_group->next; gtk_radio_button_set_group (GTK_RADIO_BUTTON (widget), group); gb_radio_button_update_radio_group (current_group); gb_radio_button_update_radio_group (gtk_radio_button_group (GTK_RADIO_BUTTON (widget))); } } else { if (g_slist_length (current_group) != 1) { current_group = gb_radio_button_reset_radio_group (widget); gb_radio_button_update_radio_group (current_group); gb_radio_button_update_radio_group (gtk_radio_button_group (GTK_RADIO_BUTTON (widget))); } } } }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_tclist_set_properties (GtkWidget * widget, GtkWidget *child, GbWidgetSetArgData * data) { gchar *widths, *pos, *mode; gchar *shadow; gboolean titles; gint col, w, i; #ifndef GTK_HAVE_FEATURES_1_1_4 gboolean myApply; gchar *hpolicy, *vpolicy; GtkPolicyType hpolicy_value = GTK_POLICY_AUTOMATIC; GtkPolicyType vpolicy_value = GTK_POLICY_AUTOMATIC; #endif if (data->action == GB_LOADING) { widths = gb_widget_input_string (data, ColumnWidths); if (data->apply) { pos = widths; for (col = 0; col < GTK_CLIST (widget)->columns; col++) { w = atoi (pos); gtk_clist_set_column_width (GTK_CLIST (widget), col, w); pos = strchr (pos, ','); if (!pos) break; pos++; } } } mode = gb_widget_input_choice (data, Mode); if (data->apply) { for (i = 0; i < sizeof (GbModeValues) / sizeof (GbModeValues[0]); i++) { if (!strcmp (mode, GbModeChoices[i]) || !strcmp (mode, GbModeSymbols[i])) { gtk_clist_set_selection_mode (GTK_CLIST (widget), GbModeValues[i]); break; } } } titles = gb_widget_input_bool (data, Titles); if (data->apply) { if (titles) gtk_clist_column_titles_show (GTK_CLIST (widget)); else gtk_clist_column_titles_hide (GTK_CLIST (widget)); } shadow = gb_widget_input_choice (data, Shadow); if (data->apply) { for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]); i ++) { if (!strcmp (shadow, GbShadowChoices[i]) || !strcmp (shadow, GbShadowSymbols[i])) { #ifdef GTK_HAVE_FEATURES_1_1_4 gtk_clist_set_shadow_type (GTK_CLIST (widget), GbShadowValues[i]); #else gtk_clist_set_border (GTK_CLIST (widget), GbShadowValues[i]); #endif break; } } } #ifndef GTK_HAVE_FEATURES_1_1_4 hpolicy = gb_widget_input_choice (data, HPolicy); myApply = data->apply; vpolicy = gb_widget_input_choice (data, VPolicy); if (data->apply || myApply) { for (i = 0; i < sizeof (GbPolicyValues) / sizeof (GbPolicyValues[0]); i ++) { if (!strcmp (hpolicy, GbPolicyChoices[i]) || !strcmp (hpolicy, GbPolicySymbols[i])) hpolicy_value = GbPolicyValues[i]; if (!strcmp (vpolicy, GbPolicyChoices[i]) || !strcmp (vpolicy, GbPolicySymbols[i])) vpolicy_value = GbPolicyValues[i]; } gtk_clist_set_policy (GTK_CLIST (widget), vpolicy_value, hpolicy_value); } #endif }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_bonobo_dock_item_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean locked, exclusive, never_floating, never_vertical, never_horizontal; gchar *shadow, *orientation; BonoboDockItemBehavior behavior; gint i; /* This is a bit of a hack, as some of the properties are now saved as packing properties instead of normal properties. */ if (data->action == GB_LOADING) { gchar *behavior_string; data->loading_type = GB_CHILD_PROPERTIES; behavior_string = load_string (data, Behavior); behavior = glade_util_flags_from_string (BONOBO_TYPE_DOCK_ITEM_BEHAVIOR, behavior_string); data->loading_type = GB_STANDARD_PROPERTIES; } else { behavior = BONOBO_DOCK_ITEM (widget)->behavior; locked = gb_widget_input_bool (data, Locked); if (data->apply) { if (locked) behavior |= BONOBO_DOCK_ITEM_BEH_LOCKED; else behavior &= ~BONOBO_DOCK_ITEM_BEH_LOCKED; /* This avoids any problems with redrawing the selection. */ if (data->action == GB_APPLYING) editor_clear_selection (NULL); gtk_widget_queue_resize (widget); } exclusive = gb_widget_input_bool (data, Exclusive); if (data->apply) { if (exclusive) behavior |= BONOBO_DOCK_ITEM_BEH_EXCLUSIVE; else behavior &= ~BONOBO_DOCK_ITEM_BEH_EXCLUSIVE; } never_floating = gb_widget_input_bool (data, NeverFloating); if (data->apply) { if (never_floating) behavior |= BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING; else behavior &= ~BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING; } never_vertical = gb_widget_input_bool (data, NeverVertical); if (data->apply) { if (never_vertical) behavior |= BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL; else behavior &= ~BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL; } never_horizontal = gb_widget_input_bool (data, NeverHorizontal); if (data->apply) { if (never_horizontal) behavior |= BONOBO_DOCK_ITEM_BEH_NEVER_HORIZONTAL; else behavior &= ~BONOBO_DOCK_ITEM_BEH_NEVER_HORIZONTAL; } } /* BonoboDockItem has no method for setting the behavior. */ BONOBO_DOCK_ITEM (widget)->behavior = behavior; shadow = gb_widget_input_choice (data, ShadowType); if (data->apply) { for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]); i++) { if (!strcmp (shadow, GbShadowChoices[i]) || !strcmp (shadow, GbShadowSymbols[i])) { bonobo_dock_item_set_shadow_type (BONOBO_DOCK_ITEM (widget), GbShadowValues[i]); break; } } } orientation = gb_widget_input_choice (data, Orientation); if (data->apply) { for (i = 0; i < GladeOrientationSize; i++) { if (!strcmp (orientation, GladeOrientationChoices[i]) || !strcmp (orientation, GladeOrientationSymbols[i])) { bonobo_dock_item_set_orientation (BONOBO_DOCK_ITEM (widget), GladeOrientationValues[i]); /* This avoids any problems with redrawing the selection. */ if (data->action == GB_APPLYING) editor_clear_selection (NULL); /* FIXME: A test to see if changing orientation works. */ if (BONOBO_DOCK_ITEM (widget)->bin.child) gtk_widget_queue_resize (BONOBO_DOCK_ITEM (widget)->bin.child); break; } } } }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ void gb_label_set_standard_properties (GtkWidget * widget, GbWidgetSetArgData * 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) { gchar *label, *justify, *accel_target; const gchar *label_text; gfloat xalign, yalign; gint xpad, ypad, i; gboolean wrap, selectable, set_alignment = FALSE, set_padding = FALSE; gboolean use_underline, use_markup; gboolean set_label = FALSE; use_underline = gb_widget_input_bool (data, use_underline_p); if (data->apply) gtk_label_set_use_underline (GTK_LABEL (widget), use_underline); use_markup = gb_widget_input_bool (data, use_markup_p); if (data->apply) { set_label = TRUE; gtk_object_set_data (GTK_OBJECT (widget), use_markup_p, GINT_TO_POINTER (use_markup)); } label = gb_widget_input_text (data, label_p); if (data->apply) { set_label = TRUE; label_text = label; } else { label_text = gtk_label_get_label (GTK_LABEL (widget)); } if (set_label) { gboolean prev_use_markup; use_markup = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), use_markup_p)); /* We try to parse the markup here, and if it isn't valid, we will turn use_markup off and show it as plain text. */ if (use_markup) { GError *error = NULL; gunichar accel_marker = 0; PangoAttrList *attrs = NULL; gunichar accel_char = 0; gchar *text = NULL; if (gtk_label_get_use_underline (GTK_LABEL (widget))) accel_marker = '_'; /* We check it is valid markup. If it isn't we will set "use_markup" to FALSE. Note that we don't need attrs, text, or accel_char but it seems to crash otherwise. */ if (!pango_parse_markup (label_text, -1, accel_marker, &attrs, &text, &accel_char, &error)) { use_markup = FALSE; g_error_free (error); } else { if (attrs) pango_attr_list_unref (attrs); g_free (text); } } /* If we are turning use_markup off, we want to do that before setting the text. If we are turning it on, we want to do it after. */ prev_use_markup = gtk_label_get_use_markup (GTK_LABEL (widget)); if (!use_markup && prev_use_markup) gtk_label_set_use_markup (GTK_LABEL (widget), use_markup); gtk_label_set_label (GTK_LABEL (widget), label_text); if (use_markup && !prev_use_markup) gtk_label_set_use_markup (GTK_LABEL (widget), use_markup); } if (data->action == GB_APPLYING) g_free (label); justify = gb_widget_input_choice (data, justify_p); if (data->apply) { for (i = 0; i < sizeof (GbJustifyValues) / sizeof (GbJustifyValues[0]); i++) { if (!strcmp (justify, GbJustifyChoices[i]) || !strcmp (justify, GbJustifySymbols[i])) { gtk_label_set_justify (GTK_LABEL (widget), GbJustifyValues[i]); break; } } } wrap = gb_widget_input_bool (data, wrap_p); if (data->apply) gtk_label_set_line_wrap (GTK_LABEL (widget), wrap); selectable = gb_widget_input_bool (data, selectable_p); if (data->apply) gtk_label_set_selectable (GTK_LABEL (widget), selectable); xalign = gb_widget_input_float (data, xalign_p); if (data->apply) set_alignment = TRUE; else xalign = GTK_MISC (widget)->xalign; yalign = gb_widget_input_float (data, yalign_p); if (data->apply) set_alignment = TRUE; else yalign = GTK_MISC (widget)->yalign; if (set_alignment) gtk_misc_set_alignment (GTK_MISC (widget), xalign, yalign); xpad = gb_widget_input_int (data, xpad_p); if (data->apply) set_padding = TRUE; else xpad = GTK_MISC (widget)->xpad; ypad = gb_widget_input_int (data, ypad_p); if (data->apply) set_padding = TRUE; else ypad = GTK_MISC (widget)->ypad; if (set_padding) gtk_misc_set_padding (GTK_MISC (widget), xpad, ypad); /* Labels not in buttons may have a focus target widget. */ accel_target = gb_widget_input_combo (data, focus_target_p); if (data->apply) { if (!gb_label_find_mnemonic_widget (widget)) { if (!strcmp (accel_target, _("Auto"))) accel_target = NULL; gtk_object_set_data_full (GTK_OBJECT (widget), focus_target_p, g_strdup (accel_target), accel_target ? g_free : NULL); } } }
void gb_window_set_standard_properties (GtkWidget * widget, GbWidgetSetArgData * 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) { gchar *title, *type, *position; gint default_width, default_height, i; gboolean modal, apply_default_width, apply_default_height; gboolean resizable, destroy_with_parent; #if 0 gchar *wmname, *wmclass; #endif if (title_p) { title = gb_widget_input_string (data, title_p); if (data->apply) gtk_window_set_title (GTK_WINDOW (widget), title); } if (type_p) { type = gb_widget_input_choice (data, type_p); if (data->apply) { for (i = 0; i < sizeof (GbTypeValues) / sizeof (GbTypeValues[0]); i++) { if (!strcmp (type, GbTypeChoices[i]) || !strcmp (type, GbTypeSymbols[i])) { gtk_object_set_data (GTK_OBJECT (widget), type_p, GINT_TO_POINTER (i)); break; } } } } if (position_p) { position = gb_widget_input_choice (data, position_p); if (data->apply) { for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]); i++) { if (!strcmp (position, GbPositionChoices[i]) || !strcmp (position, GbPositionSymbols[i])) { gtk_object_set_data (GTK_OBJECT (widget), position_p, GINT_TO_POINTER (i)); break; } } } } if (modal_p) { modal = gb_widget_input_bool (data, modal_p); if (data->apply) { gtk_object_set_data (GTK_OBJECT (widget), modal_p, modal ? "TRUE" : NULL); } } if (default_width_p && default_height_p) { default_width = gb_widget_input_int (data, default_width_p); apply_default_width = data->apply; if (apply_default_width) { gtk_object_set_data (GTK_OBJECT (widget), DefaultWidth, GINT_TO_POINTER (default_width)); } default_height = gb_widget_input_int (data, default_height_p); apply_default_height = data->apply; if (apply_default_height) { gtk_object_set_data (GTK_OBJECT (widget), DefaultHeight, GINT_TO_POINTER (default_height)); } if (apply_default_width || apply_default_height) { if (!apply_default_width) default_width = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), DefaultWidth)); if (!apply_default_height) default_height = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), DefaultHeight)); gtk_window_set_default_size (GTK_WINDOW (widget), default_width ? default_width : -1, default_height ? default_height : -1); } } #if 0 /* These are deprecated. */ if (shrink_p && grow_p) { shrink = gb_widget_input_bool (data, shrink_p); if (data->apply) set_policy = TRUE; else shrink = GTK_WINDOW (widget)->allow_shrink; grow = gb_widget_input_bool (data, grow_p); if (data->apply) set_policy = TRUE; else grow = GTK_WINDOW (widget)->allow_grow; if (set_policy) gtk_window_set_policy (GTK_WINDOW (widget), shrink, grow, FALSE); } #endif #if 0 /* These aren't necessary, and have been used incorrectly for ages. */ if (wmname_p) { wmname = gb_widget_input_string (data, wmname_p); if (wmname && wmname[0] == '\0') wmname = NULL; if (data->apply) { gtk_object_set_data_full (GTK_OBJECT (widget), wmname_p, g_strdup (wmname), wmname ? g_free : NULL); } } if (wmclass_p) { wmclass = gb_widget_input_string (data, wmclass_p); if (wmclass && wmclass[0] == '\0') wmclass = NULL; if (data->apply) { gtk_object_set_data_full (GTK_OBJECT (widget), wmclass_p, g_strdup (wmclass), wmclass ? g_free : NULL); } } #endif if (resizable_p) { resizable = gb_widget_input_bool (data, resizable_p); if (data->apply) gtk_window_set_resizable (GTK_WINDOW (widget), resizable); } if (destroy_with_parent_p) { destroy_with_parent = gb_widget_input_bool (data, destroy_with_parent_p); if (data->apply) gtk_window_set_destroy_with_parent (GTK_WINDOW (widget), destroy_with_parent); } if (icon_p) { char *filename = gb_widget_input_pixmap_filename (data, icon_p); if (data->apply) { char *old_filename; if (filename && filename[0] == '\0') filename = NULL; /* Remove the old pixmap from the project. */ old_filename = gtk_object_get_data (GTK_OBJECT (widget), icon_p); glade_project_remove_pixmap (data->project, old_filename); gtk_object_set_data_full (GTK_OBJECT (widget), icon_p, g_strdup (filename), filename ? g_free : NULL); glade_project_add_pixmap (data->project, filename); if (filename) { GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (filename, NULL); gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); if (pixbuf) gdk_pixbuf_unref (pixbuf); } } if (data->action == GB_LOADING) g_free (filename); } }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_gnome_pixmap_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gchar *filename, *old_filename; gboolean set_pixmap = FALSE, scaled; gint width, height; filename = gb_widget_input_pixmap_filename (data, Filename); if (data->apply) { set_pixmap = TRUE; if (filename && filename[0] == '\0') filename = NULL; old_filename = gtk_object_get_data (GTK_OBJECT (widget), Filename); if (old_filename) { glade_project_remove_pixmap (data->project, old_filename); g_free (old_filename); } gtk_object_set_data_full (GTK_OBJECT (widget), Filename, g_strdup (filename), filename ? g_free : NULL); if (filename) { glade_project_add_pixmap (data->project, filename); } } if (data->action == GB_LOADING) g_free (filename); scaled = gb_widget_input_bool (data, Scaled); if (data->apply) { set_pixmap = TRUE; gtk_object_set_data (GTK_OBJECT (widget), Scaled, scaled ? "Y" : NULL); if (property_get_widget() == widget) { property_set_sensitive (Width, scaled); property_set_sensitive (Height, scaled); } } width = gb_widget_input_int (data, Width); if (data->apply) { set_pixmap = TRUE; if (data->action == GB_LOADING) gtk_object_set_data (GTK_OBJECT (widget), Scaled, "Y"); gtk_object_set_data (GTK_OBJECT (widget), Width, GINT_TO_POINTER (width)); } height = gb_widget_input_int (data, Height); if (data->apply) { set_pixmap = TRUE; if (data->action == GB_LOADING) gtk_object_set_data (GTK_OBJECT (widget), Scaled, "Y"); gtk_object_set_data (GTK_OBJECT (widget), Height, GINT_TO_POINTER (height)); } if (set_pixmap) gb_gnome_pixmap_reload (widget); }