added gimp_prop_file_chooser_button_new(), a convenience constructor for

2005-03-25  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/gimppropwidgets.[ch]: added
	gimp_prop_file_chooser_button_new(), a convenience constructor for
	GtkFileChooserButton.

	* libgimpwidgets/gimpwidgets.def: updated.

	* app/dialogs/preferences-dialog.c: use the new prop widget on the
	color management page.
This commit is contained in:
Sven Neumann
2005-03-25 00:37:16 +00:00
committed by Sven Neumann
parent 51a539a529
commit 01c245133a
5 changed files with 245 additions and 46 deletions

View File

@ -93,6 +93,9 @@ gimp_prop_check_button_new (GObject *config,
GtkWidget *button;
gboolean value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_BOOLEAN, G_STRFUNC);
if (! param_spec)
@ -196,6 +199,9 @@ gimp_prop_enum_check_button_new (GObject *config,
GtkWidget *button;
gint value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_ENUM, G_STRFUNC);
if (! param_spec)
@ -334,6 +340,9 @@ gimp_prop_int_combo_box_new (GObject *config,
GtkWidget *widget;
gint value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_INT, G_STRFUNC);
if (! param_spec)
@ -402,6 +411,9 @@ gimp_prop_enum_combo_box_new (GObject *config,
GtkWidget *widget;
gint value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_ENUM, G_STRFUNC);
if (! param_spec)
@ -536,6 +548,9 @@ gimp_prop_boolean_combo_box_new (GObject *config,
GtkWidget *widget;
gboolean value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_BOOLEAN, G_STRFUNC);
if (! param_spec)
@ -658,6 +673,9 @@ gimp_prop_enum_radio_frame_new (GObject *config,
GtkWidget *button;
gint value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_ENUM, G_STRFUNC);
if (! param_spec)
@ -727,6 +745,9 @@ gimp_prop_enum_radio_box_new (GObject *config,
GtkWidget *button;
gint value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_ENUM, G_STRFUNC);
if (! param_spec)
@ -792,6 +813,9 @@ gimp_prop_boolean_radio_frame_new (GObject *config,
GtkWidget *button;
gboolean value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_BOOLEAN, G_STRFUNC);
if (! param_spec)
@ -852,6 +876,9 @@ gimp_prop_enum_stock_box_new (GObject *config,
GtkWidget *button;
gint value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_ENUM, G_STRFUNC);
if (! param_spec)
@ -1120,6 +1147,9 @@ gimp_prop_opacity_entry_new (GObject *config,
gdouble lower;
gdouble upper;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_DOUBLE, G_STRFUNC);
if (! param_spec)
@ -1338,6 +1368,9 @@ gimp_prop_memsize_entry_new (GObject *config,
GtkWidget *entry;
guint64 value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
GIMP_TYPE_PARAM_MEMSIZE, G_STRFUNC);
if (! param_spec)
@ -1446,6 +1479,9 @@ gimp_prop_label_new (GObject *config,
GtkWidget *label;
gchar *value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_STRING, G_STRFUNC);
if (! param_spec)
@ -1515,6 +1551,9 @@ gimp_prop_entry_new (GObject *config,
GtkWidget *entry;
gchar *value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_STRING, G_STRFUNC);
if (! param_spec)
@ -1630,6 +1669,9 @@ gimp_prop_text_buffer_new (GObject *config,
GtkTextBuffer *text_buffer;
gchar *value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_STRING, G_STRFUNC);
if (! param_spec)
@ -1753,7 +1795,8 @@ static void gimp_prop_file_entry_notify (GObject *config,
* @property_name: Name of Path property.
* @filesel_title: Label for the file selector.
* @dir_only: #TRUE if the file entry should accept directories only.
* @check_valid: #TRUE if the widget should check if the entered file really exists.
* @check_valid: #TRUE if the widget should check if the entered file
* really exists.
*
* Creates a #GimpFileEntry to set and display the specified Path property.
*
@ -1773,6 +1816,9 @@ gimp_prop_file_entry_new (GObject *config,
gchar *filename;
gchar *value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
GIMP_TYPE_PARAM_CONFIG_PATH, G_STRFUNC);
if (! param_spec)
@ -1863,6 +1909,138 @@ gimp_prop_file_entry_notify (GObject *config,
}
/*****************/
/* file button */
/*****************/
static void gimp_prop_file_chooser_button_callback (GtkFileChooser *button,
GObject *config);
static void gimp_prop_file_chooser_button_notify (GObject *config,
GParamSpec *param_spec,
GtkFileChooser *button);
/**
* gimp_prop_file_chooser_button_new:
* @config: object to which property is attached.
* @property_name: name of Path property.
* @title: the title of the browse dialog.
* @action: the open mode for the widget.
*
* Creates a #GtkFileChooserButton to set and display the specified
* Path property.
*
* Return value: A new #GimpFileButton widget.
*
* Since GIMP 2.4
*/
GtkWidget *
gimp_prop_file_chooser_button_new (GObject *config,
const gchar *property_name,
const gchar *title,
GtkFileChooserAction action)
{
GParamSpec *param_spec;
GtkWidget *button;
gchar *filename;
gchar *value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
GIMP_TYPE_PARAM_CONFIG_PATH, G_STRFUNC);
if (! param_spec)
return NULL;
g_object_get (config,
property_name, &value,
NULL);
filename = value ? gimp_config_path_expand (value, TRUE, NULL) : NULL;
g_free (value);
button = gtk_file_chooser_button_new (title, action);
if (filename)
{
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (button), filename);
g_free (filename);
}
set_param_spec (G_OBJECT (button), button, param_spec);
g_signal_connect (button, "file-activated",
G_CALLBACK (gimp_prop_file_chooser_button_callback),
config);
connect_notify (config, property_name,
G_CALLBACK (gimp_prop_file_chooser_button_notify),
button);
return button;
}
static void
gimp_prop_file_chooser_button_callback (GtkFileChooser *button,
GObject *config)
{
GParamSpec *param_spec;
gchar *value;
gchar *utf8;
param_spec = get_param_spec (G_OBJECT (button));
if (! param_spec)
return;
value = gtk_file_chooser_get_filename (button);
utf8 = g_filename_to_utf8 (value, -1, NULL, NULL, NULL);
g_free (value);
g_signal_handlers_block_by_func (config,
gimp_prop_file_chooser_button_notify,
button);
g_object_set (config,
param_spec->name, utf8,
NULL);
g_signal_handlers_block_by_func (config,
gimp_prop_file_chooser_button_notify,
button);
g_free (utf8);
}
static void
gimp_prop_file_chooser_button_notify (GObject *config,
GParamSpec *param_spec,
GtkFileChooser *button)
{
gchar *value;
gchar *filename;
g_object_get (config,
param_spec->name, &value,
NULL);
filename = value ? gimp_config_path_expand (value, TRUE, NULL) : NULL;
g_free (value);
g_signal_handlers_block_by_func (button,
gimp_prop_file_chooser_button_callback,
config);
gtk_file_chooser_set_filename (button, filename);
g_signal_handlers_unblock_by_func (button,
gimp_prop_file_chooser_button_callback,
config);
g_free (filename);
}
/*****************/
/* path editor */
/*****************/
@ -1890,6 +2068,9 @@ gimp_prop_path_editor_new (GObject *config,
gchar *value;
gchar *filename;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (path_property_name != NULL, NULL);
path_param_spec = check_param_spec (config, path_property_name,
GIMP_TYPE_PARAM_CONFIG_PATH, G_STRFUNC);
if (! path_param_spec)

View File

@ -141,6 +141,11 @@ GtkWidget * gimp_prop_path_editor_new (GObject *config,
const gchar *writable_property_name,
const gchar *filesel_title);
GtkWidget * gimp_prop_file_chooser_button_new (GObject *config,
const gchar *property_name,
const gchar *title,
GtkFileChooserAction action);
/* GParamInt, GParamUInt, GParamDouble unit: GimpParamUnit */

View File

@ -97,12 +97,6 @@ EXPORTS
gimp_enum_combo_box_get_type
gimp_enum_combo_box_new
gimp_enum_combo_box_set_stock_prefix
gimp_enum_store_get_type
gimp_enum_store_new_with_range
gimp_enum_store_new
gimp_enum_store_new_with_values_valist
gimp_enum_store_new_with_values
gimp_enum_store_set_stock_prefix
gimp_enum_radio_box_new
gimp_enum_radio_box_new_with_range
gimp_enum_radio_frame_new
@ -110,6 +104,12 @@ EXPORTS
gimp_enum_stock_box_new
gimp_enum_stock_box_new_with_range
gimp_enum_stock_box_set_child_padding
gimp_enum_store_get_type
gimp_enum_store_new
gimp_enum_store_new_with_range
gimp_enum_store_new_with_values
gimp_enum_store_new_with_values_valist
gimp_enum_store_set_stock_prefix
gimp_file_entry_get_filename
gimp_file_entry_get_type
gimp_file_entry_new
@ -190,31 +190,32 @@ EXPORTS
gimp_preview_set_bounds
gimp_preview_set_default_cursor
gimp_preview_set_update
gimp_prop_check_button_new
gimp_prop_boolean_combo_box_new
gimp_prop_boolean_radio_frame_new
gimp_prop_expander_new
gimp_prop_int_combo_box_new
gimp_prop_enum_combo_box_new
gimp_prop_enum_check_button_new
gimp_prop_enum_radio_frame_new
gimp_prop_enum_radio_box_new
gimp_prop_enum_stock_box_new
gimp_prop_spin_button_new
gimp_prop_scale_entry_new
gimp_prop_opacity_entry_new
gimp_prop_memsize_entry_new
gimp_prop_label_new
gimp_prop_entry_new
gimp_prop_text_buffer_new
gimp_prop_file_entry_new
gimp_prop_path_editor_new
gimp_prop_size_entry_new
gimp_prop_coordinates_new
gimp_prop_coordinates_connect
gimp_prop_check_button_new
gimp_prop_color_area_new
gimp_prop_unit_menu_new
gimp_prop_coordinates_connect
gimp_prop_coordinates_new
gimp_prop_entry_new
gimp_prop_enum_check_button_new
gimp_prop_enum_combo_box_new
gimp_prop_enum_radio_box_new
gimp_prop_enum_radio_frame_new
gimp_prop_enum_stock_box_new
gimp_prop_expander_new
gimp_prop_file_chooser_button_new
gimp_prop_file_entry_new
gimp_prop_int_combo_box_new
gimp_prop_label_new
gimp_prop_memsize_entry_new
gimp_prop_opacity_entry_new
gimp_prop_path_editor_new
gimp_prop_scale_entry_new
gimp_prop_size_entry_new
gimp_prop_spin_button_new
gimp_prop_stock_image_new
gimp_prop_text_buffer_new
gimp_prop_unit_menu_new
gimp_query_boolean_box
gimp_query_double_box
gimp_query_int_box
@ -240,7 +241,6 @@ EXPORTS
gimp_size_entry_get_value
gimp_size_entry_grab_focus
gimp_size_entry_new
gimp_size_entry_show_unit_menu
gimp_size_entry_set_activates_default
gimp_size_entry_set_pixel_digits
gimp_size_entry_set_refval
@ -251,6 +251,7 @@ EXPORTS
gimp_size_entry_set_unit
gimp_size_entry_set_value
gimp_size_entry_set_value_boundaries
gimp_size_entry_show_unit_menu
gimp_spin_button_new
gimp_standard_help_func
gimp_stock_init