]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfilechooserbutton.c
gtkdnd-quartz: use accessors and add missing include
[~andy/gtk] / gtk / gtkfilechooserbutton.c
index b7227a0becb901d1b4ad75f40ffc16e6a3c0cc1a..695664dc6507066ce2ab2e8edf27a72c18e27ca9 100644 (file)
 #include "gtkfilechooserbutton.h"
 
 #include "gtkprivate.h"
-#include "gtkalias.h"
 
 /* **************** *
  *  Private Macros  *
  * **************** */
 
-#define GTK_FILE_CHOOSER_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_FILE_CHOOSER_BUTTON, GtkFileChooserButtonPrivate))
-
 #define DEFAULT_TITLE          N_("Select A File")
 #define DESKTOP_DISPLAY_NAME   N_("Desktop")
 #define FALLBACK_DISPLAY_NAME  N_("(None)")
@@ -210,10 +207,8 @@ static void     gtk_file_chooser_button_get_property       (GObject          *ob
                                                            GParamSpec       *pspec);
 static void     gtk_file_chooser_button_finalize           (GObject          *object);
 
-/* GtkObject Functions */
-static void     gtk_file_chooser_button_destroy            (GtkObject        *object);
-
 /* GtkWidget Functions */
+static void     gtk_file_chooser_button_destroy            (GtkWidget        *widget);
 static void     gtk_file_chooser_button_drag_data_received (GtkWidget        *widget,
                                                            GdkDragContext   *context,
                                                            gint              x,
@@ -222,7 +217,6 @@ static void     gtk_file_chooser_button_drag_data_received (GtkWidget        *wi
                                                            guint             type,
                                                            guint             drag_time);
 static void     gtk_file_chooser_button_show_all           (GtkWidget        *widget);
-static void     gtk_file_chooser_button_hide_all           (GtkWidget        *widget);
 static void     gtk_file_chooser_button_show               (GtkWidget        *widget);
 static void     gtk_file_chooser_button_hide               (GtkWidget        *widget);
 static void     gtk_file_chooser_button_map                (GtkWidget        *widget);
@@ -320,11 +314,9 @@ static void
 gtk_file_chooser_button_class_init (GtkFileChooserButtonClass * class)
 {
   GObjectClass *gobject_class;
-  GtkObjectClass *gtkobject_class;
   GtkWidgetClass *widget_class;
 
   gobject_class = G_OBJECT_CLASS (class);
-  gtkobject_class = GTK_OBJECT_CLASS (class);
   widget_class = GTK_WIDGET_CLASS (class);
 
   gobject_class->constructor = gtk_file_chooser_button_constructor;
@@ -332,11 +324,9 @@ gtk_file_chooser_button_class_init (GtkFileChooserButtonClass * class)
   gobject_class->get_property = gtk_file_chooser_button_get_property;
   gobject_class->finalize = gtk_file_chooser_button_finalize;
 
-  gtkobject_class->destroy = gtk_file_chooser_button_destroy;
-
+  widget_class->destroy = gtk_file_chooser_button_destroy;
   widget_class->drag_data_received = gtk_file_chooser_button_drag_data_received;
   widget_class->show_all = gtk_file_chooser_button_show_all;
-  widget_class->hide_all = gtk_file_chooser_button_hide_all;
   widget_class->show = gtk_file_chooser_button_show;
   widget_class->hide = gtk_file_chooser_button_hide;
   widget_class->map = gtk_file_chooser_button_map;
@@ -435,7 +425,9 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
   GtkWidget *box, *image, *sep;
   GtkTargetList *target_list;
 
-  priv = button->priv = GTK_FILE_CHOOSER_BUTTON_GET_PRIVATE (button);
+  priv = button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button,
+                                                     GTK_TYPE_FILE_CHOOSER_BUTTON,
+                                                     GtkFileChooserButtonPrivate);
 
   priv->icon_size = FALLBACK_ICON_SIZE;
   priv->focus_on_click = TRUE;
@@ -449,7 +441,7 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
   gtk_container_add (GTK_CONTAINER (button), priv->button);
   gtk_widget_show (priv->button);
 
-  box = gtk_hbox_new (FALSE, 4);
+  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
   gtk_container_add (GTK_CONTAINER (priv->button), box);
   gtk_widget_show (box);
 
@@ -460,10 +452,11 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
   priv->label = gtk_label_new (_(FALLBACK_DISPLAY_NAME));
   gtk_label_set_ellipsize (GTK_LABEL (priv->label), PANGO_ELLIPSIZE_END);
   gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5);
-  gtk_container_add (GTK_CONTAINER (box), priv->label);
+  gtk_box_pack_start (GTK_BOX (box), priv->label, TRUE, TRUE, 0);
+  //gtk_container_add (GTK_CONTAINER (box), priv->label);
   gtk_widget_show (priv->label);
 
-  sep = gtk_vseparator_new ();
+  sep = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
   gtk_box_pack_start (GTK_BOX (box), sep, FALSE, FALSE, 0);
   gtk_widget_show (sep);
 
@@ -662,7 +655,7 @@ gtk_file_chooser_button_constructor (GType                  type,
 
       gtk_file_chooser_button_set_title (button, _(DEFAULT_TITLE));
     }
-  else if (!GTK_WINDOW (priv->dialog)->title)
+  else if (!gtk_window_get_title (GTK_WINDOW (priv->dialog)))
     {
       gtk_file_chooser_button_set_title (button, _(DEFAULT_TITLE));
     }
@@ -820,10 +813,6 @@ gtk_file_chooser_button_set_property (GObject      *object,
       fs_bookmarks_changed_cb (priv->fs, button);
       break;
 
-    case GTK_FILE_CHOOSER_PROP_FILE_SYSTEM_BACKEND:
-      /* Ignore property */
-      break;
-
     case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
       g_warning ("%s: Choosers of type `%s` do not support selecting multiple files.",
                 G_STRFUNC, G_OBJECT_TYPE_NAME (object));
@@ -856,7 +845,6 @@ gtk_file_chooser_button_get_property (GObject    *object,
 
     case PROP_TITLE:
     case GTK_FILE_CHOOSER_PROP_ACTION:
-    case GTK_FILE_CHOOSER_PROP_FILE_SYSTEM_BACKEND:
     case GTK_FILE_CHOOSER_PROP_FILTER:
     case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
     case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
@@ -889,13 +877,13 @@ gtk_file_chooser_button_finalize (GObject *object)
 }
 
 /* ********************* *
- *  GtkObject Functions  *
+ *  GtkWidget Functions  *
  * ********************* */
 
 static void
-gtk_file_chooser_button_destroy (GtkObject *object)
+gtk_file_chooser_button_destroy (GtkWidget *widget)
 {
-  GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (object);
+  GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (widget);
   GtkFileChooserButtonPrivate *priv = button->priv;
   GtkTreeIter iter;
   GSList *l;
@@ -955,14 +943,9 @@ gtk_file_chooser_button_destroy (GtkObject *object)
       priv->fs = NULL;
     }
 
-  GTK_OBJECT_CLASS (gtk_file_chooser_button_parent_class)->destroy (object);
+  GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->destroy (widget);
 }
 
-
-/* ********************* *
- *  GtkWidget Functions  *
- * ********************* */
-
 struct DndSelectFolderData
 {
   GtkFileSystem *file_system;
@@ -1058,7 +1041,7 @@ gtk_file_chooser_button_drag_data_received (GtkWidget          *widget,
                                                                                 data, type,
                                                                                 drag_time);
 
-  if (widget == NULL || context == NULL || data == NULL || data->length < 0)
+  if (widget == NULL || context == NULL || data == NULL || gtk_selection_data_get_length (data) < 0)
     return;
 
   switch (type)
@@ -1116,12 +1099,6 @@ gtk_file_chooser_button_show_all (GtkWidget *widget)
   gtk_widget_show (widget);
 }
 
-static void
-gtk_file_chooser_button_hide_all (GtkWidget *widget)
-{
-  gtk_widget_hide (widget);
-}
-
 static void
 gtk_file_chooser_button_show (GtkWidget *widget)
 {
@@ -1709,7 +1686,10 @@ model_add_special (GtkFileChooserButton *button)
 
   desktopdir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
 
-  if (desktopdir)
+  /* "To disable a directory, point it to the homedir."
+   * See http://freedesktop.org/wiki/Software/xdg-user-dirs
+   **/
+  if (g_strcmp0 (desktopdir, g_get_home_dir ()) != 0)
     {
       GtkTreePath *tree_path;
       GCancellable *cancellable;
@@ -2738,33 +2718,6 @@ gtk_file_chooser_button_new (const gchar          *title,
                       NULL);
 }
 
-/**
- * gtk_file_chooser_button_new_with_backend:
- * @title: the title of the browse dialog.
- * @action: the open mode for the widget.
- * @backend: the name of the #GtkFileSystem backend to use.
- * 
- * Creates a new file-selecting button widget using @backend.
- * 
- * Returns: a new button widget.
- * 
- * Since: 2.6
- * Deprecated: 2.14: Use gtk_file_chooser_button_new() instead.
- **/
-GtkWidget *
-gtk_file_chooser_button_new_with_backend (const gchar          *title,
-                                         GtkFileChooserAction  action,
-                                         const gchar          *backend)
-{
-  g_return_val_if_fail (action == GTK_FILE_CHOOSER_ACTION_OPEN ||
-                       action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, NULL);
-
-  return g_object_new (GTK_TYPE_FILE_CHOOSER_BUTTON,
-                      "action", action,
-                      "title", (title ? title : _(DEFAULT_TITLE)),
-                      NULL);
-}
-
 /**
  * gtk_file_chooser_button_new_with_dialog:
  * @dialog: the widget to use as dialog
@@ -2922,6 +2875,3 @@ gtk_file_chooser_button_get_focus_on_click (GtkFileChooserButton *button)
   
   return button->priv->focus_on_click;
 }
-
-#define __GTK_FILE_CHOOSER_BUTTON_C__
-#include "gtkaliasdef.c"