/* * 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_icon_entry_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gchar *title, *history_id; gint max_saved; title = gb_widget_input_string (data, Title); if (data->apply) { gtk_object_set_data_full (GTK_OBJECT (widget), Title, g_strdup (title), title ? g_free : NULL); gnome_icon_entry_set_browse_dialog_title (GNOME_ICON_ENTRY (widget), title && title[0] ? title : ""); } history_id = gb_widget_input_string (data, HistoryID); if (data->apply) gtk_object_set_data_full (GTK_OBJECT (widget), HistoryID, g_strdup (history_id), history_id ? g_free : NULL); max_saved = gb_widget_input_int (data, MaxSaved); if (data->apply) gtk_object_set_data (GTK_OBJECT (widget), MaxSaved, GINT_TO_POINTER (max_saved)); }
/* * 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_custom_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gchar *creation_function, *string1, *string2; gint int1, int2; creation_function = gb_widget_input_string (data, CreationFunction); if (data->apply) { g_free (gtk_object_get_data (GTK_OBJECT (widget), CreationFunction)); gtk_object_set_data (GTK_OBJECT (widget), CreationFunction, g_strdup (creation_function)); /* If we are applying the property, we set the last modification time. */ if (data->action == GB_APPLYING) { gb_custom_set_last_mod_time (widget, -1); } } string1 = gb_widget_input_string (data, String1); if (data->apply) { g_free (gtk_object_get_data (GTK_OBJECT (widget), String1)); gtk_object_set_data (GTK_OBJECT (widget), String1, g_strdup (string1)); } string2 = gb_widget_input_string (data, String2); if (data->apply) { g_free (gtk_object_get_data (GTK_OBJECT (widget), String2)); gtk_object_set_data (GTK_OBJECT (widget), String2, g_strdup (string2)); } int1 = gb_widget_input_int (data, Int1); if (data->apply) gtk_object_set_data (GTK_OBJECT (widget), Int1, GINT_TO_POINTER (int1)); int2 = gb_widget_input_int (data, Int2); if (data->apply) gtk_object_set_data (GTK_OBJECT (widget), Int2, GINT_TO_POINTER (int2)); /* If we are loading, load the last modification time. */ if (data->action == GB_LOADING) { time_t last_mod_time; last_mod_time = load_date (data, LastModTime); if (data->apply) { gb_custom_set_last_mod_time (widget, last_mod_time); } } }
/* 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_font_selection_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gchar *preview_text; preview_text = gb_widget_input_string (data, PreviewText); if (data->apply) gtk_font_selection_set_preview_text (GTK_FONT_SELECTION (widget), preview_text); }
/* * 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_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_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_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_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 }
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_menu_item_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean input_label = TRUE, input_rest = TRUE; GtkAccelGroup *accel_group; guint key; GdkModifierType modifiers; /* We only support loading the properties here. */ if (data->action != GB_LOADING) return; #ifdef USE_GNOME /* Check for a stock menu item. */ if (glade_project_get_gnome_support (data->project)) { GnomeUIInfo *uiinfo; gchar *stock_item; GtkWidget *label; gint stock_item_index; stock_item = gb_widget_input_string (data, "stock_item"); if (stock_item && stock_item[0]) { /* Special case for the NEW_SUBTREE. */ if (!strcmp (stock_item, "GNOMEUIINFO_MENU_NEW_SUBTREE")) { stock_item_index = GladeStockMenuItemNew; } else { stock_item_index = glade_util_string_array_index (GladeStockMenuItemSymbols, GladeStockMenuItemSize, stock_item); } if (stock_item_index != -1) { uiinfo = &GladeStockMenuItemValues[stock_item_index]; if (uiinfo->type == GNOME_APP_UI_ITEM_CONFIGURABLE) gnome_app_ui_configure_configurable (uiinfo); /* Note that we don't have to worry about the pixmap, since if it had a pixmap it would be a GtkImageMenuItem. */ label = gtk_accel_label_new (""); gtk_label_set_text_with_mnemonic (GTK_LABEL (label), uiinfo->label); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_show (label); gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), widget); gtk_container_add (GTK_CONTAINER (widget), label); /* Add the configured accelerator key. */ if (uiinfo->accelerator_key != 0 && widget->parent && GTK_IS_MENU (widget->parent)) { accel_group = GTK_MENU (widget->parent)->accel_group; gtk_widget_add_accelerator (widget, "activate", accel_group, uiinfo->accelerator_key, uiinfo->ac_mods, GTK_ACCEL_VISIBLE); } /* Remember the index of the stock item. */ gtk_object_set_data (GTK_OBJECT (widget), GladeMenuItemStockIndexKey, GINT_TO_POINTER (stock_item_index)); /* The 'New' item can have a label. The rest can't. */ if (stock_item_index != GladeStockMenuItemNew) input_label = FALSE; input_rest = FALSE; } else { #ifdef FIXME load_add_error_message_with_tag (data, GLADE_LINE_PROPERTY, _("Invalid stock menu item"), "stock_item", stock_item); #endif } } } #endif if (input_label) gb_widget_input_child_label (widget, data, Label); if (input_rest) { /* FIXME: should this be somewhere else? */ /* If we are loading, install the 'activate' accelerator, if it has one, so that is is visible. */ if (data->action == GB_LOADING && widget->parent && GTK_IS_MENU (widget->parent)) { int i; for (i = 0; i < data->widget_info->n_accels; i++) { if (!strcmp (data->widget_info->accels[i].signal, "activate")) { key = data->widget_info->accels[i].key; modifiers = data->widget_info->accels[i].modifiers; accel_group = GTK_MENU (widget->parent)->accel_group; gtk_widget_add_accelerator (widget, "activate", accel_group, key, modifiers, GTK_ACCEL_VISIBLE); break; } } } } }
static void gb_gnome_druid_page_standard_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { GnomeDruidPageStandard *page; gchar *string, *old_filename; GdkColor *color; GdkPixbuf *image; page = GNOME_DRUID_PAGE_STANDARD (widget); string = gb_widget_input_string (data, Title); if (data->apply) gnome_druid_page_standard_set_title (page, string); color = gb_widget_input_color (data, BackgroundColor); if (data->apply) gnome_druid_page_standard_set_bg_color (page, color); color = gb_widget_input_color (data, LogoBackgroundColor); if (data->apply) gnome_druid_page_standard_set_logo_bg_color (page, color); color = gb_widget_input_color (data, TitleColor); if (data->apply) gnome_druid_page_standard_set_title_color (page, color); color = gb_widget_input_color (data, ContentsBackgroundColor); if (data->apply) { gtk_object_set_data (GTK_OBJECT (widget), ContentsBackgroundColor, "Y"); gnome_druid_page_standard_set_contents_background (page, color); } string = gb_widget_input_pixmap_filename (data, LogoImage); if (data->apply) { if (string && string[0] == '\0') string = NULL; old_filename = gtk_object_get_data (GTK_OBJECT (widget), LogoImage); glade_project_remove_pixmap (data->project, old_filename); gtk_object_set_data_full (GTK_OBJECT (widget), LogoImage, g_strdup (string), string ? g_free : NULL); glade_project_add_pixmap (data->project, string); image = string ? gdk_pixbuf_new_from_file (string, NULL) : NULL; gnome_druid_page_standard_set_logo (page, image); if (image) gdk_pixbuf_unref (image); } if (data->action == GB_LOADING) g_free (string); string = gb_widget_input_pixmap_filename (data, TopWatermark); if (data->apply) { if (string && string[0] == '\0') string = NULL; old_filename = gtk_object_get_data (GTK_OBJECT (widget), TopWatermark); glade_project_remove_pixmap (data->project, old_filename); gtk_object_set_data_full (GTK_OBJECT (widget), TopWatermark, g_strdup (string), string ? g_free : NULL); glade_project_add_pixmap (data->project, string); image = string ? gdk_pixbuf_new_from_file (string, NULL) : NULL; gnome_druid_page_standard_set_top_watermark (page, image); if (image) gdk_pixbuf_unref (image); } if (data->action == GB_LOADING) g_free (string); }