Commit 350559de authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Remove leftover debug code.

2004-09-17  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render): Remove
	leftover debug code.

	Improve the behaviour of the file chooser in save mode. Fixes bugs
	#151031, #151608, #151994 reported by Owen Taylor and Alexander
	Larsson.

	* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_set_property):
	(location_entry_create): Propagate the action to the file
	chooser entries.
	(gtk_file_chooser_default_should_respond): Switch folders if
	the user enters a directory name in the entry and clear the entry
	after switching folders.
	(gtk_file_chooser_default_should_respond, shortcuts_row_activated_cb):
	Move focus to the file list when activating a shortcut.
	(gtk_file_chooser_default_should_respond): Handle the case where the
	user clicks on "Save" after selecting a folder in the file list.

	* gtk/gtkfilechooserbutton.c (gtk_file_chooser_button_set_property):
	Propagate the action to the file chooser entries.

	* gtk/gtkfilechooserentry.h:
	* gtk/gtkfilechooserentry.c (_gtk_file_chooser_entry_set_action):
	(_gtk_file_chooser_entry_get_action): New functions to propagate
	the GtkFileChooserAction of the file chooser to the file chooser
	entry.
	(check_completion_callback): If we are in save mode, only do
	inline completion for directories.
parent 4e7e4049
2004-09-17 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render): Remove
leftover debug code.
Improve the behaviour of the file chooser in save mode. Fixes bugs
#151031, #151608, #151994 reported by Owen Taylor and Alexander
Larsson.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_set_property):
(location_entry_create): Propagate the action to the file
chooser entries.
(gtk_file_chooser_default_should_respond): Switch folders if
the user enters a directory name in the entry and clear the entry
after switching folders.
(gtk_file_chooser_default_should_respond, shortcuts_row_activated_cb):
Move focus to the file list when activating a shortcut.
(gtk_file_chooser_default_should_respond): Handle the case where the
user clicks on "Save" after selecting a folder in the file list.
* gtk/gtkfilechooserbutton.c (gtk_file_chooser_button_set_property):
Propagate the action to the file chooser entries.
* gtk/gtkfilechooserentry.h:
* gtk/gtkfilechooserentry.c (_gtk_file_chooser_entry_set_action):
(_gtk_file_chooser_entry_get_action): New functions to propagate
the GtkFileChooserAction of the file chooser to the file chooser
entry.
(check_completion_callback): If we are in save mode, only do
inline completion for directories.
Fri Sep 17 11:20:03 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtklabel.c (gtk_label_set_markup): Add an example to the
......
2004-09-17 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render): Remove
leftover debug code.
Improve the behaviour of the file chooser in save mode. Fixes bugs
#151031, #151608, #151994 reported by Owen Taylor and Alexander
Larsson.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_set_property):
(location_entry_create): Propagate the action to the file
chooser entries.
(gtk_file_chooser_default_should_respond): Switch folders if
the user enters a directory name in the entry and clear the entry
after switching folders.
(gtk_file_chooser_default_should_respond, shortcuts_row_activated_cb):
Move focus to the file list when activating a shortcut.
(gtk_file_chooser_default_should_respond): Handle the case where the
user clicks on "Save" after selecting a folder in the file list.
* gtk/gtkfilechooserbutton.c (gtk_file_chooser_button_set_property):
Propagate the action to the file chooser entries.
* gtk/gtkfilechooserentry.h:
* gtk/gtkfilechooserentry.c (_gtk_file_chooser_entry_set_action):
(_gtk_file_chooser_entry_get_action): New functions to propagate
the GtkFileChooserAction of the file chooser to the file chooser
entry.
(check_completion_callback): If we are in save mode, only do
inline completion for directories.
Fri Sep 17 11:20:03 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtklabel.c (gtk_label_set_markup): Add an example to the
......
2004-09-17 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render): Remove
leftover debug code.
Improve the behaviour of the file chooser in save mode. Fixes bugs
#151031, #151608, #151994 reported by Owen Taylor and Alexander
Larsson.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_set_property):
(location_entry_create): Propagate the action to the file
chooser entries.
(gtk_file_chooser_default_should_respond): Switch folders if
the user enters a directory name in the entry and clear the entry
after switching folders.
(gtk_file_chooser_default_should_respond, shortcuts_row_activated_cb):
Move focus to the file list when activating a shortcut.
(gtk_file_chooser_default_should_respond): Handle the case where the
user clicks on "Save" after selecting a folder in the file list.
* gtk/gtkfilechooserbutton.c (gtk_file_chooser_button_set_property):
Propagate the action to the file chooser entries.
* gtk/gtkfilechooserentry.h:
* gtk/gtkfilechooserentry.c (_gtk_file_chooser_entry_set_action):
(_gtk_file_chooser_entry_get_action): New functions to propagate
the GtkFileChooserAction of the file chooser to the file chooser
entry.
(check_completion_callback): If we are in save mode, only do
inline completion for directories.
Fri Sep 17 11:20:03 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtklabel.c (gtk_label_set_markup): Add an example to the
......
2004-09-17 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render): Remove
leftover debug code.
Improve the behaviour of the file chooser in save mode. Fixes bugs
#151031, #151608, #151994 reported by Owen Taylor and Alexander
Larsson.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_set_property):
(location_entry_create): Propagate the action to the file
chooser entries.
(gtk_file_chooser_default_should_respond): Switch folders if
the user enters a directory name in the entry and clear the entry
after switching folders.
(gtk_file_chooser_default_should_respond, shortcuts_row_activated_cb):
Move focus to the file list when activating a shortcut.
(gtk_file_chooser_default_should_respond): Handle the case where the
user clicks on "Save" after selecting a folder in the file list.
* gtk/gtkfilechooserbutton.c (gtk_file_chooser_button_set_property):
Propagate the action to the file chooser entries.
* gtk/gtkfilechooserentry.h:
* gtk/gtkfilechooserentry.c (_gtk_file_chooser_entry_set_action):
(_gtk_file_chooser_entry_get_action): New functions to propagate
the GtkFileChooserAction of the file chooser to the file chooser
entry.
(check_completion_callback): If we are in save mode, only do
inline completion for directories.
Fri Sep 17 11:20:03 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtklabel.c (gtk_label_set_markup): Add an example to the
......
......@@ -1416,8 +1416,6 @@ gtk_cell_renderer_text_get_size (GtkCellRenderer *cell,
(1.0 - cell->xalign) : cell->xalign) * (cell_area->width - rect.width - (2 * cell->xpad));
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
*x_offset -= rect.width;
if (celltext->text && !strcmp ("Makefile", celltext->text))
g_print ("x_offset: %d %d %d\n", cell_area->width, *x_offset, rect.width);
*x_offset = MAX (*x_offset, 0);
}
if (y_offset)
......@@ -1509,8 +1507,6 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell,
else
pango_layout_set_width (layout, -1);
if (celltext->text && !strcmp ("Makefile", celltext->text))
g_print ("render: %d %d %d\n", cell_area->x, cell_area->width, cell_area->x + x_offset + cell->xpad);
gtk_paint_layout (widget->style,
window,
state,
......@@ -1521,12 +1517,6 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell,
cell_area->x + x_offset + cell->xpad,
cell_area->y + y_offset + cell->ypad,
layout);
gdk_draw_line (window, widget->style->black_gc,
cell_area->x + x_offset + cell->xpad,
cell_area->y + y_offset + cell->ypad,
cell_area->x + x_offset + cell->xpad,
cell_area->y + y_offset + cell->ypad + 20);
g_object_unref (layout);
}
......
......@@ -340,6 +340,7 @@ gtk_file_chooser_button_set_property (GObject *object,
case GTK_FILE_CHOOSER_PROP_ACTION:
g_object_set_property (G_OBJECT (priv->dialog), pspec->name, value);
_gtk_file_chooser_entry_set_action (priv->entry, g_value_get_enum (value));
switch (g_value_get_enum (value))
{
......
......@@ -3644,6 +3644,10 @@ 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;
case GTK_FILE_CHOOSER_PROP_FILE_SYSTEM_BACKEND:
......@@ -4933,20 +4937,26 @@ gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed)
gboolean is_valid, is_empty;
gboolean is_folder;
gboolean retval;
GtkFileChooserEntry *entry;
save_entry:
g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
entry = GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry);
path = check_save_entry (impl, &is_valid, &is_empty);
if (!is_valid)
if (!is_empty && !is_valid)
return FALSE;
if (is_empty)
path = gtk_file_path_copy (_gtk_file_chooser_entry_get_current_folder (entry));
is_folder = check_is_folder (impl->file_system, path, NULL);
if (is_folder)
{
_gtk_file_chooser_entry_set_file_part (entry, "");
change_folder_and_display_error (impl, path);
retval = FALSE;
}
......@@ -4965,15 +4975,31 @@ gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed)
GtkTreeIter iter;
if (shortcuts_get_selected (impl, &iter))
shortcuts_activate_iter (impl, &iter);
{
shortcuts_activate_iter (impl, &iter);
gtk_widget_grab_focus (impl->browse_files_tree_view);
}
else
goto file_list;
return FALSE;
}
else if (impl->toplevel_last_focus_widget == impl->browse_files_tree_view)
{
/* The focus is on a dialog's action area button, *and* the widget that
* was focused immediately before it is the file list.
*/
goto file_list;
}
else
goto file_list; /* The focus is on a dialog's action area button or something else */
/* The focus is on a dialog's action area button or something else */
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
goto save_entry;
else
goto file_list;
g_assert_not_reached ();
return FALSE;
}
......@@ -5174,13 +5200,14 @@ shortcuts_activate_iter (GtkFileChooserDefault *impl,
-1);
if (!col_data)
return; /* We are on a separator */
return FALSE; /* We are on a separator */
if (is_volume)
{
GtkFileSystemVolume *volume;
volume = col_data;
shortcuts_activate_volume (impl, volume);
}
else
......@@ -5209,6 +5236,8 @@ shortcuts_row_activated_cb (GtkTreeView *tree_view,
&child_iter,
&iter);
shortcuts_activate_iter (impl, &child_iter);
gtk_widget_grab_focus (impl->browse_files_tree_view);
}
/* Handler for GtkWidget::key-press-event on the shortcuts list */
......@@ -5500,7 +5529,7 @@ location_entry_create (GtkFileChooserDefault *impl)
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
_gtk_file_chooser_entry_set_file_system (GTK_FILE_CHOOSER_ENTRY (entry), impl->file_system);
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (entry), impl->current_folder);
_gtk_file_chooser_entry_set_action (GTK_FILE_CHOOSER_ENTRY (entry), impl->action);
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
|| impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
_gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (entry), "");
......
......@@ -43,6 +43,8 @@ struct _GtkFileChooserEntry
{
GtkEntry parent_instance;
GtkFileChooserAction action;
GtkFileSystem *file_system;
GtkFilePath *base_folder;
GtkFilePath *current_folder_path;
......@@ -175,6 +177,7 @@ gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry)
GtkCellRenderer *cell;
comp = gtk_entry_completion_new ();
gtk_entry_completion_set_match_func (comp,
completion_match_func,
chooser_entry,
......@@ -451,6 +454,19 @@ check_completion_callback (GtkFileChooserEntry *chooser_entry)
gtk_file_path_free (unique_path);
}
switch (chooser_entry->action)
{
case GTK_FILE_CHOOSER_ACTION_SAVE:
case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:
if (common_prefix && !g_str_has_suffix (common_prefix, "/"))
{
g_free (common_prefix);
common_prefix = NULL;
}
break;
default: ;
}
if (common_prefix)
{
gint file_part_len;
......@@ -874,6 +890,11 @@ _gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry,
const GtkFilePath *
_gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry)
{
if (chooser_entry->has_completion)
{
gtk_editable_set_position (GTK_EDITABLE (chooser_entry),
GTK_ENTRY (chooser_entry)->text_length);
}
return chooser_entry->current_folder_path;
}
......@@ -892,6 +913,11 @@ _gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry)
const gchar *
_gtk_file_chooser_entry_get_file_part (GtkFileChooserEntry *chooser_entry)
{
if (chooser_entry->has_completion)
{
gtk_editable_set_position (GTK_EDITABLE (chooser_entry),
GTK_ENTRY (chooser_entry)->text_length);
}
return chooser_entry->file_part;
}
......@@ -910,3 +936,43 @@ _gtk_file_chooser_entry_set_file_part (GtkFileChooserEntry *chooser_entry,
gtk_entry_set_text (GTK_ENTRY (chooser_entry), file_part);
}
/**
* _gtk_file_chooser_entry_set_action:
* @chooser_entry: a #GtkFileChooserEntry
* @action: the action which is performed by the file selector using this entry
*
* Sets action which is performed by the file selector using this entry.
* The #GtkFileChooserEntry will use different completion strategies for
* different actions.
**/
void
_gtk_file_chooser_entry_set_action (GtkFileChooserEntry *chooser_entry,
GtkFileChooserAction action)
{
g_return_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (chooser_entry));
if ( chooser_entry->action != action)
{
chooser_entry->action = action;
}
}
/**
* _gtk_file_chooser_entry_get_action:
* @chooser_entry: a #GtkFileChooserEntry
*
* Gets the action for this entry.
*
* Returns: the action
**/
GtkFileChooserAction
_gtk_file_chooser_entry_get_action (GtkFileChooserEntry *chooser_entry)
{
g_return_val_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (chooser_entry),
GTK_FILE_CHOOSER_ACTION_OPEN);
return chooser_entry->action;
}
......@@ -22,6 +22,7 @@
#define __GTK_FILE_CHOOSER_ENTRY_H__
#include "gtkfilesystem.h"
#include "gtkfilechooser.h"
#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
......@@ -34,6 +35,9 @@ typedef struct _GtkFileChooserEntry GtkFileChooserEntry;
GType _gtk_file_chooser_entry_get_type (void);
GtkWidget * _gtk_file_chooser_entry_new (gboolean eat_tab);
void _gtk_file_chooser_entry_set_action (GtkFileChooserEntry *chooser_entry,
GtkFileChooserAction action);
GtkFileChooserAction _gtk_file_chooser_entry_get_action (GtkFileChooserEntry *chooser_entry);
void _gtk_file_chooser_entry_set_file_system (GtkFileChooserEntry *chooser_entry,
GtkFileSystem *file_system);
void _gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry,
......
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