/* * 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_pixmap_get_properties (GtkWidget *widget, GbWidgetGetArgData * data) { gboolean scaled; gint w, h; gb_widget_output_pixmap_filename (data, Filename, gtk_object_get_data (GTK_OBJECT (widget), Filename)); scaled = gtk_object_get_data (GTK_OBJECT (widget), Scaled) != NULL ? TRUE : FALSE; if (data->action == GB_SHOWING) { gb_widget_output_bool (data, Scaled, scaled); property_set_sensitive (Width, scaled); property_set_sensitive (Height, scaled); } /* We only save the scaled width and height if the pixmap is scaled. */ w = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), Width)); if (scaled || data->action == GB_SHOWING) gb_widget_output_int (data, Width, w); h = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), Height)); if (scaled || data->action == GB_SHOWING) gb_widget_output_int (data, Height, h); }
/* If the widgets properties are currently shown, we update them if necessary. */ static void gb_bonobo_dock_item_drag_end (GtkWidget *widget, gpointer user_data) { if (property_get_widget () == widget) { /* 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_option_menu_get_properties (GtkWidget * widget, GbWidgetGetArgData * data) { GbAddLabelData add_label_data; gchar items[ITEMS_BUFFER_SIZE]; /* Clear the buffer and make sure it's seen as valid */ items[0] = '\0'; add_label_data.items = items; add_label_data.option_menu = widget; add_label_data.buffer_overflow = FALSE; add_label_data.index = 0; add_label_data.selected_index = 0; gtk_container_foreach (GTK_CONTAINER (GTK_OPTION_MENU (widget)->menu), (GtkCallback) add_label, &add_label_data); if (add_label_data.buffer_overflow) { gb_widget_output_text (data, Items, ""); gb_widget_output_int (data, Choice, 0); if (data->action == GB_SHOWING) { property_set_sensitive (Items, FALSE); property_set_sensitive (Choice, FALSE); } } else { gb_widget_output_translatable_text_in_lines (data, Items, items); gb_widget_output_int (data, Choice, add_label_data.selected_index); if (data->action == GB_SHOWING) { property_set_sensitive (Items, TRUE); property_set_sensitive (Choice, TRUE); } } }
/* * 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); } }
/* * 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); }
/* * 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); }
/* * 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); }