]> Pileus Git - ~andy/gtk/commitdiff
Use g_message() throughout, add RTL envar for rtl testing.
authorMatthias Clasen <mclasen@redhat.com>
Tue, 17 Aug 2004 16:52:04 +0000 (16:52 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Tue, 17 Aug 2004 16:52:04 +0000 (16:52 +0000)
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.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkfilechooserbutton.c
gtk/gtkfilechooserbutton.h
tests/testfilechooserbutton.c

index ef058165c6ad857800bae7e24c316f27425b8865..009da4090649fc943825c4e5493a7ee79da23b9e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+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 
index ef058165c6ad857800bae7e24c316f27425b8865..009da4090649fc943825c4e5493a7ee79da23b9e 100644 (file)
@@ -1,3 +1,18 @@
+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 
index ef058165c6ad857800bae7e24c316f27425b8865..009da4090649fc943825c4e5493a7ee79da23b9e 100644 (file)
@@ -1,3 +1,18 @@
+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 
index ef058165c6ad857800bae7e24c316f27425b8865..009da4090649fc943825c4e5493a7ee79da23b9e 100644 (file)
@@ -1,3 +1,18 @@
+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 
index dfc1b68c413ebb8bbbdb7d56c7095033b6594a3d..dd7baeda0137f304537c83cd4ebabaa50a96517e 100644 (file)
@@ -20,9 +20,7 @@
  * 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>
@@ -55,7 +53,6 @@
 
 #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
 
@@ -102,13 +99,12 @@ struct _GtkFileChooserButtonPrivate
 
 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 }
 };
 
 
@@ -223,7 +219,7 @@ gtk_file_chooser_button_class_init (GtkFileChooserButtonClass * class)
                                   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",
@@ -288,11 +284,10 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
   /* 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));
 }
 
 
@@ -467,6 +462,7 @@ gtk_file_chooser_button_drag_data_received (GtkWidget            *widget,
                                            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,
@@ -514,7 +510,7 @@ gtk_file_chooser_button_drag_data_received (GtkWidget            *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)
                  {
@@ -549,11 +545,13 @@ gtk_file_chooser_button_drag_data_received (GtkWidget          *widget,
       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);
 }
 
 
@@ -752,7 +750,7 @@ gtk_file_chooser_button_set_dialog (GObject   *object,
   /* 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",
@@ -863,9 +861,12 @@ update_dialog (gpointer user_data)
       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
     {
@@ -901,8 +902,9 @@ update_dialog (gpointer user_data)
          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
@@ -1054,12 +1056,9 @@ button_toggled_cb (GtkToggleButton *real_button,
 
          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)));
            }
index 151bbaf5e9b3e4d942a806eaabe5717b1ea1afe8..ebbad4a17052792dc116e28d1de0b5814eef32b0 100644 (file)
  */
 
 #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
 
@@ -69,19 +69,17 @@ struct _GtkFileChooserButtonClass
 };
 
 
-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
index 9635e04a152ecd4fc39188877315dceb051725f0..21ae38dff4ff2c57c0c8ec7696fa45b51c4aa449 100644 (file)
@@ -68,7 +68,7 @@ chooser_selection_changed_cb (GtkFileChooser *chooser, gpointer user_data)
 {
   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))
     {
@@ -86,7 +86,7 @@ chooser_file_activated_cb (GtkFileChooser *chooser, gpointer user_data)
 
   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);
 }
@@ -98,7 +98,7 @@ chooser_update_preview_cb (GtkFileChooser *chooser, gpointer user_data)
   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);
 }
 
@@ -111,6 +111,10 @@ main (int argc, char *argv[])
 
   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);