static void on_toggle_default_height (GtkWidget * widget, gpointer value) { GtkWidget *property_widget; gboolean value_set; gint width, height; property_widget = property_get_widget (); if (property_widget == NULL) return; value_set = GTK_TOGGLE_BUTTON (widget)->active ? TRUE : FALSE; gtk_widget_set_sensitive (GTK_WIDGET (value), value_set); if (value_set) { height = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (value)); gtk_object_set_data (GTK_OBJECT (property_widget), DefaultHeight, GINT_TO_POINTER (height)); } else { height = -1; gtk_object_set_data (GTK_OBJECT (property_widget), DefaultHeight, NULL); } width = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (property_widget), DefaultWidth)); gtk_window_set_default_size (GTK_WINDOW (property_widget), width != 0 ? width : -1, height); }
/* 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); } }
static void gb_option_menu_on_option_selected (GtkWidget *menu, GtkWidget *option_menu) { GtkWidget *active_item; gint item_index; if (property_get_widget () != option_menu) return; active_item = gtk_menu_get_active (GTK_MENU (menu)); item_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item); property_set_auto_apply (FALSE); property_set_int (Choice, item_index); property_set_auto_apply (TRUE); }
static void on_toggle_position (GtkWidget * button, gpointer value) { GtkWidget *widget; gboolean value_set; gint position; widget = property_get_widget (); if (widget == NULL) return; value_set = GTK_TOGGLE_BUTTON (button)->active ? TRUE : FALSE; gtk_widget_set_sensitive (GTK_WIDGET (value), value_set); position = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), Position)); gtk_paned_set_position (GTK_PANED (widget), value_set ? position : -1); }
static void gb_menu_bar_on_edit_menu (GtkWidget *button, gpointer data) { GtkWidget *option, *menued, *menu; option = property_get_widget (); g_return_if_fail (GTK_IS_OPTION_MENU (option)); /* * we need to remove the menu from the option menu otherwise there * will be a separator where the selected menu is */ g_object_set_data (G_OBJECT (option), History, GINT_TO_POINTER (gtk_option_menu_get_history (GTK_OPTION_MENU (option)))); menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (option)); if (!menu) menu = gb_widget_new ("GtkMenu", option); g_object_ref (menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (option), gtk_menu_new ()); menued = glade_menu_editor_new (current_project, GTK_MENU_SHELL (menu)); g_signal_connect (menued, "destroy", G_CALLBACK (set_menu), option); /* I think this was hidden as it doesn't call set_menu() to reset the history. */ gtk_widget_hide (GLADE_MENU_EDITOR (menued)->apply_button); dialogize (menued, button); gtk_widget_show (GTK_WIDGET (menued)); gtk_option_menu_set_menu (GTK_OPTION_MENU (option), menu); g_object_unref (menu); }
/* * 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); }
/* * 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); }