/* * 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_image_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gfloat xalign, yalign; gint xpad, ypad, i, pixel_size; gboolean set_alignment = FALSE, set_padding = FALSE, apply_icon_size; GtkIconSize icon_size = GTK_ICON_SIZE_BUTTON; gchar *icon_size_string, *icon, *icon_name; icon_size = GTK_IMAGE (widget)->icon_size; if (data->action == GB_APPLYING) { icon_size_string = gb_widget_input_choice (data, IconSize); apply_icon_size = data->apply; if (data->apply) { for (i = 0; i < GladeIconSizeChoicesSize; i++) { if (!strcmp (icon_size_string, GladeIconSizeChoices[i]) || !strcmp (icon_size_string, GladeIconSizeSymbols[i])) { icon_size = GladeIconSizeValues[i]; break; } } } } 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.*/ int new_size = gb_widget_input_int (data, IconSize); apply_icon_size = data->apply; if (data->apply) icon_size = new_size; } /* When loading we use different names. */ if (data->action == GB_LOADING) { icon = gb_widget_input_icon (data, "stock"); if (!data->apply) icon = gb_widget_input_icon (data, "pixbuf"); } else { icon = gb_widget_input_icon (data, Icon); } if (data->apply) { gboolean is_stock_icon = glade_util_check_is_stock_id (icon); /* Remove the old icon stored in the widget data, and remove the pixmap from the project, if necessary. */ gb_image_clear_pixmap (widget, data->project); gtk_object_set_data_full (GTK_OBJECT (widget), GladeIconKey, g_strdup (icon), icon ? g_free : NULL); if (is_stock_icon) { GtkIconSize new_icon_size; new_icon_size = check_icon_size (icon, icon_size); /* If we are showing this widget's properties, we need to update the sizes option menu. */ if (property_get_widget () == widget) { /* We set it sensitive before changing the value, so the child menu item is changed from insensitive to sensitive if needed. Otherwise it may remain insensitive. */ property_set_sensitive (IconSize, TRUE); property_set_sensitive (PixelSize, FALSE); property_set_auto_apply (FALSE); check_visible_sizes (icon, FALSE); /* Check the icon size is valid for the stock item, and if not pick the first valid size. */ for (i = 0; i < GladeIconSizeChoicesSize; i++) { if (GladeIconSizeValues[i] == new_icon_size) { property_set_choice (IconSize, i); } } property_set_named_icon (IconName, NULL); property_set_auto_apply (TRUE); } gtk_image_set_from_stock (GTK_IMAGE (widget), icon, new_icon_size); } else { /* If an icon filename is set, use that, otherwise use the icon we use for the palette. */ if (icon) { gtk_image_set_from_file (GTK_IMAGE (widget), icon); glade_project_add_pixmap (data->project, icon); } else { gtk_image_set_from_pixmap (GTK_IMAGE (widget), gbwidget.gdkpixmap, gbwidget.mask); } if (property_get_widget () == widget) { /* The icon size isn't relevant to non-stock icons. */ property_set_sensitive (IconSize, FALSE); property_set_sensitive (PixelSize, FALSE); property_set_auto_apply (FALSE); property_set_named_icon (IconName, NULL); property_set_auto_apply (TRUE); } } /* We've recreated the icon with the new size above, so we don't need to apply the size again. */ apply_icon_size = FALSE; } /* This is for the named/themed icon. */ icon_name = gb_widget_input_named_icon (data, IconName); if (data->apply) { /* Clear any stock icon or icon from a file. */ gb_image_clear_pixmap (widget, data->project); gtk_image_set_from_icon_name (GTK_IMAGE (widget), icon_name, icon_size); if (property_get_widget () == widget) { property_set_sensitive (IconSize, TRUE); property_set_sensitive (PixelSize, TRUE); /* Clear the Icon property. */ property_set_auto_apply (FALSE); property_set_icon (Icon, NULL); property_set_auto_apply (TRUE); } /* We've recreated the icon with the new size above, so we don't need to apply the size again. */ apply_icon_size = FALSE; } /* When we set the icon size, we reset the pixel size to -1, otherwise it overrides the icon size. */ if (apply_icon_size) { gtk_image_set_pixel_size (GTK_IMAGE (widget), -1); g_object_set (widget, "icon_size", icon_size, NULL); if (property_get_widget () == widget) { property_set_auto_apply (FALSE); property_set_int (PixelSize, -1); property_set_auto_apply (TRUE); } } /* GtkImage doesn't like a pixel size of 0 so we just skip that. */ pixel_size = gb_widget_input_int (data, PixelSize); if (data->apply && pixel_size != 0) gtk_image_set_pixel_size (GTK_IMAGE (widget), pixel_size); xalign = gb_widget_input_float (data, XAlign); if (data->apply) set_alignment = TRUE; else xalign = GTK_MISC (widget)->xalign; yalign = gb_widget_input_float (data, YAlign); 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); if (data->apply) set_padding = TRUE; else xpad = GTK_MISC (widget)->xpad; ypad = gb_widget_input_int (data, YPad); if (data->apply) set_padding = TRUE; else ypad = GTK_MISC (widget)->ypad; if (set_padding) gtk_misc_set_padding (GTK_MISC (widget), xpad, ypad); }
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); }
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); }