2013-02-12 05:03:26 +00:00
|
|
|
|
/* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
/* GTK+: gtkfilechooserbutton.c
|
2013-03-12 17:02:38 +00:00
|
|
|
|
*
|
2004-08-17 16:06:39 +00:00
|
|
|
|
* Copyright (c) 2004 James M. Cape <jcape@ignore-your.tv>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Library General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2004-08-17 16:06:39 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/stat.h>
|
2004-09-01 16:42:09 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
2004-08-17 16:06:39 +00:00
|
|
|
|
#include <unistd.h>
|
2004-09-01 16:42:09 +00:00
|
|
|
|
#endif
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
#include <string.h>
|
2017-01-18 21:21:42 +00:00
|
|
|
|
#include <cairo-gobject.h>
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
#include "gtkintl.h"
|
2019-09-10 11:11:03 +00:00
|
|
|
|
#include "gtkbookmarksmanagerprivate.h"
|
2004-11-30 21:06:48 +00:00
|
|
|
|
#include "gtkbutton.h"
|
2004-12-16 04:57:18 +00:00
|
|
|
|
#include "gtkcelllayout.h"
|
2004-12-16 19:13:58 +00:00
|
|
|
|
#include "gtkcellrenderertext.h"
|
2004-12-16 04:57:18 +00:00
|
|
|
|
#include "gtkcellrendererpixbuf.h"
|
2004-12-15 14:58:39 +00:00
|
|
|
|
#include "gtkcombobox.h"
|
2015-12-02 02:18:26 +00:00
|
|
|
|
#include "gtkcssiconthemevalueprivate.h"
|
2015-12-13 23:43:10 +00:00
|
|
|
|
#include "gtkdragdest.h"
|
2004-08-17 16:06:39 +00:00
|
|
|
|
#include "gtkicontheme.h"
|
|
|
|
|
#include "gtkimage.h"
|
|
|
|
|
#include "gtklabel.h"
|
2004-12-15 14:58:39 +00:00
|
|
|
|
#include "gtkliststore.h"
|
|
|
|
|
#include "gtktreemodelfilter.h"
|
2011-06-08 14:23:53 +00:00
|
|
|
|
#include "gtkseparator.h"
|
2004-08-17 16:06:39 +00:00
|
|
|
|
#include "gtkfilechooserdialog.h"
|
2015-10-29 14:13:14 +00:00
|
|
|
|
#include "gtkfilechoosernative.h"
|
2004-08-17 16:06:39 +00:00
|
|
|
|
#include "gtkfilechooserprivate.h"
|
|
|
|
|
#include "gtkfilechooserutils.h"
|
2006-12-26 22:20:06 +00:00
|
|
|
|
#include "gtkmarshalers.h"
|
2019-05-03 06:04:39 +00:00
|
|
|
|
#include "gtkbinlayout.h"
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
#include "gtkfilechooserbutton.h"
|
|
|
|
|
|
2011-06-07 23:54:40 +00:00
|
|
|
|
#include "gtkorientable.h"
|
|
|
|
|
|
2011-01-04 19:51:19 +00:00
|
|
|
|
#include "gtktypebuiltins.h"
|
2005-03-22 02:14:55 +00:00
|
|
|
|
#include "gtkprivate.h"
|
2012-03-03 18:22:22 +00:00
|
|
|
|
#include "gtksettings.h"
|
2015-07-16 19:47:13 +00:00
|
|
|
|
#include "gtkstylecontextprivate.h"
|
|
|
|
|
#include "gtkbitmaskprivate.h"
|
2020-01-06 05:12:21 +00:00
|
|
|
|
#include "gtkeventcontroller.h"
|
2011-04-13 19:46:31 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SECTION:gtkfilechooserbutton
|
|
|
|
|
* @Short_description: A button to launch a file selection dialog
|
|
|
|
|
* @Title: GtkFileChooserButton
|
|
|
|
|
* @See_also:#GtkFileChooserDialog
|
|
|
|
|
*
|
|
|
|
|
* The #GtkFileChooserButton is a widget that lets the user select a
|
|
|
|
|
* file. It implements the #GtkFileChooser interface. Visually, it is a
|
|
|
|
|
* file name with a button to bring up a #GtkFileChooserDialog.
|
|
|
|
|
* The user can then use that dialog to change the file associated with
|
|
|
|
|
* that button. This widget does not support setting the
|
|
|
|
|
* #GtkFileChooser:select-multiple property to %TRUE.
|
|
|
|
|
*
|
2014-02-04 21:57:57 +00:00
|
|
|
|
* ## Create a button to let the user select a file in /etc
|
|
|
|
|
*
|
2014-01-27 19:55:18 +00:00
|
|
|
|
* |[<!-- language="C" -->
|
2011-04-13 19:46:31 +00:00
|
|
|
|
* {
|
|
|
|
|
* GtkWidget *button;
|
|
|
|
|
*
|
|
|
|
|
* button = gtk_file_chooser_button_new (_("Select a file"),
|
|
|
|
|
* GTK_FILE_CHOOSER_ACTION_OPEN);
|
|
|
|
|
* gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button),
|
|
|
|
|
* "/etc");
|
|
|
|
|
* }
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2011-04-13 19:46:31 +00:00
|
|
|
|
*
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* The #GtkFileChooserButton supports the #GtkFileChooserActions
|
2011-04-13 19:46:31 +00:00
|
|
|
|
* %GTK_FILE_CHOOSER_ACTION_OPEN and %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
|
|
|
|
|
*
|
2014-02-05 07:25:03 +00:00
|
|
|
|
* > The #GtkFileChooserButton will ellipsize the label, and will thus
|
|
|
|
|
* > request little horizontal space. To give the button more space,
|
|
|
|
|
* > you should call gtk_widget_get_preferred_size(),
|
|
|
|
|
* > gtk_file_chooser_button_set_width_chars(), or pack the button in
|
|
|
|
|
* > such a way that other interface elements give space to the
|
|
|
|
|
* > widget.
|
2019-06-20 19:51:37 +00:00
|
|
|
|
*
|
|
|
|
|
* # CSS nodes
|
|
|
|
|
*
|
|
|
|
|
* GtkFileChooserButton has a single CSS node with the name “filechooserbutton”.
|
2011-04-13 19:46:31 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
/* **************** *
|
|
|
|
|
* Private Macros *
|
|
|
|
|
* **************** */
|
|
|
|
|
|
2017-11-15 00:47:04 +00:00
|
|
|
|
#define ICON_SIZE 16
|
2011-01-17 20:43:33 +00:00
|
|
|
|
#define DEFAULT_TITLE N_("Select a File")
|
2004-12-15 14:58:39 +00:00
|
|
|
|
#define DESKTOP_DISPLAY_NAME N_("Desktop")
|
2019-09-22 07:07:33 +00:00
|
|
|
|
#define FALLBACK_DISPLAY_NAME N_("(None)")
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
/* ********************** *
|
|
|
|
|
* Private Enumerations *
|
|
|
|
|
* ********************** */
|
|
|
|
|
|
|
|
|
|
/* Property IDs */
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
PROP_0,
|
|
|
|
|
|
|
|
|
|
PROP_DIALOG,
|
|
|
|
|
PROP_TITLE,
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
PROP_WIDTH_CHARS
|
2004-08-17 16:06:39 +00:00
|
|
|
|
};
|
|
|
|
|
|
2006-12-26 22:20:06 +00:00
|
|
|
|
/* Signals */
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
FILE_SET,
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
2013-03-30 08:12:35 +00:00
|
|
|
|
/* TreeModel Columns
|
|
|
|
|
*/
|
2004-12-15 14:58:39 +00:00
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
ICON_COLUMN,
|
|
|
|
|
DISPLAY_NAME_COLUMN,
|
|
|
|
|
TYPE_COLUMN,
|
|
|
|
|
DATA_COLUMN,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
IS_FOLDER_COLUMN,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
CANCELLABLE_COLUMN,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
NUM_COLUMNS
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* TreeModel Row Types */
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
ROW_TYPE_SPECIAL,
|
|
|
|
|
ROW_TYPE_VOLUME,
|
|
|
|
|
ROW_TYPE_SHORTCUT,
|
|
|
|
|
ROW_TYPE_BOOKMARK_SEPARATOR,
|
|
|
|
|
ROW_TYPE_BOOKMARK,
|
|
|
|
|
ROW_TYPE_CURRENT_FOLDER_SEPARATOR,
|
|
|
|
|
ROW_TYPE_CURRENT_FOLDER,
|
|
|
|
|
ROW_TYPE_OTHER_SEPARATOR,
|
|
|
|
|
ROW_TYPE_OTHER,
|
|
|
|
|
|
|
|
|
|
ROW_TYPE_INVALID = -1
|
|
|
|
|
}
|
|
|
|
|
RowType;
|
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
/* ******************** *
|
|
|
|
|
* Private Structures *
|
|
|
|
|
* ******************** */
|
|
|
|
|
|
2019-05-28 02:40:08 +00:00
|
|
|
|
typedef struct _GtkFileChooserButtonClass GtkFileChooserButtonClass;
|
|
|
|
|
|
|
|
|
|
struct _GtkFileChooserButton
|
|
|
|
|
{
|
|
|
|
|
GtkWidget parent_instance;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _GtkFileChooserButtonClass
|
|
|
|
|
{
|
|
|
|
|
GtkWidgetClass parent_class;
|
|
|
|
|
|
|
|
|
|
void (* file_set) (GtkFileChooserButton *fc);
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
typedef struct
|
2004-08-17 16:06:39 +00:00
|
|
|
|
{
|
2015-10-29 14:13:14 +00:00
|
|
|
|
GtkFileChooser *chooser; /* Points to either dialog or native, depending on which is set */
|
|
|
|
|
GtkWidget *dialog; /* Set if you explicitly enable */
|
|
|
|
|
GtkFileChooserNative *native; /* Otherwise this is set */
|
2017-01-18 21:21:42 +00:00
|
|
|
|
GtkWidget *box;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
GtkWidget *button;
|
2004-11-30 21:06:48 +00:00
|
|
|
|
GtkWidget *image;
|
|
|
|
|
GtkWidget *label;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkWidget *combo_box;
|
|
|
|
|
GtkCellRenderer *icon_cell;
|
|
|
|
|
GtkCellRenderer *name_cell;
|
|
|
|
|
|
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
GtkTreeModel *filter_model;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkFileSystem *fs;
|
2013-02-12 05:03:26 +00:00
|
|
|
|
GFile *selection_while_inactive;
|
2013-02-13 17:47:35 +00:00
|
|
|
|
GFile *current_folder_while_inactive;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
gulong fs_volumes_changed_id;
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GCancellable *dnd_select_folder_cancellable;
|
|
|
|
|
GCancellable *update_button_cancellable;
|
|
|
|
|
GSList *change_icon_theme_cancellables;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2011-09-30 13:50:15 +00:00
|
|
|
|
GtkBookmarksManager *bookmarks_manager;
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
guint8 n_special;
|
|
|
|
|
guint8 n_volumes;
|
|
|
|
|
guint8 n_shortcuts;
|
|
|
|
|
guint8 n_bookmarks;
|
2007-11-26 17:10:00 +00:00
|
|
|
|
guint has_bookmark_separator : 1;
|
|
|
|
|
guint has_current_folder_separator : 1;
|
|
|
|
|
guint has_current_folder : 1;
|
|
|
|
|
guint has_other_separator : 1;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2004-11-30 21:06:48 +00:00
|
|
|
|
/* Used for hiding/showing the dialog when the button is hidden */
|
2007-11-26 17:10:00 +00:00
|
|
|
|
guint active : 1;
|
2005-10-07 19:54:32 +00:00
|
|
|
|
|
2013-03-12 03:54:22 +00:00
|
|
|
|
/* Whether the next async callback from GIO should emit the "selection-changed" signal */
|
|
|
|
|
guint is_changing_selection : 1;
|
2018-06-18 15:24:57 +00:00
|
|
|
|
} GtkFileChooserButtonPrivate;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ********************* *
|
|
|
|
|
* Function Prototypes *
|
|
|
|
|
* ********************* */
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
/* GtkFileChooserIface Functions */
|
|
|
|
|
static void gtk_file_chooser_button_file_chooser_iface_init (GtkFileChooserIface *iface);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
static gboolean gtk_file_chooser_button_set_current_folder (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GError **error);
|
|
|
|
|
static GFile *gtk_file_chooser_button_get_current_folder (GtkFileChooser *chooser);
|
2013-02-12 05:03:26 +00:00
|
|
|
|
static gboolean gtk_file_chooser_button_select_file (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GError **error);
|
|
|
|
|
static void gtk_file_chooser_button_unselect_file (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file);
|
|
|
|
|
static void gtk_file_chooser_button_unselect_all (GtkFileChooser *chooser);
|
|
|
|
|
static GSList *gtk_file_chooser_button_get_files (GtkFileChooser *chooser);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
static gboolean gtk_file_chooser_button_add_shortcut_folder (GtkFileChooser *chooser,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GError **error);
|
|
|
|
|
static gboolean gtk_file_chooser_button_remove_shortcut_folder (GtkFileChooser *chooser,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GError **error);
|
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
/* GObject Functions */
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void gtk_file_chooser_button_constructed (GObject *object);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
static void gtk_file_chooser_button_set_property (GObject *object,
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
guint param_id,
|
2004-08-17 16:06:39 +00:00
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gtk_file_chooser_button_get_property (GObject *object,
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
guint param_id,
|
2004-08-17 16:06:39 +00:00
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
static void gtk_file_chooser_button_finalize (GObject *object);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
/* GtkWidget Functions */
|
2010-09-18 23:55:42 +00:00
|
|
|
|
static void gtk_file_chooser_button_destroy (GtkWidget *widget);
|
2020-01-02 06:51:07 +00:00
|
|
|
|
static gboolean gtk_file_chooser_button_drag_drop (GtkDropTarget *dest,
|
2020-01-08 04:31:48 +00:00
|
|
|
|
GdkDrop *drop,
|
2020-01-02 06:51:07 +00:00
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
GtkWidget *widget);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
static void gtk_file_chooser_button_show (GtkWidget *widget);
|
|
|
|
|
static void gtk_file_chooser_button_hide (GtkWidget *widget);
|
2019-05-02 00:08:49 +00:00
|
|
|
|
static void gtk_file_chooser_button_root (GtkWidget *widget);
|
2005-10-07 19:54:32 +00:00
|
|
|
|
static void gtk_file_chooser_button_map (GtkWidget *widget);
|
2004-09-19 05:40:00 +00:00
|
|
|
|
static gboolean gtk_file_chooser_button_mnemonic_activate (GtkWidget *widget,
|
|
|
|
|
gboolean group_cycling);
|
2020-02-05 01:46:13 +00:00
|
|
|
|
static void gtk_file_chooser_button_css_changed (GtkWidget *widget,
|
|
|
|
|
GtkCssStyleChange *change);
|
|
|
|
|
static void gtk_file_chooser_button_state_flags_changed (GtkWidget *widget,
|
|
|
|
|
GtkStateFlags previous_state);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
/* Utility Functions */
|
2008-06-10 00:39:35 +00:00
|
|
|
|
static void set_info_for_file_at_iter (GtkFileChooserButton *fs,
|
|
|
|
|
GFile *file,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GtkTreeIter *iter);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
static gint model_get_type_position (GtkFileChooserButton *button,
|
|
|
|
|
RowType row_type);
|
|
|
|
|
static void model_free_row_data (GtkFileChooserButton *button,
|
|
|
|
|
GtkTreeIter *iter);
|
2013-03-07 20:14:47 +00:00
|
|
|
|
static void model_add_special (GtkFileChooserButton *button);
|
|
|
|
|
static void model_add_other (GtkFileChooserButton *button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
static void model_add_volumes (GtkFileChooserButton *button,
|
|
|
|
|
GSList *volumes);
|
|
|
|
|
static void model_add_bookmarks (GtkFileChooserButton *button,
|
|
|
|
|
GSList *bookmarks);
|
|
|
|
|
static void model_update_current_folder (GtkFileChooserButton *button,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
static void model_remove_rows (GtkFileChooserButton *button,
|
|
|
|
|
gint pos,
|
|
|
|
|
gint n_rows);
|
|
|
|
|
|
|
|
|
|
static gboolean filter_model_visible_func (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
static gboolean combo_box_row_separator_func (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
static void name_cell_data_func (GtkCellLayout *layout,
|
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
static void open_dialog (GtkFileChooserButton *button);
|
|
|
|
|
static void update_combo_box (GtkFileChooserButton *button);
|
|
|
|
|
static void update_label_and_image (GtkFileChooserButton *button);
|
|
|
|
|
|
|
|
|
|
/* Child Object Callbacks */
|
|
|
|
|
static void fs_volumes_changed_cb (GtkFileSystem *fs,
|
|
|
|
|
gpointer user_data);
|
2011-09-30 13:50:15 +00:00
|
|
|
|
static void bookmarks_changed_cb (gpointer user_data);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
static void combo_box_changed_cb (GtkComboBox *combo_box,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
static void button_clicked_cb (GtkButton *real_button,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
2015-10-29 14:13:14 +00:00
|
|
|
|
static void chooser_update_preview_cb (GtkFileChooser *dialog,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gpointer user_data);
|
2015-10-29 14:13:14 +00:00
|
|
|
|
static void chooser_notify_cb (GObject *dialog,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
static void dialog_response_cb (GtkDialog *dialog,
|
|
|
|
|
gint response,
|
|
|
|
|
gpointer user_data);
|
2015-10-29 14:13:14 +00:00
|
|
|
|
static void native_response_cb (GtkFileChooserNative *native,
|
|
|
|
|
gint response,
|
|
|
|
|
gpointer user_data);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2006-12-26 22:20:06 +00:00
|
|
|
|
static guint file_chooser_button_signals[LAST_SIGNAL] = { 0 };
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
/* ******************* *
|
|
|
|
|
* GType Declaration *
|
|
|
|
|
* ******************* */
|
|
|
|
|
|
2017-01-18 21:21:42 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkFileChooserButton, gtk_file_chooser_button, GTK_TYPE_WIDGET,
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_ADD_PRIVATE (GtkFileChooserButton)
|
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER,
|
|
|
|
|
gtk_file_chooser_button_file_chooser_iface_init))
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_button_class_init (GtkFileChooserButtonClass * class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
|
|
gobject_class = G_OBJECT_CLASS (class);
|
|
|
|
|
widget_class = GTK_WIDGET_CLASS (class);
|
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
gobject_class->constructed = gtk_file_chooser_button_constructed;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
gobject_class->set_property = gtk_file_chooser_button_set_property;
|
|
|
|
|
gobject_class->get_property = gtk_file_chooser_button_get_property;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gobject_class->finalize = gtk_file_chooser_button_finalize;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2010-09-18 23:55:42 +00:00
|
|
|
|
widget_class->destroy = gtk_file_chooser_button_destroy;
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
widget_class->show = gtk_file_chooser_button_show;
|
|
|
|
|
widget_class->hide = gtk_file_chooser_button_hide;
|
2005-10-07 19:54:32 +00:00
|
|
|
|
widget_class->map = gtk_file_chooser_button_map;
|
2020-02-05 01:46:13 +00:00
|
|
|
|
widget_class->css_changed = gtk_file_chooser_button_css_changed;
|
2019-05-02 00:08:49 +00:00
|
|
|
|
widget_class->root = gtk_file_chooser_button_root;
|
2004-09-19 05:40:00 +00:00
|
|
|
|
widget_class->mnemonic_activate = gtk_file_chooser_button_mnemonic_activate;
|
2016-03-11 13:50:38 +00:00
|
|
|
|
widget_class->state_flags_changed = gtk_file_chooser_button_state_flags_changed;
|
2008-03-03 12:35:43 +00:00
|
|
|
|
|
2006-12-26 22:20:06 +00:00
|
|
|
|
/**
|
2008-03-03 12:35:43 +00:00
|
|
|
|
* GtkFileChooserButton::file-set:
|
2006-12-26 22:20:06 +00:00
|
|
|
|
* @widget: the object which received the signal.
|
|
|
|
|
*
|
|
|
|
|
* The ::file-set signal is emitted when the user selects a file.
|
2008-03-03 12:35:43 +00:00
|
|
|
|
*
|
2014-01-28 06:54:48 +00:00
|
|
|
|
* Note that this signal is only emitted when the user
|
2008-03-03 12:35:43 +00:00
|
|
|
|
* changes the file.
|
2006-12-26 22:20:06 +00:00
|
|
|
|
*/
|
|
|
|
|
file_chooser_button_signals[FILE_SET] =
|
|
|
|
|
g_signal_new (I_("file-set"),
|
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
2009-02-11 06:29:24 +00:00
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2006-12-26 22:20:06 +00:00
|
|
|
|
G_STRUCT_OFFSET (GtkFileChooserButtonClass, file_set),
|
|
|
|
|
NULL, NULL,
|
2016-08-29 14:00:17 +00:00
|
|
|
|
NULL,
|
2006-12-26 22:20:06 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2004-11-01 20:20:25 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkFileChooserButton:dialog:
|
2013-03-12 17:02:38 +00:00
|
|
|
|
*
|
2004-11-01 20:20:25 +00:00
|
|
|
|
* Instance of the #GtkFileChooserDialog associated with the button.
|
|
|
|
|
*/
|
2004-08-17 16:06:39 +00:00
|
|
|
|
g_object_class_install_property (gobject_class, PROP_DIALOG,
|
|
|
|
|
g_param_spec_object ("dialog",
|
|
|
|
|
P_("Dialog"),
|
|
|
|
|
P_("The file chooser dialog to use."),
|
2006-12-20 19:02:21 +00:00
|
|
|
|
GTK_TYPE_FILE_CHOOSER,
|
2005-03-22 02:14:55 +00:00
|
|
|
|
(GTK_PARAM_WRITABLE |
|
2004-08-17 16:06:39 +00:00
|
|
|
|
G_PARAM_CONSTRUCT_ONLY)));
|
2004-11-01 20:20:25 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkFileChooserButton:title:
|
2013-03-12 17:02:38 +00:00
|
|
|
|
*
|
2004-11-01 20:20:25 +00:00
|
|
|
|
* Title to put on the #GtkFileChooserDialog associated with the button.
|
|
|
|
|
*/
|
2004-08-17 16:06:39 +00:00
|
|
|
|
g_object_class_install_property (gobject_class, PROP_TITLE,
|
|
|
|
|
g_param_spec_string ("title",
|
|
|
|
|
P_("Title"),
|
|
|
|
|
P_("The title of the file chooser dialog."),
|
2005-01-06 06:25:30 +00:00
|
|
|
|
_(DEFAULT_TITLE),
|
2005-03-22 02:14:55 +00:00
|
|
|
|
GTK_PARAM_READWRITE));
|
2004-11-01 20:20:25 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2004-11-02 05:40:33 +00:00
|
|
|
|
* GtkFileChooserButton:width-chars:
|
2013-03-12 17:02:38 +00:00
|
|
|
|
*
|
2004-11-01 20:20:25 +00:00
|
|
|
|
* The width of the entry and label inside the button, in characters.
|
|
|
|
|
*/
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
g_object_class_install_property (gobject_class, PROP_WIDTH_CHARS,
|
|
|
|
|
g_param_spec_int ("width-chars",
|
|
|
|
|
P_("Width In Characters"),
|
|
|
|
|
P_("The desired width of the button widget, in characters."),
|
|
|
|
|
-1, G_MAXINT, -1,
|
2005-03-22 02:14:55 +00:00
|
|
|
|
GTK_PARAM_READWRITE));
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
_gtk_file_chooser_install_properties (gobject_class);
|
|
|
|
|
|
2017-11-18 03:49:57 +00:00
|
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("filechooserbutton"));
|
2019-05-06 11:06:27 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_button_init (GtkFileChooserButton *button)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2017-01-18 21:21:42 +00:00
|
|
|
|
GtkWidget *box;
|
|
|
|
|
GtkWidget *icon;
|
2020-01-07 05:45:29 +00:00
|
|
|
|
GdkContentFormatsBuilder *builder;
|
2017-11-18 01:19:53 +00:00
|
|
|
|
GdkContentFormats *target_list;
|
2020-01-02 06:51:07 +00:00
|
|
|
|
GtkDropTarget *dest;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2017-01-18 21:21:42 +00:00
|
|
|
|
priv->button = gtk_button_new ();
|
|
|
|
|
g_signal_connect (priv->button, "clicked", G_CALLBACK (button_clicked_cb), button);
|
|
|
|
|
priv->image = gtk_image_new ();
|
|
|
|
|
priv->label = gtk_label_new (_(FALLBACK_DISPLAY_NAME));
|
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (priv->label), 0.0f);
|
|
|
|
|
gtk_widget_set_hexpand (priv->label, TRUE);
|
2017-11-15 00:43:13 +00:00
|
|
|
|
icon = gtk_image_new_from_icon_name ("document-open-symbolic");
|
2017-01-18 21:21:42 +00:00
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
|
|
|
|
gtk_widget_set_valign (priv->image, GTK_ALIGN_BASELINE);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (box), priv->image);
|
|
|
|
|
gtk_widget_set_valign (priv->label, GTK_ALIGN_BASELINE);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (box), priv->label);
|
|
|
|
|
gtk_widget_set_valign (icon, GTK_ALIGN_BASELINE);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (box), icon);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (priv->button), box);
|
|
|
|
|
|
|
|
|
|
gtk_widget_set_parent (priv->button, GTK_WIDGET (button));
|
|
|
|
|
|
|
|
|
|
priv->model = GTK_TREE_MODEL (gtk_list_store_new (NUM_COLUMNS,
|
2017-11-09 01:54:48 +00:00
|
|
|
|
G_TYPE_ICON,
|
2017-01-18 21:21:42 +00:00
|
|
|
|
G_TYPE_STRING,
|
|
|
|
|
G_TYPE_CHAR,
|
|
|
|
|
G_TYPE_POINTER,
|
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
|
G_TYPE_POINTER));
|
|
|
|
|
|
|
|
|
|
priv->combo_box = gtk_combo_box_new ();
|
|
|
|
|
g_signal_connect (priv->combo_box, "changed", G_CALLBACK (combo_box_changed_cb), button);
|
|
|
|
|
priv->icon_cell = gtk_cell_renderer_pixbuf_new ();
|
|
|
|
|
priv->name_cell = gtk_cell_renderer_text_new ();
|
2019-12-26 14:29:36 +00:00
|
|
|
|
g_object_set (priv->name_cell, "xpad", 6, NULL);
|
2017-01-18 21:21:42 +00:00
|
|
|
|
|
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->combo_box), priv->icon_cell, FALSE);
|
|
|
|
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->combo_box),
|
2017-11-09 01:54:48 +00:00
|
|
|
|
priv->icon_cell, "gicon", ICON_COLUMN, NULL);
|
2017-01-18 21:21:42 +00:00
|
|
|
|
|
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->combo_box), priv->name_cell, FALSE);
|
|
|
|
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->combo_box),
|
2017-11-09 01:54:48 +00:00
|
|
|
|
priv->name_cell, "text", DISPLAY_NAME_COLUMN, NULL);
|
2017-01-18 21:21:42 +00:00
|
|
|
|
|
2017-03-26 10:42:07 +00:00
|
|
|
|
gtk_widget_hide (priv->combo_box);
|
2017-01-18 21:21:42 +00:00
|
|
|
|
gtk_widget_set_parent (priv->combo_box, GTK_WIDGET (button));
|
|
|
|
|
|
2011-09-30 13:50:15 +00:00
|
|
|
|
/* Bookmarks manager */
|
|
|
|
|
priv->bookmarks_manager = _gtk_bookmarks_manager_new (bookmarks_changed_cb, button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (priv->combo_box),
|
|
|
|
|
priv->name_cell, name_cell_data_func,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
/* DnD */
|
2020-01-07 05:45:29 +00:00
|
|
|
|
builder = gdk_content_formats_builder_new ();
|
|
|
|
|
gdk_content_formats_builder_add_gtype (builder, G_TYPE_STRING);
|
|
|
|
|
gdk_content_formats_builder_add_gtype (builder, GDK_TYPE_FILE_LIST);
|
|
|
|
|
target_list = gdk_content_formats_builder_free_to_formats (builder);
|
2020-01-05 22:23:50 +00:00
|
|
|
|
dest = gtk_drop_target_new (target_list, GDK_ACTION_COPY);
|
2020-01-02 06:51:07 +00:00
|
|
|
|
g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_file_chooser_button_drag_drop), button);
|
2020-01-06 05:12:21 +00:00
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (button), GTK_EVENT_CONTROLLER (dest));
|
2017-11-18 01:19:53 +00:00
|
|
|
|
gdk_content_formats_unref (target_list);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
/* ******************************* *
|
|
|
|
|
* GtkFileChooserIface Functions *
|
|
|
|
|
* ******************************* */
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_button_file_chooser_iface_init (GtkFileChooserIface *iface)
|
|
|
|
|
{
|
|
|
|
|
_gtk_file_chooser_delegate_iface_init (iface);
|
|
|
|
|
|
2013-02-13 17:47:35 +00:00
|
|
|
|
iface->set_current_folder = gtk_file_chooser_button_set_current_folder;
|
|
|
|
|
iface->get_current_folder = gtk_file_chooser_button_get_current_folder;
|
2013-02-12 05:03:26 +00:00
|
|
|
|
iface->select_file = gtk_file_chooser_button_select_file;
|
|
|
|
|
iface->unselect_file = gtk_file_chooser_button_unselect_file;
|
|
|
|
|
iface->unselect_all = gtk_file_chooser_button_unselect_all;
|
|
|
|
|
iface->get_files = gtk_file_chooser_button_get_files;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
iface->add_shortcut_folder = gtk_file_chooser_button_add_shortcut_folder;
|
|
|
|
|
iface->remove_shortcut_folder = gtk_file_chooser_button_remove_shortcut_folder;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-12 03:54:22 +00:00
|
|
|
|
static void
|
|
|
|
|
emit_selection_changed_if_changing_selection (GtkFileChooserButton *button)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2013-03-12 03:54:22 +00:00
|
|
|
|
|
|
|
|
|
if (priv->is_changing_selection)
|
|
|
|
|
{
|
|
|
|
|
priv->is_changing_selection = FALSE;
|
|
|
|
|
g_signal_emit_by_name (button, "selection-changed");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-13 17:47:35 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_file_chooser_button_set_current_folder (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (chooser);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
if (priv->current_folder_while_inactive)
|
|
|
|
|
g_object_unref (priv->current_folder_while_inactive);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
priv->current_folder_while_inactive = g_object_ref (file);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
update_combo_box (button);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
g_signal_emit_by_name (button, "current-folder-changed");
|
2013-03-07 19:44:33 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
if (priv->active)
|
2015-10-29 14:13:14 +00:00
|
|
|
|
gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (priv->chooser), file, NULL);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
return TRUE;
|
2013-02-13 17:47:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GFile *
|
|
|
|
|
gtk_file_chooser_button_get_current_folder (GtkFileChooser *chooser)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (chooser);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
if (priv->current_folder_while_inactive)
|
|
|
|
|
return g_object_ref (priv->current_folder_while_inactive);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
else
|
2013-03-12 17:21:35 +00:00
|
|
|
|
return NULL;
|
2013-02-13 17:47:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-12 05:03:26 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_file_chooser_button_select_file (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (chooser);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2013-02-12 05:03:26 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
if (priv->selection_while_inactive)
|
|
|
|
|
g_object_unref (priv->selection_while_inactive);
|
2013-02-12 05:03:26 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
priv->selection_while_inactive = g_object_ref (file);
|
|
|
|
|
|
|
|
|
|
priv->is_changing_selection = TRUE;
|
2013-02-12 05:03:26 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
update_label_and_image (button);
|
|
|
|
|
update_combo_box (button);
|
2013-02-12 05:03:26 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
if (priv->active)
|
2015-10-29 14:13:14 +00:00
|
|
|
|
gtk_file_chooser_select_file (GTK_FILE_CHOOSER (priv->chooser), file, NULL);
|
2013-03-12 03:54:22 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2013-03-07 19:44:33 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
static void
|
|
|
|
|
unselect_current_file (GtkFileChooserButton *button)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2013-03-12 17:21:35 +00:00
|
|
|
|
|
|
|
|
|
if (priv->selection_while_inactive)
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (priv->selection_while_inactive);
|
|
|
|
|
priv->selection_while_inactive = NULL;
|
2013-02-12 05:03:26 +00:00
|
|
|
|
}
|
2013-03-12 17:21:35 +00:00
|
|
|
|
|
|
|
|
|
priv->is_changing_selection = TRUE;
|
|
|
|
|
|
|
|
|
|
update_label_and_image (button);
|
|
|
|
|
update_combo_box (button);
|
2013-02-12 05:03:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_button_unselect_file (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (chooser);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2013-02-12 05:03:26 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
if (g_file_equal (priv->selection_while_inactive, file))
|
|
|
|
|
unselect_current_file (button);
|
2013-02-12 05:03:26 +00:00
|
|
|
|
|
|
|
|
|
if (priv->active)
|
2015-10-29 14:13:14 +00:00
|
|
|
|
gtk_file_chooser_unselect_file (GTK_FILE_CHOOSER (priv->chooser), file);
|
2013-02-12 05:03:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_button_unselect_all (GtkFileChooser *chooser)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (chooser);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2013-02-12 05:03:26 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
unselect_current_file (button);
|
2013-02-12 05:03:26 +00:00
|
|
|
|
|
|
|
|
|
if (priv->active)
|
2015-10-29 14:13:14 +00:00
|
|
|
|
gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (priv->chooser));
|
2013-02-12 05:03:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-07 19:44:33 +00:00
|
|
|
|
static GFile *
|
|
|
|
|
get_selected_file (GtkFileChooserButton *button)
|
2013-02-12 05:03:26 +00:00
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2013-03-12 17:21:35 +00:00
|
|
|
|
GFile *retval;
|
2013-02-12 05:03:26 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
retval = NULL;
|
|
|
|
|
|
|
|
|
|
if (priv->selection_while_inactive)
|
|
|
|
|
retval = priv->selection_while_inactive;
|
2015-10-29 14:13:14 +00:00
|
|
|
|
else if (priv->chooser && gtk_file_chooser_get_action (priv->chooser) == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
2013-02-12 05:03:26 +00:00
|
|
|
|
{
|
2013-03-12 17:21:35 +00:00
|
|
|
|
/* If there is no "real" selection in SELECT_FOLDER mode, then we'll just return
|
2014-01-28 09:30:33 +00:00
|
|
|
|
* the current folder, since that is what GtkFileChooserWidget would do.
|
2013-03-12 17:21:35 +00:00
|
|
|
|
*/
|
|
|
|
|
if (priv->current_folder_while_inactive)
|
|
|
|
|
retval = priv->current_folder_while_inactive;
|
2013-02-12 05:03:26 +00:00
|
|
|
|
}
|
2013-03-07 19:44:33 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
if (retval)
|
|
|
|
|
return g_object_ref (retval);
|
|
|
|
|
else
|
|
|
|
|
return NULL;
|
2013-03-07 19:44:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GSList *
|
|
|
|
|
gtk_file_chooser_button_get_files (GtkFileChooser *chooser)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (chooser);
|
2013-03-12 17:21:35 +00:00
|
|
|
|
GFile *file;
|
2013-03-07 19:44:33 +00:00
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
file = get_selected_file (button);
|
|
|
|
|
if (file)
|
|
|
|
|
return g_slist_prepend (NULL, file);
|
|
|
|
|
else
|
|
|
|
|
return NULL;
|
2013-02-12 05:03:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
static gboolean
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_file_chooser_button_add_shortcut_folder (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GError **error)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
|
|
|
|
GtkFileChooser *delegate;
|
|
|
|
|
gboolean retval;
|
|
|
|
|
|
|
|
|
|
delegate = g_object_get_qdata (G_OBJECT (chooser),
|
|
|
|
|
GTK_FILE_CHOOSER_DELEGATE_QUARK);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
retval = _gtk_file_chooser_add_shortcut_folder (delegate, file, error);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (retval)
|
|
|
|
|
{
|
2005-11-07 15:57:19 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (chooser);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gint pos;
|
|
|
|
|
|
2005-11-07 15:57:19 +00:00
|
|
|
|
pos = model_get_type_position (button, ROW_TYPE_SHORTCUT);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
pos += priv->n_shortcuts;
|
|
|
|
|
|
|
|
|
|
gtk_list_store_insert (GTK_LIST_STORE (priv->model), &iter, pos);
|
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
ICON_COLUMN, NULL,
|
|
|
|
|
DISPLAY_NAME_COLUMN, _(FALLBACK_DISPLAY_NAME),
|
2004-12-15 14:58:39 +00:00
|
|
|
|
TYPE_COLUMN, ROW_TYPE_SHORTCUT,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
DATA_COLUMN, g_object_ref (file),
|
2006-05-01 21:41:12 +00:00
|
|
|
|
IS_FOLDER_COLUMN, FALSE,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
-1);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
set_info_for_file_at_iter (button, file, &iter);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
priv->n_shortcuts++;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_file_chooser_button_remove_shortcut_folder (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GError **error)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
|
|
|
|
GtkFileChooser *delegate;
|
|
|
|
|
gboolean retval;
|
|
|
|
|
|
|
|
|
|
delegate = g_object_get_qdata (G_OBJECT (chooser),
|
|
|
|
|
GTK_FILE_CHOOSER_DELEGATE_QUARK);
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
retval = _gtk_file_chooser_remove_shortcut_folder (delegate, file, error);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (retval)
|
|
|
|
|
{
|
2005-11-07 15:57:19 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (chooser);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gint pos;
|
|
|
|
|
gchar type;
|
|
|
|
|
|
2005-11-07 15:57:19 +00:00
|
|
|
|
pos = model_get_type_position (button, ROW_TYPE_SHORTCUT);
|
2006-02-08 19:35:08 +00:00
|
|
|
|
gtk_tree_model_iter_nth_child (priv->model, &iter, NULL, pos);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
gpointer data;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (priv->model, &iter,
|
|
|
|
|
TYPE_COLUMN, &type,
|
|
|
|
|
DATA_COLUMN, &data,
|
|
|
|
|
-1);
|
|
|
|
|
|
|
|
|
|
if (type == ROW_TYPE_SHORTCUT &&
|
2008-06-10 00:39:35 +00:00
|
|
|
|
data && g_file_equal (data, file))
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
|
|
|
|
model_free_row_data (GTK_FILE_CHOOSER_BUTTON (chooser), &iter);
|
|
|
|
|
gtk_list_store_remove (GTK_LIST_STORE (priv->model), &iter);
|
|
|
|
|
priv->n_shortcuts--;
|
|
|
|
|
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model));
|
|
|
|
|
update_combo_box (GTK_FILE_CHOOSER_BUTTON (chooser));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (type == ROW_TYPE_SHORTCUT &&
|
|
|
|
|
gtk_tree_model_iter_next (priv->model, &iter));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
/* ******************* *
|
|
|
|
|
* GObject Functions *
|
|
|
|
|
* ******************* */
|
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_button_constructed (GObject *object)
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
{
|
2014-06-26 22:22:42 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (object);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GSList *list;
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_file_chooser_button_parent_class)->constructed (object);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
|
|
|
|
if (!priv->dialog)
|
|
|
|
|
{
|
2015-10-29 14:13:14 +00:00
|
|
|
|
priv->native = gtk_file_chooser_native_new (NULL,
|
|
|
|
|
NULL,
|
2008-08-04 14:43:53 +00:00
|
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
2015-10-29 14:13:14 +00:00
|
|
|
|
NULL,
|
2008-08-04 14:43:53 +00:00
|
|
|
|
NULL);
|
2015-10-29 14:13:14 +00:00
|
|
|
|
priv->chooser = GTK_FILE_CHOOSER (priv->native);
|
2007-09-11 18:54:00 +00:00
|
|
|
|
gtk_file_chooser_button_set_title (button, _(DEFAULT_TITLE));
|
2015-10-29 14:13:14 +00:00
|
|
|
|
|
|
|
|
|
g_signal_connect (priv->native, "response",
|
|
|
|
|
G_CALLBACK (native_response_cb), object);
|
2007-09-11 18:54:00 +00:00
|
|
|
|
}
|
2015-10-29 14:13:14 +00:00
|
|
|
|
else /* dialog set */
|
2007-09-11 18:54:00 +00:00
|
|
|
|
{
|
2015-10-29 14:13:14 +00:00
|
|
|
|
priv->chooser = GTK_FILE_CHOOSER (priv->dialog);
|
2017-12-31 16:41:59 +00:00
|
|
|
|
gtk_window_set_hide_on_close (GTK_WINDOW (priv->chooser), TRUE);
|
2015-10-29 14:13:14 +00:00
|
|
|
|
|
|
|
|
|
if (!gtk_window_get_title (GTK_WINDOW (priv->dialog)))
|
|
|
|
|
gtk_file_chooser_button_set_title (button, _(DEFAULT_TITLE));
|
|
|
|
|
|
|
|
|
|
g_signal_connect (priv->dialog, "response",
|
|
|
|
|
G_CALLBACK (dialog_response_cb), object);
|
|
|
|
|
|
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (priv->dialog),
|
|
|
|
|
(gpointer) (&priv->dialog));
|
2007-09-11 18:54:00 +00:00
|
|
|
|
}
|
2006-04-19 17:21:55 +00:00
|
|
|
|
|
2015-10-29 14:13:14 +00:00
|
|
|
|
g_signal_connect (priv->chooser, "notify",
|
|
|
|
|
G_CALLBACK (chooser_notify_cb), object);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
|
|
|
|
/* This is used, instead of the standard delegate, to ensure that signals are only
|
|
|
|
|
* delegated when the OK button is pressed. */
|
2015-10-29 14:13:14 +00:00
|
|
|
|
g_object_set_qdata (object, GTK_FILE_CHOOSER_DELEGATE_QUARK, priv->chooser);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
priv->fs =
|
2015-10-29 14:13:14 +00:00
|
|
|
|
g_object_ref (_gtk_file_chooser_get_file_system (priv->chooser));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2005-11-07 15:57:19 +00:00
|
|
|
|
model_add_special (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2008-06-13 16:47:41 +00:00
|
|
|
|
list = _gtk_file_system_list_volumes (priv->fs);
|
2005-11-07 15:57:19 +00:00
|
|
|
|
model_add_volumes (button, list);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
g_slist_free (list);
|
|
|
|
|
|
2011-09-30 13:50:15 +00:00
|
|
|
|
list = _gtk_bookmarks_manager_list_bookmarks (priv->bookmarks_manager);
|
2005-11-07 15:57:19 +00:00
|
|
|
|
model_add_bookmarks (button, list);
|
2015-07-31 21:57:04 +00:00
|
|
|
|
g_slist_free_full (list, g_object_unref);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2005-11-07 15:57:19 +00:00
|
|
|
|
model_add_other (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
priv->filter_model = gtk_tree_model_filter_new (priv->model, NULL);
|
|
|
|
|
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (priv->filter_model),
|
|
|
|
|
filter_model_visible_func,
|
|
|
|
|
object, NULL);
|
|
|
|
|
|
|
|
|
|
gtk_combo_box_set_model (GTK_COMBO_BOX (priv->combo_box), priv->filter_model);
|
|
|
|
|
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (priv->combo_box),
|
|
|
|
|
combo_box_row_separator_func,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
2005-05-16 21:07:16 +00:00
|
|
|
|
/* set up the action for a user-provided dialog, this also updates
|
|
|
|
|
* the label, image and combobox
|
|
|
|
|
*/
|
2013-03-12 17:02:38 +00:00
|
|
|
|
g_object_set (object,
|
2015-10-29 14:13:14 +00:00
|
|
|
|
"action", gtk_file_chooser_get_action (GTK_FILE_CHOOSER (priv->chooser)),
|
2005-05-16 21:07:16 +00:00
|
|
|
|
NULL);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
priv->fs_volumes_changed_id =
|
|
|
|
|
g_signal_connect (priv->fs, "volumes-changed",
|
|
|
|
|
G_CALLBACK (fs_volumes_changed_cb), object);
|
|
|
|
|
|
2013-03-07 19:50:34 +00:00
|
|
|
|
update_label_and_image (button);
|
|
|
|
|
update_combo_box (button);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
}
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_button_set_property (GObject *object,
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
guint param_id,
|
2004-08-17 16:06:39 +00:00
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
2005-11-07 15:57:19 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (object);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
switch (param_id)
|
2004-08-17 16:06:39 +00:00
|
|
|
|
{
|
|
|
|
|
case PROP_DIALOG:
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
/* Construct-only */
|
|
|
|
|
priv->dialog = g_value_get_object (value);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
break;
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
case PROP_WIDTH_CHARS:
|
|
|
|
|
gtk_file_chooser_button_set_width_chars (GTK_FILE_CHOOSER_BUTTON (object),
|
|
|
|
|
g_value_get_int (value));
|
|
|
|
|
break;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_ACTION:
|
2004-11-07 04:57:04 +00:00
|
|
|
|
switch (g_value_get_enum (value))
|
|
|
|
|
{
|
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER:
|
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_SAVE:
|
|
|
|
|
{
|
|
|
|
|
GEnumClass *eclass;
|
|
|
|
|
GEnumValue *eval;
|
|
|
|
|
|
|
|
|
|
eclass = g_type_class_peek (GTK_TYPE_FILE_CHOOSER_ACTION);
|
|
|
|
|
eval = g_enum_get_value (eclass, g_value_get_enum (value));
|
2015-09-20 06:32:48 +00:00
|
|
|
|
g_warning ("%s: Choosers of type '%s' do not support '%s'.",
|
2004-11-07 04:57:04 +00:00
|
|
|
|
G_STRFUNC, G_OBJECT_TYPE_NAME (object), eval->value_name);
|
|
|
|
|
|
2004-11-19 23:18:38 +00:00
|
|
|
|
g_value_set_enum ((GValue *) value, GTK_FILE_CHOOSER_ACTION_OPEN);
|
2004-11-07 04:57:04 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2017-10-06 19:19:42 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
2004-11-07 04:57:04 +00:00
|
|
|
|
}
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2015-10-29 14:13:14 +00:00
|
|
|
|
g_object_set_property (G_OBJECT (priv->chooser), pspec->name, value);
|
2004-11-30 21:06:48 +00:00
|
|
|
|
update_label_and_image (GTK_FILE_CHOOSER_BUTTON (object));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
update_combo_box (GTK_FILE_CHOOSER_BUTTON (object));
|
|
|
|
|
|
|
|
|
|
switch (g_value_get_enum (value))
|
2019-09-22 07:12:38 +00:00
|
|
|
|
{
|
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_OPEN:
|
2017-04-21 13:37:37 +00:00
|
|
|
|
gtk_widget_hide (priv->combo_box);
|
|
|
|
|
gtk_widget_show (priv->button);
|
2017-01-18 21:21:42 +00:00
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (button));
|
2019-09-22 07:12:38 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:
|
2017-04-21 13:37:37 +00:00
|
|
|
|
gtk_widget_show (priv->combo_box);
|
|
|
|
|
gtk_widget_hide (priv->button);
|
2017-01-18 21:21:42 +00:00
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (button));
|
2019-09-22 07:12:38 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2004-08-17 16:06:39 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_TITLE:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_FILTER:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
|
2005-07-20 17:55:49 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION:
|
2009-07-28 12:15:59 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS:
|
2015-10-29 14:13:14 +00:00
|
|
|
|
g_object_set_property (G_OBJECT (priv->chooser), pspec->name, value);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-09-17 03:34:17 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
|
2015-10-29 14:13:14 +00:00
|
|
|
|
g_object_set_property (G_OBJECT (priv->chooser), pspec->name, value);
|
2006-09-17 03:34:17 +00:00
|
|
|
|
fs_volumes_changed_cb (priv->fs, button);
|
2011-09-30 13:50:15 +00:00
|
|
|
|
bookmarks_changed_cb (button);
|
2006-09-17 03:34:17 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
|
2015-09-20 06:32:48 +00:00
|
|
|
|
g_warning ("%s: Choosers of type '%s' do not support selecting multiple files.",
|
2004-08-17 16:06:39 +00:00
|
|
|
|
G_STRFUNC, G_OBJECT_TYPE_NAME (object));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_button_get_property (GObject *object,
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
guint param_id,
|
2004-08-17 16:06:39 +00:00
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
2005-11-07 15:57:19 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (object);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
|
|
|
|
switch (param_id)
|
2004-08-17 16:06:39 +00:00
|
|
|
|
{
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
case PROP_WIDTH_CHARS:
|
|
|
|
|
g_value_set_int (value,
|
2004-11-30 21:06:48 +00:00
|
|
|
|
gtk_label_get_width_chars (GTK_LABEL (priv->label)));
|
2004-08-17 16:06:39 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_TITLE:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_ACTION:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_FILTER:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
|
2005-07-20 17:55:49 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION:
|
2009-12-20 22:56:28 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS:
|
2015-10-29 14:13:14 +00:00
|
|
|
|
g_object_get_property (G_OBJECT (priv->chooser), pspec->name, value);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_button_finalize (GObject *object)
|
|
|
|
|
{
|
2005-11-07 15:57:19 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (object);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2019-05-03 06:15:27 +00:00
|
|
|
|
g_clear_object (&priv->selection_while_inactive);
|
|
|
|
|
g_clear_object (&priv->current_folder_while_inactive);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
|
2017-01-18 21:21:42 +00:00
|
|
|
|
gtk_widget_unparent (priv->button);
|
|
|
|
|
gtk_widget_unparent (priv->combo_box);
|
|
|
|
|
|
2008-08-07 14:21:47 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_file_chooser_button_parent_class)->finalize (object);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
|
|
|
|
/* ********************* *
|
2010-09-18 23:55:42 +00:00
|
|
|
|
* GtkWidget Functions *
|
2004-08-17 16:06:39 +00:00
|
|
|
|
* ********************* */
|
|
|
|
|
|
2016-03-11 13:50:38 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_button_state_flags_changed (GtkWidget *widget,
|
|
|
|
|
GtkStateFlags previous_state)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (widget);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2016-03-11 13:50:38 +00:00
|
|
|
|
|
|
|
|
|
if (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_DROP_ACTIVE)
|
2019-09-22 07:12:38 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_widget_set_state_flags (priv->button, GTK_STATE_FLAG_DROP_ACTIVE, FALSE);
|
|
|
|
|
gtk_widget_set_state_flags (priv->combo_box, GTK_STATE_FLAG_DROP_ACTIVE, FALSE);
|
|
|
|
|
}
|
2016-03-11 13:50:38 +00:00
|
|
|
|
else
|
2019-09-22 07:12:38 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_widget_unset_state_flags (priv->button, GTK_STATE_FLAG_DROP_ACTIVE);
|
|
|
|
|
gtk_widget_unset_state_flags (priv->combo_box, GTK_STATE_FLAG_DROP_ACTIVE);
|
|
|
|
|
}
|
2016-03-11 13:50:38 +00:00
|
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->state_flags_changed (widget, previous_state);
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
static void
|
2010-09-18 23:55:42 +00:00
|
|
|
|
gtk_file_chooser_button_destroy (GtkWidget *widget)
|
2004-08-17 16:06:39 +00:00
|
|
|
|
{
|
2010-09-18 23:55:42 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (widget);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GSList *l;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2019-05-03 06:10:50 +00:00
|
|
|
|
if (priv->model)
|
|
|
|
|
{
|
|
|
|
|
model_remove_rows (button, 0, gtk_tree_model_iter_n_children (priv->model, NULL));
|
|
|
|
|
g_clear_object (&priv->model);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-03 06:15:27 +00:00
|
|
|
|
g_clear_pointer (&priv->dialog, gtk_widget_destroy);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2015-11-11 15:06:44 +00:00
|
|
|
|
if (priv->native)
|
2019-05-03 06:15:27 +00:00
|
|
|
|
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (priv->native));
|
2015-10-29 14:13:14 +00:00
|
|
|
|
|
2019-05-03 06:15:27 +00:00
|
|
|
|
g_clear_object (&priv->native);
|
|
|
|
|
priv->chooser = NULL; /* Was either priv->dialog or priv->native! */
|
2015-10-29 14:13:14 +00:00
|
|
|
|
|
2019-05-03 06:15:27 +00:00
|
|
|
|
g_clear_pointer (&priv->dnd_select_folder_cancellable, g_cancellable_cancel);
|
|
|
|
|
g_clear_pointer (&priv->update_button_cancellable, g_cancellable_cancel);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (priv->change_icon_theme_cancellables)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
for (l = priv->change_icon_theme_cancellables; l; l = l->next)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GCancellable *cancellable = G_CANCELLABLE (l->data);
|
|
|
|
|
g_cancellable_cancel (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_slist_free (priv->change_icon_theme_cancellables);
|
|
|
|
|
priv->change_icon_theme_cancellables = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-03 06:15:27 +00:00
|
|
|
|
g_clear_object (&priv->filter_model);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
if (priv->fs)
|
|
|
|
|
{
|
|
|
|
|
g_signal_handler_disconnect (priv->fs, priv->fs_volumes_changed_id);
|
2019-05-03 06:15:27 +00:00
|
|
|
|
g_clear_object (&priv->fs);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
2004-11-30 21:06:48 +00:00
|
|
|
|
|
2019-05-03 06:15:27 +00:00
|
|
|
|
g_clear_pointer (&priv->bookmarks_manager, _gtk_bookmarks_manager_free);
|
2011-09-30 13:50:15 +00:00
|
|
|
|
|
2010-09-18 23:55:42 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->destroy (widget);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
struct DndSelectFolderData
|
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GtkFileSystem *file_system;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GtkFileChooserButton *button;
|
|
|
|
|
GtkFileChooserAction action;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gchar **uris;
|
|
|
|
|
guint i;
|
|
|
|
|
gboolean selected;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
dnd_select_folder_get_info_cb (GCancellable *cancellable,
|
|
|
|
|
GFileInfo *info,
|
|
|
|
|
const GError *error,
|
|
|
|
|
gpointer user_data)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
|
|
|
|
struct DndSelectFolderData *data = user_data;
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButton *button = data->button;
|
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
|
|
|
|
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
if (cancellable != priv->dnd_select_folder_cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
|
|
|
|
g_object_unref (data->button);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (data->file);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
g_strfreev (data->uris);
|
|
|
|
|
g_free (data);
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
priv->dnd_select_folder_cancellable = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
if (!cancelled && !error && info != NULL)
|
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gboolean is_folder;
|
|
|
|
|
|
2008-12-14 02:14:19 +00:00
|
|
|
|
is_folder = _gtk_file_info_consider_as_directory (info);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
|
|
|
|
data->selected =
|
|
|
|
|
(((data->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER && is_folder) ||
|
|
|
|
|
(data->action == GTK_FILE_CHOOSER_ACTION_OPEN && !is_folder)) &&
|
2015-01-29 03:36:47 +00:00
|
|
|
|
gtk_file_chooser_select_file (GTK_FILE_CHOOSER (data->button), data->file, NULL));
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
data->selected = FALSE;
|
|
|
|
|
|
|
|
|
|
if (data->selected || data->uris[++data->i] == NULL)
|
|
|
|
|
{
|
2009-02-11 06:52:43 +00:00
|
|
|
|
g_signal_emit (data->button, file_chooser_button_signals[FILE_SET], 0);
|
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
g_object_unref (data->button);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (data->file);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
g_strfreev (data->uris);
|
|
|
|
|
g_free (data);
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (data->file)
|
|
|
|
|
g_object_unref (data->file);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
data->file = g_file_new_for_uri (data->uris[data->i]);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
priv->dnd_select_folder_cancellable =
|
2008-06-13 16:47:41 +00:00
|
|
|
|
_gtk_file_system_get_info (data->file_system, data->file,
|
2018-06-18 15:24:57 +00:00
|
|
|
|
"standard::type",
|
|
|
|
|
dnd_select_folder_get_info_cb, user_data);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
static void
|
2020-01-02 06:51:07 +00:00
|
|
|
|
dnd_select_file (GtkFileChooserButton *button,
|
|
|
|
|
GFile *file)
|
2004-08-17 16:06:39 +00:00
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2020-01-02 06:51:07 +00:00
|
|
|
|
struct DndSelectFolderData *info;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2020-01-02 06:51:07 +00:00
|
|
|
|
info = g_new0 (struct DndSelectFolderData, 1);
|
|
|
|
|
info->button = g_object_ref (button);
|
|
|
|
|
info->i = 0;
|
|
|
|
|
info->uris = g_new0 (char *, 2);
|
|
|
|
|
info->selected = FALSE;
|
|
|
|
|
info->file_system = priv->fs;
|
|
|
|
|
g_object_get (priv->chooser, "action", &info->action, NULL);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2020-01-02 06:51:07 +00:00
|
|
|
|
info->file = g_object_ref (file);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2020-01-02 06:51:07 +00:00
|
|
|
|
if (priv->dnd_select_folder_cancellable)
|
|
|
|
|
g_cancellable_cancel (priv->dnd_select_folder_cancellable);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2020-01-02 06:51:07 +00:00
|
|
|
|
priv->dnd_select_folder_cancellable =
|
|
|
|
|
_gtk_file_system_get_info (priv->fs, info->file,
|
|
|
|
|
"standard::type",
|
|
|
|
|
dnd_select_folder_get_info_cb, info);
|
|
|
|
|
}
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2020-01-02 06:51:07 +00:00
|
|
|
|
static void
|
|
|
|
|
got_file (GObject *source,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (data);
|
|
|
|
|
GdkDrop *drop = GDK_DROP (source);
|
|
|
|
|
const GValue *value;
|
|
|
|
|
|
|
|
|
|
value = gdk_drop_read_value_finish (drop, result, NULL);
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
GFile *file;
|
|
|
|
|
|
|
|
|
|
file = g_value_get_object (value);
|
|
|
|
|
dnd_select_file (button, file);
|
2017-11-16 21:50:37 +00:00
|
|
|
|
}
|
2020-01-02 06:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
got_text (GObject *source,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (data);
|
|
|
|
|
GdkDrop *drop = GDK_DROP (source);
|
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
|
|
str = gdk_drop_read_text_finish (drop, result, NULL);
|
|
|
|
|
if (str)
|
2017-11-16 21:50:37 +00:00
|
|
|
|
{
|
2020-01-02 06:51:07 +00:00
|
|
|
|
GFile *file;
|
|
|
|
|
|
|
|
|
|
file = g_file_new_for_uri (str);
|
|
|
|
|
dnd_select_file (button, file);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (file);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-02 06:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_file_chooser_button_drag_drop (GtkDropTarget *dest,
|
2020-01-08 04:31:48 +00:00
|
|
|
|
GdkDrop *drop,
|
2020-01-02 06:51:07 +00:00
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
GtkWidget *button)
|
|
|
|
|
{
|
|
|
|
|
if (gdk_drop_has_value (drop, G_TYPE_FILE))
|
|
|
|
|
{
|
|
|
|
|
gdk_drop_read_value_async (drop, G_TYPE_FILE, G_PRIORITY_DEFAULT, NULL, got_file, button);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gdk_drop_read_text_async (drop, NULL, got_text, button);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_button_show (GtkWidget *widget)
|
|
|
|
|
{
|
2005-11-07 15:57:19 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (widget);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
|
|
|
|
if (GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->show)
|
2008-08-12 09:06:34 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->show (widget);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2004-11-30 21:06:48 +00:00
|
|
|
|
if (priv->active)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
open_dialog (GTK_FILE_CHOOSER_BUTTON (widget));
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_button_hide (GtkWidget *widget)
|
|
|
|
|
{
|
2005-11-07 15:57:19 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (widget);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2015-10-29 14:13:14 +00:00
|
|
|
|
if (priv->dialog)
|
|
|
|
|
gtk_widget_hide (priv->dialog);
|
2019-10-03 08:17:56 +00:00
|
|
|
|
else if (priv->native)
|
2015-10-29 14:13:14 +00:00
|
|
|
|
gtk_native_dialog_hide (GTK_NATIVE_DIALOG (priv->native));
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
|
|
|
|
if (GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->hide)
|
2008-08-12 09:06:34 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->hide (widget);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
}
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2005-10-07 19:54:32 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_button_map (GtkWidget *widget)
|
|
|
|
|
{
|
2008-08-12 09:44:32 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->map (widget);
|
2005-10-07 19:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-09-19 05:40:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_file_chooser_button_mnemonic_activate (GtkWidget *widget,
|
|
|
|
|
gboolean group_cycling)
|
|
|
|
|
{
|
2005-11-07 15:57:19 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (widget);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-09-19 05:40:00 +00:00
|
|
|
|
|
2015-10-29 14:13:14 +00:00
|
|
|
|
switch (gtk_file_chooser_get_action (GTK_FILE_CHOOSER (priv->chooser)))
|
2004-12-16 13:33:43 +00:00
|
|
|
|
{
|
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_OPEN:
|
|
|
|
|
gtk_widget_grab_focus (priv->button);
|
|
|
|
|
break;
|
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:
|
|
|
|
|
return gtk_widget_mnemonic_activate (priv->combo_box, group_cycling);
|
|
|
|
|
break;
|
2017-10-06 19:19:42 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_SAVE:
|
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER:
|
2004-12-16 13:33:43 +00:00
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2004-09-19 05:40:00 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
/* Changes the icons wherever it is needed */
|
2006-05-01 21:41:12 +00:00
|
|
|
|
struct ChangeIconThemeData
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserButton *button;
|
|
|
|
|
GtkTreeRowReference *row_ref;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
change_icon_theme_get_info_cb (GCancellable *cancellable,
|
|
|
|
|
GFileInfo *info,
|
|
|
|
|
const GError *error,
|
|
|
|
|
gpointer user_data)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
|
2017-11-09 01:54:48 +00:00
|
|
|
|
GIcon *icon;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
struct ChangeIconThemeData *data = user_data;
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (data->button);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
if (!g_slist_find (priv->change_icon_theme_cancellables, cancellable))
|
2006-05-01 21:41:12 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
priv->change_icon_theme_cancellables =
|
|
|
|
|
g_slist_remove (priv->change_icon_theme_cancellables, cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
if (cancelled || error)
|
|
|
|
|
goto out;
|
|
|
|
|
|
2017-11-15 00:47:04 +00:00
|
|
|
|
icon = _gtk_file_info_get_icon (info, ICON_SIZE, gtk_widget_get_scale_factor (GTK_WIDGET (data->button)));
|
2017-11-09 01:54:48 +00:00
|
|
|
|
if (icon)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
|
|
|
|
gint width = 0;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
2017-11-15 00:47:04 +00:00
|
|
|
|
width = MAX (width, ICON_SIZE);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
path = gtk_tree_row_reference_get_path (data->row_ref);
|
2013-03-12 17:02:38 +00:00
|
|
|
|
if (path)
|
2007-03-12 04:09:25 +00:00
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_tree_model_get_iter (priv->model, &iter, path);
|
2007-03-12 04:09:25 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
|
2017-11-09 01:54:48 +00:00
|
|
|
|
ICON_COLUMN, icon,
|
2007-03-12 04:09:25 +00:00
|
|
|
|
-1);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
g_object_set (priv->icon_cell,
|
2007-03-12 04:09:25 +00:00
|
|
|
|
"width", width,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
2017-11-09 01:54:48 +00:00
|
|
|
|
g_object_unref (icon);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
g_object_unref (data->button);
|
|
|
|
|
gtk_tree_row_reference_free (data->row_ref);
|
|
|
|
|
g_free (data);
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
static void
|
|
|
|
|
change_icon_theme (GtkFileChooserButton *button)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkTreeIter iter;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GSList *l;
|
2017-11-15 00:47:04 +00:00
|
|
|
|
gint width = 0;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
for (l = priv->change_icon_theme_cancellables; l; l = l->next)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GCancellable *cancellable = G_CANCELLABLE (l->data);
|
|
|
|
|
g_cancellable_cancel (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
2018-06-18 15:24:57 +00:00
|
|
|
|
g_slist_free (priv->change_icon_theme_cancellables);
|
|
|
|
|
priv->change_icon_theme_cancellables = NULL;
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2004-11-30 21:06:48 +00:00
|
|
|
|
update_label_and_image (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2006-02-08 19:35:08 +00:00
|
|
|
|
gtk_tree_model_get_iter_first (priv->model, &iter);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
2017-11-09 01:54:48 +00:00
|
|
|
|
GIcon *icon = NULL;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gchar type;
|
|
|
|
|
gpointer data;
|
|
|
|
|
|
|
|
|
|
type = ROW_TYPE_INVALID;
|
|
|
|
|
gtk_tree_model_get (priv->model, &iter,
|
|
|
|
|
TYPE_COLUMN, &type,
|
|
|
|
|
DATA_COLUMN, &data,
|
|
|
|
|
-1);
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case ROW_TYPE_SPECIAL:
|
|
|
|
|
case ROW_TYPE_SHORTCUT:
|
|
|
|
|
case ROW_TYPE_BOOKMARK:
|
|
|
|
|
case ROW_TYPE_CURRENT_FOLDER:
|
|
|
|
|
if (data)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (g_file_is_native (G_FILE (data)))
|
2006-09-22 16:11:04 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreePath *path;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GCancellable *cancellable;
|
2013-03-12 17:02:38 +00:00
|
|
|
|
struct ChangeIconThemeData *info;
|
|
|
|
|
|
2006-09-22 16:11:04 +00:00
|
|
|
|
info = g_new0 (struct ChangeIconThemeData, 1);
|
|
|
|
|
info->button = g_object_ref (button);
|
|
|
|
|
path = gtk_tree_model_get_path (priv->model, &iter);
|
|
|
|
|
info->row_ref = gtk_tree_row_reference_new (priv->model, path);
|
|
|
|
|
gtk_tree_path_free (path);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
|
|
|
|
cancellable =
|
2008-06-13 16:47:41 +00:00
|
|
|
|
_gtk_file_system_get_info (priv->fs, data,
|
|
|
|
|
"standard::icon",
|
|
|
|
|
change_icon_theme_get_info_cb,
|
|
|
|
|
info);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
priv->change_icon_theme_cancellables =
|
|
|
|
|
g_slist_append (priv->change_icon_theme_cancellables, cancellable);
|
2017-11-09 01:54:48 +00:00
|
|
|
|
icon = NULL;
|
2006-09-22 16:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2013-07-03 11:26:03 +00:00
|
|
|
|
{
|
|
|
|
|
/* Don't call get_info for remote paths to avoid latency and
|
|
|
|
|
* auth dialogs.
|
|
|
|
|
* If we switch to a better bookmarks file format (XBEL), we
|
|
|
|
|
* should use mime info to get a better icon.
|
|
|
|
|
*/
|
2017-11-09 01:54:48 +00:00
|
|
|
|
icon = g_themed_icon_new ("folder-remote");
|
2013-07-03 11:26:03 +00:00
|
|
|
|
}
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
2004-12-15 14:58:39 +00:00
|
|
|
|
break;
|
|
|
|
|
case ROW_TYPE_VOLUME:
|
|
|
|
|
if (data)
|
2017-11-09 01:54:48 +00:00
|
|
|
|
icon = _gtk_file_system_volume_get_icon (data);
|
2013-07-03 11:26:03 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
continue;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-09 01:54:48 +00:00
|
|
|
|
if (icon)
|
2017-11-15 00:47:04 +00:00
|
|
|
|
width = MAX (width, ICON_SIZE);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
|
2017-11-09 01:54:48 +00:00
|
|
|
|
ICON_COLUMN, icon,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
-1);
|
2005-08-19 18:21:31 +00:00
|
|
|
|
|
2017-11-09 01:54:48 +00:00
|
|
|
|
if (icon)
|
|
|
|
|
g_object_unref (icon);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
while (gtk_tree_model_iter_next (priv->model, &iter));
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
g_object_set (priv->icon_cell,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
"width", width,
|
|
|
|
|
NULL);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-02-05 01:46:13 +00:00
|
|
|
|
gtk_file_chooser_button_css_changed (GtkWidget *widget,
|
|
|
|
|
GtkCssStyleChange *change)
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
{
|
2020-02-05 01:46:13 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->css_changed (widget, change);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2017-10-31 02:19:29 +00:00
|
|
|
|
/* We need to update the icon surface, but only in case
|
|
|
|
|
* the icon theme really changed. */
|
|
|
|
|
if (!change || gtk_css_style_change_changes_property (change, GTK_CSS_PROPERTY_ICON_THEME))
|
|
|
|
|
change_icon_theme (GTK_FILE_CHOOSER_BUTTON (widget));
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-05-02 00:08:49 +00:00
|
|
|
|
gtk_file_chooser_button_root (GtkWidget *widget)
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
{
|
2019-05-02 00:08:49 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->root (widget);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2008-08-12 09:06:34 +00:00
|
|
|
|
change_icon_theme (GTK_FILE_CHOOSER_BUTTON (widget));
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
/* ******************* *
|
|
|
|
|
* Utility Functions *
|
|
|
|
|
* ******************* */
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
/* General */
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
struct SetDisplayNameData
|
2004-08-17 16:06:39 +00:00
|
|
|
|
{
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GtkFileChooserButton *button;
|
2006-09-17 04:20:43 +00:00
|
|
|
|
char *label;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GtkTreeRowReference *row_ref;
|
|
|
|
|
};
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
set_info_get_info_cb (GCancellable *cancellable,
|
|
|
|
|
GFileInfo *info,
|
|
|
|
|
const GError *error,
|
|
|
|
|
gpointer callback_data)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
|
2017-11-09 01:54:48 +00:00
|
|
|
|
GIcon *icon;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
GtkTreeIter iter;
|
2011-04-01 22:06:51 +00:00
|
|
|
|
GCancellable *model_cancellable = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
struct SetDisplayNameData *data = callback_data;
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (data->button);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gboolean is_folder;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
if (!priv->model)
|
2006-08-17 04:42:27 +00:00
|
|
|
|
/* button got destroyed */
|
|
|
|
|
goto out;
|
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
path = gtk_tree_row_reference_get_path (data->row_ref);
|
|
|
|
|
if (!path)
|
2008-06-10 00:39:35 +00:00
|
|
|
|
/* Cancellable doesn't exist anymore in the model */
|
2006-05-01 21:41:12 +00:00
|
|
|
|
goto out;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_tree_model_get_iter (priv->model, &iter, path);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
/* Validate the cancellable */
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_tree_model_get (priv->model, &iter,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
CANCELLABLE_COLUMN, &model_cancellable,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
-1);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (cancellable != model_cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
goto out;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
CANCELLABLE_COLUMN, NULL,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
-1);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
if (cancelled || error)
|
|
|
|
|
/* There was an error, leave the fallback name in there */
|
|
|
|
|
goto out;
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2017-11-15 00:47:04 +00:00
|
|
|
|
icon = _gtk_file_info_get_icon (info, ICON_SIZE, gtk_widget_get_scale_factor (GTK_WIDGET (data->button)));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2006-09-17 04:20:43 +00:00
|
|
|
|
if (!data->label)
|
2008-06-10 00:39:35 +00:00
|
|
|
|
data->label = g_strdup (g_file_info_get_display_name (info));
|
|
|
|
|
|
2008-12-14 02:14:19 +00:00
|
|
|
|
is_folder = _gtk_file_info_consider_as_directory (info);
|
2006-09-17 04:20:43 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
|
2017-11-09 01:54:48 +00:00
|
|
|
|
ICON_COLUMN, icon,
|
2006-09-17 04:20:43 +00:00
|
|
|
|
DISPLAY_NAME_COLUMN, data->label,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
IS_FOLDER_COLUMN, is_folder,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
-1);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2017-11-09 01:54:48 +00:00
|
|
|
|
if (icon)
|
|
|
|
|
g_object_unref (icon);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
g_object_unref (data->button);
|
2006-09-17 04:20:43 +00:00
|
|
|
|
g_free (data->label);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gtk_tree_row_reference_free (data->row_ref);
|
|
|
|
|
g_free (data);
|
|
|
|
|
|
2015-08-06 12:51:25 +00:00
|
|
|
|
g_object_unref (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
set_info_for_file_at_iter (GtkFileChooserButton *button,
|
|
|
|
|
GFile *file,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
struct SetDisplayNameData *data;
|
|
|
|
|
GtkTreePath *tree_path;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GCancellable *cancellable;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
data = g_new0 (struct SetDisplayNameData, 1);
|
|
|
|
|
data->button = g_object_ref (button);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
data->label = _gtk_bookmarks_manager_get_bookmark_label (priv->bookmarks_manager, file);
|
2006-09-17 04:20:43 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
tree_path = gtk_tree_model_get_path (priv->model, iter);
|
|
|
|
|
data->row_ref = gtk_tree_row_reference_new (priv->model, tree_path);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gtk_tree_path_free (tree_path);
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
cancellable = _gtk_file_system_get_info (priv->fs, file,
|
2008-06-13 16:47:41 +00:00
|
|
|
|
"standard::type,standard::icon,standard::display-name",
|
|
|
|
|
set_info_get_info_cb, data);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (priv->model), iter,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
CANCELLABLE_COLUMN, cancellable,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
-1);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
/* Shortcuts Model */
|
|
|
|
|
static gint
|
|
|
|
|
model_get_type_position (GtkFileChooserButton *button,
|
|
|
|
|
RowType row_type)
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gint retval = 0;
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
if (row_type == ROW_TYPE_SPECIAL)
|
|
|
|
|
return retval;
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
retval += priv->n_special;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
if (row_type == ROW_TYPE_VOLUME)
|
|
|
|
|
return retval;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
retval += priv->n_volumes;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (row_type == ROW_TYPE_SHORTCUT)
|
|
|
|
|
return retval;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
retval += priv->n_shortcuts;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (row_type == ROW_TYPE_BOOKMARK_SEPARATOR)
|
|
|
|
|
return retval;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
retval += priv->has_bookmark_separator;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (row_type == ROW_TYPE_BOOKMARK)
|
|
|
|
|
return retval;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
retval += priv->n_bookmarks;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (row_type == ROW_TYPE_CURRENT_FOLDER_SEPARATOR)
|
|
|
|
|
return retval;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
retval += priv->has_current_folder_separator;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (row_type == ROW_TYPE_CURRENT_FOLDER)
|
|
|
|
|
return retval;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
retval += priv->has_current_folder;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (row_type == ROW_TYPE_OTHER_SEPARATOR)
|
|
|
|
|
return retval;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
retval += priv->has_other_separator;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (row_type == ROW_TYPE_OTHER)
|
|
|
|
|
return retval;
|
|
|
|
|
|
2013-03-07 20:14:47 +00:00
|
|
|
|
retval++;
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
model_free_row_data (GtkFileChooserButton *button,
|
|
|
|
|
GtkTreeIter *iter)
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gchar type;
|
|
|
|
|
gpointer data;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GCancellable *cancellable;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_tree_model_get (priv->model, iter,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
TYPE_COLUMN, &type,
|
|
|
|
|
DATA_COLUMN, &data,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
CANCELLABLE_COLUMN, &cancellable,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
-1);
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (cancellable)
|
2015-08-06 12:51:25 +00:00
|
|
|
|
g_cancellable_cancel (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case ROW_TYPE_SPECIAL:
|
|
|
|
|
case ROW_TYPE_SHORTCUT:
|
|
|
|
|
case ROW_TYPE_BOOKMARK:
|
|
|
|
|
case ROW_TYPE_CURRENT_FOLDER:
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (data);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
break;
|
|
|
|
|
case ROW_TYPE_VOLUME:
|
2010-03-09 04:56:43 +00:00
|
|
|
|
_gtk_file_system_volume_unref (data);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
model_add_special_get_info_cb (GCancellable *cancellable,
|
|
|
|
|
GFileInfo *info,
|
|
|
|
|
const GError *error,
|
|
|
|
|
gpointer user_data)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreePath *path;
|
2017-11-09 01:54:48 +00:00
|
|
|
|
GIcon *icon;
|
2011-04-01 22:06:51 +00:00
|
|
|
|
GCancellable *model_cancellable = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
struct ChangeIconThemeData *data = user_data;
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (data->button);
|
2007-09-11 18:54:00 +00:00
|
|
|
|
gchar *name;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
if (!priv->model)
|
2006-08-17 04:42:27 +00:00
|
|
|
|
/* button got destroyed */
|
|
|
|
|
goto out;
|
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
path = gtk_tree_row_reference_get_path (data->row_ref);
|
|
|
|
|
if (!path)
|
2008-06-10 00:39:35 +00:00
|
|
|
|
/* Cancellable doesn't exist anymore in the model */
|
2006-05-01 21:41:12 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_tree_model_get_iter (priv->model, &iter, path);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_tree_model_get (priv->model, &iter,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
CANCELLABLE_COLUMN, &model_cancellable,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
-1);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (cancellable != model_cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
CANCELLABLE_COLUMN, NULL,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
-1);
|
|
|
|
|
|
|
|
|
|
if (cancelled || error)
|
|
|
|
|
goto out;
|
|
|
|
|
|
2017-11-15 00:47:04 +00:00
|
|
|
|
icon = _gtk_file_info_get_icon (info, ICON_SIZE, gtk_widget_get_scale_factor (GTK_WIDGET (data->button)));
|
2017-11-09 01:54:48 +00:00
|
|
|
|
if (icon)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
|
2017-11-09 01:54:48 +00:00
|
|
|
|
ICON_COLUMN, icon,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
-1);
|
2017-11-09 01:54:48 +00:00
|
|
|
|
g_object_unref (icon);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_tree_model_get (priv->model, &iter,
|
2007-06-07 04:23:10 +00:00
|
|
|
|
DISPLAY_NAME_COLUMN, &name,
|
|
|
|
|
-1);
|
|
|
|
|
if (!name)
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
DISPLAY_NAME_COLUMN, g_file_info_get_display_name (info),
|
2007-06-07 04:23:10 +00:00
|
|
|
|
-1);
|
2007-07-16 15:30:43 +00:00
|
|
|
|
g_free (name);
|
2013-03-12 17:02:38 +00:00
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
out:
|
2006-07-10 16:51:52 +00:00
|
|
|
|
g_object_unref (data->button);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gtk_tree_row_reference_free (data->row_ref);
|
|
|
|
|
g_free (data);
|
|
|
|
|
|
2015-08-06 12:51:25 +00:00
|
|
|
|
g_object_unref (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-07 20:14:47 +00:00
|
|
|
|
static void
|
2004-12-15 14:58:39 +00:00
|
|
|
|
model_add_special (GtkFileChooserButton *button)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
const gchar *homedir;
|
2007-09-11 18:54:00 +00:00
|
|
|
|
const gchar *desktopdir;
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
|
GtkListStore *store;
|
|
|
|
|
GtkTreeIter iter;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
|
gint pos;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
store = GTK_LIST_STORE (priv->model);
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
|
pos = model_get_type_position (button, ROW_TYPE_SPECIAL);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
homedir = g_get_home_dir ();
|
|
|
|
|
|
|
|
|
|
if (homedir)
|
|
|
|
|
{
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GtkTreePath *tree_path;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GCancellable *cancellable;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
struct ChangeIconThemeData *info;
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
file = g_file_new_for_path (homedir);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gtk_list_store_insert (store, &iter, pos);
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
|
pos++;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
info = g_new0 (struct ChangeIconThemeData, 1);
|
|
|
|
|
info->button = g_object_ref (button);
|
|
|
|
|
tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter);
|
|
|
|
|
info->row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (store),
|
|
|
|
|
tree_path);
|
|
|
|
|
gtk_tree_path_free (tree_path);
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
cancellable = _gtk_file_system_get_info (priv->fs, file,
|
2008-06-13 16:47:41 +00:00
|
|
|
|
"standard::icon,standard::display-name",
|
|
|
|
|
model_add_special_get_info_cb, info);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gtk_list_store_set (store, &iter,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
ICON_COLUMN, NULL,
|
|
|
|
|
DISPLAY_NAME_COLUMN, NULL,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
TYPE_COLUMN, ROW_TYPE_SPECIAL,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
DATA_COLUMN, file,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
IS_FOLDER_COLUMN, TRUE,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
CANCELLABLE_COLUMN, cancellable,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
-1);
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
priv->n_special++;
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
|
}
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2007-06-07 04:23:10 +00:00
|
|
|
|
desktopdir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
|
|
2010-10-22 14:07:25 +00:00
|
|
|
|
/* "To disable a directory, point it to the homedir."
|
|
|
|
|
* See http://freedesktop.org/wiki/Software/xdg-user-dirs
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*/
|
2010-10-22 14:07:25 +00:00
|
|
|
|
if (g_strcmp0 (desktopdir, g_get_home_dir ()) != 0)
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
|
{
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GtkTreePath *tree_path;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GCancellable *cancellable;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
struct ChangeIconThemeData *info;
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
file = g_file_new_for_path (desktopdir);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gtk_list_store_insert (store, &iter, pos);
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
|
pos++;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
info = g_new0 (struct ChangeIconThemeData, 1);
|
|
|
|
|
info->button = g_object_ref (button);
|
|
|
|
|
tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter);
|
|
|
|
|
info->row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (store),
|
|
|
|
|
tree_path);
|
|
|
|
|
gtk_tree_path_free (tree_path);
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
cancellable = _gtk_file_system_get_info (priv->fs, file,
|
2008-06-13 16:47:41 +00:00
|
|
|
|
"standard::icon,standard::display-name",
|
|
|
|
|
model_add_special_get_info_cb, info);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gtk_list_store_set (store, &iter,
|
|
|
|
|
TYPE_COLUMN, ROW_TYPE_SPECIAL,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
ICON_COLUMN, NULL,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
DISPLAY_NAME_COLUMN, _(DESKTOP_DISPLAY_NAME),
|
2008-06-10 00:39:35 +00:00
|
|
|
|
DATA_COLUMN, file,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
IS_FOLDER_COLUMN, TRUE,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
CANCELLABLE_COLUMN, cancellable,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
-1);
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
priv->n_special++;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
model_add_volumes (GtkFileChooserButton *button,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GSList *volumes)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkListStore *store;
|
|
|
|
|
gint pos;
|
2006-09-17 03:34:17 +00:00
|
|
|
|
gboolean local_only;
|
|
|
|
|
GSList *l;
|
2011-01-24 02:50:39 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
if (!volumes)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
store = GTK_LIST_STORE (priv->model);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
pos = model_get_type_position (button, ROW_TYPE_VOLUME);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
local_only = gtk_file_chooser_get_local_only (GTK_FILE_CHOOSER (priv->chooser));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2006-09-17 03:34:17 +00:00
|
|
|
|
for (l = volumes; l; l = l->next)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
2006-09-17 03:34:17 +00:00
|
|
|
|
GtkFileSystemVolume *volume;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkTreeIter iter;
|
2017-11-09 01:54:48 +00:00
|
|
|
|
GIcon *icon;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gchar *display_name;
|
|
|
|
|
|
2006-09-17 03:34:17 +00:00
|
|
|
|
volume = l->data;
|
|
|
|
|
|
|
|
|
|
if (local_only)
|
2011-01-24 02:50:39 +00:00
|
|
|
|
{
|
|
|
|
|
if (_gtk_file_system_volume_is_mounted (volume))
|
|
|
|
|
{
|
|
|
|
|
GFile *base_file;
|
2006-09-17 03:34:17 +00:00
|
|
|
|
|
2011-01-24 02:50:39 +00:00
|
|
|
|
base_file = _gtk_file_system_volume_get_root (volume);
|
|
|
|
|
if (base_file != NULL)
|
2010-03-09 04:56:43 +00:00
|
|
|
|
{
|
2013-03-05 23:17:00 +00:00
|
|
|
|
if (!_gtk_file_has_native_path (base_file))
|
2010-03-09 04:56:43 +00:00
|
|
|
|
{
|
|
|
|
|
g_object_unref (base_file);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
g_object_unref (base_file);
|
|
|
|
|
}
|
2011-01-24 02:50:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2006-09-17 03:34:17 +00:00
|
|
|
|
|
2017-11-09 01:54:48 +00:00
|
|
|
|
icon = _gtk_file_system_volume_get_icon (volume);
|
2008-06-13 16:47:41 +00:00
|
|
|
|
display_name = _gtk_file_system_volume_get_display_name (volume);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
gtk_list_store_insert (store, &iter, pos);
|
|
|
|
|
gtk_list_store_set (store, &iter,
|
2017-11-09 01:54:48 +00:00
|
|
|
|
ICON_COLUMN, icon,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
DISPLAY_NAME_COLUMN, display_name,
|
|
|
|
|
TYPE_COLUMN, ROW_TYPE_VOLUME,
|
|
|
|
|
DATA_COLUMN, _gtk_file_system_volume_ref (volume),
|
|
|
|
|
IS_FOLDER_COLUMN, TRUE,
|
|
|
|
|
-1);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2017-11-09 01:54:48 +00:00
|
|
|
|
if (icon)
|
|
|
|
|
g_object_unref (icon);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
g_free (display_name);
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
priv->n_volumes++;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
pos++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
model_add_bookmarks (GtkFileChooserButton *button,
|
|
|
|
|
GSList *bookmarks)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkListStore *store;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gint pos;
|
2006-09-17 03:34:17 +00:00
|
|
|
|
gboolean local_only;
|
|
|
|
|
GSList *l;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (!bookmarks)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
store = GTK_LIST_STORE (priv->model);
|
2006-09-17 03:34:17 +00:00
|
|
|
|
pos = model_get_type_position (button, ROW_TYPE_BOOKMARK);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
local_only = gtk_file_chooser_get_local_only (GTK_FILE_CHOOSER (priv->chooser));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2006-09-17 03:34:17 +00:00
|
|
|
|
for (l = bookmarks; l; l = l->next)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
2006-09-17 03:34:17 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
file = l->data;
|
2006-09-17 03:34:17 +00:00
|
|
|
|
|
2013-03-05 23:17:00 +00:00
|
|
|
|
if (_gtk_file_has_native_path (file))
|
2006-09-22 16:11:04 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_list_store_insert (store, &iter, pos);
|
|
|
|
|
gtk_list_store_set (store, &iter,
|
|
|
|
|
ICON_COLUMN, NULL,
|
|
|
|
|
DISPLAY_NAME_COLUMN, _(FALLBACK_DISPLAY_NAME),
|
|
|
|
|
TYPE_COLUMN, ROW_TYPE_BOOKMARK,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
DATA_COLUMN, g_object_ref (file),
|
2006-09-22 16:11:04 +00:00
|
|
|
|
IS_FOLDER_COLUMN, FALSE,
|
|
|
|
|
-1);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
set_info_for_file_at_iter (button, file, &iter);
|
2006-09-22 16:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gchar *label;
|
2017-11-09 01:54:48 +00:00
|
|
|
|
GIcon *icon;
|
2006-09-22 16:11:04 +00:00
|
|
|
|
|
|
|
|
|
if (local_only)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* Don't call get_info for remote paths to avoid latency and
|
|
|
|
|
* auth dialogs.
|
|
|
|
|
* If we switch to a better bookmarks file format (XBEL), we
|
|
|
|
|
* should use mime info to get a better icon.
|
|
|
|
|
*/
|
2018-06-18 15:24:57 +00:00
|
|
|
|
label = _gtk_bookmarks_manager_get_bookmark_label (priv->bookmarks_manager, file);
|
2006-09-22 16:11:04 +00:00
|
|
|
|
if (!label)
|
2008-06-10 00:39:35 +00:00
|
|
|
|
label = _gtk_file_chooser_label_for_file (file);
|
2006-09-22 16:11:04 +00:00
|
|
|
|
|
2017-11-09 01:54:48 +00:00
|
|
|
|
icon = g_themed_icon_new ("folder-remote");
|
2006-09-22 16:11:04 +00:00
|
|
|
|
|
|
|
|
|
gtk_list_store_insert (store, &iter, pos);
|
|
|
|
|
gtk_list_store_set (store, &iter,
|
2017-11-09 01:54:48 +00:00
|
|
|
|
ICON_COLUMN, icon,
|
2006-09-22 16:11:04 +00:00
|
|
|
|
DISPLAY_NAME_COLUMN, label,
|
|
|
|
|
TYPE_COLUMN, ROW_TYPE_BOOKMARK,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
DATA_COLUMN, g_object_ref (file),
|
2006-09-22 16:11:04 +00:00
|
|
|
|
IS_FOLDER_COLUMN, TRUE,
|
|
|
|
|
-1);
|
|
|
|
|
|
|
|
|
|
g_free (label);
|
2017-11-09 01:54:48 +00:00
|
|
|
|
if (icon)
|
|
|
|
|
g_object_unref (icon);
|
2006-09-22 16:11:04 +00:00
|
|
|
|
}
|
2006-09-17 03:34:17 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
priv->n_bookmarks++;
|
2006-09-17 03:34:17 +00:00
|
|
|
|
pos++;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
if (priv->n_bookmarks > 0 &&
|
|
|
|
|
!priv->has_bookmark_separator)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
2006-09-17 03:34:17 +00:00
|
|
|
|
pos = model_get_type_position (button, ROW_TYPE_BOOKMARK_SEPARATOR);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
gtk_list_store_insert (store, &iter, pos);
|
|
|
|
|
gtk_list_store_set (store, &iter,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
ICON_COLUMN, NULL,
|
2006-09-17 03:34:17 +00:00
|
|
|
|
DISPLAY_NAME_COLUMN, NULL,
|
|
|
|
|
TYPE_COLUMN, ROW_TYPE_BOOKMARK_SEPARATOR,
|
|
|
|
|
DATA_COLUMN, NULL,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
IS_FOLDER_COLUMN, FALSE,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
-1);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
priv->has_bookmark_separator = TRUE;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
model_update_current_folder (GtkFileChooserButton *button,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkListStore *store;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gint pos;
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (!file)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
store = GTK_LIST_STORE (priv->model);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
if (!priv->has_current_folder_separator)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
|
|
|
|
pos = model_get_type_position (button, ROW_TYPE_CURRENT_FOLDER_SEPARATOR);
|
|
|
|
|
gtk_list_store_insert (store, &iter, pos);
|
|
|
|
|
gtk_list_store_set (store, &iter,
|
|
|
|
|
ICON_COLUMN, NULL,
|
|
|
|
|
DISPLAY_NAME_COLUMN, NULL,
|
|
|
|
|
TYPE_COLUMN, ROW_TYPE_CURRENT_FOLDER_SEPARATOR,
|
|
|
|
|
DATA_COLUMN, NULL,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
IS_FOLDER_COLUMN, FALSE,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
-1);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
priv->has_current_folder_separator = TRUE;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pos = model_get_type_position (button, ROW_TYPE_CURRENT_FOLDER);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
if (!priv->has_current_folder)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_list_store_insert (store, &iter, pos);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
priv->has_current_folder = TRUE;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2005-06-13 13:50:49 +00:00
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_tree_model_iter_nth_child (priv->model, &iter, NULL, pos);
|
2005-06-13 13:50:49 +00:00
|
|
|
|
model_free_row_data (button, &iter);
|
|
|
|
|
}
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (g_file_is_native (file))
|
2006-09-22 16:11:04 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_list_store_set (store, &iter,
|
|
|
|
|
ICON_COLUMN, NULL,
|
|
|
|
|
DISPLAY_NAME_COLUMN, _(FALLBACK_DISPLAY_NAME),
|
|
|
|
|
TYPE_COLUMN, ROW_TYPE_CURRENT_FOLDER,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
DATA_COLUMN, g_object_ref (file),
|
2006-09-22 16:11:04 +00:00
|
|
|
|
IS_FOLDER_COLUMN, FALSE,
|
|
|
|
|
-1);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
set_info_for_file_at_iter (button, file, &iter);
|
2006-09-22 16:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gchar *label;
|
2017-11-09 01:54:48 +00:00
|
|
|
|
GIcon *icon;
|
2006-09-22 16:11:04 +00:00
|
|
|
|
|
|
|
|
|
/* Don't call get_info for remote paths to avoid latency and
|
|
|
|
|
* auth dialogs.
|
|
|
|
|
* If we switch to a better bookmarks file format (XBEL), we
|
|
|
|
|
* should use mime info to get a better icon.
|
|
|
|
|
*/
|
2018-06-18 15:24:57 +00:00
|
|
|
|
label = _gtk_bookmarks_manager_get_bookmark_label (priv->bookmarks_manager, file);
|
2006-09-22 16:11:04 +00:00
|
|
|
|
if (!label)
|
2008-06-10 00:39:35 +00:00
|
|
|
|
label = _gtk_file_chooser_label_for_file (file);
|
|
|
|
|
|
|
|
|
|
if (g_file_is_native (file))
|
2017-11-09 01:54:48 +00:00
|
|
|
|
icon = g_themed_icon_new ("folder");
|
2007-06-17 12:02:42 +00:00
|
|
|
|
else
|
2017-11-09 01:54:48 +00:00
|
|
|
|
icon = g_themed_icon_new ("folder-remote");
|
2007-06-17 12:02:44 +00:00
|
|
|
|
|
2006-09-22 16:11:04 +00:00
|
|
|
|
gtk_list_store_set (store, &iter,
|
2017-11-09 01:54:48 +00:00
|
|
|
|
ICON_COLUMN, icon,
|
|
|
|
|
DISPLAY_NAME_COLUMN, label,
|
|
|
|
|
TYPE_COLUMN, ROW_TYPE_CURRENT_FOLDER,
|
|
|
|
|
DATA_COLUMN, g_object_ref (file),
|
|
|
|
|
IS_FOLDER_COLUMN, TRUE,
|
|
|
|
|
-1);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
2006-09-22 16:11:04 +00:00
|
|
|
|
g_free (label);
|
2017-11-09 01:54:48 +00:00
|
|
|
|
if (icon)
|
|
|
|
|
g_object_unref (icon);
|
2006-09-22 16:11:04 +00:00
|
|
|
|
}
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-07 20:14:47 +00:00
|
|
|
|
static void
|
2004-12-15 14:58:39 +00:00
|
|
|
|
model_add_other (GtkFileChooserButton *button)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkListStore *store;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gint pos;
|
2019-12-26 14:29:36 +00:00
|
|
|
|
GIcon *icon;
|
2013-03-12 17:02:38 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
store = GTK_LIST_STORE (priv->model);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
pos = model_get_type_position (button, ROW_TYPE_OTHER_SEPARATOR);
|
2019-12-26 14:29:36 +00:00
|
|
|
|
icon = g_themed_icon_new ("document-open-symbolic");
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
gtk_list_store_insert (store, &iter, pos);
|
|
|
|
|
gtk_list_store_set (store, &iter,
|
2019-12-26 14:29:36 +00:00
|
|
|
|
ICON_COLUMN, icon,
|
|
|
|
|
DISPLAY_NAME_COLUMN, _(FALLBACK_DISPLAY_NAME),
|
|
|
|
|
TYPE_COLUMN, ROW_TYPE_OTHER_SEPARATOR,
|
|
|
|
|
DATA_COLUMN, NULL,
|
|
|
|
|
IS_FOLDER_COLUMN, FALSE,
|
|
|
|
|
-1);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
priv->has_other_separator = TRUE;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
pos++;
|
|
|
|
|
|
|
|
|
|
gtk_list_store_insert (store, &iter, pos);
|
|
|
|
|
gtk_list_store_set (store, &iter,
|
|
|
|
|
ICON_COLUMN, NULL,
|
2012-11-26 08:59:27 +00:00
|
|
|
|
DISPLAY_NAME_COLUMN, _("Other…"),
|
2004-12-15 14:58:39 +00:00
|
|
|
|
TYPE_COLUMN, ROW_TYPE_OTHER,
|
|
|
|
|
DATA_COLUMN, NULL,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
IS_FOLDER_COLUMN, FALSE,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
-1);
|
2019-09-22 07:20:36 +00:00
|
|
|
|
|
|
|
|
|
g_object_unref (icon);
|
2013-03-07 20:14:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
static void
|
|
|
|
|
model_remove_rows (GtkFileChooserButton *button,
|
|
|
|
|
gint pos,
|
|
|
|
|
gint n_rows)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkListStore *store;
|
|
|
|
|
|
|
|
|
|
if (!n_rows)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
store = GTK_LIST_STORE (priv->model);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
if (!gtk_tree_model_iter_nth_child (priv->model, &iter, NULL, pos))
|
2004-12-15 14:58:39 +00:00
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
|
|
|
|
model_free_row_data (button, &iter);
|
|
|
|
|
gtk_list_store_remove (store, &iter);
|
|
|
|
|
n_rows--;
|
|
|
|
|
}
|
|
|
|
|
while (n_rows);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Filter Model */
|
2013-03-07 20:14:47 +00:00
|
|
|
|
static gboolean
|
2008-06-10 00:39:35 +00:00
|
|
|
|
test_if_file_is_visible (GtkFileSystem *fs,
|
|
|
|
|
GFile *file,
|
|
|
|
|
gboolean local_only,
|
|
|
|
|
gboolean is_folder)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (!file)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2013-03-05 23:17:00 +00:00
|
|
|
|
if (local_only && !_gtk_file_has_native_path (file))
|
2004-12-15 14:58:39 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
if (!is_folder)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
filter_model_visible_func (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2005-11-07 15:57:19 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (user_data);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gchar type;
|
|
|
|
|
gpointer data;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gboolean local_only, retval, is_folder;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
type = ROW_TYPE_INVALID;
|
|
|
|
|
data = NULL;
|
2015-10-29 14:13:14 +00:00
|
|
|
|
local_only = gtk_file_chooser_get_local_only (GTK_FILE_CHOOSER (priv->chooser));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, iter,
|
|
|
|
|
TYPE_COLUMN, &type,
|
|
|
|
|
DATA_COLUMN, &data,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
IS_FOLDER_COLUMN, &is_folder,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
-1);
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case ROW_TYPE_CURRENT_FOLDER:
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case ROW_TYPE_SPECIAL:
|
|
|
|
|
case ROW_TYPE_SHORTCUT:
|
|
|
|
|
case ROW_TYPE_BOOKMARK:
|
2008-06-10 00:39:35 +00:00
|
|
|
|
retval = test_if_file_is_visible (priv->fs, data, local_only, is_folder);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
break;
|
|
|
|
|
case ROW_TYPE_VOLUME:
|
|
|
|
|
{
|
2006-09-22 16:11:04 +00:00
|
|
|
|
retval = TRUE;
|
2006-09-17 03:34:17 +00:00
|
|
|
|
if (local_only)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
2008-06-13 16:47:41 +00:00
|
|
|
|
if (_gtk_file_system_volume_is_mounted (data))
|
2006-09-17 03:34:17 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *base_file;
|
|
|
|
|
|
2008-06-13 16:47:41 +00:00
|
|
|
|
base_file = _gtk_file_system_volume_get_root (data);
|
2006-09-17 03:34:17 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (base_file)
|
|
|
|
|
{
|
2013-03-05 23:17:00 +00:00
|
|
|
|
if (!_gtk_file_has_native_path (base_file))
|
2006-09-17 03:34:17 +00:00
|
|
|
|
retval = FALSE;
|
2008-09-21 05:21:00 +00:00
|
|
|
|
g_object_unref (base_file);
|
2006-09-17 03:34:17 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
}
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Combo Box */
|
|
|
|
|
static void
|
|
|
|
|
name_cell_data_func (GtkCellLayout *layout,
|
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
gchar type;
|
|
|
|
|
|
|
|
|
|
type = 0;
|
|
|
|
|
gtk_tree_model_get (model, iter,
|
|
|
|
|
TYPE_COLUMN, &type,
|
|
|
|
|
-1);
|
|
|
|
|
|
|
|
|
|
if (type == ROW_TYPE_CURRENT_FOLDER)
|
|
|
|
|
g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
2013-08-13 21:33:55 +00:00
|
|
|
|
else if (type == ROW_TYPE_BOOKMARK || type == ROW_TYPE_SHORTCUT)
|
|
|
|
|
g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_MIDDLE, NULL);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
else
|
|
|
|
|
g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_NONE, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
combo_box_row_separator_func (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
gchar type = ROW_TYPE_INVALID;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, iter, TYPE_COLUMN, &type, -1);
|
|
|
|
|
|
|
|
|
|
return (type == ROW_TYPE_BOOKMARK_SEPARATOR ||
|
|
|
|
|
type == ROW_TYPE_CURRENT_FOLDER_SEPARATOR ||
|
|
|
|
|
type == ROW_TYPE_OTHER_SEPARATOR);
|
2013-03-07 23:20:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
select_combo_box_row_no_notify (GtkFileChooserButton *button, int pos)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2013-03-07 23:20:16 +00:00
|
|
|
|
GtkTreeIter iter, filter_iter;
|
2013-03-12 17:02:38 +00:00
|
|
|
|
|
2013-03-07 23:20:16 +00:00
|
|
|
|
gtk_tree_model_iter_nth_child (priv->model, &iter, NULL, pos);
|
|
|
|
|
gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (priv->filter_model),
|
|
|
|
|
&filter_iter, &iter);
|
|
|
|
|
|
2013-03-30 08:12:35 +00:00
|
|
|
|
g_signal_handlers_block_by_func (priv->combo_box, combo_box_changed_cb, button);
|
2013-03-07 23:20:16 +00:00
|
|
|
|
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->combo_box), &filter_iter);
|
2013-03-30 08:12:35 +00:00
|
|
|
|
g_signal_handlers_unblock_by_func (priv->combo_box, combo_box_changed_cb, button);
|
2013-03-07 23:20:16 +00:00
|
|
|
|
}
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
update_combo_box (GtkFileChooserButton *button)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2013-02-22 00:44:38 +00:00
|
|
|
|
GFile *file;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gboolean row_found;
|
|
|
|
|
|
2013-03-07 19:44:33 +00:00
|
|
|
|
file = get_selected_file (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
row_found = FALSE;
|
|
|
|
|
|
2013-03-07 19:44:33 +00:00
|
|
|
|
gtk_tree_model_get_iter_first (priv->filter_model, &iter);
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
gchar type;
|
|
|
|
|
gpointer data;
|
|
|
|
|
|
|
|
|
|
type = ROW_TYPE_INVALID;
|
|
|
|
|
data = NULL;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (priv->filter_model, &iter,
|
|
|
|
|
TYPE_COLUMN, &type,
|
|
|
|
|
DATA_COLUMN, &data,
|
|
|
|
|
-1);
|
2013-03-12 17:02:38 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case ROW_TYPE_SPECIAL:
|
|
|
|
|
case ROW_TYPE_SHORTCUT:
|
|
|
|
|
case ROW_TYPE_BOOKMARK:
|
|
|
|
|
case ROW_TYPE_CURRENT_FOLDER:
|
2013-02-22 00:44:38 +00:00
|
|
|
|
row_found = (file && g_file_equal (data, file));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
break;
|
|
|
|
|
case ROW_TYPE_VOLUME:
|
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *base_file;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2008-06-13 16:47:41 +00:00
|
|
|
|
base_file = _gtk_file_system_volume_get_root (data);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (base_file)
|
2006-09-30 13:30:55 +00:00
|
|
|
|
{
|
2013-02-22 00:44:38 +00:00
|
|
|
|
row_found = (file && g_file_equal (base_file, file));
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (base_file);
|
2006-09-30 13:30:55 +00:00
|
|
|
|
}
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
row_found = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (row_found)
|
|
|
|
|
{
|
2013-03-30 08:12:35 +00:00
|
|
|
|
g_signal_handlers_block_by_func (priv->combo_box, combo_box_changed_cb, button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->combo_box),
|
|
|
|
|
&iter);
|
2013-03-30 08:12:35 +00:00
|
|
|
|
g_signal_handlers_unblock_by_func (priv->combo_box, combo_box_changed_cb, button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (!row_found && gtk_tree_model_iter_next (priv->filter_model, &iter));
|
|
|
|
|
|
2013-03-07 20:14:47 +00:00
|
|
|
|
if (!row_found)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
|
|
|
|
gint pos;
|
|
|
|
|
|
2013-03-07 20:14:47 +00:00
|
|
|
|
/* If it hasn't been found already, update & select the current-folder row. */
|
|
|
|
|
if (file)
|
|
|
|
|
{
|
|
|
|
|
model_update_current_folder (button, file);
|
|
|
|
|
pos = model_get_type_position (button, ROW_TYPE_CURRENT_FOLDER);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* No selection; switch to that row */
|
|
|
|
|
|
2019-12-26 14:29:36 +00:00
|
|
|
|
pos = model_get_type_position (button, ROW_TYPE_OTHER_SEPARATOR);
|
2013-03-07 20:14:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-07 23:20:16 +00:00
|
|
|
|
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2013-03-07 23:20:16 +00:00
|
|
|
|
select_combo_box_row_no_notify (button, pos);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-22 00:44:38 +00:00
|
|
|
|
if (file)
|
|
|
|
|
g_object_unref (file);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
/* Button */
|
2006-05-01 21:41:12 +00:00
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
update_label_get_info_cb (GCancellable *cancellable,
|
|
|
|
|
GFileInfo *info,
|
|
|
|
|
const GError *error,
|
|
|
|
|
gpointer data)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
|
2017-11-09 01:54:48 +00:00
|
|
|
|
GIcon *icon;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GtkFileChooserButton *button = data;
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (cancellable != priv->update_button_cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
priv->update_button_cancellable = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
if (cancelled || error)
|
|
|
|
|
goto out;
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (priv->label), g_file_info_get_display_name (info));
|
|
|
|
|
|
2017-11-15 00:47:04 +00:00
|
|
|
|
icon = _gtk_file_info_get_icon (info, ICON_SIZE, gtk_widget_get_scale_factor (GTK_WIDGET (button)));
|
2017-11-15 00:43:13 +00:00
|
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (priv->image), icon);
|
2017-11-15 00:47:04 +00:00
|
|
|
|
gtk_image_set_pixel_size (GTK_IMAGE (priv->image), ICON_SIZE);
|
2017-11-09 01:54:48 +00:00
|
|
|
|
if (icon)
|
|
|
|
|
g_object_unref (icon);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
out:
|
2013-03-12 03:54:22 +00:00
|
|
|
|
emit_selection_changed_if_changing_selection (button);
|
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
g_object_unref (button);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
static void
|
2004-11-30 21:06:48 +00:00
|
|
|
|
update_label_and_image (GtkFileChooserButton *button)
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
gchar *label_text;
|
2013-02-22 00:44:38 +00:00
|
|
|
|
GFile *file;
|
2013-03-12 03:54:22 +00:00
|
|
|
|
gboolean done_changing_selection;
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2013-03-07 19:44:33 +00:00
|
|
|
|
file = get_selected_file (button);
|
|
|
|
|
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
label_text = NULL;
|
2013-03-12 03:54:22 +00:00
|
|
|
|
done_changing_selection = FALSE;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2009-10-21 17:29:03 +00:00
|
|
|
|
if (priv->update_button_cancellable)
|
|
|
|
|
{
|
|
|
|
|
g_cancellable_cancel (priv->update_button_cancellable);
|
|
|
|
|
priv->update_button_cancellable = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-22 00:44:38 +00:00
|
|
|
|
if (file)
|
2004-08-17 16:06:39 +00:00
|
|
|
|
{
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GtkFileSystemVolume *volume = NULL;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2008-06-13 16:47:41 +00:00
|
|
|
|
volume = _gtk_file_system_get_volume_for_file (priv->fs, file);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
if (volume)
|
2011-01-24 02:50:39 +00:00
|
|
|
|
{
|
|
|
|
|
GFile *base_file;
|
|
|
|
|
|
|
|
|
|
base_file = _gtk_file_system_volume_get_root (volume);
|
|
|
|
|
if (base_file && g_file_equal (base_file, file))
|
|
|
|
|
{
|
2017-11-09 01:54:48 +00:00
|
|
|
|
GIcon *icon;
|
2011-01-24 02:50:39 +00:00
|
|
|
|
|
|
|
|
|
label_text = _gtk_file_system_volume_get_display_name (volume);
|
2017-11-09 01:54:48 +00:00
|
|
|
|
icon = _gtk_file_system_volume_get_icon (volume);
|
2017-11-15 00:43:13 +00:00
|
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (priv->image), icon);
|
2017-11-15 00:47:04 +00:00
|
|
|
|
gtk_image_set_pixel_size (GTK_IMAGE (priv->image), ICON_SIZE);
|
2017-11-09 01:54:48 +00:00
|
|
|
|
if (icon)
|
|
|
|
|
g_object_unref (icon);
|
2011-01-24 02:50:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (base_file)
|
|
|
|
|
g_object_unref (base_file);
|
|
|
|
|
|
|
|
|
|
_gtk_file_system_volume_unref (volume);
|
|
|
|
|
|
|
|
|
|
if (label_text)
|
2013-03-12 03:54:22 +00:00
|
|
|
|
{
|
|
|
|
|
done_changing_selection = TRUE;
|
2013-03-07 19:44:33 +00:00
|
|
|
|
goto out;
|
2013-03-12 03:54:22 +00:00
|
|
|
|
}
|
2011-01-24 02:50:39 +00:00
|
|
|
|
}
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (g_file_is_native (file))
|
2011-01-24 02:50:39 +00:00
|
|
|
|
{
|
|
|
|
|
priv->update_button_cancellable =
|
|
|
|
|
_gtk_file_system_get_info (priv->fs, file,
|
|
|
|
|
"standard::icon,standard::display-name",
|
|
|
|
|
update_label_get_info_cb,
|
|
|
|
|
g_object_ref (button));
|
|
|
|
|
}
|
2006-09-22 16:11:04 +00:00
|
|
|
|
else
|
2011-01-24 02:50:39 +00:00
|
|
|
|
{
|
2017-11-09 01:54:48 +00:00
|
|
|
|
GIcon *icon;
|
2011-01-24 02:50:39 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
label_text = _gtk_bookmarks_manager_get_bookmark_label (priv->bookmarks_manager, file);
|
2017-11-09 01:54:48 +00:00
|
|
|
|
icon = g_themed_icon_new ("text-x-generic");
|
2017-11-15 00:43:13 +00:00
|
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (priv->image), icon);
|
2017-11-15 00:47:04 +00:00
|
|
|
|
gtk_image_set_pixel_size (GTK_IMAGE (priv->image), ICON_SIZE);
|
2017-11-09 01:54:48 +00:00
|
|
|
|
if (icon)
|
|
|
|
|
g_object_unref (icon);
|
2013-03-12 03:54:22 +00:00
|
|
|
|
|
|
|
|
|
done_changing_selection = TRUE;
|
2011-01-24 02:50:39 +00:00
|
|
|
|
}
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
}
|
2013-03-12 03:54:22 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We know the selection is empty */
|
|
|
|
|
done_changing_selection = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-09 00:44:15 +00:00
|
|
|
|
out:
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2013-03-07 19:44:33 +00:00
|
|
|
|
if (file)
|
|
|
|
|
g_object_unref (file);
|
|
|
|
|
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
if (label_text)
|
|
|
|
|
{
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (priv->label), label_text);
|
|
|
|
|
g_free (label_text);
|
|
|
|
|
}
|
2004-08-17 16:06:39 +00:00
|
|
|
|
else
|
2008-07-15 05:29:41 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (priv->label), _(FALLBACK_DISPLAY_NAME));
|
2017-11-15 00:43:13 +00:00
|
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (priv->image), NULL);
|
2008-07-15 05:29:41 +00:00
|
|
|
|
}
|
2013-03-12 03:54:22 +00:00
|
|
|
|
|
|
|
|
|
if (done_changing_selection)
|
|
|
|
|
emit_selection_changed_if_changing_selection (button);
|
2004-08-30 13:16:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
/* ************************ *
|
2008-08-04 15:17:27 +00:00
|
|
|
|
* Child Object Callbacks *
|
2004-08-17 16:06:39 +00:00
|
|
|
|
* ************************ */
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
/* File System */
|
|
|
|
|
static void
|
|
|
|
|
fs_volumes_changed_cb (GtkFileSystem *fs,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2005-11-07 15:57:19 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (user_data);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GSList *volumes;
|
|
|
|
|
|
|
|
|
|
model_remove_rows (user_data,
|
|
|
|
|
model_get_type_position (user_data, ROW_TYPE_VOLUME),
|
|
|
|
|
priv->n_volumes);
|
|
|
|
|
|
|
|
|
|
priv->n_volumes = 0;
|
|
|
|
|
|
2008-06-13 16:47:41 +00:00
|
|
|
|
volumes = _gtk_file_system_list_volumes (fs);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
model_add_volumes (user_data, volumes);
|
|
|
|
|
g_slist_free (volumes);
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model));
|
|
|
|
|
|
|
|
|
|
update_label_and_image (user_data);
|
|
|
|
|
update_combo_box (user_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2011-09-30 13:50:15 +00:00
|
|
|
|
bookmarks_changed_cb (gpointer user_data)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
2005-11-07 15:57:19 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (user_data);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GSList *bookmarks;
|
|
|
|
|
|
2011-09-30 13:50:15 +00:00
|
|
|
|
bookmarks = _gtk_bookmarks_manager_list_bookmarks (priv->bookmarks_manager);
|
2006-09-17 03:34:17 +00:00
|
|
|
|
model_remove_rows (user_data,
|
2015-07-31 21:57:04 +00:00
|
|
|
|
model_get_type_position (user_data, ROW_TYPE_BOOKMARK_SEPARATOR),
|
|
|
|
|
priv->n_bookmarks + priv->has_bookmark_separator);
|
2006-09-17 03:34:17 +00:00
|
|
|
|
priv->has_bookmark_separator = FALSE;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
priv->n_bookmarks = 0;
|
|
|
|
|
model_add_bookmarks (user_data, bookmarks);
|
2015-07-31 21:57:04 +00:00
|
|
|
|
g_slist_free_full (bookmarks, g_object_unref);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model));
|
|
|
|
|
|
|
|
|
|
update_label_and_image (user_data);
|
|
|
|
|
update_combo_box (user_data);
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-13 17:01:50 +00:00
|
|
|
|
static void
|
2013-02-13 17:47:35 +00:00
|
|
|
|
save_inactive_state (GtkFileChooserButton *button)
|
2013-02-13 17:01:50 +00:00
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2013-02-13 17:01:50 +00:00
|
|
|
|
|
2013-02-13 17:47:35 +00:00
|
|
|
|
if (priv->current_folder_while_inactive)
|
|
|
|
|
g_object_unref (priv->current_folder_while_inactive);
|
|
|
|
|
|
|
|
|
|
if (priv->selection_while_inactive)
|
|
|
|
|
g_object_unref (priv->selection_while_inactive);
|
|
|
|
|
|
2015-10-29 14:13:14 +00:00
|
|
|
|
priv->current_folder_while_inactive = gtk_file_chooser_get_current_folder_file (GTK_FILE_CHOOSER (priv->chooser));
|
|
|
|
|
priv->selection_while_inactive = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (priv->chooser));
|
2013-02-13 17:47:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
restore_inactive_state (GtkFileChooserButton *button)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
|
|
|
|
|
if (priv->current_folder_while_inactive)
|
2015-10-29 14:13:14 +00:00
|
|
|
|
gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (priv->chooser), priv->current_folder_while_inactive, NULL);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
|
2013-02-13 17:01:50 +00:00
|
|
|
|
if (priv->selection_while_inactive)
|
2015-10-29 14:13:14 +00:00
|
|
|
|
gtk_file_chooser_select_file (GTK_FILE_CHOOSER (priv->chooser), priv->selection_while_inactive, NULL);
|
2013-02-13 17:01:50 +00:00
|
|
|
|
else
|
2015-10-29 14:13:14 +00:00
|
|
|
|
gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (priv->chooser));
|
2013-02-13 17:01:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
/* Dialog */
|
|
|
|
|
static void
|
|
|
|
|
open_dialog (GtkFileChooserButton *button)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2015-10-29 14:13:14 +00:00
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
|
2019-05-20 04:47:50 +00:00
|
|
|
|
toplevel = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (button)));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
/* Setup the dialog parent to be chooser button's toplevel, and be modal
|
|
|
|
|
as needed. */
|
2015-10-29 14:13:14 +00:00
|
|
|
|
if (priv->dialog != NULL)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
2015-10-29 14:13:14 +00:00
|
|
|
|
if (!gtk_widget_get_visible (priv->dialog))
|
|
|
|
|
{
|
2019-05-20 03:31:03 +00:00
|
|
|
|
if (GTK_IS_WINDOW (toplevel))
|
2015-10-29 14:13:14 +00:00
|
|
|
|
{
|
|
|
|
|
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));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2015-10-29 14:13:14 +00:00
|
|
|
|
gtk_window_set_modal (GTK_WINDOW (priv->dialog),
|
|
|
|
|
gtk_window_get_modal (GTK_WINDOW (toplevel)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!gtk_native_dialog_get_visible (GTK_NATIVE_DIALOG (priv->native)))
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
2019-05-20 03:31:03 +00:00
|
|
|
|
if (GTK_IS_WINDOW (toplevel))
|
2015-10-29 14:13:14 +00:00
|
|
|
|
{
|
|
|
|
|
if (GTK_WINDOW (toplevel) != gtk_native_dialog_get_transient_for (GTK_NATIVE_DIALOG (priv->native)))
|
|
|
|
|
gtk_native_dialog_set_transient_for (GTK_NATIVE_DIALOG (priv->native),
|
|
|
|
|
GTK_WINDOW (toplevel));
|
2013-03-12 17:02:38 +00:00
|
|
|
|
|
2015-10-29 14:13:14 +00:00
|
|
|
|
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (priv->native),
|
|
|
|
|
gtk_window_get_modal (GTK_WINDOW (toplevel)));
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!priv->active)
|
|
|
|
|
{
|
2013-02-13 17:47:35 +00:00
|
|
|
|
restore_inactive_state (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
priv->active = TRUE;
|
2015-10-29 14:13:14 +00:00
|
|
|
|
|
|
|
|
|
/* Only handle update-preview handler if it is handled on the button */
|
|
|
|
|
if (g_signal_has_handler_pending (button,
|
|
|
|
|
g_signal_lookup ("update-preview", GTK_TYPE_FILE_CHOOSER),
|
|
|
|
|
0, TRUE))
|
|
|
|
|
{
|
|
|
|
|
g_signal_connect (priv->chooser, "update-preview",
|
|
|
|
|
G_CALLBACK (chooser_update_preview_cb), button);
|
|
|
|
|
}
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (priv->combo_box, FALSE);
|
2015-10-29 14:13:14 +00:00
|
|
|
|
if (priv->dialog)
|
2018-07-25 15:42:26 +00:00
|
|
|
|
{
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
|
|
|
gtk_window_present (GTK_WINDOW (priv->dialog));
|
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
|
|
|
}
|
2015-10-29 14:13:14 +00:00
|
|
|
|
else
|
|
|
|
|
gtk_native_dialog_show (GTK_NATIVE_DIALOG (priv->native));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Combo Box */
|
|
|
|
|
static void
|
|
|
|
|
combo_box_changed_cb (GtkComboBox *combo_box,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2013-06-22 00:14:36 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (user_data);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkTreeIter iter;
|
2013-06-22 00:14:36 +00:00
|
|
|
|
gboolean file_was_set;
|
|
|
|
|
|
|
|
|
|
file_was_set = FALSE;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (gtk_combo_box_get_active_iter (combo_box, &iter))
|
|
|
|
|
{
|
|
|
|
|
gchar type;
|
|
|
|
|
gpointer data;
|
|
|
|
|
|
|
|
|
|
type = ROW_TYPE_INVALID;
|
|
|
|
|
data = NULL;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (priv->filter_model, &iter,
|
|
|
|
|
TYPE_COLUMN, &type,
|
|
|
|
|
DATA_COLUMN, &data,
|
|
|
|
|
-1);
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case ROW_TYPE_SPECIAL:
|
|
|
|
|
case ROW_TYPE_SHORTCUT:
|
|
|
|
|
case ROW_TYPE_BOOKMARK:
|
|
|
|
|
case ROW_TYPE_CURRENT_FOLDER:
|
|
|
|
|
if (data)
|
2013-06-22 00:14:36 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_file_chooser_button_select_file (GTK_FILE_CHOOSER (button), data, NULL);
|
|
|
|
|
file_was_set = TRUE;
|
|
|
|
|
}
|
2004-12-15 14:58:39 +00:00
|
|
|
|
break;
|
|
|
|
|
case ROW_TYPE_VOLUME:
|
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *base_file;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2008-06-13 16:47:41 +00:00
|
|
|
|
base_file = _gtk_file_system_volume_get_root (data);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (base_file)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
2013-03-11 22:48:17 +00:00
|
|
|
|
gtk_file_chooser_button_select_file (GTK_FILE_CHOOSER (button), base_file, NULL);
|
2013-06-22 00:14:36 +00:00
|
|
|
|
file_was_set = TRUE;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (base_file);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case ROW_TYPE_OTHER:
|
|
|
|
|
open_dialog (user_data);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-22 00:14:36 +00:00
|
|
|
|
|
|
|
|
|
if (file_was_set)
|
|
|
|
|
g_signal_emit (button, file_chooser_button_signals[FILE_SET], 0);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Button */
|
|
|
|
|
static void
|
|
|
|
|
button_clicked_cb (GtkButton *real_button,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
open_dialog (user_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Dialog */
|
2013-03-12 16:05:22 +00:00
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
static void
|
2015-10-29 14:13:14 +00:00
|
|
|
|
chooser_update_preview_cb (GtkFileChooser *dialog,
|
|
|
|
|
gpointer user_data)
|
2004-08-17 16:06:39 +00:00
|
|
|
|
{
|
|
|
|
|
g_signal_emit_by_name (user_data, "update-preview");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-10-29 14:13:14 +00:00
|
|
|
|
chooser_notify_cb (GObject *dialog,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer user_data)
|
2004-08-17 16:06:39 +00:00
|
|
|
|
{
|
|
|
|
|
gpointer iface;
|
|
|
|
|
|
|
|
|
|
iface = g_type_interface_peek (g_type_class_peek (G_OBJECT_TYPE (dialog)),
|
|
|
|
|
GTK_TYPE_FILE_CHOOSER);
|
|
|
|
|
if (g_object_interface_find_property (iface, pspec->name))
|
|
|
|
|
g_object_notify (user_data, pspec->name);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2005-03-26 05:49:15 +00:00
|
|
|
|
if (g_ascii_strcasecmp (pspec->name, "local-only") == 0)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
2005-11-07 15:57:19 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (user_data);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (priv->has_current_folder)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gint pos;
|
|
|
|
|
gpointer data;
|
|
|
|
|
|
|
|
|
|
pos = model_get_type_position (user_data,
|
|
|
|
|
ROW_TYPE_CURRENT_FOLDER);
|
2006-02-08 19:35:08 +00:00
|
|
|
|
gtk_tree_model_iter_nth_child (priv->model, &iter, NULL, pos);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
data = NULL;
|
|
|
|
|
gtk_tree_model_get (priv->model, &iter, DATA_COLUMN, &data, -1);
|
|
|
|
|
|
|
|
|
|
/* If the path isn't local but we're in local-only mode now, remove
|
|
|
|
|
* the custom-folder row */
|
2013-03-05 23:17:00 +00:00
|
|
|
|
if (data && _gtk_file_has_native_path (G_FILE (data)) &&
|
2015-10-29 14:13:14 +00:00
|
|
|
|
gtk_file_chooser_get_local_only (GTK_FILE_CHOOSER (priv->chooser)))
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
|
|
|
|
pos--;
|
|
|
|
|
model_remove_rows (user_data, pos, 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model));
|
|
|
|
|
update_combo_box (user_data);
|
|
|
|
|
}
|
2004-08-17 16:06:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-10-29 14:13:14 +00:00
|
|
|
|
common_response_cb (GtkFileChooserButton *button,
|
|
|
|
|
gint response)
|
2004-08-17 16:06:39 +00:00
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2007-09-11 18:54:00 +00:00
|
|
|
|
if (response == GTK_RESPONSE_ACCEPT ||
|
|
|
|
|
response == GTK_RESPONSE_OK)
|
2004-08-17 16:06:39 +00:00
|
|
|
|
{
|
2013-02-13 17:47:35 +00:00
|
|
|
|
save_inactive_state (button);
|
2013-02-12 05:03:26 +00:00
|
|
|
|
|
2012-08-31 17:02:00 +00:00
|
|
|
|
g_signal_emit_by_name (button, "current-folder-changed");
|
|
|
|
|
g_signal_emit_by_name (button, "selection-changed");
|
2004-08-17 16:06:39 +00:00
|
|
|
|
}
|
2013-02-13 17:01:50 +00:00
|
|
|
|
else
|
2004-08-17 16:06:39 +00:00
|
|
|
|
{
|
2013-02-13 17:47:35 +00:00
|
|
|
|
restore_inactive_state (button);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-16 14:18:52 +00:00
|
|
|
|
if (priv->active)
|
2015-10-29 14:13:14 +00:00
|
|
|
|
{
|
|
|
|
|
priv->active = FALSE;
|
|
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (priv->chooser, chooser_update_preview_cb, button);
|
|
|
|
|
}
|
2004-11-30 21:06:48 +00:00
|
|
|
|
|
2013-03-08 18:43:10 +00:00
|
|
|
|
update_label_and_image (button);
|
|
|
|
|
update_combo_box (button);
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gtk_widget_set_sensitive (priv->combo_box, TRUE);
|
2015-10-29 14:13:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dialog_response_cb (GtkDialog *dialog,
|
|
|
|
|
gint response,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (user_data);
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
2015-10-29 14:13:14 +00:00
|
|
|
|
|
|
|
|
|
common_response_cb (button, response);
|
|
|
|
|
|
2004-11-30 21:06:48 +00:00
|
|
|
|
gtk_widget_hide (priv->dialog);
|
2006-12-26 22:20:06 +00:00
|
|
|
|
|
2009-02-11 06:52:43 +00:00
|
|
|
|
if (response == GTK_RESPONSE_ACCEPT ||
|
|
|
|
|
response == GTK_RESPONSE_OK)
|
2012-08-31 17:02:00 +00:00
|
|
|
|
g_signal_emit (button, file_chooser_button_signals[FILE_SET], 0);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-29 14:13:14 +00:00
|
|
|
|
static void
|
|
|
|
|
native_response_cb (GtkFileChooserNative *native,
|
|
|
|
|
gint response,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (user_data);
|
|
|
|
|
|
|
|
|
|
common_response_cb (button, response);
|
|
|
|
|
|
|
|
|
|
/* dialog already hidden */
|
|
|
|
|
|
|
|
|
|
if (response == GTK_RESPONSE_ACCEPT ||
|
|
|
|
|
response == GTK_RESPONSE_OK)
|
|
|
|
|
g_signal_emit (button, file_chooser_button_signals[FILE_SET], 0);
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
/* ************************************************************************** *
|
|
|
|
|
* Public API *
|
|
|
|
|
* ************************************************************************** */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_file_chooser_button_new:
|
|
|
|
|
* @title: the title of the browse dialog.
|
|
|
|
|
* @action: the open mode for the widget.
|
2013-03-12 17:02:38 +00:00
|
|
|
|
*
|
2004-12-15 14:58:39 +00:00
|
|
|
|
* Creates a new file-selecting button widget.
|
2013-03-12 17:02:38 +00:00
|
|
|
|
*
|
2004-12-15 14:58:39 +00:00
|
|
|
|
* Returns: a new button widget.
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*/
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_file_chooser_button_new (const gchar *title,
|
|
|
|
|
GtkFileChooserAction action)
|
2004-08-17 16:06:39 +00:00
|
|
|
|
{
|
2004-12-15 14:58:39 +00:00
|
|
|
|
g_return_val_if_fail (action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
|
|
|
|
action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, NULL);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
return g_object_new (GTK_TYPE_FILE_CHOOSER_BUTTON,
|
|
|
|
|
"action", action,
|
2005-01-06 06:25:30 +00:00
|
|
|
|
"title", (title ? title : _(DEFAULT_TITLE)),
|
2004-12-15 14:58:39 +00:00
|
|
|
|
NULL);
|
|
|
|
|
}
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_file_chooser_button_new_with_dialog:
|
2014-05-26 16:41:21 +00:00
|
|
|
|
* @dialog: (type Gtk.Dialog): the widget to use as dialog
|
2007-09-11 18:54:00 +00:00
|
|
|
|
*
|
|
|
|
|
* Creates a #GtkFileChooserButton widget which uses @dialog as its
|
|
|
|
|
* file-picking window.
|
|
|
|
|
*
|
|
|
|
|
* Note that @dialog must be a #GtkDialog (or subclass) which
|
|
|
|
|
* implements the #GtkFileChooser interface and must not have
|
|
|
|
|
* %GTK_DIALOG_DESTROY_WITH_PARENT set.
|
|
|
|
|
*
|
|
|
|
|
* Also note that the dialog needs to have its confirmative button
|
|
|
|
|
* added with response %GTK_RESPONSE_ACCEPT or %GTK_RESPONSE_OK in
|
|
|
|
|
* order for the button to take over the file selected in the dialog.
|
|
|
|
|
*
|
2004-12-15 14:58:39 +00:00
|
|
|
|
* Returns: a new button widget.
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*/
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_file_chooser_button_new_with_dialog (GtkWidget *dialog)
|
|
|
|
|
{
|
2006-12-20 19:02:21 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (dialog) && GTK_IS_DIALOG (dialog), NULL);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
return g_object_new (GTK_TYPE_FILE_CHOOSER_BUTTON,
|
|
|
|
|
"dialog", dialog,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_file_chooser_button_set_title:
|
|
|
|
|
* @button: the button widget to modify.
|
|
|
|
|
* @title: the new browse dialog title.
|
2013-03-12 17:02:38 +00:00
|
|
|
|
*
|
2004-12-15 14:58:39 +00:00
|
|
|
|
* Modifies the @title of the browse dialog used by @button.
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*/
|
2004-12-15 14:58:39 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_file_chooser_button_set_title (GtkFileChooserButton *button,
|
|
|
|
|
const gchar *title)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_FILE_CHOOSER_BUTTON (button));
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
if (priv->dialog)
|
|
|
|
|
gtk_window_set_title (GTK_WINDOW (priv->dialog), title);
|
2015-10-29 14:13:14 +00:00
|
|
|
|
else
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_native_dialog_set_title (GTK_NATIVE_DIALOG (priv->native), title);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
g_object_notify (G_OBJECT (button), "title");
|
|
|
|
|
}
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_file_chooser_button_get_title:
|
|
|
|
|
* @button: the button widget to examine.
|
2013-03-12 17:02:38 +00:00
|
|
|
|
*
|
2004-12-15 14:58:39 +00:00
|
|
|
|
* Retrieves the title of the browse dialog used by @button. The returned value
|
|
|
|
|
* should not be modified or freed.
|
2013-03-12 17:02:38 +00:00
|
|
|
|
*
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* Returns: a pointer to the browse dialog’s title.
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*/
|
2011-06-06 18:13:44 +00:00
|
|
|
|
const gchar *
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gtk_file_chooser_button_get_title (GtkFileChooserButton *button)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_FILE_CHOOSER_BUTTON (button), NULL);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
if (priv->dialog)
|
|
|
|
|
return gtk_window_get_title (GTK_WINDOW (priv->dialog));
|
2015-10-29 14:13:14 +00:00
|
|
|
|
else
|
2018-06-18 15:24:57 +00:00
|
|
|
|
return gtk_native_dialog_get_title (GTK_NATIVE_DIALOG (priv->native));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_file_chooser_button_get_width_chars:
|
|
|
|
|
* @button: the button widget to examine.
|
2013-03-12 17:02:38 +00:00
|
|
|
|
*
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* Retrieves the width in characters of the @button widget’s entry and/or label.
|
2013-03-12 17:02:38 +00:00
|
|
|
|
*
|
2004-12-15 14:58:39 +00:00
|
|
|
|
* Returns: an integer width (in characters) that the button will use to size itself.
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*/
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gint
|
|
|
|
|
gtk_file_chooser_button_get_width_chars (GtkFileChooserButton *button)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_FILE_CHOOSER_BUTTON (button), -1);
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
return gtk_label_get_width_chars (GTK_LABEL (priv->label));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_file_chooser_button_set_width_chars:
|
|
|
|
|
* @button: the button widget to examine.
|
2005-01-06 06:25:30 +00:00
|
|
|
|
* @n_chars: the new width, in characters.
|
2013-03-12 17:02:38 +00:00
|
|
|
|
*
|
2004-12-15 14:58:39 +00:00
|
|
|
|
* Sets the width (in characters) that @button will use to @n_chars.
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*/
|
2004-12-15 14:58:39 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_file_chooser_button_set_width_chars (GtkFileChooserButton *button,
|
|
|
|
|
gint n_chars)
|
|
|
|
|
{
|
2018-06-18 15:24:57 +00:00
|
|
|
|
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_FILE_CHOOSER_BUTTON (button));
|
|
|
|
|
|
2018-06-18 15:24:57 +00:00
|
|
|
|
gtk_label_set_width_chars (GTK_LABEL (priv->label), n_chars);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
g_object_notify (G_OBJECT (button), "width-chars");
|
2004-08-17 16:06:39 +00:00
|
|
|
|
}
|