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"
|
2020-02-29 02:47:17 +00:00
|
|
|
|
#include "gtkdroptarget.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"
|
2020-04-08 11:43:28 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2011-04-13 19:46:31 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SECTION:gtkfilechooserbutton
|
2020-04-18 00:08:21 +00:00
|
|
|
|
* @Short_description: A button to launch a file chooser dialog
|
2011-04-13 19:46:31 +00:00
|
|
|
|
* @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;
|
2020-02-21 15:11:15 +00:00
|
|
|
|
* GFile *cwd = g_file_new_for_path ("/etc");
|
2011-04-13 19:46:31 +00:00
|
|
|
|
*
|
|
|
|
|
* button = gtk_file_chooser_button_new (_("Select a file"),
|
|
|
|
|
* GTK_FILE_CHOOSER_ACTION_OPEN);
|
2020-02-21 15:11:15 +00:00
|
|
|
|
* gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button), cwd);
|
|
|
|
|
* g_object_unref (cwd);
|
2011-04-13 19:46:31 +00:00
|
|
|
|
* }
|
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,
|
2020-04-13 03:45:03 +00:00
|
|
|
|
PROP_WIDTH_CHARS,
|
|
|
|
|
PROP_MODAL
|
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;
|
|
|
|
|
|
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;
|
2020-04-13 03:57:49 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _GtkFileChooserButtonClass
|
|
|
|
|
{
|
|
|
|
|
GtkWidgetClass parent_class;
|
|
|
|
|
|
|
|
|
|
void (* file_set) (GtkFileChooserButton *fc);
|
|
|
|
|
};
|
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);
|
2020-05-05 20:48:11 +00:00
|
|
|
|
static void gtk_file_chooser_button_dispose (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 */
|
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_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);
|
|
|
|
|
|
|
|
|
|
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_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER,
|
|
|
|
|
gtk_file_chooser_button_file_chooser_iface_init))
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2020-02-29 02:47:17 +00:00
|
|
|
|
struct DndSelectFolderData
|
|
|
|
|
{
|
|
|
|
|
GtkFileSystem *file_system;
|
|
|
|
|
GtkFileChooserButton *button;
|
|
|
|
|
GtkFileChooserAction action;
|
|
|
|
|
GFile *file;
|
|
|
|
|
gchar **uris;
|
|
|
|
|
guint i;
|
|
|
|
|
gboolean selected;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dnd_select_folder_get_info_cb (GCancellable *cancellable,
|
|
|
|
|
GFileInfo *info,
|
|
|
|
|
const GError *error,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
struct DndSelectFolderData *data = user_data;
|
|
|
|
|
GtkFileChooserButton *button = data->button;
|
|
|
|
|
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (cancellable != button->dnd_select_folder_cancellable)
|
2020-02-29 02:47:17 +00:00
|
|
|
|
{
|
|
|
|
|
g_object_unref (data->button);
|
|
|
|
|
g_object_unref (data->file);
|
|
|
|
|
g_strfreev (data->uris);
|
|
|
|
|
g_free (data);
|
|
|
|
|
|
|
|
|
|
g_object_unref (cancellable);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->dnd_select_folder_cancellable = NULL;
|
2020-02-29 02:47:17 +00:00
|
|
|
|
|
|
|
|
|
if (!cancelled && !error && info != NULL)
|
|
|
|
|
{
|
|
|
|
|
gboolean is_folder;
|
|
|
|
|
|
|
|
|
|
is_folder = _gtk_file_info_consider_as_directory (info);
|
|
|
|
|
|
|
|
|
|
data->selected =
|
|
|
|
|
(((data->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER && is_folder) ||
|
|
|
|
|
(data->action == GTK_FILE_CHOOSER_ACTION_OPEN && !is_folder)) &&
|
|
|
|
|
gtk_file_chooser_select_file (GTK_FILE_CHOOSER (data->button), data->file, NULL));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
data->selected = FALSE;
|
|
|
|
|
|
|
|
|
|
if (data->selected || data->uris[++data->i] == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_signal_emit (data->button, file_chooser_button_signals[FILE_SET], 0);
|
|
|
|
|
|
|
|
|
|
g_object_unref (data->button);
|
|
|
|
|
g_object_unref (data->file);
|
|
|
|
|
g_strfreev (data->uris);
|
|
|
|
|
g_free (data);
|
|
|
|
|
|
|
|
|
|
g_object_unref (cancellable);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data->file)
|
|
|
|
|
g_object_unref (data->file);
|
|
|
|
|
|
|
|
|
|
data->file = g_file_new_for_uri (data->uris[data->i]);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->dnd_select_folder_cancellable =
|
2020-02-29 02:47:17 +00:00
|
|
|
|
_gtk_file_system_get_info (data->file_system, data->file,
|
|
|
|
|
"standard::type",
|
|
|
|
|
dnd_select_folder_get_info_cb, user_data);
|
|
|
|
|
|
|
|
|
|
g_object_unref (cancellable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_file_chooser_button_drop (GtkDropTarget *target,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
GtkFileChooserButton *button)
|
|
|
|
|
{
|
|
|
|
|
struct DndSelectFolderData *info;
|
|
|
|
|
GFile *file;
|
|
|
|
|
|
|
|
|
|
file = g_value_get_object (value);
|
|
|
|
|
|
|
|
|
|
info = g_new0 (struct DndSelectFolderData, 1);
|
|
|
|
|
info->button = g_object_ref (button);
|
|
|
|
|
info->i = 0;
|
|
|
|
|
info->uris = g_new0 (char *, 2);
|
|
|
|
|
info->selected = FALSE;
|
2020-04-13 03:57:49 +00:00
|
|
|
|
info->file_system = button->fs;
|
|
|
|
|
g_object_get (button->chooser, "action", &info->action, NULL);
|
2020-02-29 02:47:17 +00:00
|
|
|
|
|
|
|
|
|
info->file = g_object_ref (file);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->dnd_select_folder_cancellable)
|
|
|
|
|
g_cancellable_cancel (button->dnd_select_folder_cancellable);
|
2020-02-29 02:47:17 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->dnd_select_folder_cancellable =
|
|
|
|
|
_gtk_file_system_get_info (button->fs, info->file,
|
2020-02-29 02:47:17 +00:00
|
|
|
|
"standard::type",
|
|
|
|
|
dnd_select_folder_get_info_cb, info);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2020-05-05 20:48:11 +00:00
|
|
|
|
gobject_class->dispose = gtk_file_chooser_button_dispose;
|
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
|
|
|
|
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;
|
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;
|
2020-04-08 11:43:28 +00:00
|
|
|
|
widget_class->grab_focus = gtk_widget_grab_focus_child;
|
|
|
|
|
widget_class->focus = gtk_widget_focus_child;
|
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
|
|
|
|
|
2020-04-13 03:45:03 +00:00
|
|
|
|
g_object_class_install_property (gobject_class, PROP_MODAL,
|
|
|
|
|
g_param_spec_boolean ("modal",
|
|
|
|
|
P_("Modal"),
|
|
|
|
|
P_("Whether to make the dialog modal"),
|
2020-04-13 04:12:30 +00:00
|
|
|
|
TRUE,
|
2020-04-13 03:45:03 +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)
|
|
|
|
|
{
|
2017-01-18 21:21:42 +00:00
|
|
|
|
GtkWidget *box;
|
|
|
|
|
GtkWidget *icon;
|
2020-02-29 02:47:17 +00:00
|
|
|
|
GtkDropTarget *target;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->button = gtk_button_new ();
|
|
|
|
|
g_signal_connect (button->button, "clicked", G_CALLBACK (button_clicked_cb), button);
|
|
|
|
|
button->image = gtk_image_new ();
|
|
|
|
|
button->label = gtk_label_new (_(FALLBACK_DISPLAY_NAME));
|
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (button->label), 0.0f);
|
|
|
|
|
gtk_widget_set_hexpand (button->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);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_widget_set_valign (button->image, GTK_ALIGN_BASELINE);
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (box), button->image);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_widget_set_valign (button->label, GTK_ALIGN_BASELINE);
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (box), button->label);
|
2017-01-18 21:21:42 +00:00
|
|
|
|
gtk_widget_set_valign (icon, GTK_ALIGN_BASELINE);
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (box), icon);
|
2020-05-02 07:05:19 +00:00
|
|
|
|
gtk_button_set_child (GTK_BUTTON (button->button), box);
|
2017-01-18 21:21:42 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_widget_set_parent (button->button, GTK_WIDGET (button));
|
2017-01-18 21:21:42 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->model = GTK_TREE_MODEL (gtk_list_store_new (NUM_COLUMNS,
|
|
|
|
|
G_TYPE_ICON,
|
|
|
|
|
G_TYPE_STRING,
|
|
|
|
|
G_TYPE_CHAR,
|
|
|
|
|
G_TYPE_POINTER,
|
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
|
G_TYPE_POINTER));
|
2017-01-18 21:21:42 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->combo_box = gtk_combo_box_new ();
|
|
|
|
|
g_signal_connect (button->combo_box, "changed", G_CALLBACK (combo_box_changed_cb), button);
|
|
|
|
|
button->icon_cell = gtk_cell_renderer_pixbuf_new ();
|
|
|
|
|
button->name_cell = gtk_cell_renderer_text_new ();
|
|
|
|
|
g_object_set (button->name_cell, "xpad", 6, NULL);
|
2017-01-18 21:21:42 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (button->combo_box), button->icon_cell, FALSE);
|
|
|
|
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (button->combo_box),
|
|
|
|
|
button->icon_cell, "gicon", ICON_COLUMN, NULL);
|
2017-01-18 21:21:42 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (button->combo_box), button->name_cell, FALSE);
|
|
|
|
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (button->combo_box),
|
|
|
|
|
button->name_cell, "text", DISPLAY_NAME_COLUMN, NULL);
|
2017-01-18 21:21:42 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_widget_hide (button->combo_box);
|
|
|
|
|
gtk_widget_set_parent (button->combo_box, GTK_WIDGET (button));
|
2017-01-18 21:21:42 +00:00
|
|
|
|
|
2011-09-30 13:50:15 +00:00
|
|
|
|
/* Bookmarks manager */
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->bookmarks_manager = _gtk_bookmarks_manager_new (bookmarks_changed_cb, button);
|
|
|
|
|
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (button->combo_box),
|
|
|
|
|
button->name_cell, name_cell_data_func,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
/* DnD */
|
2020-02-29 02:47:17 +00:00
|
|
|
|
target = gtk_drop_target_new (G_TYPE_FILE, GDK_ACTION_COPY);
|
|
|
|
|
g_signal_connect (target, "drop", G_CALLBACK (gtk_file_chooser_button_drop), button);
|
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (button), GTK_EVENT_CONTROLLER (target));
|
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)
|
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->is_changing_selection)
|
2013-03-12 03:54:22 +00:00
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->is_changing_selection = FALSE;
|
2013-03-12 03:54:22 +00:00
|
|
|
|
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);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->current_folder_while_inactive)
|
|
|
|
|
g_object_unref (button->current_folder_while_inactive);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->active)
|
|
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button->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);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->current_folder_while_inactive)
|
|
|
|
|
return g_object_ref (button->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);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->selection_while_inactive)
|
|
|
|
|
g_object_unref (button->selection_while_inactive);
|
2013-02-12 05:03:26 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->selection_while_inactive = g_object_ref (file);
|
2013-03-12 17:21:35 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->active)
|
|
|
|
|
gtk_file_chooser_select_file (GTK_FILE_CHOOSER (button->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)
|
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->selection_while_inactive)
|
2013-03-12 17:21:35 +00:00
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_object_unref (button->selection_while_inactive);
|
|
|
|
|
button->selection_while_inactive = NULL;
|
2013-02-12 05:03:26 +00:00
|
|
|
|
}
|
2013-03-12 17:21:35 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->is_changing_selection = TRUE;
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_button_unselect_file (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (chooser);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (g_file_equal (button->selection_while_inactive, file))
|
2013-03-12 17:21:35 +00:00
|
|
|
|
unselect_current_file (button);
|
2013-02-12 05:03:26 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->active)
|
|
|
|
|
gtk_file_chooser_unselect_file (GTK_FILE_CHOOSER (button->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);
|
|
|
|
|
|
2013-03-12 17:21:35 +00:00
|
|
|
|
unselect_current_file (button);
|
2013-02-12 05:03:26 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->active)
|
|
|
|
|
gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (button->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
|
|
|
|
{
|
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;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->selection_while_inactive)
|
|
|
|
|
retval = button->selection_while_inactive;
|
|
|
|
|
else if (button->chooser && gtk_file_chooser_get_action (button->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
|
|
|
|
*/
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->current_folder_while_inactive)
|
|
|
|
|
retval = button->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);
|
2020-02-21 15:11:15 +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);
|
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);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
pos += button->n_shortcuts;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_list_store_insert (GTK_LIST_STORE (button->model), &iter, pos);
|
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (button->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);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->n_shortcuts++;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (button->filter_model));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2020-02-21 15:11:15 +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);
|
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);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_iter_nth_child (button->model, &iter, NULL, pos);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
gpointer data;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_get (button->model, &iter,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
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);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_list_store_remove (GTK_LIST_STORE (button->model), &iter);
|
|
|
|
|
button->n_shortcuts--;
|
|
|
|
|
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (button->filter_model));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
update_combo_box (GTK_FILE_CHOOSER_BUTTON (chooser));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (type == ROW_TYPE_SHORTCUT &&
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_iter_next (button->model, &iter));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (!button->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
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->native = gtk_file_chooser_native_new (NULL,
|
2020-04-13 04:12:30 +00:00
|
|
|
|
NULL,
|
|
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->chooser = GTK_FILE_CHOOSER (button->native);
|
2007-09-11 18:54:00 +00:00
|
|
|
|
gtk_file_chooser_button_set_title (button, _(DEFAULT_TITLE));
|
2020-04-13 04:12:30 +00:00
|
|
|
|
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (button->native), TRUE);
|
2015-10-29 14:13:14 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_signal_connect (button->native, "response",
|
2015-10-29 14:13:14 +00:00
|
|
|
|
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
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->chooser = GTK_FILE_CHOOSER (button->dialog);
|
|
|
|
|
gtk_window_set_hide_on_close (GTK_WINDOW (button->chooser), TRUE);
|
2015-10-29 14:13:14 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (!gtk_window_get_title (GTK_WINDOW (button->dialog)))
|
2015-10-29 14:13:14 +00:00
|
|
|
|
gtk_file_chooser_button_set_title (button, _(DEFAULT_TITLE));
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_signal_connect (button->dialog, "response",
|
2015-10-29 14:13:14 +00:00
|
|
|
|
G_CALLBACK (dialog_response_cb), object);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (button->dialog),
|
|
|
|
|
(gpointer) (&button->dialog));
|
2007-09-11 18:54:00 +00:00
|
|
|
|
}
|
2006-04-19 17:21:55 +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
|
|
|
|
/* This is used, instead of the standard delegate, to ensure that signals are only
|
|
|
|
|
* delegated when the OK button is pressed. */
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_object_set_qdata (object, GTK_FILE_CHOOSER_DELEGATE_QUARK, button->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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->fs =
|
|
|
|
|
g_object_ref (_gtk_file_chooser_get_file_system (button->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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
list = _gtk_file_system_list_volumes (button->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);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
list = _gtk_bookmarks_manager_list_bookmarks (button->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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->filter_model = gtk_tree_model_filter_new (button->model, NULL);
|
|
|
|
|
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (button->filter_model),
|
2004-12-15 14:58:39 +00:00
|
|
|
|
filter_model_visible_func,
|
|
|
|
|
object, NULL);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_combo_box_set_model (GTK_COMBO_BOX (button->combo_box), button->filter_model);
|
|
|
|
|
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (button->combo_box),
|
2004-12-15 14:58:39 +00:00
|
|
|
|
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,
|
2020-04-13 03:57:49 +00:00
|
|
|
|
"action", gtk_file_chooser_get_action (GTK_FILE_CHOOSER (button->chooser)),
|
2005-05-16 21:07:16 +00:00
|
|
|
|
NULL);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->fs_volumes_changed_id =
|
|
|
|
|
g_signal_connect (button->fs, "volumes-changed",
|
2004-12-15 14:58:39 +00:00
|
|
|
|
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);
|
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 */
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->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_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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_object_set_property (G_OBJECT (button->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:
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_widget_hide (button->combo_box);
|
|
|
|
|
gtk_widget_show (button->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:
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_widget_show (button->combo_box);
|
|
|
|
|
gtk_widget_hide (button->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:
|
2020-04-13 03:45:03 +00:00
|
|
|
|
case PROP_MODAL:
|
2004-08-17 16:06:39 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_FILTER:
|
2009-07-28 12:15:59 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS:
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_object_set_property (G_OBJECT (button->chooser), pspec->name, value);
|
2004-08-17 16:06:39 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
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);
|
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,
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_label_get_width_chars (GTK_LABEL (button->label)));
|
2004-08-17 16:06:39 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_TITLE:
|
2020-04-13 03:45:03 +00:00
|
|
|
|
case PROP_MODAL:
|
2004-08-17 16:06:39 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_ACTION:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_FILTER:
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
|
2009-12-20 22:56:28 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS:
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_object_get_property (G_OBJECT (button->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);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_clear_object (&button->selection_while_inactive);
|
|
|
|
|
g_clear_object (&button->current_folder_while_inactive);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_widget_unparent (button->button);
|
|
|
|
|
gtk_widget_unparent (button->combo_box);
|
2017-01-18 21:21:42 +00:00
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
if (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_DROP_ACTIVE)
|
2019-09-22 07:12:38 +00:00
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_widget_set_state_flags (button->button, GTK_STATE_FLAG_DROP_ACTIVE, FALSE);
|
|
|
|
|
gtk_widget_set_state_flags (button->combo_box, GTK_STATE_FLAG_DROP_ACTIVE, FALSE);
|
2019-09-22 07:12:38 +00:00
|
|
|
|
}
|
2016-03-11 13:50:38 +00:00
|
|
|
|
else
|
2019-09-22 07:12:38 +00:00
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_widget_unset_state_flags (button->button, GTK_STATE_FLAG_DROP_ACTIVE);
|
|
|
|
|
gtk_widget_unset_state_flags (button->combo_box, GTK_STATE_FLAG_DROP_ACTIVE);
|
2019-09-22 07:12:38 +00:00
|
|
|
|
}
|
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
|
2020-05-05 20:48:11 +00:00
|
|
|
|
gtk_file_chooser_button_dispose (GObject *object)
|
2004-08-17 16:06:39 +00:00
|
|
|
|
{
|
2020-05-05 20:48:11 +00:00
|
|
|
|
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (object);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GSList *l;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->model)
|
2019-05-03 06:10:50 +00:00
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
model_remove_rows (button, 0, gtk_tree_model_iter_n_children (button->model, NULL));
|
|
|
|
|
g_clear_object (&button->model);
|
2019-05-03 06:10:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-09 14:26:22 +00:00
|
|
|
|
g_clear_pointer ((GtkWindow **)&button->dialog, gtk_window_destroy);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->native)
|
|
|
|
|
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (button->native));
|
2015-10-29 14:13:14 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_clear_object (&button->native);
|
|
|
|
|
button->chooser = NULL; /* Was either button->dialog or button->native! */
|
2015-10-29 14:13:14 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_clear_pointer (&button->dnd_select_folder_cancellable, g_cancellable_cancel);
|
|
|
|
|
g_clear_pointer (&button->update_button_cancellable, g_cancellable_cancel);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->change_icon_theme_cancellables)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
for (l = button->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
|
|
|
|
}
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_slist_free (button->change_icon_theme_cancellables);
|
|
|
|
|
button->change_icon_theme_cancellables = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_clear_object (&button->filter_model);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->fs)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_signal_handler_disconnect (button->fs, button->fs_volumes_changed_id);
|
|
|
|
|
g_clear_object (&button->fs);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
2004-11-30 21:06:48 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_clear_pointer (&button->bookmarks_manager, _gtk_bookmarks_manager_free);
|
2011-09-30 13:50:15 +00:00
|
|
|
|
|
2020-05-05 20:48:11 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_file_chooser_button_parent_class)->dispose (object);
|
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);
|
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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->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);
|
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-04-13 03:57:49 +00:00
|
|
|
|
if (button->dialog)
|
|
|
|
|
gtk_widget_hide (button->dialog);
|
|
|
|
|
else if (button->native)
|
|
|
|
|
gtk_native_dialog_hide (GTK_NATIVE_DIALOG (button->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);
|
2004-09-19 05:40:00 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
switch (gtk_file_chooser_get_action (GTK_FILE_CHOOSER (button->chooser)))
|
2004-12-16 13:33:43 +00:00
|
|
|
|
{
|
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_OPEN:
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_widget_grab_focus (button->button);
|
2004-12-16 13:33:43 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:
|
2020-04-13 03:57:49 +00:00
|
|
|
|
return gtk_widget_mnemonic_activate (button->combo_box, group_cycling);
|
2004-12-16 13:33:43 +00:00
|
|
|
|
break;
|
2017-10-06 19:19:42 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_SAVE:
|
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;
|
2020-04-13 03:57:49 +00:00
|
|
|
|
GtkFileChooserButton *button = data->button;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (!g_slist_find (button->change_icon_theme_cancellables, cancellable))
|
2006-05-01 21:41:12 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->change_icon_theme_cancellables =
|
|
|
|
|
g_slist_remove (button->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
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_get_iter (button->model, &iter, path);
|
2007-03-12 04:09:25 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (button->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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_object_set (button->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)
|
|
|
|
|
{
|
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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
for (l = button->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
|
|
|
|
}
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_slist_free (button->change_icon_theme_cancellables);
|
|
|
|
|
button->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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_get_iter_first (button->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;
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_get (button->model, &iter,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
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);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
path = gtk_tree_model_get_path (button->model, &iter);
|
|
|
|
|
info->row_ref = gtk_tree_row_reference_new (button->model, path);
|
2006-09-22 16:11:04 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
|
|
|
|
cancellable =
|
2020-04-13 03:57:49 +00:00
|
|
|
|
_gtk_file_system_get_info (button->fs, data,
|
2008-06-13 16:47:41 +00:00
|
|
|
|
"standard::icon",
|
|
|
|
|
change_icon_theme_get_info_cb,
|
|
|
|
|
info);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->change_icon_theme_cancellables =
|
|
|
|
|
g_slist_append (button->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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (button->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
|
|
|
|
}
|
2020-04-13 03:57:49 +00:00
|
|
|
|
while (gtk_tree_model_iter_next (button->model, &iter));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_object_set (button->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
|
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;
|
2020-04-13 03:57:49 +00:00
|
|
|
|
GtkFileChooserButton *button = data->button;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gboolean is_folder;
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (!button->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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_get_iter (button->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 */
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_get (button->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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (button->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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (button->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)
|
|
|
|
|
{
|
|
|
|
|
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);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
data->label = _gtk_bookmarks_manager_get_bookmark_label (button->bookmarks_manager, file);
|
2006-09-17 04:20:43 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
tree_path = gtk_tree_model_get_path (button->model, iter);
|
|
|
|
|
data->row_ref = gtk_tree_row_reference_new (button->model, tree_path);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gtk_tree_path_free (tree_path);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
cancellable = _gtk_file_system_get_info (button->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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (button->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
|
|
|
|
{
|
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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
retval += button->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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
retval += button->n_volumes;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (row_type == ROW_TYPE_SHORTCUT)
|
|
|
|
|
return retval;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
retval += button->n_shortcuts;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (row_type == ROW_TYPE_BOOKMARK_SEPARATOR)
|
|
|
|
|
return retval;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
retval += button->has_bookmark_separator;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (row_type == ROW_TYPE_BOOKMARK)
|
|
|
|
|
return retval;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
retval += button->n_bookmarks;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (row_type == ROW_TYPE_CURRENT_FOLDER_SEPARATOR)
|
|
|
|
|
return retval;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
retval += button->has_current_folder_separator;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (row_type == ROW_TYPE_CURRENT_FOLDER)
|
|
|
|
|
return retval;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
retval += button->has_current_folder;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (row_type == ROW_TYPE_OTHER_SEPARATOR)
|
|
|
|
|
return retval;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
retval += button->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
|
|
|
|
{
|
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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_get (button->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;
|
2020-04-13 03:57:49 +00:00
|
|
|
|
GtkFileChooserButton *button = data->button;
|
2007-09-11 18:54:00 +00:00
|
|
|
|
gchar *name;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (!button->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;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_get_iter (button->model, &iter, path);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_get (button->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)
|
2020-04-13 03:57:49 +00:00
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (button->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
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (button->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
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_get (button->model, &iter,
|
2007-06-07 04:23:10 +00:00
|
|
|
|
DISPLAY_NAME_COLUMN, &name,
|
|
|
|
|
-1);
|
|
|
|
|
if (!name)
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (button->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)
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
store = GTK_LIST_STORE (button->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);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
cancellable = _gtk_file_system_get_info (button->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);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->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);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
cancellable = _gtk_file_system_get_info (button->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);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->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
|
|
|
|
{
|
|
|
|
|
GtkListStore *store;
|
|
|
|
|
gint pos;
|
2006-09-17 03:34:17 +00:00
|
|
|
|
GSList *l;
|
2011-01-24 02:50:39 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
if (!volumes)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
store = GTK_LIST_STORE (button->model);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
pos = model_get_type_position (button, ROW_TYPE_VOLUME);
|
|
|
|
|
|
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;
|
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);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->n_volumes++;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
pos++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
model_add_bookmarks (GtkFileChooserButton *button,
|
|
|
|
|
GSList *bookmarks)
|
|
|
|
|
{
|
|
|
|
|
GtkListStore *store;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gint pos;
|
2006-09-17 03:34:17 +00:00
|
|
|
|
GSList *l;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
if (!bookmarks)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
store = GTK_LIST_STORE (button->model);
|
2006-09-17 03:34:17 +00:00
|
|
|
|
pos = model_get_type_position (button, ROW_TYPE_BOOKMARK);
|
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
|
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
|
*/
|
2020-04-13 03:57:49 +00:00
|
|
|
|
label = _gtk_bookmarks_manager_get_bookmark_label (button->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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->n_bookmarks++;
|
2006-09-17 03:34:17 +00:00
|
|
|
|
pos++;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->n_bookmarks > 0 &&
|
|
|
|
|
!button->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);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->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
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
store = GTK_LIST_STORE (button->model);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (!button->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);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->has_current_folder_separator = TRUE;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pos = model_get_type_position (button, ROW_TYPE_CURRENT_FOLDER);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (!button->has_current_folder)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_list_store_insert (store, &iter, pos);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->has_current_folder = TRUE;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2005-06-13 13:50:49 +00:00
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_iter_nth_child (button->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.
|
|
|
|
|
*/
|
2020-04-13 03:57:49 +00:00
|
|
|
|
label = _gtk_bookmarks_manager_get_bookmark_label (button->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)
|
|
|
|
|
{
|
|
|
|
|
GtkListStore *store;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gint pos;
|
2019-12-26 14:29:36 +00:00
|
|
|
|
GIcon *icon;
|
2013-03-12 17:02:38 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
store = GTK_LIST_STORE (button->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);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->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)
|
|
|
|
|
{
|
|
|
|
|
GtkListStore *store;
|
|
|
|
|
|
|
|
|
|
if (!n_rows)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
store = GTK_LIST_STORE (button->model);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (!gtk_tree_model_iter_nth_child (button->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 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;
|
|
|
|
|
|
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);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
gchar type;
|
|
|
|
|
gpointer data;
|
2020-02-21 16:44:39 +00:00
|
|
|
|
gboolean retval, is_folder;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
type = ROW_TYPE_INVALID;
|
|
|
|
|
data = NULL;
|
|
|
|
|
|
|
|
|
|
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:
|
2020-04-13 03:57:49 +00:00
|
|
|
|
retval = test_if_file_is_visible (button->fs, data, is_folder);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
break;
|
|
|
|
|
case ROW_TYPE_VOLUME:
|
2020-02-21 16:44:39 +00:00
|
|
|
|
retval = TRUE;
|
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)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter, filter_iter;
|
2013-03-12 17:02:38 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_iter_nth_child (button->model, &iter, NULL, pos);
|
|
|
|
|
gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (button->filter_model),
|
2013-03-07 23:20:16 +00:00
|
|
|
|
&filter_iter, &iter);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_signal_handlers_block_by_func (button->combo_box, combo_box_changed_cb, button);
|
|
|
|
|
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (button->combo_box), &filter_iter);
|
|
|
|
|
g_signal_handlers_unblock_by_func (button->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)
|
|
|
|
|
{
|
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;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_get_iter_first (button->filter_model, &iter);
|
2013-03-07 19:44:33 +00:00
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
gchar type;
|
|
|
|
|
gpointer data;
|
|
|
|
|
|
|
|
|
|
type = ROW_TYPE_INVALID;
|
|
|
|
|
data = NULL;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_get (button->filter_model, &iter,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_signal_handlers_block_by_func (button->combo_box, combo_box_changed_cb, button);
|
|
|
|
|
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (button->combo_box),
|
2004-12-15 14:58:39 +00:00
|
|
|
|
&iter);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_signal_handlers_unblock_by_func (button->combo_box, combo_box_changed_cb, button);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-13 03:57:49 +00:00
|
|
|
|
while (!row_found && gtk_tree_model_iter_next (button->filter_model, &iter));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (button->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;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (cancellable != button->update_button_cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->update_button_cancellable = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
if (cancelled || error)
|
|
|
|
|
goto out;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (button->label), g_file_info_get_display_name (info));
|
2008-06-10 00:39:35 +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 (button)));
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (button->image), icon);
|
|
|
|
|
gtk_image_set_pixel_size (GTK_IMAGE (button->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
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->update_button_cancellable)
|
2009-10-21 17:29:03 +00:00
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
g_cancellable_cancel (button->update_button_cancellable);
|
|
|
|
|
button->update_button_cancellable = NULL;
|
2009-10-21 17:29:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
volume = _gtk_file_system_get_volume_for_file (button->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);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (button->image), icon);
|
|
|
|
|
gtk_image_set_pixel_size (GTK_IMAGE (button->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
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->update_button_cancellable =
|
|
|
|
|
_gtk_file_system_get_info (button->fs, file,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
"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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
label_text = _gtk_bookmarks_manager_get_bookmark_label (button->bookmarks_manager, file);
|
2017-11-09 01:54:48 +00:00
|
|
|
|
icon = g_themed_icon_new ("text-x-generic");
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (button->image), icon);
|
|
|
|
|
gtk_image_set_pixel_size (GTK_IMAGE (button->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)
|
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (button->label), label_text);
|
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_free (label_text);
|
|
|
|
|
}
|
2004-08-17 16:06:39 +00:00
|
|
|
|
else
|
2008-07-15 05:29:41 +00:00
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (button->label), _(FALLBACK_DISPLAY_NAME));
|
|
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (button->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);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GSList *volumes;
|
|
|
|
|
|
|
|
|
|
model_remove_rows (user_data,
|
|
|
|
|
model_get_type_position (user_data, ROW_TYPE_VOLUME),
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->n_volumes);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->n_volumes = 0;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
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);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (button->filter_model));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
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);
|
2004-12-15 14:58:39 +00:00
|
|
|
|
GSList *bookmarks;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
bookmarks = _gtk_bookmarks_manager_list_bookmarks (button->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),
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->n_bookmarks + button->has_bookmark_separator);
|
|
|
|
|
button->has_bookmark_separator = FALSE;
|
|
|
|
|
button->n_bookmarks = 0;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (button->filter_model));
|
2004-12-15 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->current_folder_while_inactive)
|
|
|
|
|
g_object_unref (button->current_folder_while_inactive);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->selection_while_inactive)
|
|
|
|
|
g_object_unref (button->selection_while_inactive);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->current_folder_while_inactive = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (button->chooser));
|
|
|
|
|
button->selection_while_inactive = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (button->chooser));
|
2013-02-13 17:47:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
restore_inactive_state (GtkFileChooserButton *button)
|
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->current_folder_while_inactive)
|
|
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button->chooser), button->current_folder_while_inactive, NULL);
|
2013-02-13 17:47:35 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->selection_while_inactive)
|
|
|
|
|
gtk_file_chooser_select_file (GTK_FILE_CHOOSER (button->chooser), button->selection_while_inactive, NULL);
|
2013-02-13 17:01:50 +00:00
|
|
|
|
else
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (button->chooser));
|
2013-02-13 17:01:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-15 14:58:39 +00:00
|
|
|
|
/* Dialog */
|
|
|
|
|
static void
|
|
|
|
|
open_dialog (GtkFileChooserButton *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. */
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->dialog != NULL)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (!gtk_widget_get_visible (button->dialog))
|
2015-10-29 14:13:14 +00:00
|
|
|
|
{
|
2019-05-20 03:31:03 +00:00
|
|
|
|
if (GTK_IS_WINDOW (toplevel))
|
2015-10-29 14:13:14 +00:00
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (GTK_WINDOW (toplevel) != gtk_window_get_transient_for (GTK_WINDOW (button->dialog)))
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (button->dialog),
|
2015-10-29 14:13:14 +00:00
|
|
|
|
GTK_WINDOW (toplevel));
|
2020-04-13 04:12:30 +00:00
|
|
|
|
if (gtk_window_get_modal (GTK_WINDOW (toplevel)))
|
|
|
|
|
gtk_window_set_modal (GTK_WINDOW (button->dialog), TRUE);
|
2015-10-29 14:13:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (!gtk_native_dialog_get_visible (GTK_NATIVE_DIALOG (button->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
|
|
|
|
{
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (GTK_WINDOW (toplevel) != gtk_native_dialog_get_transient_for (GTK_NATIVE_DIALOG (button->native)))
|
|
|
|
|
gtk_native_dialog_set_transient_for (GTK_NATIVE_DIALOG (button->native),
|
2015-10-29 14:13:14 +00:00
|
|
|
|
GTK_WINDOW (toplevel));
|
2013-03-12 17:02:38 +00:00
|
|
|
|
|
2020-04-13 04:12:30 +00:00
|
|
|
|
if (gtk_window_get_modal (GTK_WINDOW (toplevel)))
|
|
|
|
|
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (button->native), TRUE);
|
2015-10-29 14:13:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (!button->active)
|
2004-12-15 14:58:39 +00:00
|
|
|
|
{
|
2013-02-13 17:47:35 +00:00
|
|
|
|
restore_inactive_state (button);
|
2020-04-13 03:57:49 +00:00
|
|
|
|
button->active = TRUE;
|
2004-12-15 14:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_widget_set_sensitive (button->combo_box, FALSE);
|
|
|
|
|
if (button->dialog)
|
2018-07-25 15:42:26 +00:00
|
|
|
|
{
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_window_present (GTK_WINDOW (button->dialog));
|
2018-07-25 15:42:26 +00:00
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
|
|
|
}
|
2015-10-29 14:13:14 +00:00
|
|
|
|
else
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_native_dialog_show (GTK_NATIVE_DIALOG (button->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);
|
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;
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_tree_model_get (button->filter_model, &iter,
|
2004-12-15 14:58:39 +00:00
|
|
|
|
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
|
|
|
|
common_response_cb (GtkFileChooserButton *button,
|
|
|
|
|
gint response)
|
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
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->active)
|
|
|
|
|
button->active = FALSE;
|
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);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_widget_set_sensitive (button->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);
|
|
|
|
|
|
|
|
|
|
common_response_cb (button, response);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_widget_hide (button->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)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_FILE_CHOOSER_BUTTON (button));
|
2004-08-17 16:06:39 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->dialog)
|
|
|
|
|
gtk_window_set_title (GTK_WINDOW (button->dialog), title);
|
2015-10-29 14:13:14 +00:00
|
|
|
|
else
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_native_dialog_set_title (GTK_NATIVE_DIALOG (button->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)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
if (button->dialog)
|
|
|
|
|
return gtk_window_get_title (GTK_WINDOW (button->dialog));
|
2015-10-29 14:13:14 +00:00
|
|
|
|
else
|
2020-04-13 03:57:49 +00:00
|
|
|
|
return gtk_native_dialog_get_title (GTK_NATIVE_DIALOG (button->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)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_FILE_CHOOSER_BUTTON (button), -1);
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
return gtk_label_get_width_chars (GTK_LABEL (button->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)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_FILE_CHOOSER_BUTTON (button));
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
gtk_label_set_width_chars (GTK_LABEL (button->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
|
|
|
|
}
|
2020-04-13 03:45:03 +00:00
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_file_chooser_button_set_modal:
|
|
|
|
|
* @button: a #GtkFileChooserButton
|
|
|
|
|
* @modal: %TRUE to make the dialog modal
|
|
|
|
|
*
|
|
|
|
|
* Sets whether the dialog should be modal.
|
|
|
|
|
*/
|
2020-04-13 03:45:03 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_file_chooser_button_set_modal (GtkFileChooserButton *button,
|
|
|
|
|
gboolean modal)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_FILE_CHOOSER_BUTTON (button));
|
|
|
|
|
|
|
|
|
|
g_object_set (button, "modal", modal, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 03:57:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_file_chooser_button_get_modal:
|
|
|
|
|
* @button: a #GtkFileChooserButton
|
|
|
|
|
*
|
|
|
|
|
* Gets whether the dialog is modal.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the dialog is modal
|
|
|
|
|
*/
|
2020-04-13 03:45:03 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_file_chooser_button_get_modal (GtkFileChooserButton *button)
|
|
|
|
|
{
|
|
|
|
|
gboolean modal;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_FILE_CHOOSER_BUTTON (button), FALSE);
|
|
|
|
|
|
|
|
|
|
g_object_get (button, "modal", &modal, NULL);
|
|
|
|
|
|
|
|
|
|
return modal;
|
|
|
|
|
}
|