Commit e9465843 authored by Federico Mena Quintero's avatar Federico Mena Quintero Committed by Federico Mena Quintero

Do not create the save mode-specific widgets in the open modes, so that we

2005-09-26  Federico Mena Quintero  <federico@ximian.com>

	Do not create the save mode-specific widgets in the open modes, so
	that we don't carry their baggage around.

	* gtk/gtkfilechooserdefault.c
	(gtk_file_chooser_default_constructor): Don't create the
	save_widgets here.
	(save_widgets_create): Set the impl->save_widgets directly here,
	instead of passing the widgets back to the caller.  Also, pack
	them into the impl's box.
	(update_appearance): Create or destroy the save widgets as
	appropriate.  Set the action of the save_file_name_entry here.
	(shortcuts_add_current_folder): Set the active item in the
	save_folder_combo only if it exists.
	(gtk_file_chooser_default_set_property): Don't set the action of
	the save_file_name_entry here.
	(gtk_file_chooser_default_update_current_folder): Set the base
	folder of the save_file_name_entry only if the entry exists.
	(shortcuts_drag_data_received_cb): Cast the selection_data->data
	to (const char *) since that's what shortcuts_drop_uris() expects.
	(file_list_drag_data_received_cb): Likewise, for
	g_uri_list_extract_uris().
parent bca0cefe
2005-09-26 Federico Mena Quintero <federico@ximian.com>
Do not create the save mode-specific widgets in the open modes, so
that we don't carry their baggage around.
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_constructor): Don't create the
save_widgets here.
(save_widgets_create): Set the impl->save_widgets directly here,
instead of passing the widgets back to the caller. Also, pack
them into the impl's box.
(update_appearance): Create or destroy the save widgets as
appropriate. Set the action of the save_file_name_entry here.
(shortcuts_add_current_folder): Set the active item in the
save_folder_combo only if it exists.
(gtk_file_chooser_default_set_property): Don't set the action of
the save_file_name_entry here.
(gtk_file_chooser_default_update_current_folder): Set the base
folder of the save_file_name_entry only if the entry exists.
(shortcuts_drag_data_received_cb): Cast the selection_data->data
to (const char *) since that's what shortcuts_drop_uris() expects.
(file_list_drag_data_received_cb): Likewise, for
g_uri_list_extract_uris().
2005-09-26 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkwindow-win32.c (gdk_window_shape_combine_mask): Set
......
2005-09-26 Federico Mena Quintero <federico@ximian.com>
Do not create the save mode-specific widgets in the open modes, so
that we don't carry their baggage around.
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_constructor): Don't create the
save_widgets here.
(save_widgets_create): Set the impl->save_widgets directly here,
instead of passing the widgets back to the caller. Also, pack
them into the impl's box.
(update_appearance): Create or destroy the save widgets as
appropriate. Set the action of the save_file_name_entry here.
(shortcuts_add_current_folder): Set the active item in the
save_folder_combo only if it exists.
(gtk_file_chooser_default_set_property): Don't set the action of
the save_file_name_entry here.
(gtk_file_chooser_default_update_current_folder): Set the base
folder of the save_file_name_entry only if the entry exists.
(shortcuts_drag_data_received_cb): Cast the selection_data->data
to (const char *) since that's what shortcuts_drop_uris() expects.
(file_list_drag_data_received_cb): Likewise, for
g_uri_list_extract_uris().
2005-09-26 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkwindow-win32.c (gdk_window_shape_combine_mask): Set
......
......@@ -1688,7 +1688,7 @@ shortcuts_add_current_folder (GtkFileChooserDefault *impl)
impl->shortcuts_current_folder_active = success;
}
if (success)
if (success && impl->save_folder_combo != NULL)
gtk_combo_box_set_active (GTK_COMBO_BOX (impl->save_folder_combo), pos);
}
......@@ -2857,7 +2857,7 @@ shortcuts_drag_data_received_cb (GtkWidget *widget,
position -= bookmarks_index;
if (selection_data->target == gdk_atom_intern_static_string ("text/uri-list"))
shortcuts_drop_uris (impl, selection_data->data, position);
shortcuts_drop_uris (impl, (const char *) selection_data->data, position);
else if (selection_data->target == gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW"))
shortcuts_reorder (impl, position);
......@@ -3356,7 +3356,7 @@ file_list_drag_data_received_cb (GtkWidget *widget,
chooser = GTK_FILE_CHOOSER (data);
/* Parse the text/uri-list string, navigate to the first one */
uris = g_uri_list_extract_uris (selection_data->data);
uris = g_uri_list_extract_uris ((const char *) selection_data->data);
if (uris[0])
{
uri = uris[0];
......@@ -3795,6 +3795,7 @@ file_pane_create (GtkFileChooserDefault *impl,
return vbox;
}
/* Callback used when the "Browse for more folders" expander is toggled */
static void
expander_changed_cb (GtkExpander *expander,
......@@ -3858,7 +3859,7 @@ save_folder_combo_create (GtkFileChooserDefault *impl)
}
/* Creates the widgets specific to Save mode */
static GtkWidget *
static void
save_widgets_create (GtkFileChooserDefault *impl)
{
GtkWidget *vbox;
......@@ -3866,6 +3867,9 @@ save_widgets_create (GtkFileChooserDefault *impl)
GtkWidget *widget;
GtkWidget *alignment;
if (impl->save_widgets != NULL)
return;
vbox = gtk_vbox_new (FALSE, 12);
table = gtk_table_new (2, 2, FALSE);
......@@ -3923,7 +3927,25 @@ save_widgets_create (GtkFileChooserDefault *impl)
impl);
gtk_widget_show_all (alignment);
return vbox;
impl->save_widgets = vbox;
gtk_box_pack_start (GTK_BOX (impl), impl->save_widgets, FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (impl), impl->save_widgets, 0);
gtk_widget_show (impl->save_widgets);
}
/* Destroys the widgets specific to Save mode */
static void
save_widgets_destroy (GtkFileChooserDefault *impl)
{
if (impl->save_widgets == NULL)
return;
gtk_widget_destroy (impl->save_widgets);
impl->save_widgets = NULL;
impl->save_file_name_entry = NULL;
impl->save_folder_label = NULL;
impl->save_folder_combo = NULL;
impl->save_expander = NULL;
}
/* Creates the main hpaned with the widgets shared by Open and Save mode */
......@@ -3976,10 +3998,6 @@ gtk_file_chooser_default_constructor (GType type,
shortcuts_model_create (impl);
/* Widgets for Save mode */
impl->save_widgets = save_widgets_create (impl);
gtk_box_pack_start (GTK_BOX (impl), impl->save_widgets, FALSE, FALSE, 0);
/* The browse widgets */
impl->browse_widgets = browse_widgets_create (impl);
gtk_box_pack_start (GTK_BOX (impl), impl->browse_widgets, TRUE, TRUE, 0);
......@@ -4168,7 +4186,7 @@ update_appearance (GtkFileChooserDefault *impl)
{
const char *text;
gtk_widget_show (impl->save_widgets);
save_widgets_create (impl);
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
text = _("Save in _folder:");
......@@ -4177,6 +4195,8 @@ update_appearance (GtkFileChooserDefault *impl)
gtk_label_set_text_with_mnemonic (GTK_LABEL (impl->save_folder_label), text);
_gtk_file_chooser_entry_set_action (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry), impl->action);
if (gtk_expander_get_expanded (GTK_EXPANDER (impl->save_expander)))
{
gtk_widget_set_sensitive (impl->save_folder_label, FALSE);
......@@ -4202,7 +4222,7 @@ update_appearance (GtkFileChooserDefault *impl)
else if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
gtk_widget_hide (impl->save_widgets);
save_widgets_destroy (impl);
gtk_widget_show (impl->browse_widgets);
}
......@@ -4211,6 +4231,9 @@ update_appearance (GtkFileChooserDefault *impl)
else
gtk_widget_show (impl->browse_new_folder_button);
/* This *is* needed; we need to redraw the file list because the "sensitivity"
* of files may change depending whether we are in a file or folder-only mode.
*/
gtk_widget_queue_draw (impl->browse_files_tree_view);
g_signal_emit_by_name (impl, "default-size-changed");
......@@ -4246,10 +4269,6 @@ gtk_file_chooser_default_set_property (GObject *object,
impl->action = action;
update_appearance (impl);
}
if (impl->save_file_name_entry)
_gtk_file_chooser_entry_set_action (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry),
action);
}
break;
......@@ -5249,8 +5268,9 @@ gtk_file_chooser_default_update_current_folder (GtkFileChooser *chooser,
/* Set the folder on the save entry */
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry),
impl->current_folder);
if (impl->save_file_name_entry)
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry),
impl->current_folder);
/* Create a new list model. This is slightly evil; we store the result value
* but perform more actions rather than returning immediately even if it
......@@ -6229,7 +6249,7 @@ gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed)
g_assert_not_reached ();
}
}
else if (current_focus == impl->save_file_name_entry)
else if ((impl->save_file_name_entry != NULL) && (current_focus == impl->save_file_name_entry))
{
GtkFilePath *path;
gboolean is_well_formed, is_empty, is_file_part_empty;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment