mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-11 03:10:09 +00:00
Allow disabling New Folder button in File Choser
Bug #570516. Add a new property "create-folders" meaning that the "New Folder" button should be displayed in the modes where it used to be.
This commit is contained in:
parent
d75ccb5c0d
commit
a4514f993e
@ -1483,6 +1483,8 @@ gtk_file_chooser_set_show_hidden
|
||||
gtk_file_chooser_get_show_hidden
|
||||
gtk_file_chooser_set_do_overwrite_confirmation
|
||||
gtk_file_chooser_get_do_overwrite_confirmation
|
||||
gtk_file_chooser_set_create_folders
|
||||
gtk_file_chooser_get_create_folders
|
||||
gtk_file_chooser_set_current_name
|
||||
gtk_file_chooser_get_filename
|
||||
gtk_file_chooser_set_filename
|
||||
|
@ -1531,6 +1531,8 @@ gtk_file_chooser_get_select_multiple
|
||||
gtk_file_chooser_get_show_hidden
|
||||
gtk_file_chooser_set_do_overwrite_confirmation
|
||||
gtk_file_chooser_get_do_overwrite_confirmation
|
||||
gtk_file_chooser_set_create_folders
|
||||
gtk_file_chooser_get_create_folders
|
||||
gtk_file_chooser_get_type G_GNUC_CONST
|
||||
gtk_file_chooser_get_uri
|
||||
gtk_file_chooser_get_uris
|
||||
|
@ -269,6 +269,22 @@ gtk_file_chooser_class_init (gpointer g_iface)
|
||||
"if necessary."),
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkFileChooser:create-folders:
|
||||
*
|
||||
* Whether a file chooser not in %GTK_FILE_CHOOSER_ACTION_OPEN mode
|
||||
* will offer the user to create new folders.
|
||||
*
|
||||
* Since: 2.18
|
||||
*/
|
||||
g_object_interface_install_property (g_iface,
|
||||
g_param_spec_boolean ("create-folders",
|
||||
P_("Allow folders creation"),
|
||||
P_("Whether a file chooser not in open mode "
|
||||
"will offer the user to create new folders."),
|
||||
TRUE,
|
||||
GTK_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -423,6 +439,49 @@ gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
|
||||
return select_multiple;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_chooser_set_create_folders:
|
||||
* @chooser: a #GtkFileChooser
|
||||
* @create_folders: %TRUE if the New Folder button should be displayed
|
||||
*
|
||||
* Sets whether file choser will offer to create new folders.
|
||||
* This is only relevant if the action is not set to be
|
||||
* GTK_FILE_CHOOSER_ACTION_OPEN.
|
||||
*
|
||||
* Since: 2.18
|
||||
**/
|
||||
void
|
||||
gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
|
||||
gboolean create_folders)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
|
||||
|
||||
g_object_set (chooser, "create-folders", create_folders, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_chooser_get_create_folders:
|
||||
* @chooser: a #GtkFileChooser
|
||||
*
|
||||
* Gets whether file choser will offer to create new folders.
|
||||
* See gtk_file_chooser_set_create_folders().
|
||||
*
|
||||
* Return value: %TRUE if the New Folder button should be displayed.
|
||||
*
|
||||
* Since: 2.18
|
||||
**/
|
||||
gboolean
|
||||
gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
|
||||
{
|
||||
gboolean create_folders;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
|
||||
|
||||
g_object_get (chooser, "create-folders", &create_folders, NULL);
|
||||
|
||||
return create_folders;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_chooser_get_filename:
|
||||
* @chooser: a #GtkFileChooser
|
||||
|
@ -85,6 +85,10 @@ void gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChoo
|
||||
gboolean do_overwrite_confirmation);
|
||||
gboolean gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser);
|
||||
|
||||
void gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
|
||||
gboolean create_folders);
|
||||
gboolean gtk_file_chooser_get_create_folders (GtkFileChooser *chooser);
|
||||
|
||||
/* Suggested name for the Save-type actions
|
||||
*/
|
||||
void gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
|
||||
|
@ -810,6 +810,7 @@ gtk_file_chooser_button_set_property (GObject *object,
|
||||
case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
|
||||
case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
|
||||
case GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION:
|
||||
case GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS:
|
||||
g_object_set_property (G_OBJECT (priv->dialog), pspec->name, value);
|
||||
break;
|
||||
|
||||
|
@ -801,6 +801,7 @@ _gtk_file_chooser_default_init (GtkFileChooserDefault *impl)
|
||||
impl->sort_column = FILE_LIST_COL_NAME;
|
||||
impl->sort_order = GTK_SORT_ASCENDING;
|
||||
impl->recent_manager = gtk_recent_manager_get_default ();
|
||||
impl->create_folders = TRUE;
|
||||
|
||||
gtk_box_set_spacing (GTK_BOX (impl), 12);
|
||||
|
||||
@ -5621,7 +5622,7 @@ update_appearance (GtkFileChooserDefault *impl)
|
||||
if (impl->location_entry)
|
||||
_gtk_file_chooser_entry_set_action (GTK_FILE_CHOOSER_ENTRY (impl->location_entry), impl->action);
|
||||
|
||||
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
|
||||
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN || !impl->create_folders)
|
||||
gtk_widget_hide (impl->browse_new_folder_button);
|
||||
else
|
||||
gtk_widget_show (impl->browse_new_folder_button);
|
||||
@ -5736,6 +5737,14 @@ gtk_file_chooser_default_set_property (GObject *object,
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS:
|
||||
{
|
||||
gboolean create_folders = g_value_get_boolean (value);
|
||||
impl->create_folders = create_folders;
|
||||
update_appearance (impl);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -5792,6 +5801,10 @@ gtk_file_chooser_default_get_property (GObject *object,
|
||||
g_value_set_boolean (value, impl->do_overwrite_confirmation);
|
||||
break;
|
||||
|
||||
case GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS:
|
||||
g_value_set_boolean (value, impl->create_folders);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -9211,7 +9224,7 @@ search_switch_to_browse_mode (GtkFileChooserDefault *impl)
|
||||
impl->search_entry = NULL;
|
||||
|
||||
gtk_widget_show (impl->browse_path_bar);
|
||||
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
|
||||
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN || !impl->create_folders)
|
||||
gtk_widget_hide (impl->browse_new_folder_button);
|
||||
else
|
||||
gtk_widget_show (impl->browse_new_folder_button);
|
||||
@ -9783,7 +9796,7 @@ recent_switch_to_browse_mode (GtkFileChooserDefault *impl)
|
||||
impl->recent_hbox = NULL;
|
||||
|
||||
gtk_widget_show (impl->browse_path_bar);
|
||||
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
|
||||
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN || !impl->create_folders)
|
||||
gtk_widget_hide (impl->browse_new_folder_button);
|
||||
else
|
||||
gtk_widget_show (impl->browse_new_folder_button);
|
||||
|
@ -308,6 +308,7 @@ struct _GtkFileChooserDefault
|
||||
guint has_search : 1;
|
||||
guint has_recent : 1;
|
||||
guint show_size_column : 1;
|
||||
guint create_folders : 1;
|
||||
|
||||
#if 0
|
||||
guint shortcuts_drag_outside : 1;
|
||||
|
@ -117,6 +117,9 @@ _gtk_file_chooser_install_properties (GObjectClass *klass)
|
||||
g_object_class_override_property (klass,
|
||||
GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION,
|
||||
"do-overwrite-confirmation");
|
||||
g_object_class_override_property (klass,
|
||||
GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS,
|
||||
"create-folders");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,8 @@ typedef enum {
|
||||
GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE,
|
||||
GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN,
|
||||
GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION,
|
||||
GTK_FILE_CHOOSER_PROP_LAST = GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION
|
||||
GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS,
|
||||
GTK_FILE_CHOOSER_PROP_LAST = GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS
|
||||
} GtkFileChooserProp;
|
||||
|
||||
void _gtk_file_chooser_install_properties (GObjectClass *klass);
|
||||
|
Loading…
Reference in New Issue
Block a user