2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2004-02-27 14:20:19 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpfiledialog.c
|
|
|
|
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2004-02-27 14:20:19 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2004-02-27 14:20:19 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2004-02-27 14:20:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-09 20:24:04 +00:00
|
|
|
#include <gegl.h>
|
2004-02-27 14:20:19 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2007-05-13 17:18:35 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2015-08-31 20:57:37 +02:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2004-02-27 14:20:19 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
|
|
|
#include "core/gimpimage.h"
|
2004-08-10 18:47:21 +00:00
|
|
|
#include "core/gimpprogress.h"
|
2004-02-27 14:20:19 +00:00
|
|
|
|
2004-10-04 22:25:04 +00:00
|
|
|
#include "config/gimpguiconfig.h"
|
2004-02-27 15:43:58 +00:00
|
|
|
|
2016-01-06 15:07:41 +01:00
|
|
|
#include "plug-in/gimppluginmanager-file.h"
|
2006-08-05 21:21:01 +00:00
|
|
|
#include "plug-in/gimppluginprocedure.h"
|
2006-03-31 09:15:08 +00:00
|
|
|
|
2004-02-27 14:20:19 +00:00
|
|
|
#include "gimpfiledialog.h"
|
2004-07-16 21:24:39 +00:00
|
|
|
#include "gimpfileprocview.h"
|
2005-09-28 21:20:05 +00:00
|
|
|
#include "gimpprogressbox.h"
|
2004-07-17 19:53:05 +00:00
|
|
|
#include "gimpthumbbox.h"
|
2006-11-24 14:08:40 +00:00
|
|
|
#include "gimpwidgets-utils.h"
|
2004-04-15 16:28:26 +00:00
|
|
|
|
2004-02-27 14:20:19 +00:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
2015-09-09 00:00:50 +02:00
|
|
|
|
2015-08-31 20:57:37 +02:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_GIMP,
|
|
|
|
PROP_HELP_ID,
|
2017-02-12 16:06:34 +01:00
|
|
|
PROP_OK_BUTTON_LABEL,
|
2015-08-31 20:57:37 +02:00
|
|
|
PROP_AUTOMATIC_HELP_ID,
|
|
|
|
PROP_AUTOMATIC_LABEL,
|
|
|
|
PROP_FILE_FILTER_LABEL,
|
|
|
|
PROP_FILE_PROCS,
|
2018-07-25 15:28:04 +02:00
|
|
|
PROP_FILE_PROCS_ALL_IMAGES,
|
|
|
|
PROP_SHOW_ALL_FILES,
|
2015-08-31 20:57:37 +02:00
|
|
|
};
|
2008-05-08 11:30:54 +00:00
|
|
|
|
2015-09-09 00:00:50 +02:00
|
|
|
typedef struct _GimpFileDialogState GimpFileDialogState;
|
|
|
|
|
|
|
|
struct _GimpFileDialogState
|
|
|
|
{
|
|
|
|
gchar *filter_name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-09-08 23:09:06 +02:00
|
|
|
static void gimp_file_dialog_progress_iface_init (GimpProgressInterface *iface);
|
|
|
|
|
|
|
|
static void gimp_file_dialog_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_file_dialog_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_file_dialog_constructed (GObject *object);
|
|
|
|
static void gimp_file_dialog_dispose (GObject *object);
|
|
|
|
|
|
|
|
static gboolean gimp_file_dialog_delete_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *event);
|
|
|
|
static void gimp_file_dialog_response (GtkDialog *dialog,
|
|
|
|
gint response_id);
|
2015-09-08 23:27:17 +02:00
|
|
|
static GFile * gimp_file_dialog_real_get_default_folder (GimpFileDialog *dialog);
|
|
|
|
static void gimp_file_dialog_real_save_state (GimpFileDialog *dialog,
|
|
|
|
const gchar *state_name);
|
|
|
|
static void gimp_file_dialog_real_load_state (GimpFileDialog *dialog,
|
|
|
|
const gchar *state_name);
|
|
|
|
|
2004-08-10 18:47:21 +00:00
|
|
|
static GimpProgress *
|
2015-09-08 23:09:06 +02:00
|
|
|
gimp_file_dialog_progress_start (GimpProgress *progress,
|
|
|
|
gboolean cancellable,
|
|
|
|
const gchar *message);
|
|
|
|
static void gimp_file_dialog_progress_end (GimpProgress *progress);
|
|
|
|
static gboolean gimp_file_dialog_progress_is_active (GimpProgress *progress);
|
|
|
|
static void gimp_file_dialog_progress_set_text (GimpProgress *progress,
|
|
|
|
const gchar *message);
|
|
|
|
static void gimp_file_dialog_progress_set_value (GimpProgress *progress,
|
|
|
|
gdouble percentage);
|
|
|
|
static gdouble gimp_file_dialog_progress_get_value (GimpProgress *progress);
|
|
|
|
static void gimp_file_dialog_progress_pulse (GimpProgress *progress);
|
app, libgimp*, pdb, plug-ins: reimplement generic inter-process transient window.
Having windows ID as guint32 is a mistake. Different systems have
different protocols. In Wayland in particular, Windows handles are
exchanged as strings. What this commit does is the following:
In core:
- get_window_id() virtual function in core GimpProgress is changed to
return a GBytes, as a generic "data" to represent a window differently
on different systems.
- All implementations of get_window_id() in various classes implementing
this interface are updated accordingly:
* GimpSubProgress
* GimpDisplay returns the handle of its shell.
* GimpDisplayShell now creates its window handle at construction with
libgimpwidget's gimp_widget_set_native_handle() and simply return
this handle every time it's requested.
* GimpFileDialog also creates its window handle at construction with
gimp_widget_set_native_handle().
- gimp_window_set_transient_for() in core is changed to take a
GimpProgress as argument (instead of a guint32 ID), requests and
process the ID itself, according to the running platform. In
particular, the following were improved:
* Unlike old code, it will work even if the window is not visible yet.
In such a case, the function simply adds a signal handler to set
transient at mapping. It makes it easier to use it at construction
in a reliable way.
* It now works for Wayland too, additionally to X11.
- GimpPdbProgress now exchanges a GBytes too with the command
GIMP_PROGRESS_COMMAND_GET_WINDOW.
- display_get_window_id() in gimp-gui.h also returns a GBytes now.
PDB/libgimp:
- gimp_display_get_window_handle() and gimp_progress_get_window_handle()
now return a GBytes to represent a window handle in an opaque way
(depending on the running platform).
In libgimp:
- GimpProgress's get_window() virtual function changed to return a
GBytes and renamed get_window_handle().
- In particular GimpProgressBar is the only implementation of
get_window_handle(). It creates its handle at object construction with
libgimpwidget's gimp_widget_set_native_handle() and the virtual
method's implementation simply returns the GBytes.
In libgimpUi:
- gimp_ui_get_display_window() and gimp_ui_get_progress_window() were
removed. We should not assume anymore that it is possible to create a
GdkWindow to be used. For instance this is not possible with Wayland
which has its own way to set a window transient with a string handle.
- gimp_window_set_transient_for_display() and
gimp_window_set_transient() now use an internal implementation similar
to core gimp_window_set_transient_for(), with the same improvements
(works even at construction when the window is not visible yet + works
for Wayland too).
In libgimpwidgets:
- New gimp_widget_set_native_handle() is a helper function used both in
core and libgimp* libraries for widgets which we want to be usable as
possible parents. It takes care of getting the relevant window handle
(depending on the running platform) and stores it in a given pointer,
either immediately or after a callback once the widget is mapped. So
it can be used at construction. Also it sets a handle for X11 or
Wayland.
In plug-ins:
- Screenshot uses the new gimp_progress_get_window_handle() directly now
in its X11 code path and creates out of it a GdkWindows itself with
gdk_x11_window_foreign_new_for_display().
Our inter-process transient implementation only worked for X11, and with
this commit, it works for Wayland too.
There is code for Windows but it is currently disabled as it apparently
hangs (there is a comment in-code which links to this old report:
https://bugzilla.gnome.org/show_bug.cgi?id=359538). NikcDC tested
yesterday with re-enabling the code and said they experienced a freeze.
;-(
Finally there is no infrastructure yet to make this work on macOS and
apparently there is no implementation of window handle in GDK for macOS
that I could find. I'm not sure if macOS doesn't have this concept of
setting transient on another processus's window or GDK is simply lacking
the implementation.
2023-08-14 14:23:06 +02:00
|
|
|
static GBytes * gimp_file_dialog_progress_get_window_id (GimpProgress *progress);
|
2015-09-08 23:09:06 +02:00
|
|
|
|
|
|
|
static void gimp_file_dialog_add_user_dir (GimpFileDialog *dialog,
|
|
|
|
GUserDirectory directory);
|
|
|
|
static void gimp_file_dialog_add_preview (GimpFileDialog *dialog);
|
|
|
|
static void gimp_file_dialog_add_proc_selection (GimpFileDialog *dialog);
|
|
|
|
|
|
|
|
static void gimp_file_dialog_selection_changed (GtkFileChooser *chooser,
|
|
|
|
GimpFileDialog *dialog);
|
|
|
|
static void gimp_file_dialog_update_preview (GtkFileChooser *chooser,
|
|
|
|
GimpFileDialog *dialog);
|
|
|
|
|
|
|
|
static void gimp_file_dialog_proc_changed (GimpFileProcView *view,
|
|
|
|
GimpFileDialog *dialog);
|
|
|
|
|
|
|
|
static void gimp_file_dialog_help_func (const gchar *help_id,
|
|
|
|
gpointer help_data);
|
|
|
|
|
2015-09-01 13:49:59 +02:00
|
|
|
static GimpFileDialogState
|
2015-09-08 23:09:06 +02:00
|
|
|
* gimp_file_dialog_get_state (GimpFileDialog *dialog);
|
|
|
|
static void gimp_file_dialog_set_state (GimpFileDialog *dialog,
|
|
|
|
GimpFileDialogState *state);
|
|
|
|
static void gimp_file_dialog_state_destroy (GimpFileDialogState *state);
|
2015-09-01 13:49:59 +02:00
|
|
|
|
|
|
|
|
2015-09-09 00:00:50 +02:00
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpFileDialog, gimp_file_dialog,
|
|
|
|
GTK_TYPE_FILE_CHOOSER_DIALOG,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS,
|
2006-05-15 09:46:31 +00:00
|
|
|
gimp_file_dialog_progress_iface_init))
|
2005-12-19 22:37:49 +00:00
|
|
|
|
|
|
|
#define parent_class gimp_file_dialog_parent_class
|
|
|
|
|
2004-02-27 14:20:19 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_file_dialog_class_init (GimpFileDialogClass *klass)
|
|
|
|
{
|
2010-10-15 14:08:36 +02:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2004-02-27 14:20:19 +00:00
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2004-08-10 21:20:38 +00:00
|
|
|
GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
|
2004-02-27 14:20:19 +00:00
|
|
|
|
2015-08-31 20:57:37 +02:00
|
|
|
object_class->set_property = gimp_file_dialog_set_property;
|
|
|
|
object_class->get_property = gimp_file_dialog_get_property;
|
|
|
|
object_class->constructed = gimp_file_dialog_constructed;
|
2010-10-15 14:08:36 +02:00
|
|
|
object_class->dispose = gimp_file_dialog_dispose;
|
2008-10-21 19:23:44 +00:00
|
|
|
|
2004-02-27 14:20:19 +00:00
|
|
|
widget_class->delete_event = gimp_file_dialog_delete_event;
|
2004-08-10 21:20:38 +00:00
|
|
|
|
|
|
|
dialog_class->response = gimp_file_dialog_response;
|
2015-08-31 20:57:37 +02:00
|
|
|
|
2015-09-08 23:09:06 +02:00
|
|
|
klass->get_default_folder = gimp_file_dialog_real_get_default_folder;
|
2015-09-01 13:49:59 +02:00
|
|
|
klass->save_state = gimp_file_dialog_real_save_state;
|
|
|
|
klass->load_state = gimp_file_dialog_real_load_state;
|
|
|
|
|
2015-08-31 20:57:37 +02:00
|
|
|
g_object_class_install_property (object_class, PROP_GIMP,
|
|
|
|
g_param_spec_object ("gimp", NULL, NULL,
|
|
|
|
GIMP_TYPE_GIMP,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2016-01-06 14:10:36 +01:00
|
|
|
|
2015-08-31 20:57:37 +02:00
|
|
|
g_object_class_install_property (object_class, PROP_HELP_ID,
|
|
|
|
g_param_spec_string ("help-id", NULL, NULL,
|
|
|
|
NULL,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2017-02-12 16:06:34 +01:00
|
|
|
g_object_class_install_property (object_class, PROP_OK_BUTTON_LABEL,
|
|
|
|
g_param_spec_string ("ok-button-label",
|
|
|
|
NULL, NULL,
|
|
|
|
_("_OK"),
|
2016-01-06 14:23:28 +01:00
|
|
|
GIMP_PARAM_WRITABLE |
|
2015-08-31 20:57:37 +02:00
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2016-01-06 14:10:36 +01:00
|
|
|
|
2015-08-31 20:57:37 +02:00
|
|
|
g_object_class_install_property (object_class, PROP_AUTOMATIC_HELP_ID,
|
2016-01-06 14:10:36 +01:00
|
|
|
g_param_spec_string ("automatic-help-id",
|
|
|
|
NULL, NULL,
|
2015-08-31 20:57:37 +02:00
|
|
|
NULL,
|
2016-01-06 14:23:28 +01:00
|
|
|
GIMP_PARAM_WRITABLE |
|
2015-08-31 20:57:37 +02:00
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2016-01-06 14:10:36 +01:00
|
|
|
|
2015-08-31 20:57:37 +02:00
|
|
|
g_object_class_install_property (object_class, PROP_AUTOMATIC_LABEL,
|
2016-01-06 14:10:36 +01:00
|
|
|
g_param_spec_string ("automatic-label",
|
|
|
|
NULL, NULL,
|
2015-08-31 20:57:37 +02:00
|
|
|
NULL,
|
2016-01-06 14:23:28 +01:00
|
|
|
GIMP_PARAM_WRITABLE |
|
2015-08-31 20:57:37 +02:00
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_FILE_FILTER_LABEL,
|
2016-01-06 14:10:36 +01:00
|
|
|
g_param_spec_string ("file-filter-label",
|
|
|
|
NULL, NULL,
|
2015-08-31 20:57:37 +02:00
|
|
|
NULL,
|
2016-01-06 14:23:28 +01:00
|
|
|
GIMP_PARAM_WRITABLE |
|
2015-08-31 20:57:37 +02:00
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2016-01-06 14:10:36 +01:00
|
|
|
|
2015-08-31 20:57:37 +02:00
|
|
|
g_object_class_install_property (object_class, PROP_FILE_PROCS,
|
2016-01-06 15:07:41 +01:00
|
|
|
g_param_spec_enum ("file-procs",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_FILE_PROCEDURE_GROUP,
|
|
|
|
GIMP_FILE_PROCEDURE_GROUP_NONE,
|
|
|
|
GIMP_PARAM_WRITABLE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2016-01-06 14:10:36 +01:00
|
|
|
|
2015-08-31 20:57:37 +02:00
|
|
|
g_object_class_install_property (object_class, PROP_FILE_PROCS_ALL_IMAGES,
|
2016-01-06 15:07:41 +01:00
|
|
|
g_param_spec_enum ("file-procs-all-images",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_FILE_PROCEDURE_GROUP,
|
|
|
|
GIMP_FILE_PROCEDURE_GROUP_NONE,
|
|
|
|
GIMP_PARAM_WRITABLE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2018-07-03 19:40:42 +02:00
|
|
|
|
2018-07-25 15:28:04 +02:00
|
|
|
g_object_class_install_property (object_class, PROP_SHOW_ALL_FILES,
|
|
|
|
g_param_spec_boolean ("show-all-files",
|
|
|
|
NULL, NULL, FALSE,
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
|
2018-07-03 19:40:42 +02:00
|
|
|
gtk_widget_class_set_css_name (widget_class, "GimpFileDialog");
|
2004-02-27 14:20:19 +00:00
|
|
|
}
|
|
|
|
|
2004-08-10 18:47:21 +00:00
|
|
|
static void
|
2005-12-19 22:37:49 +00:00
|
|
|
gimp_file_dialog_init (GimpFileDialog *dialog)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_file_dialog_progress_iface_init (GimpProgressInterface *iface)
|
2004-08-10 18:47:21 +00:00
|
|
|
{
|
2011-02-06 12:07:55 +01:00
|
|
|
iface->start = gimp_file_dialog_progress_start;
|
|
|
|
iface->end = gimp_file_dialog_progress_end;
|
|
|
|
iface->is_active = gimp_file_dialog_progress_is_active;
|
|
|
|
iface->set_text = gimp_file_dialog_progress_set_text;
|
|
|
|
iface->set_value = gimp_file_dialog_progress_set_value;
|
|
|
|
iface->get_value = gimp_file_dialog_progress_get_value;
|
|
|
|
iface->pulse = gimp_file_dialog_progress_pulse;
|
|
|
|
iface->get_window_id = gimp_file_dialog_progress_get_window_id;
|
2004-08-10 18:47:21 +00:00
|
|
|
}
|
|
|
|
|
2015-08-31 20:57:37 +02:00
|
|
|
static void
|
|
|
|
gimp_file_dialog_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2016-01-06 14:10:36 +01:00
|
|
|
GimpFileDialog *dialog = GIMP_FILE_DIALOG (object);
|
2015-08-31 20:57:37 +02:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_GIMP:
|
|
|
|
dialog->gimp = g_value_get_object (value);
|
|
|
|
break;
|
|
|
|
case PROP_HELP_ID:
|
|
|
|
dialog->help_id = g_value_dup_string (value);
|
|
|
|
break;
|
2017-02-12 16:06:34 +01:00
|
|
|
case PROP_OK_BUTTON_LABEL:
|
|
|
|
dialog->ok_button_label = g_value_dup_string (value);
|
2015-08-31 20:57:37 +02:00
|
|
|
break;
|
|
|
|
case PROP_AUTOMATIC_HELP_ID:
|
|
|
|
dialog->automatic_help_id = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
case PROP_AUTOMATIC_LABEL:
|
|
|
|
dialog->automatic_label = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
case PROP_FILE_FILTER_LABEL:
|
|
|
|
dialog->file_filter_label = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
case PROP_FILE_PROCS:
|
2016-01-06 15:07:41 +01:00
|
|
|
dialog->file_procs =
|
|
|
|
gimp_plug_in_manager_get_file_procedures (dialog->gimp->plug_in_manager,
|
|
|
|
g_value_get_enum (value));
|
2015-08-31 20:57:37 +02:00
|
|
|
break;
|
|
|
|
case PROP_FILE_PROCS_ALL_IMAGES:
|
2016-01-06 15:07:41 +01:00
|
|
|
dialog->file_procs_all_images =
|
|
|
|
gimp_plug_in_manager_get_file_procedures (dialog->gimp->plug_in_manager,
|
|
|
|
g_value_get_enum (value));
|
2015-08-31 20:57:37 +02:00
|
|
|
break;
|
2018-07-25 15:28:04 +02:00
|
|
|
case PROP_SHOW_ALL_FILES:
|
|
|
|
dialog->show_all_files = g_value_get_boolean (value);
|
|
|
|
gimp_file_dialog_proc_changed (GIMP_FILE_PROC_VIEW (dialog->proc_view),
|
|
|
|
dialog);
|
|
|
|
break;
|
2015-08-31 20:57:37 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_file_dialog_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2016-01-06 14:10:36 +01:00
|
|
|
GimpFileDialog *dialog = GIMP_FILE_DIALOG (object);
|
2015-08-31 20:57:37 +02:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_GIMP:
|
|
|
|
g_value_set_object (value, dialog->gimp);
|
|
|
|
break;
|
|
|
|
case PROP_HELP_ID:
|
|
|
|
g_value_set_string (value, dialog->help_id);
|
|
|
|
break;
|
2018-07-25 15:28:04 +02:00
|
|
|
case PROP_SHOW_ALL_FILES:
|
|
|
|
g_value_set_boolean (value, dialog->show_all_files);
|
|
|
|
break;
|
2015-08-31 20:57:37 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_file_dialog_constructed (GObject *object)
|
|
|
|
{
|
|
|
|
GimpFileDialog *dialog = GIMP_FILE_DIALOG (object);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
|
|
|
|
|
|
|
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
|
2017-02-12 16:06:34 +01:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
dialog->ok_button_label, GTK_RESPONSE_OK,
|
2015-08-31 20:57:37 +02:00
|
|
|
NULL);
|
2017-02-12 16:06:34 +01:00
|
|
|
|
2015-08-31 20:57:37 +02:00
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
2018-05-10 17:04:37 +02:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2015-08-31 20:57:37 +02:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
|
|
|
|
2016-01-06 15:07:41 +01:00
|
|
|
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (object), FALSE);
|
|
|
|
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (object),
|
|
|
|
TRUE);
|
|
|
|
|
2015-08-31 20:57:37 +02:00
|
|
|
if (dialog->help_id)
|
|
|
|
{
|
|
|
|
gimp_help_connect (GTK_WIDGET (dialog),
|
2019-08-09 13:11:30 +02:00
|
|
|
gimp_file_dialog_help_func, dialog->help_id,
|
|
|
|
dialog, NULL);
|
2015-08-31 20:57:37 +02:00
|
|
|
|
|
|
|
if (GIMP_GUI_CONFIG (dialog->gimp->config)->show_help_button)
|
|
|
|
{
|
2018-05-11 12:56:01 +02:00
|
|
|
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
|
|
|
|
_("_Help"), GTK_RESPONSE_HELP,
|
|
|
|
NULL);
|
2015-08-31 20:57:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All classes derivated from GimpFileDialog should show these. */
|
|
|
|
gimp_file_dialog_add_user_dir (dialog, G_USER_DIRECTORY_PICTURES);
|
|
|
|
gimp_file_dialog_add_user_dir (dialog, G_USER_DIRECTORY_DOCUMENTS);
|
|
|
|
|
|
|
|
gimp_file_dialog_add_preview (dialog);
|
|
|
|
|
|
|
|
dialog->extra_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
|
|
|
|
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog),
|
|
|
|
dialog->extra_vbox);
|
|
|
|
gtk_widget_show (dialog->extra_vbox);
|
|
|
|
|
|
|
|
gimp_file_dialog_add_proc_selection (dialog);
|
|
|
|
|
|
|
|
dialog->progress = gimp_progress_box_new ();
|
|
|
|
gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
|
|
|
dialog->progress, FALSE, FALSE, 0);
|
app, libgimp*, pdb, plug-ins: reimplement generic inter-process transient window.
Having windows ID as guint32 is a mistake. Different systems have
different protocols. In Wayland in particular, Windows handles are
exchanged as strings. What this commit does is the following:
In core:
- get_window_id() virtual function in core GimpProgress is changed to
return a GBytes, as a generic "data" to represent a window differently
on different systems.
- All implementations of get_window_id() in various classes implementing
this interface are updated accordingly:
* GimpSubProgress
* GimpDisplay returns the handle of its shell.
* GimpDisplayShell now creates its window handle at construction with
libgimpwidget's gimp_widget_set_native_handle() and simply return
this handle every time it's requested.
* GimpFileDialog also creates its window handle at construction with
gimp_widget_set_native_handle().
- gimp_window_set_transient_for() in core is changed to take a
GimpProgress as argument (instead of a guint32 ID), requests and
process the ID itself, according to the running platform. In
particular, the following were improved:
* Unlike old code, it will work even if the window is not visible yet.
In such a case, the function simply adds a signal handler to set
transient at mapping. It makes it easier to use it at construction
in a reliable way.
* It now works for Wayland too, additionally to X11.
- GimpPdbProgress now exchanges a GBytes too with the command
GIMP_PROGRESS_COMMAND_GET_WINDOW.
- display_get_window_id() in gimp-gui.h also returns a GBytes now.
PDB/libgimp:
- gimp_display_get_window_handle() and gimp_progress_get_window_handle()
now return a GBytes to represent a window handle in an opaque way
(depending on the running platform).
In libgimp:
- GimpProgress's get_window() virtual function changed to return a
GBytes and renamed get_window_handle().
- In particular GimpProgressBar is the only implementation of
get_window_handle(). It creates its handle at object construction with
libgimpwidget's gimp_widget_set_native_handle() and the virtual
method's implementation simply returns the GBytes.
In libgimpUi:
- gimp_ui_get_display_window() and gimp_ui_get_progress_window() were
removed. We should not assume anymore that it is possible to create a
GdkWindow to be used. For instance this is not possible with Wayland
which has its own way to set a window transient with a string handle.
- gimp_window_set_transient_for_display() and
gimp_window_set_transient() now use an internal implementation similar
to core gimp_window_set_transient_for(), with the same improvements
(works even at construction when the window is not visible yet + works
for Wayland too).
In libgimpwidgets:
- New gimp_widget_set_native_handle() is a helper function used both in
core and libgimp* libraries for widgets which we want to be usable as
possible parents. It takes care of getting the relevant window handle
(depending on the running platform) and stores it in a given pointer,
either immediately or after a callback once the widget is mapped. So
it can be used at construction. Also it sets a handle for X11 or
Wayland.
In plug-ins:
- Screenshot uses the new gimp_progress_get_window_handle() directly now
in its X11 code path and creates out of it a GdkWindows itself with
gdk_x11_window_foreign_new_for_display().
Our inter-process transient implementation only worked for X11, and with
this commit, it works for Wayland too.
There is code for Windows but it is currently disabled as it apparently
hangs (there is a comment in-code which links to this old report:
https://bugzilla.gnome.org/show_bug.cgi?id=359538). NikcDC tested
yesterday with re-enabling the code and said they experienced a freeze.
;-(
Finally there is no infrastructure yet to make this work on macOS and
apparently there is no implementation of window handle in GDK for macOS
that I could find. I'm not sure if macOS doesn't have this concept of
setting transient on another processus's window or GDK is simply lacking
the implementation.
2023-08-14 14:23:06 +02:00
|
|
|
|
|
|
|
gimp_widget_set_native_handle (GTK_WIDGET (dialog), &dialog->window_handle);
|
2015-08-31 20:57:37 +02:00
|
|
|
}
|
|
|
|
|
2008-10-21 19:23:44 +00:00
|
|
|
static void
|
2010-10-15 14:08:36 +02:00
|
|
|
gimp_file_dialog_dispose (GObject *object)
|
2008-10-21 19:23:44 +00:00
|
|
|
{
|
|
|
|
GimpFileDialog *dialog = GIMP_FILE_DIALOG (object);
|
|
|
|
|
2010-10-15 14:08:36 +02:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
2008-10-21 19:23:44 +00:00
|
|
|
|
|
|
|
dialog->progress = NULL;
|
2015-08-31 20:57:37 +02:00
|
|
|
|
2019-05-27 17:47:55 +02:00
|
|
|
g_clear_pointer (&dialog->help_id, g_free);
|
|
|
|
g_clear_pointer (&dialog->ok_button_label, g_free);
|
|
|
|
g_clear_pointer (&dialog->automatic_help_id, g_free);
|
|
|
|
g_clear_pointer (&dialog->automatic_label, g_free);
|
|
|
|
g_clear_pointer (&dialog->file_filter_label, g_free);
|
2008-10-21 19:23:44 +00:00
|
|
|
}
|
|
|
|
|
2004-02-27 14:20:19 +00:00
|
|
|
static gboolean
|
|
|
|
gimp_file_dialog_delete_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *event)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-08-10 21:20:38 +00:00
|
|
|
static void
|
|
|
|
gimp_file_dialog_response (GtkDialog *dialog,
|
|
|
|
gint response_id)
|
|
|
|
{
|
|
|
|
GimpFileDialog *file_dialog = GIMP_FILE_DIALOG (dialog);
|
|
|
|
|
2018-05-11 12:56:01 +02:00
|
|
|
if (response_id == GTK_RESPONSE_HELP)
|
|
|
|
{
|
|
|
|
gimp_standard_help_func (file_dialog->help_id, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-08-10 21:20:38 +00:00
|
|
|
if (response_id != GTK_RESPONSE_OK && file_dialog->busy)
|
|
|
|
{
|
|
|
|
file_dialog->canceled = TRUE;
|
|
|
|
|
2008-10-21 19:23:44 +00:00
|
|
|
if (file_dialog->progress &&
|
|
|
|
GIMP_PROGRESS_BOX (file_dialog->progress)->active &&
|
2014-07-12 23:45:20 +02:00
|
|
|
GIMP_PROGRESS_BOX (file_dialog->progress)->cancellable)
|
2005-09-28 21:20:05 +00:00
|
|
|
{
|
|
|
|
gimp_progress_cancel (GIMP_PROGRESS (dialog));
|
|
|
|
}
|
2004-08-10 21:20:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-08 23:27:17 +02:00
|
|
|
static GFile *
|
|
|
|
gimp_file_dialog_real_get_default_folder (GimpFileDialog *dialog)
|
|
|
|
{
|
|
|
|
GFile *file = NULL;
|
|
|
|
|
|
|
|
if (dialog->gimp->default_folder)
|
|
|
|
{
|
|
|
|
file = dialog->gimp->default_folder;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
file = g_object_get_data (G_OBJECT (dialog->gimp),
|
2016-02-12 23:09:03 +01:00
|
|
|
"gimp-default-folder");
|
2015-09-08 23:27:17 +02:00
|
|
|
|
|
|
|
if (! file)
|
|
|
|
{
|
|
|
|
gchar *path;
|
|
|
|
|
2016-02-12 23:09:03 +01:00
|
|
|
/* Make sure the paths end with G_DIR_SEPARATOR_S */
|
|
|
|
|
|
|
|
#ifdef PLATFORM_OSX
|
|
|
|
/* See bug 753683, "Desktop" is expected on OS X */
|
|
|
|
path = g_build_path (G_DIR_SEPARATOR_S,
|
|
|
|
g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP),
|
|
|
|
G_DIR_SEPARATOR_S,
|
|
|
|
NULL);
|
|
|
|
#else
|
2015-09-08 23:27:17 +02:00
|
|
|
path = g_build_path (G_DIR_SEPARATOR_S,
|
|
|
|
g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS),
|
|
|
|
G_DIR_SEPARATOR_S,
|
|
|
|
NULL);
|
2016-02-12 23:09:03 +01:00
|
|
|
#endif
|
2015-09-08 23:27:17 +02:00
|
|
|
|
|
|
|
/* Paranoia fallback, see bug #722400 */
|
|
|
|
if (! path)
|
|
|
|
path = g_build_path (G_DIR_SEPARATOR_S,
|
|
|
|
g_get_home_dir (),
|
|
|
|
G_DIR_SEPARATOR_S,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
file = g_file_new_for_path (path);
|
|
|
|
g_free (path);
|
|
|
|
|
2016-01-06 14:10:36 +01:00
|
|
|
g_object_set_data_full (G_OBJECT (dialog->gimp),
|
2016-02-12 23:09:03 +01:00
|
|
|
"gimp-default-folder",
|
2015-09-08 23:27:17 +02:00
|
|
|
file, (GDestroyNotify) g_object_unref);
|
|
|
|
}
|
|
|
|
}
|
2016-01-06 14:10:36 +01:00
|
|
|
|
2015-09-08 23:27:17 +02:00
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_file_dialog_real_save_state (GimpFileDialog *dialog,
|
|
|
|
const gchar *state_name)
|
|
|
|
{
|
|
|
|
g_object_set_data_full (G_OBJECT (dialog->gimp), state_name,
|
|
|
|
gimp_file_dialog_get_state (dialog),
|
|
|
|
(GDestroyNotify) gimp_file_dialog_state_destroy);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_file_dialog_real_load_state (GimpFileDialog *dialog,
|
|
|
|
const gchar *state_name)
|
|
|
|
{
|
|
|
|
GimpFileDialogState *state;
|
|
|
|
|
|
|
|
state = g_object_get_data (G_OBJECT (dialog->gimp), state_name);
|
|
|
|
|
|
|
|
if (state)
|
|
|
|
gimp_file_dialog_set_state (GIMP_FILE_DIALOG (dialog), state);
|
|
|
|
}
|
|
|
|
|
2004-08-10 18:47:21 +00:00
|
|
|
static GimpProgress *
|
|
|
|
gimp_file_dialog_progress_start (GimpProgress *progress,
|
2014-07-12 23:45:20 +02:00
|
|
|
gboolean cancellable,
|
|
|
|
const gchar *message)
|
2004-08-10 18:47:21 +00:00
|
|
|
{
|
|
|
|
GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress);
|
2008-10-21 19:23:44 +00:00
|
|
|
GimpProgress *retval = NULL;
|
2004-08-10 18:47:21 +00:00
|
|
|
|
2008-10-21 19:23:44 +00:00
|
|
|
if (dialog->progress)
|
|
|
|
{
|
|
|
|
retval = gimp_progress_start (GIMP_PROGRESS (dialog->progress),
|
2014-07-12 23:45:20 +02:00
|
|
|
cancellable, "%s", message);
|
2008-10-21 19:23:44 +00:00
|
|
|
gtk_widget_show (dialog->progress);
|
2004-08-10 18:47:21 +00:00
|
|
|
|
2008-10-21 19:23:44 +00:00
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
2014-07-12 23:45:20 +02:00
|
|
|
GTK_RESPONSE_CANCEL, cancellable);
|
2008-10-21 19:23:44 +00:00
|
|
|
}
|
2007-05-16 08:21:35 +00:00
|
|
|
|
2005-09-28 21:20:05 +00:00
|
|
|
return retval;
|
2004-08-10 18:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_file_dialog_progress_end (GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress);
|
|
|
|
|
2008-10-21 19:23:44 +00:00
|
|
|
if (dialog->progress)
|
|
|
|
{
|
|
|
|
gimp_progress_end (GIMP_PROGRESS (dialog->progress));
|
|
|
|
gtk_widget_hide (dialog->progress);
|
|
|
|
}
|
2004-08-10 18:47:21 +00:00
|
|
|
}
|
|
|
|
|
2004-08-11 10:29:56 +00:00
|
|
|
static gboolean
|
|
|
|
gimp_file_dialog_progress_is_active (GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress);
|
|
|
|
|
2008-10-21 19:23:44 +00:00
|
|
|
if (dialog->progress)
|
|
|
|
return gimp_progress_is_active (GIMP_PROGRESS (dialog->progress));
|
|
|
|
|
|
|
|
return FALSE;
|
2004-08-11 10:29:56 +00:00
|
|
|
}
|
|
|
|
|
2004-08-10 18:47:21 +00:00
|
|
|
static void
|
|
|
|
gimp_file_dialog_progress_set_text (GimpProgress *progress,
|
|
|
|
const gchar *message)
|
|
|
|
{
|
|
|
|
GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress);
|
|
|
|
|
2008-10-21 19:23:44 +00:00
|
|
|
if (dialog->progress)
|
2014-07-20 23:32:19 +02:00
|
|
|
gimp_progress_set_text_literal (GIMP_PROGRESS (dialog->progress), message);
|
2004-08-10 18:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_file_dialog_progress_set_value (GimpProgress *progress,
|
|
|
|
gdouble percentage)
|
|
|
|
{
|
|
|
|
GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress);
|
|
|
|
|
2008-10-21 19:23:44 +00:00
|
|
|
if (dialog->progress)
|
|
|
|
gimp_progress_set_value (GIMP_PROGRESS (dialog->progress), percentage);
|
2004-08-10 18:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gdouble
|
|
|
|
gimp_file_dialog_progress_get_value (GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress);
|
|
|
|
|
2008-10-21 19:23:44 +00:00
|
|
|
if (dialog->progress)
|
|
|
|
return gimp_progress_get_value (GIMP_PROGRESS (dialog->progress));
|
|
|
|
|
|
|
|
return 0.0;
|
2004-08-10 18:47:21 +00:00
|
|
|
}
|
|
|
|
|
2005-02-12 14:18:12 +00:00
|
|
|
static void
|
|
|
|
gimp_file_dialog_progress_pulse (GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress);
|
|
|
|
|
2008-10-21 19:23:44 +00:00
|
|
|
if (dialog->progress)
|
|
|
|
gimp_progress_pulse (GIMP_PROGRESS (dialog->progress));
|
2005-02-12 14:18:12 +00:00
|
|
|
}
|
|
|
|
|
app, libgimp*, pdb, plug-ins: reimplement generic inter-process transient window.
Having windows ID as guint32 is a mistake. Different systems have
different protocols. In Wayland in particular, Windows handles are
exchanged as strings. What this commit does is the following:
In core:
- get_window_id() virtual function in core GimpProgress is changed to
return a GBytes, as a generic "data" to represent a window differently
on different systems.
- All implementations of get_window_id() in various classes implementing
this interface are updated accordingly:
* GimpSubProgress
* GimpDisplay returns the handle of its shell.
* GimpDisplayShell now creates its window handle at construction with
libgimpwidget's gimp_widget_set_native_handle() and simply return
this handle every time it's requested.
* GimpFileDialog also creates its window handle at construction with
gimp_widget_set_native_handle().
- gimp_window_set_transient_for() in core is changed to take a
GimpProgress as argument (instead of a guint32 ID), requests and
process the ID itself, according to the running platform. In
particular, the following were improved:
* Unlike old code, it will work even if the window is not visible yet.
In such a case, the function simply adds a signal handler to set
transient at mapping. It makes it easier to use it at construction
in a reliable way.
* It now works for Wayland too, additionally to X11.
- GimpPdbProgress now exchanges a GBytes too with the command
GIMP_PROGRESS_COMMAND_GET_WINDOW.
- display_get_window_id() in gimp-gui.h also returns a GBytes now.
PDB/libgimp:
- gimp_display_get_window_handle() and gimp_progress_get_window_handle()
now return a GBytes to represent a window handle in an opaque way
(depending on the running platform).
In libgimp:
- GimpProgress's get_window() virtual function changed to return a
GBytes and renamed get_window_handle().
- In particular GimpProgressBar is the only implementation of
get_window_handle(). It creates its handle at object construction with
libgimpwidget's gimp_widget_set_native_handle() and the virtual
method's implementation simply returns the GBytes.
In libgimpUi:
- gimp_ui_get_display_window() and gimp_ui_get_progress_window() were
removed. We should not assume anymore that it is possible to create a
GdkWindow to be used. For instance this is not possible with Wayland
which has its own way to set a window transient with a string handle.
- gimp_window_set_transient_for_display() and
gimp_window_set_transient() now use an internal implementation similar
to core gimp_window_set_transient_for(), with the same improvements
(works even at construction when the window is not visible yet + works
for Wayland too).
In libgimpwidgets:
- New gimp_widget_set_native_handle() is a helper function used both in
core and libgimp* libraries for widgets which we want to be usable as
possible parents. It takes care of getting the relevant window handle
(depending on the running platform) and stores it in a given pointer,
either immediately or after a callback once the widget is mapped. So
it can be used at construction. Also it sets a handle for X11 or
Wayland.
In plug-ins:
- Screenshot uses the new gimp_progress_get_window_handle() directly now
in its X11 code path and creates out of it a GdkWindows itself with
gdk_x11_window_foreign_new_for_display().
Our inter-process transient implementation only worked for X11, and with
this commit, it works for Wayland too.
There is code for Windows but it is currently disabled as it apparently
hangs (there is a comment in-code which links to this old report:
https://bugzilla.gnome.org/show_bug.cgi?id=359538). NikcDC tested
yesterday with re-enabling the code and said they experienced a freeze.
;-(
Finally there is no infrastructure yet to make this work on macOS and
apparently there is no implementation of window handle in GDK for macOS
that I could find. I'm not sure if macOS doesn't have this concept of
setting transient on another processus's window or GDK is simply lacking
the implementation.
2023-08-14 14:23:06 +02:00
|
|
|
static GBytes *
|
2011-02-06 12:07:55 +01:00
|
|
|
gimp_file_dialog_progress_get_window_id (GimpProgress *progress)
|
2005-09-09 18:07:31 +00:00
|
|
|
{
|
|
|
|
GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress);
|
|
|
|
|
app, libgimp*, pdb, plug-ins: reimplement generic inter-process transient window.
Having windows ID as guint32 is a mistake. Different systems have
different protocols. In Wayland in particular, Windows handles are
exchanged as strings. What this commit does is the following:
In core:
- get_window_id() virtual function in core GimpProgress is changed to
return a GBytes, as a generic "data" to represent a window differently
on different systems.
- All implementations of get_window_id() in various classes implementing
this interface are updated accordingly:
* GimpSubProgress
* GimpDisplay returns the handle of its shell.
* GimpDisplayShell now creates its window handle at construction with
libgimpwidget's gimp_widget_set_native_handle() and simply return
this handle every time it's requested.
* GimpFileDialog also creates its window handle at construction with
gimp_widget_set_native_handle().
- gimp_window_set_transient_for() in core is changed to take a
GimpProgress as argument (instead of a guint32 ID), requests and
process the ID itself, according to the running platform. In
particular, the following were improved:
* Unlike old code, it will work even if the window is not visible yet.
In such a case, the function simply adds a signal handler to set
transient at mapping. It makes it easier to use it at construction
in a reliable way.
* It now works for Wayland too, additionally to X11.
- GimpPdbProgress now exchanges a GBytes too with the command
GIMP_PROGRESS_COMMAND_GET_WINDOW.
- display_get_window_id() in gimp-gui.h also returns a GBytes now.
PDB/libgimp:
- gimp_display_get_window_handle() and gimp_progress_get_window_handle()
now return a GBytes to represent a window handle in an opaque way
(depending on the running platform).
In libgimp:
- GimpProgress's get_window() virtual function changed to return a
GBytes and renamed get_window_handle().
- In particular GimpProgressBar is the only implementation of
get_window_handle(). It creates its handle at object construction with
libgimpwidget's gimp_widget_set_native_handle() and the virtual
method's implementation simply returns the GBytes.
In libgimpUi:
- gimp_ui_get_display_window() and gimp_ui_get_progress_window() were
removed. We should not assume anymore that it is possible to create a
GdkWindow to be used. For instance this is not possible with Wayland
which has its own way to set a window transient with a string handle.
- gimp_window_set_transient_for_display() and
gimp_window_set_transient() now use an internal implementation similar
to core gimp_window_set_transient_for(), with the same improvements
(works even at construction when the window is not visible yet + works
for Wayland too).
In libgimpwidgets:
- New gimp_widget_set_native_handle() is a helper function used both in
core and libgimp* libraries for widgets which we want to be usable as
possible parents. It takes care of getting the relevant window handle
(depending on the running platform) and stores it in a given pointer,
either immediately or after a callback once the widget is mapped. So
it can be used at construction. Also it sets a handle for X11 or
Wayland.
In plug-ins:
- Screenshot uses the new gimp_progress_get_window_handle() directly now
in its X11 code path and creates out of it a GdkWindows itself with
gdk_x11_window_foreign_new_for_display().
Our inter-process transient implementation only worked for X11, and with
this commit, it works for Wayland too.
There is code for Windows but it is currently disabled as it apparently
hangs (there is a comment in-code which links to this old report:
https://bugzilla.gnome.org/show_bug.cgi?id=359538). NikcDC tested
yesterday with re-enabling the code and said they experienced a freeze.
;-(
Finally there is no infrastructure yet to make this work on macOS and
apparently there is no implementation of window handle in GDK for macOS
that I could find. I'm not sure if macOS doesn't have this concept of
setting transient on another processus's window or GDK is simply lacking
the implementation.
2023-08-14 14:23:06 +02:00
|
|
|
return dialog->window_handle;
|
2005-09-09 18:07:31 +00:00
|
|
|
}
|
|
|
|
|
2004-02-27 14:20:19 +00:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2015-08-31 20:57:37 +02:00
|
|
|
void
|
|
|
|
gimp_file_dialog_add_extra_widget (GimpFileDialog *dialog,
|
|
|
|
GtkWidget *widget,
|
|
|
|
gboolean expand,
|
|
|
|
gboolean fill,
|
|
|
|
guint padding)
|
2004-02-27 14:20:19 +00:00
|
|
|
{
|
2015-08-31 20:57:37 +02:00
|
|
|
gtk_box_pack_start (GTK_BOX (dialog->extra_vbox),
|
|
|
|
widget, expand, fill, padding);
|
2004-02-27 14:20:19 +00:00
|
|
|
}
|
|
|
|
|
2004-08-10 21:20:38 +00:00
|
|
|
void
|
|
|
|
gimp_file_dialog_set_sensitive (GimpFileDialog *dialog,
|
|
|
|
gboolean sensitive)
|
|
|
|
{
|
2009-03-22 16:35:53 +00:00
|
|
|
GtkWidget *content_area;
|
|
|
|
GList *children;
|
|
|
|
GList *list;
|
2006-11-14 13:46:43 +00:00
|
|
|
|
2004-08-10 21:20:38 +00:00
|
|
|
g_return_if_fail (GIMP_IS_FILE_DIALOG (dialog));
|
|
|
|
|
2008-10-21 19:23:44 +00:00
|
|
|
/* bail out if we are already destroyed */
|
|
|
|
if (! dialog->progress)
|
|
|
|
return;
|
|
|
|
|
2009-03-22 16:35:53 +00:00
|
|
|
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
|
|
|
|
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (content_area));
|
2006-11-14 13:46:43 +00:00
|
|
|
|
|
|
|
for (list = children; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
/* skip the last item (the action area) */
|
|
|
|
if (! g_list_next (list))
|
|
|
|
break;
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (list->data, sensitive);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (children);
|
|
|
|
|
2007-05-16 08:21:35 +00:00
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
|
|
|
GTK_RESPONSE_CANCEL, sensitive);
|
2006-11-14 13:46:43 +00:00
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
|
|
|
GTK_RESPONSE_OK, sensitive);
|
2004-08-10 21:20:38 +00:00
|
|
|
|
|
|
|
dialog->busy = ! sensitive;
|
|
|
|
dialog->canceled = FALSE;
|
|
|
|
}
|
|
|
|
|
2004-02-27 14:20:19 +00:00
|
|
|
void
|
2006-04-05 08:38:33 +00:00
|
|
|
gimp_file_dialog_set_file_proc (GimpFileDialog *dialog,
|
|
|
|
GimpPlugInProcedure *file_proc)
|
2004-02-27 14:20:19 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_FILE_DIALOG (dialog));
|
|
|
|
|
2004-07-16 21:24:39 +00:00
|
|
|
if (file_proc != dialog->file_proc)
|
|
|
|
gimp_file_proc_view_set_proc (GIMP_FILE_PROC_VIEW (dialog->proc_view),
|
|
|
|
file_proc);
|
2004-02-27 14:20:19 +00:00
|
|
|
}
|
2004-02-27 15:43:58 +00:00
|
|
|
|
2015-09-08 23:09:06 +02:00
|
|
|
GFile *
|
|
|
|
gimp_file_dialog_get_default_folder (GimpFileDialog *dialog)
|
|
|
|
{
|
2015-09-08 23:59:13 +02:00
|
|
|
g_return_val_if_fail (GIMP_IS_FILE_DIALOG (dialog), NULL);
|
2015-09-08 23:09:06 +02:00
|
|
|
|
2015-09-09 00:00:50 +02:00
|
|
|
return GIMP_FILE_DIALOG_GET_CLASS (dialog)->get_default_folder (dialog);
|
2015-09-08 23:09:06 +02:00
|
|
|
}
|
|
|
|
|
2008-05-08 11:30:54 +00:00
|
|
|
void
|
2015-09-01 13:49:59 +02:00
|
|
|
gimp_file_dialog_save_state (GimpFileDialog *dialog,
|
|
|
|
const gchar *state_name)
|
2008-05-08 11:30:54 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_FILE_DIALOG (dialog));
|
|
|
|
|
2015-09-01 13:49:59 +02:00
|
|
|
GIMP_FILE_DIALOG_GET_CLASS (dialog)->save_state (dialog, state_name);
|
2008-05-08 11:30:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-09-01 13:49:59 +02:00
|
|
|
gimp_file_dialog_load_state (GimpFileDialog *dialog,
|
|
|
|
const gchar *state_name)
|
2008-05-08 11:30:54 +00:00
|
|
|
{
|
2015-09-01 13:49:59 +02:00
|
|
|
g_return_if_fail (GIMP_IS_FILE_DIALOG (dialog));
|
2008-05-08 11:30:54 +00:00
|
|
|
|
2015-09-01 13:49:59 +02:00
|
|
|
GIMP_FILE_DIALOG_GET_CLASS (dialog)->load_state (dialog, state_name);
|
2008-05-08 11:30:54 +00:00
|
|
|
}
|
|
|
|
|
2015-09-09 00:00:50 +02:00
|
|
|
|
2004-02-27 15:43:58 +00:00
|
|
|
/* private functions */
|
|
|
|
|
2007-12-14 20:08:39 +00:00
|
|
|
static void
|
|
|
|
gimp_file_dialog_add_user_dir (GimpFileDialog *dialog,
|
|
|
|
GUserDirectory directory)
|
|
|
|
{
|
|
|
|
const gchar *user_dir = g_get_user_special_dir (directory);
|
|
|
|
|
|
|
|
if (user_dir)
|
|
|
|
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog),
|
|
|
|
user_dir, NULL);
|
|
|
|
}
|
|
|
|
|
2004-07-16 21:24:39 +00:00
|
|
|
static void
|
2015-08-31 20:57:37 +02:00
|
|
|
gimp_file_dialog_add_preview (GimpFileDialog *dialog)
|
2004-07-16 21:24:39 +00:00
|
|
|
{
|
2015-08-31 20:57:37 +02:00
|
|
|
if (dialog->gimp->config->thumbnail_size <= 0)
|
2004-07-16 21:24:39 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_file_chooser_set_use_preview_label (GTK_FILE_CHOOSER (dialog), FALSE);
|
|
|
|
|
|
|
|
g_signal_connect (dialog, "selection-changed",
|
|
|
|
G_CALLBACK (gimp_file_dialog_selection_changed),
|
|
|
|
dialog);
|
|
|
|
g_signal_connect (dialog, "update-preview",
|
|
|
|
G_CALLBACK (gimp_file_dialog_update_preview),
|
|
|
|
dialog);
|
|
|
|
|
2015-08-31 20:57:37 +02:00
|
|
|
dialog->thumb_box = gimp_thumb_box_new (gimp_get_user_context (dialog->gimp));
|
2004-07-16 21:24:39 +00:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (dialog->thumb_box), FALSE);
|
|
|
|
gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (dialog),
|
|
|
|
dialog->thumb_box);
|
|
|
|
gtk_widget_show (dialog->thumb_box);
|
|
|
|
|
|
|
|
#ifdef ENABLE_FILE_SYSTEM_ICONS
|
2004-08-26 14:20:30 +00:00
|
|
|
GIMP_VIEW_RENDERER_IMAGEFILE (GIMP_VIEW (GIMP_THUMB_BOX (dialog->thumb_box)->preview)->renderer)->file_system = _gtk_file_chooser_get_file_system (GTK_FILE_CHOOSER (dialog));
|
2004-07-16 21:24:39 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-08-31 20:57:37 +02:00
|
|
|
gimp_file_dialog_add_proc_selection (GimpFileDialog *dialog)
|
2004-07-16 21:24:39 +00:00
|
|
|
{
|
2018-07-25 15:28:04 +02:00
|
|
|
GtkWidget *box;
|
2004-07-17 13:06:59 +00:00
|
|
|
GtkWidget *scrolled_window;
|
2018-07-25 15:28:04 +02:00
|
|
|
GtkWidget *checkbox;
|
2004-07-16 21:24:39 +00:00
|
|
|
|
2018-07-25 16:50:05 +02:00
|
|
|
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 1);
|
|
|
|
gimp_file_dialog_add_extra_widget (dialog, box, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (box);
|
|
|
|
|
2004-07-16 21:24:39 +00:00
|
|
|
dialog->proc_expander = gtk_expander_new_with_mnemonic (NULL);
|
2011-03-21 21:12:48 +01:00
|
|
|
gtk_expander_set_resize_toplevel (GTK_EXPANDER (dialog->proc_expander), TRUE);
|
2018-07-25 14:42:07 +02:00
|
|
|
gtk_widget_set_hexpand (GTK_WIDGET (dialog->proc_expander), TRUE);
|
2018-07-25 16:50:05 +02:00
|
|
|
gtk_box_pack_end (GTK_BOX (box), dialog->proc_expander, FALSE, FALSE, 1);
|
2004-07-16 21:24:39 +00:00
|
|
|
gtk_widget_show (dialog->proc_expander);
|
|
|
|
|
2018-07-25 15:28:04 +02:00
|
|
|
/* The list of file formats. */
|
2004-07-17 13:06:59 +00:00
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
2004-07-16 21:24:39 +00:00
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
2004-07-17 13:06:59 +00:00
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
|
|
GTK_SHADOW_IN);
|
2018-07-25 16:50:05 +02:00
|
|
|
gtk_container_add (GTK_CONTAINER (dialog->proc_expander), scrolled_window);
|
2004-07-17 13:06:59 +00:00
|
|
|
gtk_widget_show (scrolled_window);
|
2004-07-16 21:24:39 +00:00
|
|
|
|
2004-07-17 13:06:59 +00:00
|
|
|
gtk_widget_set_size_request (scrolled_window, -1, 200);
|
2004-07-16 21:24:39 +00:00
|
|
|
|
2016-01-06 14:10:36 +01:00
|
|
|
dialog->proc_view = gimp_file_proc_view_new (dialog->gimp,
|
|
|
|
dialog->file_procs,
|
2015-08-31 20:57:37 +02:00
|
|
|
dialog->automatic_label,
|
|
|
|
dialog->automatic_help_id);
|
2004-07-17 13:06:59 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), dialog->proc_view);
|
2004-07-16 21:24:39 +00:00
|
|
|
gtk_widget_show (dialog->proc_view);
|
|
|
|
|
|
|
|
g_signal_connect (dialog->proc_view, "changed",
|
|
|
|
G_CALLBACK (gimp_file_dialog_proc_changed),
|
|
|
|
dialog);
|
|
|
|
|
|
|
|
gimp_file_proc_view_set_proc (GIMP_FILE_PROC_VIEW (dialog->proc_view), NULL);
|
2018-07-25 15:28:04 +02:00
|
|
|
|
|
|
|
/* Checkbox to show all files. */
|
|
|
|
checkbox = gimp_prop_check_button_new (G_OBJECT (dialog),
|
|
|
|
"show-all-files",
|
Missing mnemonics on several file dialogs
This path corrects missing mnemonics on several save/open/export dialogs.
save: file
open: file, dds, fits, tiff
export: bmp, dds, fli, gbr, gih, mng, pat, pnm, pdf, raw, sunras, sgi, webp
2019-09-09 18:06:29 +00:00
|
|
|
_("Show _All Files"));
|
2018-07-25 16:50:05 +02:00
|
|
|
gtk_box_pack_end (GTK_BOX (box), checkbox, FALSE, FALSE, 1);
|
2004-07-16 21:24:39 +00:00
|
|
|
}
|
|
|
|
|
2004-02-27 15:43:58 +00:00
|
|
|
static void
|
2004-04-15 16:28:26 +00:00
|
|
|
gimp_file_dialog_selection_changed (GtkFileChooser *chooser,
|
|
|
|
GimpFileDialog *dialog)
|
2004-02-27 15:43:58 +00:00
|
|
|
{
|
2014-07-08 00:58:42 +02:00
|
|
|
gimp_thumb_box_take_files (GIMP_THUMB_BOX (dialog->thumb_box),
|
|
|
|
gtk_file_chooser_get_files (chooser));
|
2004-04-15 16:28:26 +00:00
|
|
|
}
|
2004-02-27 15:43:58 +00:00
|
|
|
|
2004-04-15 16:28:26 +00:00
|
|
|
static void
|
|
|
|
gimp_file_dialog_update_preview (GtkFileChooser *chooser,
|
|
|
|
GimpFileDialog *dialog)
|
|
|
|
{
|
2014-07-08 00:58:42 +02:00
|
|
|
gimp_thumb_box_take_file (GIMP_THUMB_BOX (dialog->thumb_box),
|
|
|
|
gtk_file_chooser_get_preview_file (chooser));
|
2004-02-27 15:43:58 +00:00
|
|
|
}
|
2004-07-16 21:24:39 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_file_dialog_proc_changed (GimpFileProcView *view,
|
|
|
|
GimpFileDialog *dialog)
|
|
|
|
{
|
|
|
|
GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
|
2018-07-25 14:37:10 +02:00
|
|
|
GtkFileFilter *filter;
|
2004-07-16 21:24:39 +00:00
|
|
|
gchar *name;
|
Issue #2237 - export as, select file type (by extention) list problem
In gimp_file_proc_view_get_proc(), when there is no selected
procedure (which can happen, in particular, when searching the
list), return the "automatic" procedure and its corresponding name/
filter, if one exists, instead of bailing.
Additionally, in GimpFileDialog, use a match-all filter when
gimp_file_proc_view_get_proc() returns no filter, avoiding
CRITICALs/segfault.
2018-10-16 04:28:28 -04:00
|
|
|
gchar *label;
|
2004-07-16 21:24:39 +00:00
|
|
|
|
2018-07-25 14:37:10 +02:00
|
|
|
dialog->file_proc = gimp_file_proc_view_get_proc (view, &name, &filter);
|
2004-07-16 21:24:39 +00:00
|
|
|
|
2004-11-15 13:42:22 +00:00
|
|
|
if (name)
|
Issue #2237 - export as, select file type (by extention) list problem
In gimp_file_proc_view_get_proc(), when there is no selected
procedure (which can happen, in particular, when searching the
list), return the "automatic" procedure and its corresponding name/
filter, if one exists, instead of bailing.
Additionally, in GimpFileDialog, use a match-all filter when
gimp_file_proc_view_get_proc() returns no filter, avoiding
CRITICALs/segfault.
2018-10-16 04:28:28 -04:00
|
|
|
label = g_strdup_printf (_("Select File _Type (%s)"), name);
|
|
|
|
else
|
|
|
|
label = g_strdup (_("Select File _Type"));
|
2004-07-16 21:24:39 +00:00
|
|
|
|
Issue #2237 - export as, select file type (by extention) list problem
In gimp_file_proc_view_get_proc(), when there is no selected
procedure (which can happen, in particular, when searching the
list), return the "automatic" procedure and its corresponding name/
filter, if one exists, instead of bailing.
Additionally, in GimpFileDialog, use a match-all filter when
gimp_file_proc_view_get_proc() returns no filter, avoiding
CRITICALs/segfault.
2018-10-16 04:28:28 -04:00
|
|
|
gtk_expander_set_label (GTK_EXPANDER (dialog->proc_expander), label);
|
|
|
|
|
|
|
|
g_free (label);
|
|
|
|
g_free (name);
|
2004-07-16 21:24:39 +00:00
|
|
|
|
2018-07-25 15:28:04 +02:00
|
|
|
if (dialog->show_all_files)
|
Issue #2237 - export as, select file type (by extention) list problem
In gimp_file_proc_view_get_proc(), when there is no selected
procedure (which can happen, in particular, when searching the
list), return the "automatic" procedure and its corresponding name/
filter, if one exists, instead of bailing.
Additionally, in GimpFileDialog, use a match-all filter when
gimp_file_proc_view_get_proc() returns no filter, avoiding
CRITICALs/segfault.
2018-10-16 04:28:28 -04:00
|
|
|
g_clear_object (&filter);
|
|
|
|
|
|
|
|
if (! filter)
|
2018-07-25 15:28:04 +02:00
|
|
|
{
|
Issue #2237 - export as, select file type (by extention) list problem
In gimp_file_proc_view_get_proc(), when there is no selected
procedure (which can happen, in particular, when searching the
list), return the "automatic" procedure and its corresponding name/
filter, if one exists, instead of bailing.
Additionally, in GimpFileDialog, use a match-all filter when
gimp_file_proc_view_get_proc() returns no filter, avoiding
CRITICALs/segfault.
2018-10-16 04:28:28 -04:00
|
|
|
filter = g_object_ref_sink (gtk_file_filter_new ());
|
|
|
|
|
2018-07-25 15:28:04 +02:00
|
|
|
gtk_file_filter_add_pattern (filter, "*");
|
|
|
|
}
|
Issue #2237 - export as, select file type (by extention) list problem
In gimp_file_proc_view_get_proc(), when there is no selected
procedure (which can happen, in particular, when searching the
list), return the "automatic" procedure and its corresponding name/
filter, if one exists, instead of bailing.
Additionally, in GimpFileDialog, use a match-all filter when
gimp_file_proc_view_get_proc() returns no filter, avoiding
CRITICALs/segfault.
2018-10-16 04:28:28 -04:00
|
|
|
|
2018-07-25 14:37:10 +02:00
|
|
|
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
|
Issue #2237 - export as, select file type (by extention) list problem
In gimp_file_proc_view_get_proc(), when there is no selected
procedure (which can happen, in particular, when searching the
list), return the "automatic" procedure and its corresponding name/
filter, if one exists, instead of bailing.
Additionally, in GimpFileDialog, use a match-all filter when
gimp_file_proc_view_get_proc() returns no filter, avoiding
CRITICALs/segfault.
2018-10-16 04:28:28 -04:00
|
|
|
|
2018-07-25 15:28:04 +02:00
|
|
|
g_object_unref (filter);
|
2004-07-16 21:24:39 +00:00
|
|
|
|
|
|
|
if (gtk_file_chooser_get_action (chooser) == GTK_FILE_CHOOSER_ACTION_SAVE)
|
|
|
|
{
|
2006-04-05 08:38:33 +00:00
|
|
|
GimpPlugInProcedure *proc = dialog->file_proc;
|
2004-07-16 21:24:39 +00:00
|
|
|
|
2004-11-15 13:42:22 +00:00
|
|
|
if (proc && proc->extensions_list)
|
2004-07-16 21:24:39 +00:00
|
|
|
{
|
|
|
|
gchar *uri = gtk_file_chooser_get_uri (chooser);
|
|
|
|
|
|
|
|
if (uri && strlen (uri))
|
|
|
|
{
|
|
|
|
const gchar *last_dot = strrchr (uri, '.');
|
|
|
|
|
2005-08-20 20:34:25 +00:00
|
|
|
/* if the dot is before the last slash, ignore it */
|
|
|
|
if (last_dot && strrchr (uri, '/') > last_dot)
|
|
|
|
last_dot = NULL;
|
|
|
|
|
2004-11-18 11:50:25 +00:00
|
|
|
/* check if the uri has a "meta extension" (e.g. foo.bar.gz)
|
|
|
|
* and try to truncate both extensions away.
|
|
|
|
*/
|
|
|
|
if (last_dot && last_dot != uri)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
for (list = view->meta_extensions;
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
const gchar *ext = list->data;
|
|
|
|
|
|
|
|
if (! strcmp (ext, last_dot + 1))
|
|
|
|
{
|
|
|
|
const gchar *p = last_dot - 1;
|
|
|
|
|
|
|
|
while (p > uri && *p != '.')
|
|
|
|
p--;
|
|
|
|
|
|
|
|
if (p != uri && *p == '.')
|
|
|
|
{
|
|
|
|
last_dot = p;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-16 21:24:39 +00:00
|
|
|
if (last_dot != uri)
|
|
|
|
{
|
|
|
|
GString *s = g_string_new (uri);
|
2014-07-08 01:41:45 +02:00
|
|
|
GFile *file;
|
2004-07-16 21:24:39 +00:00
|
|
|
gchar *basename;
|
|
|
|
|
|
|
|
if (last_dot)
|
|
|
|
g_string_truncate (s, last_dot - uri);
|
|
|
|
|
|
|
|
g_string_append (s, ".");
|
|
|
|
g_string_append (s, (gchar *) proc->extensions_list->data);
|
|
|
|
|
2014-07-08 01:41:45 +02:00
|
|
|
file = g_file_new_for_uri (s->str);
|
|
|
|
g_string_free (s, TRUE);
|
|
|
|
|
|
|
|
gtk_file_chooser_set_file (chooser, file, NULL);
|
2004-07-16 21:24:39 +00:00
|
|
|
|
2014-07-08 01:41:45 +02:00
|
|
|
basename = g_path_get_basename (gimp_file_get_utf8_name (file));
|
2004-07-16 21:24:39 +00:00
|
|
|
gtk_file_chooser_set_current_name (chooser, basename);
|
|
|
|
g_free (basename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-07-17 19:53:05 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_file_dialog_help_func (const gchar *help_id,
|
|
|
|
gpointer help_data)
|
|
|
|
{
|
|
|
|
GimpFileDialog *dialog = GIMP_FILE_DIALOG (help_data);
|
|
|
|
GtkWidget *focus;
|
|
|
|
|
|
|
|
focus = gtk_window_get_focus (GTK_WINDOW (dialog));
|
|
|
|
|
|
|
|
if (focus == dialog->proc_view)
|
|
|
|
{
|
|
|
|
gchar *proc_help_id;
|
|
|
|
|
|
|
|
proc_help_id =
|
|
|
|
gimp_file_proc_view_get_help_id (GIMP_FILE_PROC_VIEW (dialog->proc_view));
|
|
|
|
|
|
|
|
gimp_standard_help_func (proc_help_id, NULL);
|
|
|
|
|
|
|
|
g_free (proc_help_id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_standard_help_func (help_id, NULL);
|
|
|
|
}
|
|
|
|
}
|
2004-10-04 22:25:04 +00:00
|
|
|
|
2015-09-01 13:49:59 +02:00
|
|
|
static GimpFileDialogState *
|
|
|
|
gimp_file_dialog_get_state (GimpFileDialog *dialog)
|
|
|
|
{
|
|
|
|
GimpFileDialogState *state;
|
|
|
|
GtkFileFilter *filter;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_FILE_DIALOG (dialog), NULL);
|
|
|
|
|
|
|
|
state = g_slice_new0 (GimpFileDialogState);
|
|
|
|
|
|
|
|
filter = gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog));
|
|
|
|
|
|
|
|
if (filter)
|
|
|
|
state->filter_name = g_strdup (gtk_file_filter_get_name (filter));
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_file_dialog_set_state (GimpFileDialog *dialog,
|
|
|
|
GimpFileDialogState *state)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_FILE_DIALOG (dialog));
|
|
|
|
g_return_if_fail (state != NULL);
|
|
|
|
|
|
|
|
if (state->filter_name)
|
|
|
|
{
|
|
|
|
GSList *filters;
|
|
|
|
GSList *list;
|
|
|
|
|
|
|
|
filters = gtk_file_chooser_list_filters (GTK_FILE_CHOOSER (dialog));
|
|
|
|
|
|
|
|
for (list = filters; list; list = list->next)
|
|
|
|
{
|
|
|
|
GtkFileFilter *filter = GTK_FILE_FILTER (list->data);
|
|
|
|
const gchar *name = gtk_file_filter_get_name (filter);
|
|
|
|
|
|
|
|
if (name && strcmp (state->filter_name, name) == 0)
|
|
|
|
{
|
|
|
|
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_free (filters);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_file_dialog_state_destroy (GimpFileDialogState *state)
|
|
|
|
{
|
|
|
|
g_return_if_fail (state != NULL);
|
|
|
|
|
|
|
|
g_free (state->filter_name);
|
|
|
|
g_slice_free (GimpFileDialogState, state);
|
|
|
|
}
|