+2004-08-17 Matthias Clasen <mclasen@redhat.com>
+
+ * tests/testfilechooserbutton.c: Use g_message() throughout, add RTL envar for
+ rtl testing.
+
+ * gtk/gtkfilechooserbutton.c: Get rid of HAVE_CONFIG_H.
+ (gtk_file_chooser_button_init): Use gtk_drag_dest_add_text_targets().
+ (gtk_file_chooser_button_drag_data_received): Use gtk_selection_data_get_text().
+ (gtk_file_chooser_button_set_dialog): _gtk_file_chooser_entry_set_base_folder()
+ seems to expect a path, not an uri.
+ (update_dialog): Handle g_filename_from_uri() returning NULL, don't free
+ info if it is NULL.
+
+ * gtk/gtkfilechooserbutton.h: Minor stylistic changes.
+
2004-08-17 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserbutton.[hc]: New widget to go along with
+2004-08-17 Matthias Clasen <mclasen@redhat.com>
+
+ * tests/testfilechooserbutton.c: Use g_message() throughout, add RTL envar for
+ rtl testing.
+
+ * gtk/gtkfilechooserbutton.c: Get rid of HAVE_CONFIG_H.
+ (gtk_file_chooser_button_init): Use gtk_drag_dest_add_text_targets().
+ (gtk_file_chooser_button_drag_data_received): Use gtk_selection_data_get_text().
+ (gtk_file_chooser_button_set_dialog): _gtk_file_chooser_entry_set_base_folder()
+ seems to expect a path, not an uri.
+ (update_dialog): Handle g_filename_from_uri() returning NULL, don't free
+ info if it is NULL.
+
+ * gtk/gtkfilechooserbutton.h: Minor stylistic changes.
+
2004-08-17 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserbutton.[hc]: New widget to go along with
+2004-08-17 Matthias Clasen <mclasen@redhat.com>
+
+ * tests/testfilechooserbutton.c: Use g_message() throughout, add RTL envar for
+ rtl testing.
+
+ * gtk/gtkfilechooserbutton.c: Get rid of HAVE_CONFIG_H.
+ (gtk_file_chooser_button_init): Use gtk_drag_dest_add_text_targets().
+ (gtk_file_chooser_button_drag_data_received): Use gtk_selection_data_get_text().
+ (gtk_file_chooser_button_set_dialog): _gtk_file_chooser_entry_set_base_folder()
+ seems to expect a path, not an uri.
+ (update_dialog): Handle g_filename_from_uri() returning NULL, don't free
+ info if it is NULL.
+
+ * gtk/gtkfilechooserbutton.h: Minor stylistic changes.
+
2004-08-17 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserbutton.[hc]: New widget to go along with
+2004-08-17 Matthias Clasen <mclasen@redhat.com>
+
+ * tests/testfilechooserbutton.c: Use g_message() throughout, add RTL envar for
+ rtl testing.
+
+ * gtk/gtkfilechooserbutton.c: Get rid of HAVE_CONFIG_H.
+ (gtk_file_chooser_button_init): Use gtk_drag_dest_add_text_targets().
+ (gtk_file_chooser_button_drag_data_received): Use gtk_selection_data_get_text().
+ (gtk_file_chooser_button_set_dialog): _gtk_file_chooser_entry_set_base_folder()
+ seems to expect a path, not an uri.
+ (update_dialog): Handle g_filename_from_uri() returning NULL, don't free
+ info if it is NULL.
+
+ * gtk/gtkfilechooserbutton.h: Minor stylistic changes.
+
2004-08-17 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserbutton.[hc]: New widget to go along with
* Boston, MA 02111-1307, USA.
*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
#include <sys/types.h>
#include <sys/stat.h>
#define GTK_FILE_CHOOSER_BUTTON_GET_PRIVATE(object) (GTK_FILE_CHOOSER_BUTTON ((object))->priv)
-#define DEFAULT_TITLE N_("Select a File")
#define DEFAULT_FILENAME N_("(None)")
#define DEFAULT_SPACING 0
enum
{
- TEXT_URI_LIST,
- TEXT_PLAIN
+ TEXT_PLAIN,
+ TEXT_URI_LIST
};
static const GtkTargetEntry drop_targets[] = {
- { "text/uri-list", 0, TEXT_URI_LIST },
- { "text/plain", 0, TEXT_PLAIN }
+ { "text/uri-list", 0, TEXT_URI_LIST }
};
g_param_spec_string ("title",
P_("Title"),
P_("The title of the file chooser dialog."),
- _(DEFAULT_TITLE),
+ _("Select a File"),
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_ACTIVE,
g_param_spec_boolean ("active",
/* DnD */
gtk_drag_dest_unset (priv->entry);
gtk_drag_dest_set (GTK_WIDGET (button),
- (GTK_DEST_DEFAULT_MOTION |
- GTK_DEST_DEFAULT_HIGHLIGHT |
- GTK_DEST_DEFAULT_DROP),
+ (GTK_DEST_DEFAULT_ALL),
drop_targets, G_N_ELEMENTS (drop_targets),
GDK_ACTION_COPY);
+ gtk_drag_dest_add_text_targets (GTK_WIDGET (button));
}
guint drag_time)
{
GtkFileChooserButtonPrivate *priv;
+ gchar *text;
if (GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->drag_data_received != NULL)
(*GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->drag_data_received) (widget,
GTK_FILE_INFO_IS_FOLDER,
NULL);
- info = gtk_file_folder_get_info (folder, base_path, NULL);
+ info = gtk_file_folder_get_info (folder, path, NULL);
if (info != NULL)
{
break;
case TEXT_PLAIN:
- gtk_entry_set_text (GTK_ENTRY (priv->entry), data->data);
+ text = gtk_selection_data_get_text (data);
+ gtk_entry_set_text (GTK_ENTRY (priv->entry), text);
+ g_free (text);
break;
}
- gtk_drag_finish (context, FALSE, FALSE, drag_time);
+ gtk_drag_finish (context, TRUE, FALSE, drag_time);
}
/* Kinda ugly to set this here... */
_gtk_file_chooser_entry_set_file_system (GTK_FILE_CHOOSER_ENTRY (priv->entry),
_gtk_file_chooser_get_file_system (GTK_FILE_CHOOSER (priv->dialog)));
- path = gtk_file_path_new_steal ("file:///");
+ path = gtk_file_path_new_steal ("/");
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (priv->entry),
path);
priv->entry_changed_id = g_signal_connect_after (priv->entry, "changed",
gchar *display_name;
display_name = g_filename_from_uri (full_uri, NULL, NULL);
- display_name = get_display_name (display_name);
- gtk_label_set_text (GTK_LABEL (priv->label), display_name);
- g_free (display_name);
+ if (display_name)
+ {
+ display_name = get_display_name (display_name);
+ gtk_label_set_text (GTK_LABEL (priv->label), display_name);
+ g_free (display_name);
+ }
}
else
{
else
_gtk_file_chooser_select_path (GTK_FILE_CHOOSER (priv->dialog),
full_path, NULL);
-
- gtk_file_info_free (info);
+
+ if (info)
+ gtk_file_info_free (info);
gtk_file_path_free (full_path);
}
else
if (GTK_WIDGET_TOPLEVEL (toplevel) && GTK_IS_WINDOW (toplevel))
{
- if (GTK_WINDOW (toplevel) !=
- gtk_window_get_transient_for (GTK_WINDOW (priv->dialog)))
- {
- gtk_window_set_transient_for (GTK_WINDOW (priv->dialog),
- GTK_WINDOW (toplevel));
- }
+ if (GTK_WINDOW (toplevel) != gtk_window_get_transient_for (GTK_WINDOW (priv->dialog)))
+ gtk_window_set_transient_for (GTK_WINDOW (priv->dialog), GTK_WINDOW (toplevel));
+
gtk_window_set_modal (GTK_WINDOW (priv->dialog),
gtk_window_get_modal (GTK_WINDOW (toplevel)));
}
*/
#ifndef __GTK_FILE_CHOOSER_BUTTON_H__
-#define __GTK_FILE_CHOOSER_BUTTON_H__ 1
+#define __GTK_FILE_CHOOSER_BUTTON_H__
-#include "gtkhbox.h"
-#include "gtkfilechooser.h"
+#include <gtk/gtkhbox.h>
+#include <gtk/gtkfilechooser.h>
G_BEGIN_DECLS
};
-GType gtk_file_chooser_button_get_type (void) G_GNUC_CONST;
-
-GtkWidget *gtk_file_chooser_button_new (const gchar *title);
-GtkWidget *gtk_file_chooser_button_new_with_backend (const gchar *title,
- const gchar *backend);
-GtkWidget *gtk_file_chooser_button_new_with_dialog (GtkWidget *dialog);
-
-G_CONST_RETURN gchar *gtk_file_chooser_button_get_title (GtkFileChooserButton *button);
-void gtk_file_chooser_button_set_title (GtkFileChooserButton *button,
- const gchar *title);
-gboolean gtk_file_chooser_button_get_active (GtkFileChooserButton *button);
-void gtk_file_chooser_button_set_active (GtkFileChooserButton *button,
- gboolean is_active);
+GType gtk_file_chooser_button_get_type (void) G_GNUC_CONST;
+GtkWidget * gtk_file_chooser_button_new (const gchar *title);
+GtkWidget * gtk_file_chooser_button_new_with_backend (const gchar *title,
+ const gchar *backend);
+GtkWidget * gtk_file_chooser_button_new_with_dialog (GtkWidget *dialog);
+G_CONST_RETURN gchar *gtk_file_chooser_button_get_title (GtkFileChooserButton *button);
+void gtk_file_chooser_button_set_title (GtkFileChooserButton *button,
+ const gchar *title);
+gboolean gtk_file_chooser_button_get_active (GtkFileChooserButton *button);
+void gtk_file_chooser_button_set_active (GtkFileChooserButton *button,
+ gboolean is_active);
G_END_DECLS
{
GSList *selection;
- g_warning ("%s:%s:\n`%s` Selection:", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser));
+ g_message ("%s:%s:\n`%s` Selection:", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser));
for (selection = gtk_file_chooser_get_filenames (chooser); selection != NULL;
selection = g_slist_remove_link (selection, selection))
{
folder = gtk_file_chooser_get_current_folder (chooser);
filename = gtk_file_chooser_get_filename (chooser);
- g_warning ("%s:%s:\n`%s`\nFolder: `%s'\nFilename: `%s'", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser), folder, filename);
+ g_message ("%s:%s:\n`%s`\nFolder: `%s'\nFilename: `%s'", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser), folder, filename);
g_free (folder);
g_free (filename);
}
gchar *filename;
filename = gtk_file_chooser_get_preview_filename (chooser);
- g_warning ("%s:%s:\n`%s`\nPreview Filename: `%s'", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser), filename);
+ g_message ("%s:%s:\n`%s`\nPreview Filename: `%s'", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser), filename);
g_free (filename);
}
gtk_init (&argc, &argv);
+ /* to test rtl layout, set RTL=1 in the environment */
+ if (g_getenv ("RTL"))
+ gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
+
win = gtk_dialog_new_with_buttons ("TestFileChooserButton", NULL, GTK_DIALOG_NO_SEPARATOR,
GTK_STOCK_QUIT, GTK_RESPONSE_CLOSE, NULL);
g_signal_connect (win, "style-set", G_CALLBACK (win_style_set_cb), NULL);