forked from AuroraMiddleware/gtk
Merge branch 'async-dialog-api2' into 'main'
Add new async APIs to replace chooser dialogs See merge request GNOME/gtk!5174
This commit is contained in:
commit
251dcc2f86
22
NEWS
22
NEWS
@ -1,9 +1,11 @@
|
||||
Overview of Changes in 4.9.1, dd-mm-yyyy
|
||||
========================================
|
||||
|
||||
Note that deprecations are an early outlook
|
||||
at changes that will appear in an eventual
|
||||
GTK 5 release, which is still far away.
|
||||
Note that deprecations are an early outlook at changes
|
||||
that will appear in an eventual GTK 5 release, which is
|
||||
still far away. We are introducing deprecations in 4.10
|
||||
as a way to give users time to adapt, and to provide
|
||||
feedback on our plans.
|
||||
|
||||
* GtkTreeView, GtkIconView, GtkComboBox and
|
||||
auxiliary classes have been deprecated
|
||||
@ -15,7 +17,19 @@ GTK 5 release, which is still far away.
|
||||
* gtk_render_ and gtk_snapshot_render_ APIs
|
||||
have been deprecated
|
||||
|
||||
* GtkAppChooser widgets hae been deprecated
|
||||
* GtkAppChooser widgets have been deprecated
|
||||
|
||||
* GtkMessageDialog has been deprecated and
|
||||
replaced by a new async dialog API
|
||||
|
||||
* GtkColorChooser, GtkFontChooser, GtkFileChooser
|
||||
interfaces and their implementations have been
|
||||
deprecated. A new family of async dialog APIs
|
||||
has been introduced to replace them
|
||||
|
||||
* GtkColorDialog, GtkFontDialog, GtkFileDialog
|
||||
and GtkAlertDialog are new dialog classes with
|
||||
a consistent and well-bindable API
|
||||
|
||||
* GtkMountOperation:
|
||||
- Fix the dialog to look reasonable
|
||||
|
@ -202,43 +202,36 @@ constraint_editor_window_load (ConstraintEditorWindow *self,
|
||||
}
|
||||
|
||||
static void
|
||||
open_response_cb (GtkNativeDialog *dialog,
|
||||
int response,
|
||||
ConstraintEditorWindow *self)
|
||||
open_response_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
{
|
||||
gtk_native_dialog_hide (dialog);
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
ConstraintEditorWindow *self = user_data;
|
||||
GFile *file;
|
||||
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
constraint_editor_window_load (self, file);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gtk_native_dialog_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
open_cb (GtkWidget *button,
|
||||
ConstraintEditorWindow *self)
|
||||
{
|
||||
GtkFileChooserNative *dialog;
|
||||
GtkFileDialog *dialog;
|
||||
GFile *cwd;
|
||||
|
||||
dialog = gtk_file_chooser_native_new ("Open file",
|
||||
GTK_WINDOW (self),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Load",
|
||||
"_Cancel");
|
||||
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
|
||||
|
||||
GFile *cwd = g_file_new_for_path (".");
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), cwd, NULL);
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Open file");
|
||||
cwd = g_file_new_for_path (".");
|
||||
gtk_file_dialog_set_current_folder (dialog, cwd);
|
||||
g_object_unref (cwd);
|
||||
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), self);
|
||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
|
||||
gtk_file_dialog_open (dialog, GTK_WINDOW (self), NULL, NULL, open_response_cb, self);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -294,22 +287,23 @@ serialize_model (GListModel *list)
|
||||
|
||||
|
||||
static void
|
||||
save_response_cb (GtkNativeDialog *dialog,
|
||||
int response,
|
||||
ConstraintEditorWindow *self)
|
||||
save_response_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
{
|
||||
gtk_native_dialog_hide (dialog);
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
ConstraintEditorWindow *self = user_data;
|
||||
GFile *file;
|
||||
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
file = gtk_file_dialog_save_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
{
|
||||
GListModel *model;
|
||||
GFile *file;
|
||||
char *text;
|
||||
GError *error = NULL;
|
||||
|
||||
model = constraint_view_get_model (CONSTRAINT_VIEW (self->view));
|
||||
text = serialize_model (model);
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
g_file_replace_contents (file, text, strlen (text),
|
||||
NULL, FALSE,
|
||||
G_FILE_CREATE_NONE,
|
||||
@ -318,46 +312,39 @@ save_response_cb (GtkNativeDialog *dialog,
|
||||
&error);
|
||||
if (error != NULL)
|
||||
{
|
||||
GtkWidget *message_dialog;
|
||||
GtkAlertDialog *alert;
|
||||
|
||||
message_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))),
|
||||
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK,
|
||||
"Saving failed");
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
|
||||
"%s", error->message);
|
||||
g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_widget_show (message_dialog);
|
||||
alert = gtk_alert_dialog_new ("Saving failed");
|
||||
gtk_alert_dialog_set_detail (alert, error->message);
|
||||
gtk_alert_dialog_show (alert,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))));
|
||||
g_object_unref (alert);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_free (text);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gtk_native_dialog_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
save_cb (GtkWidget *button,
|
||||
ConstraintEditorWindow *self)
|
||||
{
|
||||
GtkFileChooserNative *dialog;
|
||||
GtkFileDialog *dialog;
|
||||
GFile *cwd;
|
||||
|
||||
dialog = gtk_file_chooser_native_new ("Save constraints",
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
"_Save",
|
||||
"_Cancel");
|
||||
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
|
||||
|
||||
GFile *cwd = g_file_new_for_path (".");
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), cwd, NULL);
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Save constraints");
|
||||
cwd = g_file_new_for_path (".");
|
||||
gtk_file_dialog_set_current_folder (dialog, cwd);
|
||||
g_object_unref (cwd);
|
||||
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (save_response_cb), self);
|
||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
save_response_cb, self);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -33,22 +33,12 @@ static void create_window (GApplication *app, const char *contents);
|
||||
static void
|
||||
show_action_dialog (GSimpleAction *action)
|
||||
{
|
||||
const char *name;
|
||||
GtkWidget *dialog;
|
||||
GtkAlertDialog *dialog;
|
||||
|
||||
name = g_action_get_name (G_ACTION (action));
|
||||
|
||||
dialog = gtk_message_dialog_new (NULL,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"You activated action: \"%s\"",
|
||||
name);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
dialog = gtk_alert_dialog_new ("You activated action: \"%s\n",
|
||||
g_action_get_name (G_ACTION (action)));
|
||||
gtk_alert_dialog_show (dialog, NULL);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -90,20 +80,19 @@ activate_new (GSimpleAction *action,
|
||||
}
|
||||
|
||||
static void
|
||||
open_response_cb (GtkNativeDialog *dialog,
|
||||
int response_id,
|
||||
gpointer user_data)
|
||||
open_response_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkFileChooserNative *native = user_data;
|
||||
GApplication *app = g_object_get_data (G_OBJECT (native), "app");
|
||||
GtkWidget *message_dialog;
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GApplication *app = G_APPLICATION (user_data);
|
||||
GFile *file;
|
||||
char *contents;
|
||||
GError *error = NULL;
|
||||
|
||||
if (response_id == GTK_RESPONSE_ACCEPT)
|
||||
file = gtk_file_dialog_save_finish (dialog, result, &error);
|
||||
if (file)
|
||||
{
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (native));
|
||||
char *contents;
|
||||
|
||||
if (g_file_load_contents (file, NULL, &contents, NULL, NULL, &error))
|
||||
{
|
||||
@ -112,21 +101,16 @@ open_response_cb (GtkNativeDialog *dialog,
|
||||
}
|
||||
else
|
||||
{
|
||||
message_dialog = gtk_message_dialog_new (NULL,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Error loading file: \"%s\"",
|
||||
error->message);
|
||||
g_signal_connect (message_dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_widget_show (message_dialog);
|
||||
GtkAlertDialog *alert;
|
||||
|
||||
alert = gtk_alert_dialog_new ("Error loading file: \"%s\"", error->message);
|
||||
gtk_alert_dialog_show (alert, NULL);
|
||||
g_object_unref (alert);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (native));
|
||||
g_object_unref (native);
|
||||
g_object_unref (app);
|
||||
}
|
||||
|
||||
|
||||
@ -136,21 +120,11 @@ activate_open (GSimpleAction *action,
|
||||
gpointer user_data)
|
||||
{
|
||||
GApplication *app = user_data;
|
||||
GtkFileChooserNative *native;
|
||||
GtkFileDialog *dialog;
|
||||
|
||||
native = gtk_file_chooser_native_new ("Open File",
|
||||
NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Open",
|
||||
"_Cancel");
|
||||
|
||||
g_object_set_data_full (G_OBJECT (native), "app", g_object_ref (app), g_object_unref);
|
||||
g_signal_connect (native,
|
||||
"response",
|
||||
G_CALLBACK (open_response_cb),
|
||||
native);
|
||||
|
||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (native));
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_open (dialog, NULL, NULL, NULL, open_response_cb, g_object_ref (app));
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -50,10 +50,10 @@ copy_button_clicked (GtkStack *source_stack,
|
||||
}
|
||||
else if (strcmp (visible_child_name, "Color") == 0)
|
||||
{
|
||||
GdkRGBA color;
|
||||
const GdkRGBA *color;
|
||||
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (visible_child), &color);
|
||||
gdk_clipboard_set (clipboard, GDK_TYPE_RGBA, &color);
|
||||
color = gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (visible_child));
|
||||
gdk_clipboard_set (clipboard, GDK_TYPE_RGBA, color);
|
||||
}
|
||||
else if (strcmp (visible_child_name, "File") == 0)
|
||||
{
|
||||
@ -215,37 +215,36 @@ file_button_set_file (GtkButton *button,
|
||||
}
|
||||
|
||||
static void
|
||||
file_chooser_response (GtkNativeDialog *dialog,
|
||||
int response,
|
||||
GtkButton *button)
|
||||
file_chooser_response (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
gtk_native_dialog_hide (dialog);
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GtkButton *button = GTK_BUTTON (user_data);
|
||||
GFile *file;
|
||||
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
{
|
||||
GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
file_button_set_file (button, file);
|
||||
g_object_unref (file);
|
||||
|
||||
update_copy_button_sensitivity (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_STACK));
|
||||
}
|
||||
|
||||
gtk_native_dialog_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
open_file_cb (GtkWidget *button)
|
||||
{
|
||||
GtkFileChooserNative *chooser;
|
||||
GtkFileDialog *dialog;
|
||||
|
||||
chooser = gtk_file_chooser_native_new ("Choose a file",
|
||||
GTK_WINDOW (gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW)),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Open",
|
||||
"_Cancel");
|
||||
dialog = gtk_file_dialog_new ();
|
||||
|
||||
g_signal_connect (chooser, "response", G_CALLBACK (file_chooser_response), button);
|
||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (chooser));
|
||||
gtk_file_dialog_open (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW)),
|
||||
NULL,
|
||||
NULL,
|
||||
file_chooser_response, button);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -64,7 +64,11 @@
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">Color</property>
|
||||
<property name="child">
|
||||
<object class="GtkColorButton" id="source_color">
|
||||
<object class="GtkColorDialogButton" id="source_color">
|
||||
<property name="dialog">
|
||||
<object class="GtkColorDialog">
|
||||
</object>
|
||||
</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="rgba">purple</property>
|
||||
</object>
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
static GtkWidget *entry1 = NULL;
|
||||
static GtkWidget *entry2 = NULL;
|
||||
|
@ -726,7 +726,9 @@ do_dnd (GtkWidget *do_widget)
|
||||
GtkCssProvider *provider;
|
||||
GString *css;
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
button = gtk_color_button_new ();
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_object_unref (g_object_ref_sink (button));
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
static void
|
||||
|
@ -68,11 +68,13 @@ create_blurred_button (void)
|
||||
return w;
|
||||
}
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
static GtkWidget *
|
||||
create_font_button (void)
|
||||
{
|
||||
return gtk_font_button_new ();
|
||||
}
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkWidget *
|
||||
create_level_bar (void)
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "script-names.h"
|
||||
#include "language-names.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/* {{{ ScriptLang object */
|
||||
|
||||
G_DECLARE_FINAL_TYPE (ScriptLang, script_lang, SCRIPT, LANG, GObject)
|
||||
@ -256,10 +258,10 @@ swap_colors (void)
|
||||
GdkRGBA fg;
|
||||
GdkRGBA bg;
|
||||
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->foreground), &fg);
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->background), &bg);
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (demo->foreground), &bg);
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (demo->background), &fg);
|
||||
fg = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground));
|
||||
bg = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background));
|
||||
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground), &bg);
|
||||
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background), &fg);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -268,8 +270,8 @@ font_features_reset_basic (void)
|
||||
gtk_adjustment_set_value (demo->size_adjustment, 20);
|
||||
gtk_adjustment_set_value (demo->letterspacing_adjustment, 0);
|
||||
gtk_adjustment_set_value (demo->line_height_adjustment, 1);
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (demo->foreground), &(GdkRGBA){0.,0.,0.,1.});
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (demo->background), &(GdkRGBA){1.,1.,1.,1.});
|
||||
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground), &(GdkRGBA){0.,0.,0.,1.});
|
||||
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background), &(GdkRGBA){1.,1.,1.,1.});
|
||||
}
|
||||
|
||||
static void
|
||||
@ -277,7 +279,7 @@ update_basic (void)
|
||||
{
|
||||
PangoFontDescription *desc;
|
||||
|
||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
|
||||
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||
|
||||
gtk_adjustment_set_value (demo->size_adjustment,
|
||||
pango_font_description_get_size (desc) / (double) PANGO_SCALE);
|
||||
@ -588,7 +590,7 @@ update_display (void)
|
||||
end = PANGO_ATTR_INDEX_TO_TEXT_END;
|
||||
}
|
||||
|
||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
|
||||
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||
|
||||
value = gtk_adjustment_get_value (demo->size_adjustment);
|
||||
pango_font_description_set_size (desc, value * PANGO_SCALE);
|
||||
@ -679,7 +681,7 @@ update_display (void)
|
||||
GdkRGBA rgba;
|
||||
char *fg, *bg, *css;
|
||||
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->foreground), &rgba);
|
||||
rgba = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground));
|
||||
attr = pango_attr_foreground_new (65535 * rgba.red,
|
||||
65535 * rgba.green,
|
||||
65535 * rgba.blue);
|
||||
@ -692,7 +694,7 @@ update_display (void)
|
||||
pango_attr_list_insert (attrs, attr);
|
||||
|
||||
fg = gdk_rgba_to_string (&rgba);
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->background), &rgba);
|
||||
rgba = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background));
|
||||
bg = gdk_rgba_to_string (&rgba);
|
||||
css = g_strdup_printf (".font_features_background { caret-color: %s; background-color: %s; }", fg, bg);
|
||||
gtk_css_provider_load_from_data (demo->provider, css, strlen (css));
|
||||
@ -767,7 +769,6 @@ update_display (void)
|
||||
gtk_label_set_attributes (GTK_LABEL (demo->the_label), attrs);
|
||||
|
||||
g_free (font_desc);
|
||||
pango_font_description_free (desc);
|
||||
g_free (features);
|
||||
pango_attr_list_unref (attrs);
|
||||
g_free (text);
|
||||
@ -779,7 +780,7 @@ get_pango_font (void)
|
||||
PangoFontDescription *desc;
|
||||
PangoContext *context;
|
||||
|
||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
|
||||
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||
context = gtk_widget_get_pango_context (demo->font);
|
||||
|
||||
return pango_context_load_font (context, desc);
|
||||
@ -831,17 +832,17 @@ update_script_combo (void)
|
||||
GHashTable *tags;
|
||||
GHashTableIter iter;
|
||||
TagPair *pair;
|
||||
char *lang;
|
||||
PangoLanguage *language;
|
||||
const char *lang;
|
||||
hb_tag_t active;
|
||||
|
||||
lang = gtk_font_chooser_get_language (GTK_FONT_CHOOSER (demo->font));
|
||||
language = gtk_font_dialog_button_get_language (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||
lang = pango_language_to_string (language);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
active = hb_ot_tag_from_language (hb_language_from_string (lang, -1));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
g_free (lang);
|
||||
|
||||
store = g_list_store_new (script_lang_get_type ());
|
||||
|
||||
pango_font = get_pango_font ();
|
||||
@ -1005,7 +1006,7 @@ update_features (void)
|
||||
{
|
||||
hb_tag_t tables[2] = { HB_OT_TAG_GSUB, HB_OT_TAG_GPOS };
|
||||
hb_face_t *hb_face;
|
||||
char *feat;
|
||||
const char *feat;
|
||||
|
||||
hb_face = hb_font_get_face (hb_font);
|
||||
|
||||
@ -1098,7 +1099,7 @@ update_features (void)
|
||||
}
|
||||
}
|
||||
|
||||
feat = gtk_font_chooser_get_font_features (GTK_FONT_CHOOSER (demo->font));
|
||||
feat = gtk_font_dialog_button_get_font_features (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||
if (feat)
|
||||
{
|
||||
for (l = demo->feature_items; l; l = l->next)
|
||||
@ -1124,8 +1125,6 @@ update_features (void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_free (feat);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1780,6 +1779,7 @@ do_font_features (GtkWidget *do_widget)
|
||||
demo->description = GTK_WIDGET (gtk_builder_get_object (builder, "description"));
|
||||
demo->font = GTK_WIDGET (gtk_builder_get_object (builder, "font"));
|
||||
demo->script_lang = GTK_WIDGET (gtk_builder_get_object (builder, "script_lang"));
|
||||
g_assert (GTK_IS_DROP_DOWN (demo->script_lang));
|
||||
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, G_CALLBACK (script_lang_get_langname), NULL, NULL);
|
||||
gtk_drop_down_set_expression (GTK_DROP_DOWN (demo->script_lang), expression);
|
||||
gtk_expression_unref (expression);
|
||||
|
@ -58,11 +58,14 @@
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkFontButton" id="font">
|
||||
<object class="GtkFontDialogButton" id="font">
|
||||
<property name="dialog">
|
||||
<object class="GtkFontDialog">
|
||||
</object>
|
||||
</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="font">Sans 12</property>
|
||||
<property name="level">family|style</property>
|
||||
<signal name="font-set" handler="font_features_font_changed" swapped="no"/>
|
||||
<property name="level">face</property>
|
||||
<signal name="notify::font-desc" handler="font_features_font_changed" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@ -192,7 +195,11 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColorButton" id="foreground">
|
||||
<object class="GtkColorDialogButton" id="foreground">
|
||||
<property name="dialog">
|
||||
<object class="GtkColorDialog">
|
||||
</object>
|
||||
</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="rgba">black</property>
|
||||
<signal name="notify::rgba" handler="color_set_cb"/>
|
||||
@ -214,7 +221,11 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColorButton" id="background">
|
||||
<object class="GtkColorDialogButton" id="background">
|
||||
<property name="dialog">
|
||||
<object class="GtkColorDialog">
|
||||
</object>
|
||||
</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="rgba">white</property>
|
||||
<signal name="notify::rgba" handler="color_set_cb"/>
|
||||
|
@ -53,7 +53,7 @@ update_image (void)
|
||||
context = gtk_widget_create_pango_context (image);
|
||||
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (font_button));
|
||||
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (font_button));
|
||||
|
||||
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
|
||||
|
||||
@ -287,8 +287,6 @@ retry:
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (image), pixbuf2);
|
||||
|
||||
g_object_unref (pixbuf2);
|
||||
|
||||
pango_font_description_free (desc);
|
||||
}
|
||||
|
||||
static gboolean fading = FALSE;
|
||||
|
@ -74,7 +74,11 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFontButton" id="font_button">
|
||||
<object class="GtkFontDialogButton" id="font_button">
|
||||
<property name="dialog">
|
||||
<object class="GtkFontDialog">
|
||||
</object>
|
||||
</property>
|
||||
<layout>
|
||||
<property name="column">2</property>
|
||||
<property name="row">1</property>
|
||||
|
@ -83,24 +83,17 @@ progressive_timeout (gpointer data)
|
||||
|
||||
if (bytes_read < 0)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkAlertDialog *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Failure reading image file 'alphatest.png': %s",
|
||||
error->message);
|
||||
dialog = gtk_alert_dialog_new ("Failure reading image file 'alphatest.png': %s",
|
||||
error->message);
|
||||
gtk_alert_dialog_show (dialog, NULL);
|
||||
g_object_unref (dialog);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
|
||||
g_object_unref (image_stream);
|
||||
image_stream = NULL;
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
load_timeout = 0;
|
||||
|
||||
return FALSE; /* uninstall the timeout */
|
||||
@ -110,25 +103,17 @@ progressive_timeout (gpointer data)
|
||||
buf, bytes_read,
|
||||
&error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Failed to load image: %s",
|
||||
error->message);
|
||||
GtkAlertDialog *dialog;
|
||||
|
||||
dialog = gtk_alert_dialog_new ("Failed to load image: %s",
|
||||
error->message);
|
||||
gtk_alert_dialog_show (dialog, NULL);
|
||||
g_object_unref (dialog);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
|
||||
g_object_unref (image_stream);
|
||||
image_stream = NULL;
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
load_timeout = 0;
|
||||
|
||||
return FALSE; /* uninstall the timeout */
|
||||
@ -143,22 +128,14 @@ progressive_timeout (gpointer data)
|
||||
error = NULL;
|
||||
if (!g_input_stream_close (image_stream, NULL, &error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Failed to load image: %s",
|
||||
error->message);
|
||||
GtkAlertDialog *dialog;
|
||||
|
||||
dialog = gtk_alert_dialog_new ("Failed to load image: %s",
|
||||
error->message);
|
||||
gtk_alert_dialog_show (dialog, NULL);
|
||||
g_object_unref (dialog);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
g_object_unref (image_stream);
|
||||
image_stream = NULL;
|
||||
g_object_unref (pixbuf_loader);
|
||||
@ -177,25 +154,16 @@ progressive_timeout (gpointer data)
|
||||
* it was incomplete.
|
||||
*/
|
||||
error = NULL;
|
||||
if (!gdk_pixbuf_loader_close (pixbuf_loader,
|
||||
&error))
|
||||
if (!gdk_pixbuf_loader_close (pixbuf_loader, &error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Failed to load image: %s",
|
||||
error->message);
|
||||
GtkAlertDialog *dialog;
|
||||
|
||||
dialog = gtk_alert_dialog_new ("Failed to load image: %s",
|
||||
error->message);
|
||||
gtk_alert_dialog_show (dialog, NULL);
|
||||
g_object_unref (dialog);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
g_object_unref (pixbuf_loader);
|
||||
pixbuf_loader = NULL;
|
||||
|
||||
@ -216,20 +184,14 @@ progressive_timeout (gpointer data)
|
||||
|
||||
if (image_stream == NULL)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkAlertDialog *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s", error->message);
|
||||
dialog = gtk_alert_dialog_new ("%s",
|
||||
error->message);
|
||||
gtk_alert_dialog_show (dialog, NULL);
|
||||
g_object_unref (dialog);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
load_timeout = 0;
|
||||
|
||||
return FALSE; /* uninstall the timeout */
|
||||
|
@ -12,8 +12,8 @@ on_bar_response (GtkInfoBar *info_bar,
|
||||
int response_id,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *window;
|
||||
GtkAlertDialog *dialog;
|
||||
char *detail;
|
||||
|
||||
if (response_id == GTK_RESPONSE_CLOSE)
|
||||
{
|
||||
@ -21,19 +21,12 @@ on_bar_response (GtkInfoBar *info_bar,
|
||||
return;
|
||||
}
|
||||
|
||||
window = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (info_bar)));
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK,
|
||||
"You clicked a button on an info bar");
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"Your response has id %d", response_id);
|
||||
|
||||
g_signal_connect_swapped (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), dialog);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
dialog = gtk_alert_dialog_new ("You clicked a button on an info bar");
|
||||
detail = g_strdup_printf ("Your response has been %d", response_id);
|
||||
gtk_alert_dialog_set_detail (dialog, detail);
|
||||
g_free (detail);
|
||||
gtk_alert_dialog_show (dialog, GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (info_bar))));
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
@ -7,38 +7,22 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
response_cb (GtkWidget *dialog,
|
||||
int response_id,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
activate_link (GtkWidget *label,
|
||||
activate_link (GtkWidget *label,
|
||||
const char *uri,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
if (g_strcmp0 (uri, "keynav") == 0)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *parent;
|
||||
GtkAlertDialog *dialog;
|
||||
|
||||
parent = GTK_WIDGET (gtk_widget_get_root (label));
|
||||
dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (parent),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK,
|
||||
"Keyboard navigation");
|
||||
gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
|
||||
"The term <i>keynav</i> is a shorthand for "
|
||||
"keyboard navigation and refers to the process of using "
|
||||
"a program (exclusively) via keyboard input.");
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (response_cb), NULL);
|
||||
dialog = gtk_alert_dialog_new ("Keyboard navigation");
|
||||
gtk_alert_dialog_set_detail (dialog,
|
||||
"The term ‘keynav’ is a shorthand for "
|
||||
"keyboard navigation and refers to the process of using "
|
||||
"a program (exclusively) via keyboard input.");
|
||||
gtk_alert_dialog_show (dialog, GTK_WINDOW (gtk_widget_get_root (label)));
|
||||
g_object_unref (dialog);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -117,19 +117,16 @@ activate_cb (GtkListView *list,
|
||||
G_APP_LAUNCH_CONTEXT (context),
|
||||
&error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkAlertDialog *dialog;
|
||||
|
||||
/* And because error handling is important, even a simple demo has it:
|
||||
* We display an error dialog that something went wrong.
|
||||
*/
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (list))),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Could not launch %s", g_app_info_get_display_name (app_info));
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
|
||||
dialog = gtk_alert_dialog_new ("Could not launch %s", g_app_info_get_display_name (app_info));
|
||||
gtk_alert_dialog_set_detail (dialog, error->message);
|
||||
gtk_alert_dialog_show (dialog, GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (list))));
|
||||
g_object_unref (dialog);
|
||||
g_clear_error (&error);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
g_object_unref (context);
|
||||
|
@ -141,39 +141,35 @@ load_file (GtkStringList *list,
|
||||
}
|
||||
|
||||
static void
|
||||
open_response_cb (GtkNativeDialog *dialog,
|
||||
int response,
|
||||
GtkStringList *stringlist)
|
||||
open_response_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
{
|
||||
gtk_native_dialog_hide (dialog);
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GtkStringList *stringlist = GTK_STRING_LIST (user_data);
|
||||
GFile *file;
|
||||
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
load_file (stringlist, file);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gtk_native_dialog_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
file_open_cb (GtkWidget *button,
|
||||
GtkStringList *stringlist)
|
||||
{
|
||||
GtkFileChooserNative *dialog;
|
||||
GtkFileDialog *dialog;
|
||||
|
||||
dialog = gtk_file_chooser_native_new ("Open file",
|
||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Load",
|
||||
"_Cancel");
|
||||
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
|
||||
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), stringlist);
|
||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_open (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||
NULL,
|
||||
NULL,
|
||||
open_response_cb, stringlist);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
enum {
|
||||
COLOR_SET,
|
||||
N_SIGNALS
|
||||
@ -51,8 +53,8 @@ static const char *pad_colors[] = {
|
||||
static GType drawing_area_get_type (void);
|
||||
G_DEFINE_TYPE (DrawingArea, drawing_area, GTK_TYPE_WIDGET)
|
||||
|
||||
static void drawing_area_set_color (DrawingArea *area,
|
||||
GdkRGBA *color);
|
||||
static void drawing_area_set_color (DrawingArea *area,
|
||||
const GdkRGBA *color);
|
||||
|
||||
static void
|
||||
drawing_area_ensure_surface (DrawingArea *area,
|
||||
@ -350,8 +352,8 @@ drawing_area_new (void)
|
||||
}
|
||||
|
||||
static void
|
||||
drawing_area_set_color (DrawingArea *area,
|
||||
GdkRGBA *color)
|
||||
drawing_area_set_color (DrawingArea *area,
|
||||
const GdkRGBA *color)
|
||||
{
|
||||
if (gdk_rgba_equal (&area->draw_color, color))
|
||||
return;
|
||||
@ -361,21 +363,22 @@ drawing_area_set_color (DrawingArea *area,
|
||||
}
|
||||
|
||||
static void
|
||||
color_button_color_set (GtkColorButton *button,
|
||||
DrawingArea *draw_area)
|
||||
color_button_color_set (GtkColorDialogButton *button,
|
||||
GParamSpec *pspec,
|
||||
DrawingArea *draw_area)
|
||||
{
|
||||
GdkRGBA color;
|
||||
const GdkRGBA *color;
|
||||
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &color);
|
||||
drawing_area_set_color (draw_area, &color);
|
||||
color = gtk_color_dialog_button_get_rgba (button);
|
||||
drawing_area_set_color (draw_area, color);
|
||||
}
|
||||
|
||||
static void
|
||||
drawing_area_color_set (DrawingArea *area,
|
||||
GdkRGBA *color,
|
||||
GtkColorButton *button)
|
||||
drawing_area_color_set (DrawingArea *area,
|
||||
GdkRGBA *color,
|
||||
GtkColorDialogButton *button)
|
||||
{
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), color);
|
||||
gtk_color_dialog_button_set_rgba (button, color);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
@ -394,13 +397,13 @@ do_paint (GtkWidget *toplevel)
|
||||
|
||||
headerbar = gtk_header_bar_new ();
|
||||
|
||||
colorbutton = gtk_color_button_new ();
|
||||
g_signal_connect (colorbutton, "color-set",
|
||||
colorbutton = gtk_color_dialog_button_new (gtk_color_dialog_new ());
|
||||
g_signal_connect (colorbutton, "notify::rgba",
|
||||
G_CALLBACK (color_button_color_set), draw_area);
|
||||
g_signal_connect (draw_area, "color-set",
|
||||
G_CALLBACK (drawing_area_color_set), colorbutton);
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (colorbutton),
|
||||
&(GdkRGBA) { 0, 0, 0, 1 });
|
||||
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (colorbutton),
|
||||
&(GdkRGBA) { 0, 0, 0, 1 });
|
||||
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), colorbutton);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
|
||||
|
@ -13,25 +13,24 @@
|
||||
|
||||
|
||||
static void
|
||||
open_response_cb (GtkNativeDialog *dialog,
|
||||
int response,
|
||||
GtkPicture *picture)
|
||||
open_response_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *data)
|
||||
{
|
||||
gtk_native_dialog_hide (dialog);
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GtkPicture *picture = data;
|
||||
GFile *file;
|
||||
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
{
|
||||
GFile *file;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
paintable = svg_paintable_new (file);
|
||||
gtk_picture_set_paintable (GTK_PICTURE (picture), paintable);
|
||||
g_object_unref (paintable);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gtk_native_dialog_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -39,20 +38,25 @@ show_file_open (GtkWidget *button,
|
||||
GtkPicture *picture)
|
||||
{
|
||||
GtkFileFilter *filter;
|
||||
GtkFileChooserNative *dialog;
|
||||
GtkFileDialog *dialog;
|
||||
GListStore *filters;
|
||||
|
||||
dialog = gtk_file_chooser_native_new ("Open node file",
|
||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Load",
|
||||
"_Cancel");
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Open node file");
|
||||
|
||||
filter = gtk_file_filter_new ();
|
||||
gtk_file_filter_add_mime_type (filter, "image/svg+xml");
|
||||
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
|
||||
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), picture);
|
||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
|
||||
filters = g_list_store_new (GTK_TYPE_FILE_FILTER);
|
||||
g_list_store_append (filters, filter);
|
||||
g_object_unref (filter);
|
||||
gtk_file_dialog_set_filters (dialog, G_LIST_MODEL (filters));
|
||||
g_object_unref (filters);
|
||||
|
||||
gtk_file_dialog_open (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||
NULL,
|
||||
NULL,
|
||||
open_response_cb, picture);
|
||||
}
|
||||
|
||||
static GtkWidget *window;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Pickers
|
||||
* #Keywords: GtkColorChooser, GtkFontChooser, GtkApplicationChooser
|
||||
* #Keywords: GtkColorDialog, GtkFontDialog, GtkFileDialog
|
||||
*
|
||||
* These widgets are mainly intended for use in preference dialogs.
|
||||
* They allow to select colors, fonts and applications.
|
||||
@ -10,25 +10,40 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static gboolean
|
||||
filter_font_cb (const PangoFontFamily *family,
|
||||
const PangoFontFace *face,
|
||||
gpointer data)
|
||||
static void
|
||||
file_opened (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *data)
|
||||
{
|
||||
const char *alias_families[] = {
|
||||
"Cursive",
|
||||
"Fantasy",
|
||||
"Monospace",
|
||||
"Sans",
|
||||
"Serif",
|
||||
"System-ui",
|
||||
NULL
|
||||
};
|
||||
const char *family_name;
|
||||
GFile *file;
|
||||
GError *error = NULL;
|
||||
char *name;
|
||||
|
||||
family_name = pango_font_family_get_name (PANGO_FONT_FAMILY (family));
|
||||
file = gtk_file_dialog_open_finish (GTK_FILE_DIALOG (source), result, &error);
|
||||
|
||||
return g_strv_contains (alias_families, family_name);
|
||||
if (!file)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
name = g_file_get_basename (file);
|
||||
gtk_button_set_label (GTK_BUTTON (data), name);
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
static void
|
||||
open_file (GtkButton *picker)
|
||||
{
|
||||
GtkWindow *parent = GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (picker)));
|
||||
GtkFileDialog *dialog;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
|
||||
gtk_file_dialog_open (dialog, parent, NULL, NULL, file_opened, picker);
|
||||
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
#define COLOR(r,g,b) { r/255., g/255., b/255., 1.0 }
|
||||
@ -38,27 +53,6 @@ do_pickers (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *table, *label, *picker;
|
||||
GdkRGBA solarized[] = {
|
||||
COLOR (0xff, 0xff, 0xff),
|
||||
COLOR (0x07, 0x36, 0x42),
|
||||
COLOR (0xdc, 0x32, 0x2f),
|
||||
COLOR (0x85, 0x99, 0x00),
|
||||
COLOR (0xb5, 0x89, 0x00),
|
||||
COLOR (0x26, 0x8b, 0xd2),
|
||||
COLOR (0xd3, 0x36, 0x82),
|
||||
COLOR (0x2a, 0xa1, 0x98),
|
||||
COLOR (0xee, 0xe8, 0xd5),
|
||||
|
||||
COLOR (0x00, 0x00, 0x00),
|
||||
COLOR (0x00, 0x2b, 0x36),
|
||||
COLOR (0xcb, 0x4b, 0x16),
|
||||
COLOR (0x58, 0x6e, 0x75),
|
||||
COLOR (0x65, 0x7b, 0x83),
|
||||
COLOR (0x83, 0x94, 0x96),
|
||||
COLOR (0x6c, 0x71, 0xc4),
|
||||
COLOR (0x93, 0xa1, 0xa1),
|
||||
COLOR (0xfd, 0xf6, 0xe3),
|
||||
};
|
||||
|
||||
if (!window)
|
||||
{
|
||||
@ -77,55 +71,41 @@ do_pickers (GtkWidget *do_widget)
|
||||
gtk_grid_set_column_spacing (GTK_GRID (table), 10);
|
||||
gtk_window_set_child (GTK_WINDOW (window), table);
|
||||
|
||||
label = gtk_label_new ("Standard");
|
||||
gtk_widget_add_css_class (label, "title-4");
|
||||
gtk_grid_attach (GTK_GRID (table), label, 1, -1, 1, 1);
|
||||
label = gtk_label_new ("Custom");
|
||||
gtk_widget_add_css_class (label, "title-4");
|
||||
gtk_grid_attach (GTK_GRID (table), label, 2, -1, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Color:");
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
|
||||
|
||||
picker = gtk_color_button_new ();
|
||||
picker = gtk_color_dialog_button_new (gtk_color_dialog_new ());
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 1, 0, 1, 1);
|
||||
|
||||
picker = gtk_color_button_new ();
|
||||
gtk_color_button_set_title (GTK_COLOR_BUTTON (picker), "Solarized colors");
|
||||
gtk_color_chooser_add_palette (GTK_COLOR_CHOOSER (picker),
|
||||
GTK_ORIENTATION_HORIZONTAL,
|
||||
9,
|
||||
18,
|
||||
solarized);
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 2, 0, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Font:");
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1);
|
||||
|
||||
picker = gtk_font_button_new ();
|
||||
picker = gtk_font_dialog_button_new (gtk_font_dialog_new ());
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 1, 1, 1, 1);
|
||||
|
||||
picker = gtk_font_button_new ();
|
||||
gtk_font_chooser_set_level (GTK_FONT_CHOOSER (picker),
|
||||
GTK_FONT_CHOOSER_LEVEL_FAMILY |
|
||||
GTK_FONT_CHOOSER_LEVEL_SIZE);
|
||||
gtk_font_chooser_set_filter_func (GTK_FONT_CHOOSER (picker), filter_font_cb, NULL, NULL);
|
||||
label = gtk_label_new ("File:");
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 2, 1, 1);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 2, 1, 1, 1);
|
||||
picker = gtk_button_new_with_label ("[...]");
|
||||
g_signal_connect (picker, "clicked", G_CALLBACK (open_file), NULL);
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 1, 2, 1, 1);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
label = gtk_label_new ("Mail:");
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
picker = gtk_app_chooser_button_new ("x-scheme-handler/mailto");
|
||||
gtk_app_chooser_button_set_show_dialog_item (GTK_APP_CHOOSER_BUTTON (picker), TRUE);
|
||||
|
||||
|
@ -177,19 +177,12 @@ do_printing (GtkWidget *do_widget)
|
||||
|
||||
if (error)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkAlertDialog *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (do_widget),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s", error->message);
|
||||
dialog = gtk_alert_dialog_new ("%s", error->message);
|
||||
gtk_alert_dialog_show (dialog, GTK_WINDOW (do_widget));
|
||||
g_object_unref (dialog);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,60 +10,63 @@
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
static void
|
||||
open_dialog_response_cb (GtkNativeDialog *dialog,
|
||||
int response,
|
||||
GtkWidget *video)
|
||||
open_dialog_response_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
{
|
||||
gtk_native_dialog_hide (dialog);
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GtkWidget *video = user_data;
|
||||
GFile *file;
|
||||
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
gtk_video_set_file (GTK_VIDEO (video), file);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gtk_native_dialog_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
open_clicked_cb (GtkWidget *button,
|
||||
GtkWidget *video)
|
||||
{
|
||||
GtkFileChooserNative *dialog;
|
||||
GtkFileDialog *dialog;
|
||||
GtkFileFilter *filter;
|
||||
GListStore *filters;
|
||||
|
||||
dialog = gtk_file_chooser_native_new ("Select a video",
|
||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Open",
|
||||
"_Cancel");
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Select a video");
|
||||
|
||||
filters = g_list_store_new (GTK_TYPE_FILE_FILTER);
|
||||
|
||||
filter = gtk_file_filter_new ();
|
||||
gtk_file_filter_add_pattern (filter, "*");
|
||||
gtk_file_filter_set_name (filter, "All Files");
|
||||
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
||||
g_list_store_append (filters, filter);
|
||||
g_object_unref (filter);
|
||||
|
||||
filter = gtk_file_filter_new ();
|
||||
gtk_file_filter_add_mime_type (filter, "image/*");
|
||||
gtk_file_filter_set_name (filter, "Images");
|
||||
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
||||
g_list_store_append (filters, filter);
|
||||
g_object_unref (filter);
|
||||
|
||||
filter = gtk_file_filter_new ();
|
||||
gtk_file_filter_add_mime_type (filter, "video/*");
|
||||
gtk_file_filter_set_name (filter, "Video");
|
||||
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
||||
|
||||
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
|
||||
g_list_store_append (filters, filter);
|
||||
|
||||
gtk_file_dialog_set_current_filter (dialog, filter);
|
||||
g_object_unref (filter);
|
||||
|
||||
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (open_dialog_response_cb), video);
|
||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
|
||||
gtk_file_dialog_set_filters (dialog, G_LIST_MODEL (filters));
|
||||
g_object_unref (filters);
|
||||
|
||||
gtk_file_dialog_open (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||
NULL,
|
||||
NULL,
|
||||
open_dialog_response_cb, video);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -548,45 +548,36 @@ node_editor_window_load (NodeEditorWindow *self,
|
||||
}
|
||||
|
||||
static void
|
||||
open_response_cb (GtkWidget *dialog,
|
||||
int response,
|
||||
NodeEditorWindow *self)
|
||||
open_response_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
{
|
||||
gtk_widget_hide (dialog);
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
NodeEditorWindow *self = user_data;
|
||||
GFile *file;
|
||||
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
node_editor_window_load (self, file);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
static void
|
||||
show_open_filechooser (NodeEditorWindow *self)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkFileDialog *dialog;
|
||||
GFile *cwd;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new ("Open node file",
|
||||
GTK_WINDOW (self),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL,
|
||||
"_Load", GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
GFile *cwd = g_file_new_for_path (".");
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), cwd, NULL);
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Open node file");
|
||||
cwd = g_file_new_for_path (".");
|
||||
gtk_file_dialog_set_current_folder (dialog, cwd);
|
||||
g_object_unref (cwd);
|
||||
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), self);
|
||||
gtk_widget_show (dialog);
|
||||
gtk_file_dialog_open (dialog, GTK_WINDOW (self),
|
||||
NULL, NULL, open_response_cb, self);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -597,21 +588,22 @@ open_cb (GtkWidget *button,
|
||||
}
|
||||
|
||||
static void
|
||||
save_response_cb (GtkWidget *dialog,
|
||||
int response,
|
||||
NodeEditorWindow *self)
|
||||
save_response_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
{
|
||||
gtk_widget_hide (dialog);
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
NodeEditorWindow *self = user_data;
|
||||
GFile *file;
|
||||
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
file = gtk_file_dialog_save_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
{
|
||||
GFile *file;
|
||||
char *text;
|
||||
GError *error = NULL;
|
||||
|
||||
text = get_current_text (self->text_buffer);
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
g_file_replace_contents (file, text, strlen (text),
|
||||
NULL, FALSE,
|
||||
G_FILE_CREATE_NONE,
|
||||
@ -620,49 +612,40 @@ save_response_cb (GtkWidget *dialog,
|
||||
&error);
|
||||
if (error != NULL)
|
||||
{
|
||||
GtkWidget *message_dialog;
|
||||
GtkAlertDialog *alert;
|
||||
|
||||
message_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))),
|
||||
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK,
|
||||
"Saving failed");
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
|
||||
"%s", error->message);
|
||||
g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_widget_show (message_dialog);
|
||||
alert = gtk_alert_dialog_new ("Saving failed");
|
||||
gtk_alert_dialog_set_detail (alert, error->message);
|
||||
gtk_alert_dialog_show (alert,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))));
|
||||
g_object_unref (alert);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_free (text);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
static void
|
||||
save_cb (GtkWidget *button,
|
||||
NodeEditorWindow *self)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkFileDialog *dialog;
|
||||
GFile *cwd;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new ("Save node",
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL,
|
||||
"_Save", GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
GFile *cwd = g_file_new_for_path (".");
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), cwd, NULL);
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Save node");
|
||||
cwd = g_file_new_for_path (".");
|
||||
gtk_file_dialog_set_current_folder (dialog, cwd);
|
||||
g_object_unref (cwd);
|
||||
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (save_response_cb), self);
|
||||
gtk_widget_show (dialog);
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
||||
NULL,
|
||||
"demo.node",
|
||||
NULL,
|
||||
save_response_cb, self);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static GdkTexture *
|
||||
@ -724,34 +707,29 @@ create_cairo_texture (NodeEditorWindow *self)
|
||||
}
|
||||
|
||||
static void
|
||||
export_image_response_cb (GtkWidget *dialog,
|
||||
int response,
|
||||
GdkTexture *texture)
|
||||
export_image_response_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
{
|
||||
gtk_widget_hide (dialog);
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GdkTexture *texture = user_data;
|
||||
GFile *file;
|
||||
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
file = gtk_file_dialog_save_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
if (!gdk_texture_save_to_png (texture, g_file_peek_path (file)))
|
||||
{
|
||||
GtkWidget *message_dialog;
|
||||
GtkAlertDialog *alert;
|
||||
|
||||
message_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_window_get_transient_for (GTK_WINDOW (dialog))),
|
||||
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK,
|
||||
"Exporting to image failed");
|
||||
g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_widget_show (message_dialog);
|
||||
alert = gtk_alert_dialog_new ("Exporting to image failed");
|
||||
gtk_alert_dialog_show (alert, GTK_WINDOW (gtk_window_get_transient_for (GTK_WINDOW (dialog))));
|
||||
g_object_unref (alert);
|
||||
}
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
g_object_unref (texture);
|
||||
}
|
||||
|
||||
@ -760,25 +738,24 @@ export_image_cb (GtkWidget *button,
|
||||
NodeEditorWindow *self)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
GtkWidget *dialog;
|
||||
GtkFileDialog *dialog;
|
||||
|
||||
texture = create_texture (self);
|
||||
if (texture == NULL)
|
||||
return;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new ("",
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL,
|
||||
"_Save", GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (export_image_response_cb), texture);
|
||||
gtk_widget_show (dialog);
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "");
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
||||
NULL,
|
||||
"example.png",
|
||||
NULL,
|
||||
export_image_response_cb, texture);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
clip_image_cb (GtkWidget *button,
|
||||
NodeEditorWindow *self)
|
||||
|
@ -96,12 +96,10 @@ set_text (const char *text,
|
||||
static void
|
||||
load_file (GFile *open_filename)
|
||||
{
|
||||
GtkWidget *error_dialog;
|
||||
char *contents;
|
||||
GError *error;
|
||||
gsize len;
|
||||
|
||||
error_dialog = NULL;
|
||||
error = NULL;
|
||||
g_file_load_contents (open_filename, NULL, &contents, &len, NULL, &error);
|
||||
if (error == NULL)
|
||||
@ -117,36 +115,28 @@ load_file (GFile *open_filename)
|
||||
{
|
||||
GFileInfo *info = g_file_query_info (open_filename, "standard::display-name", 0, NULL, &error);
|
||||
const char *display_name = g_file_info_get_display_name (info);
|
||||
error_dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Error loading file %s:\n%s",
|
||||
display_name,
|
||||
"Not valid utf8");
|
||||
g_object_unref (info);
|
||||
}
|
||||
GtkAlertDialog *alert;
|
||||
|
||||
alert = gtk_alert_dialog_new ("Error loading file %s", display_name);
|
||||
gtk_alert_dialog_set_detail (alert, "Not valid utf8");
|
||||
gtk_alert_dialog_show (alert, GTK_WINDOW (main_window));
|
||||
g_object_unref (alert);
|
||||
g_object_unref (info);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GFileInfo *info = g_file_query_info (open_filename, "standard::display-name", 0, NULL, &error);
|
||||
const char *display_name = g_file_info_get_display_name (info);
|
||||
error_dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Error loading file %s:\n%s",
|
||||
display_name,
|
||||
error->message);
|
||||
GtkAlertDialog *alert;
|
||||
|
||||
alert = gtk_alert_dialog_new ("Error loading file %s", display_name);
|
||||
gtk_alert_dialog_set_detail (alert, error->message);
|
||||
gtk_alert_dialog_show (alert, GTK_WINDOW (main_window));
|
||||
g_object_unref (alert);
|
||||
g_object_unref (info);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
if (error_dialog)
|
||||
{
|
||||
g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_widget_show (error_dialog);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -154,7 +144,6 @@ static void
|
||||
save_file (GFile *save_filename)
|
||||
{
|
||||
char *text = get_text ();
|
||||
GtkWidget *error_dialog;
|
||||
GError *error;
|
||||
|
||||
error = NULL;
|
||||
@ -180,18 +169,12 @@ save_file (GFile *save_filename)
|
||||
{
|
||||
GFileInfo *info = g_file_query_info (save_filename, "standard::display-name", 0, NULL, NULL);
|
||||
const char *display_name = g_file_info_get_display_name (info);
|
||||
GtkAlertDialog *alert;
|
||||
|
||||
error_dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Error saving to file %s:\n%s",
|
||||
display_name,
|
||||
error->message);
|
||||
|
||||
g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_widget_show (error_dialog);
|
||||
|
||||
alert = gtk_alert_dialog_new ("Error saving to file %s", display_name);
|
||||
gtk_alert_dialog_set_detail (alert, error->message);
|
||||
gtk_alert_dialog_show (alert, GTK_WINDOW (main_window));
|
||||
g_object_unref (alert);
|
||||
g_error_free (error);
|
||||
g_object_unref (info);
|
||||
}
|
||||
@ -340,21 +323,24 @@ create_custom_widget (GtkPrintOperation *operation,
|
||||
PrintData *data)
|
||||
{
|
||||
GtkWidget *vbox, *hbox, *font, *label;
|
||||
GtkFontDialog *dialog;
|
||||
PangoFontDescription *desc;
|
||||
|
||||
gtk_print_operation_set_custom_tab_label (operation, "Other");
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
|
||||
gtk_box_append (GTK_BOX (vbox), hbox);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
label = gtk_label_new ("Font:");
|
||||
gtk_box_append (GTK_BOX (hbox), label);
|
||||
gtk_widget_show (label);
|
||||
|
||||
font = gtk_font_button_new_with_font (data->font);
|
||||
dialog = gtk_font_dialog_new ();
|
||||
font = gtk_font_dialog_button_new (dialog);
|
||||
desc = pango_font_description_from_string (data->font);
|
||||
gtk_font_dialog_button_set_font_desc (GTK_FONT_DIALOG_BUTTON (font), desc);
|
||||
pango_font_description_free (desc);
|
||||
gtk_box_append (GTK_BOX (hbox), font);
|
||||
gtk_widget_show (font);
|
||||
data->font_button = font;
|
||||
|
||||
return vbox;
|
||||
@ -365,11 +351,12 @@ custom_widget_apply (GtkPrintOperation *operation,
|
||||
GtkWidget *widget,
|
||||
PrintData *data)
|
||||
{
|
||||
const char *selected_font;
|
||||
selected_font = gtk_font_chooser_get_font (GTK_FONT_CHOOSER (data->font_button));
|
||||
PangoFontDescription *desc;
|
||||
|
||||
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (data->font_button));
|
||||
|
||||
g_free (data->font);
|
||||
data->font = g_strdup (selected_font);
|
||||
data->font = pango_font_description_to_string (desc);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -377,23 +364,18 @@ print_done (GtkPrintOperation *op,
|
||||
GtkPrintOperationResult res,
|
||||
PrintData *print_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
|
||||
{
|
||||
|
||||
GtkWidget *error_dialog;
|
||||
GtkAlertDialog *alert;
|
||||
GError *error = NULL;
|
||||
|
||||
gtk_print_operation_get_error (op, &error);
|
||||
|
||||
error_dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Error printing file:\n%s",
|
||||
error ? error->message : "no details");
|
||||
g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_widget_show (error_dialog);
|
||||
alert = gtk_alert_dialog_new ("Error printing file");
|
||||
if (error)
|
||||
gtk_alert_dialog_set_detail (alert, error->message);
|
||||
gtk_alert_dialog_show (alert, GTK_WINDOW (main_window));
|
||||
g_object_unref (alert);
|
||||
}
|
||||
else if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
|
||||
{
|
||||
@ -499,17 +481,19 @@ activate_preview (GSimpleAction *action,
|
||||
}
|
||||
|
||||
static void
|
||||
on_save_response (GtkWidget *dialog,
|
||||
int response)
|
||||
on_save_response (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
{
|
||||
if (response == GTK_RESPONSE_OK)
|
||||
{
|
||||
GFile *save_filename = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
save_file (save_filename);
|
||||
g_object_unref (save_filename);
|
||||
}
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GFile *file;
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
file = gtk_file_dialog_save_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
{
|
||||
save_file (file);
|
||||
g_object_unref (file);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -517,21 +501,17 @@ activate_save_as (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkFileDialog *dialog;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new ("Select file",
|
||||
GTK_WINDOW (main_window),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL,
|
||||
"_Save", GTK_RESPONSE_OK,
|
||||
NULL);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (on_save_response),
|
||||
NULL);
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Select file");
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (main_window),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
on_save_response, NULL);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -546,17 +526,19 @@ activate_save (GSimpleAction *action,
|
||||
}
|
||||
|
||||
static void
|
||||
on_open_response (GtkWidget *dialog,
|
||||
int response)
|
||||
on_open_response (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
{
|
||||
if (response == GTK_RESPONSE_OK)
|
||||
{
|
||||
GFile *open_filename = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
load_file (open_filename);
|
||||
g_object_unref (open_filename);
|
||||
}
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GFile *file;
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
{
|
||||
load_file (file);
|
||||
g_object_unref (file);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -564,21 +546,16 @@ activate_open (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkFileDialog *dialog;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new ("Select file",
|
||||
GTK_WINDOW (main_window),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL,
|
||||
"_Open", GTK_RESPONSE_OK,
|
||||
NULL);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (on_open_response),
|
||||
NULL);
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Select file");
|
||||
gtk_file_dialog_open (dialog,
|
||||
GTK_WINDOW (main_window),
|
||||
NULL,
|
||||
NULL,
|
||||
on_open_response, NULL);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -214,10 +214,19 @@ activate_background (GSimpleAction *action,
|
||||
}
|
||||
|
||||
static void
|
||||
file_chooser_response (GtkNativeDialog *self,
|
||||
int response)
|
||||
file_chooser_response (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
{
|
||||
gtk_native_dialog_destroy (self);
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GFile *file;
|
||||
|
||||
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
{
|
||||
g_print ("File selected: %s", g_file_peek_path (file));
|
||||
g_object_unref (file);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -225,17 +234,11 @@ activate_open_file (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkFileChooserNative *chooser;
|
||||
GtkFileDialog *dialog;
|
||||
|
||||
chooser = gtk_file_chooser_native_new ("Open file",
|
||||
NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"Open",
|
||||
"Cancel");
|
||||
|
||||
g_signal_connect (chooser, "response", G_CALLBACK (file_chooser_response), NULL);
|
||||
|
||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (chooser));
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_open (dialog, NULL, NULL, NULL, file_chooser_response, NULL);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1093,7 +1096,9 @@ set_color (GtkListBox *box, GtkListBoxRow *row, GtkColorChooser *chooser)
|
||||
if (gdk_rgba_parse (&rgba, color))
|
||||
{
|
||||
g_signal_handlers_block_by_func (chooser, rgba_changed, box);
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_color_chooser_set_rgba (chooser, &rgba);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_signal_handlers_unblock_by_func (chooser, rgba_changed, box);
|
||||
}
|
||||
}
|
||||
|
@ -6,19 +6,11 @@ action_activated (GSimpleAction *action,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWindow *parent = user_data;
|
||||
GtkWidget *dialog;
|
||||
GtkAlertDialog *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (parent,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Activated action `%s`",
|
||||
g_action_get_name (G_ACTION (action)));
|
||||
|
||||
g_signal_connect_swapped (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), dialog);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
dialog = gtk_alert_dialog_new ("Activated action `%s`", g_action_get_name (G_ACTION (action)));
|
||||
gtk_alert_dialog_show (dialog, NULL);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static GActionEntry doc_entries[] = {
|
||||
|
@ -46,6 +46,8 @@
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/**
|
||||
* GtkColorButton:
|
||||
*
|
||||
@ -67,6 +69,8 @@
|
||||
* `GtkColorButton` has a single CSS node with name colorbutton which
|
||||
* contains a button node. To differentiate it from a plain `GtkButton`,
|
||||
* it gets the .color style class.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.ColorDialogButton] instead
|
||||
*/
|
||||
|
||||
typedef struct _GtkColorButtonClass GtkColorButtonClass;
|
||||
@ -353,6 +357,8 @@ gtk_color_button_finalize (GObject *object)
|
||||
* color when the user finishes.
|
||||
*
|
||||
* Returns: a new color button
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.ColorDialogButton] instead
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_color_button_new (void)
|
||||
@ -561,6 +567,8 @@ set_use_alpha (GtkColorButton *button,
|
||||
* @title: String containing new window title
|
||||
*
|
||||
* Sets the title for the color chooser dialog.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.ColorDialogButton] instead
|
||||
*/
|
||||
void
|
||||
gtk_color_button_set_title (GtkColorButton *button,
|
||||
@ -587,6 +595,8 @@ gtk_color_button_set_title (GtkColorButton *button,
|
||||
* Gets the title of the color chooser dialog.
|
||||
*
|
||||
* Returns: An internal string, do not free the return value
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.ColorDialogButton] instead
|
||||
*/
|
||||
const char *
|
||||
gtk_color_button_get_title (GtkColorButton *button)
|
||||
@ -602,6 +612,8 @@ gtk_color_button_get_title (GtkColorButton *button)
|
||||
* @modal: %TRUE to make the dialog modal
|
||||
*
|
||||
* Sets whether the dialog should be modal.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.ColorDialogButton] instead
|
||||
*/
|
||||
void
|
||||
gtk_color_button_set_modal (GtkColorButton *button,
|
||||
@ -627,6 +639,8 @@ gtk_color_button_set_modal (GtkColorButton *button,
|
||||
* Gets whether the dialog is modal.
|
||||
*
|
||||
* Returns: %TRUE if the dialog is modal
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.ColorDialogButton] instead
|
||||
*/
|
||||
gboolean
|
||||
gtk_color_button_get_modal (GtkColorButton *button)
|
@ -48,19 +48,19 @@ typedef struct _GtkColorButton GtkColorButton;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_color_button_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkWidget * gtk_color_button_new (void);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkWidget * gtk_color_button_new_with_rgba (const GdkRGBA *rgba);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_color_button_set_title (GtkColorButton *button,
|
||||
const char *title);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
const char *gtk_color_button_get_title (GtkColorButton *button);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
gboolean gtk_color_button_get_modal (GtkColorButton *button);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_color_button_set_modal (GtkColorButton *button,
|
||||
gboolean modal);
|
||||
|
@ -36,6 +36,9 @@
|
||||
* In GTK, the main widgets that implement this interface are
|
||||
* [class@Gtk.ColorChooserWidget], [class@Gtk.ColorChooserDialog] and
|
||||
* [class@Gtk.ColorButton].
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.ColorDialog] and [class@Gtk.ColorDialogButton]
|
||||
* instead of widgets implementing `GtkColorChooser`
|
||||
*/
|
||||
|
||||
enum
|
||||
@ -116,6 +119,8 @@ _gtk_color_chooser_color_activated (GtkColorChooser *chooser,
|
||||
* @color: (out): a `GdkRGBA` to fill in with the current color
|
||||
*
|
||||
* Gets the currently-selected color.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.ColorDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_color_chooser_get_rgba (GtkColorChooser *chooser,
|
||||
@ -132,6 +137,8 @@ gtk_color_chooser_get_rgba (GtkColorChooser *chooser,
|
||||
* @color: the new color
|
||||
*
|
||||
* Sets the color.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.ColorDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_color_chooser_set_rgba (GtkColorChooser *chooser,
|
||||
@ -151,6 +158,8 @@ gtk_color_chooser_set_rgba (GtkColorChooser *chooser,
|
||||
*
|
||||
* Returns: %TRUE if the color chooser uses the alpha channel,
|
||||
* %FALSE if not
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.ColorDialog] instead
|
||||
*/
|
||||
gboolean
|
||||
gtk_color_chooser_get_use_alpha (GtkColorChooser *chooser)
|
||||
@ -170,6 +179,8 @@ gtk_color_chooser_get_use_alpha (GtkColorChooser *chooser)
|
||||
* @use_alpha: %TRUE if color chooser should use alpha channel, %FALSE if not
|
||||
*
|
||||
* Sets whether or not the color chooser should use the alpha channel.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.ColorDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_color_chooser_set_use_alpha (GtkColorChooser *chooser,
|
||||
@ -207,6 +218,8 @@ gtk_color_chooser_set_use_alpha (GtkColorChooser *chooser,
|
||||
* of removing the default color palette from the color chooser.
|
||||
*
|
||||
* If @colors is %NULL, removes all previously added palettes.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.ColorDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_color_chooser_add_palette (GtkColorChooser *chooser,
|
@ -63,20 +63,20 @@ struct _GtkColorChooserInterface
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_color_chooser_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_color_chooser_get_rgba (GtkColorChooser *chooser,
|
||||
GdkRGBA *color);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_color_chooser_set_rgba (GtkColorChooser *chooser,
|
||||
const GdkRGBA *color);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
gboolean gtk_color_chooser_get_use_alpha (GtkColorChooser *chooser);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_color_chooser_set_use_alpha (GtkColorChooser *chooser,
|
||||
gboolean use_alpha);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_color_chooser_add_palette (GtkColorChooser *chooser,
|
||||
GtkOrientation orientation,
|
||||
int colors_per_line,
|
@ -35,7 +35,7 @@ typedef struct _GtkColorChooserDialog GtkColorChooserDialog;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_color_chooser_dialog_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkWidget * gtk_color_chooser_dialog_new (const char *title,
|
||||
GtkWindow *parent);
|
||||
|
@ -35,7 +35,7 @@ typedef struct _GtkColorChooserWidget GtkColorChooserWidget;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_color_chooser_widget_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkWidget * gtk_color_chooser_widget_new (void);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorChooserWidget, g_object_unref)
|
@ -24,6 +24,8 @@
|
||||
#include "gtkmarshalers.h"
|
||||
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/**
|
||||
* GtkFileChooser:
|
||||
*
|
||||
@ -67,6 +69,8 @@
|
||||
* options. If a choice has no option, it will be rendered as a
|
||||
* check button with the given label; if a choice has options, it will
|
||||
* be rendered as a combo box.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
|
||||
|
||||
@ -173,6 +177,8 @@ gtk_file_chooser_error_quark (void)
|
||||
* For example, an option to create a new folder might be shown
|
||||
* if the action is %GTK_FILE_CHOOSER_ACTION_SAVE but not if the
|
||||
* action is %GTK_FILE_CHOOSER_ACTION_OPEN.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
**/
|
||||
void
|
||||
gtk_file_chooser_set_action (GtkFileChooser *chooser,
|
||||
@ -190,6 +196,8 @@ gtk_file_chooser_set_action (GtkFileChooser *chooser,
|
||||
* Gets the type of operation that the file chooser is performing.
|
||||
*
|
||||
* Returns: the action that the file selector is performing
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
GtkFileChooserAction
|
||||
gtk_file_chooser_get_action (GtkFileChooser *chooser)
|
||||
@ -213,6 +221,8 @@ gtk_file_chooser_get_action (GtkFileChooser *chooser)
|
||||
* This is only relevant if the action is set to be
|
||||
* %GTK_FILE_CHOOSER_ACTION_OPEN or
|
||||
* %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
|
||||
@ -231,6 +241,8 @@ gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
|
||||
* chooser.
|
||||
*
|
||||
* Returns: %TRUE if multiple files can be selected.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
gboolean
|
||||
gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
|
||||
@ -253,6 +265,8 @@ gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
|
||||
*
|
||||
* This is only relevant if the action is not set to be
|
||||
* %GTK_FILE_CHOOSER_ACTION_OPEN.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
|
||||
@ -270,6 +284,8 @@ gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
|
||||
* Gets whether file chooser will offer to create new folders.
|
||||
*
|
||||
* Returns: %TRUE if the Create Folder button should be displayed.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
gboolean
|
||||
gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
|
||||
@ -301,6 +317,8 @@ gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
|
||||
*
|
||||
* Please see the documentation for those functions for an example
|
||||
* of using [method@Gtk.FileChooser.set_current_name] as well.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
**/
|
||||
void
|
||||
gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
|
||||
@ -326,6 +344,8 @@ gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
|
||||
* whatever the contents of the entry are. Note also that this string is
|
||||
* in UTF-8 encoding, which is not necessarily the system’s encoding for
|
||||
* filenames.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
char *
|
||||
gtk_file_chooser_get_current_name (GtkFileChooser *chooser)
|
||||
@ -362,6 +382,8 @@ gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
|
||||
*
|
||||
* Returns: %TRUE if the folder could be changed successfully, %FALSE
|
||||
* otherwise.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
gboolean
|
||||
gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
|
||||
@ -382,6 +404,8 @@ gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
|
||||
* Gets the current folder of @chooser as `GFile`.
|
||||
*
|
||||
* Returns: (transfer full) (nullable): the `GFile` for the current folder.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
GFile *
|
||||
gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
|
||||
@ -423,6 +447,8 @@ gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
|
||||
* Returns: (transfer full): a list model containing a `GFile` for each
|
||||
* selected file and subfolder in the current folder. Free the returned
|
||||
* list with g_object_unref().
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
GListModel *
|
||||
gtk_file_chooser_get_files (GtkFileChooser *chooser)
|
||||
@ -482,6 +508,8 @@ gtk_file_chooser_get_files (GtkFileChooser *chooser)
|
||||
* ```
|
||||
*
|
||||
* Returns: Not useful
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
gboolean
|
||||
gtk_file_chooser_set_file (GtkFileChooser *chooser,
|
||||
@ -511,6 +539,8 @@ gtk_file_chooser_set_file (GtkFileChooser *chooser,
|
||||
*
|
||||
* Returns: (transfer full) (nullable): a selected `GFile`. You own the
|
||||
* returned file; use g_object_unref() to release it.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
GFile *
|
||||
gtk_file_chooser_get_file (GtkFileChooser *chooser)
|
||||
@ -539,6 +569,8 @@ gtk_file_chooser_get_file (GtkFileChooser *chooser)
|
||||
*
|
||||
* Returns: %TRUE if the folder could be added successfully,
|
||||
* %FALSE otherwise.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
gboolean
|
||||
gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
|
||||
@ -561,6 +593,8 @@ gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
|
||||
*
|
||||
* Returns: %TRUE if the folder could be removed successfully,
|
||||
* %FALSE otherwise.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
gboolean
|
||||
gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
|
||||
@ -601,6 +635,8 @@ gtk_file_chooser_add_filter (GtkFileChooser *chooser,
|
||||
* @filter: a `GtkFileFilter`
|
||||
*
|
||||
* Removes @filter from the list of filters that the user can select between.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
|
||||
@ -648,6 +684,8 @@ gtk_file_chooser_get_filters (GtkFileChooser *chooser)
|
||||
* Setting the current filter when the list of filters is
|
||||
* empty is useful if you want to restrict the displayed
|
||||
* set of files without letting the user change it.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_file_chooser_set_filter (GtkFileChooser *chooser,
|
||||
@ -666,6 +704,8 @@ gtk_file_chooser_set_filter (GtkFileChooser *chooser,
|
||||
* Gets the current filter.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the current filter
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
GtkFileFilter *
|
||||
gtk_file_chooser_get_filter (GtkFileChooser *chooser)
|
||||
@ -695,6 +735,8 @@ gtk_file_chooser_get_filter (GtkFileChooser *chooser)
|
||||
* @chooser may or may not affect the returned model.
|
||||
*
|
||||
* Returns: (transfer full): A list model of `GFile`s
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
GListModel *
|
||||
gtk_file_chooser_get_shortcut_folders (GtkFileChooser *chooser)
|
||||
@ -720,6 +762,8 @@ gtk_file_chooser_get_shortcut_folders (GtkFileChooser *chooser)
|
||||
* and you can obtain the user-selected value in the
|
||||
* [signal@Gtk.Dialog::response] signal handler using
|
||||
* [method@Gtk.FileChooser.get_choice].
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_file_chooser_add_choice (GtkFileChooser *chooser,
|
||||
@ -740,6 +784,8 @@ gtk_file_chooser_add_choice (GtkFileChooser *chooser,
|
||||
* @id: the ID of the choice to remove
|
||||
*
|
||||
* Removes a 'choice' that has been added with gtk_file_chooser_add_choice().
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_file_chooser_remove_choice (GtkFileChooser *chooser,
|
||||
@ -761,6 +807,8 @@ gtk_file_chooser_remove_choice (GtkFileChooser *chooser,
|
||||
* gtk_file_chooser_add_choice().
|
||||
*
|
||||
* For a boolean choice, the possible options are "true" and "false".
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_file_chooser_set_choice (GtkFileChooser *chooser,
|
||||
@ -781,6 +829,8 @@ gtk_file_chooser_set_choice (GtkFileChooser *chooser,
|
||||
* Gets the currently selected option in the 'choice' with the given ID.
|
||||
*
|
||||
* Returns: (nullable): the ID of the currently selected option
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
const char *
|
||||
gtk_file_chooser_get_choice (GtkFileChooser *chooser,
|
@ -85,101 +85,101 @@ typedef enum {
|
||||
GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME
|
||||
} GtkFileChooserError;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GQuark gtk_file_chooser_error_quark (void);
|
||||
|
||||
/* Configuration */
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_file_chooser_set_action (GtkFileChooser *chooser,
|
||||
GtkFileChooserAction action);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkFileChooserAction gtk_file_chooser_get_action (GtkFileChooser *chooser);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
|
||||
gboolean select_multiple);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
gboolean gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
|
||||
gboolean create_folders);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
gboolean gtk_file_chooser_get_create_folders (GtkFileChooser *chooser);
|
||||
|
||||
/* Suggested name for the Save-type actions */
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
|
||||
const char *name);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
char * gtk_file_chooser_get_current_name (GtkFileChooser *chooser);
|
||||
|
||||
/* GFile manipulation */
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GFile * gtk_file_chooser_get_file (GtkFileChooser *chooser);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
gboolean gtk_file_chooser_set_file (GtkFileChooser *chooser,
|
||||
GFile *file,
|
||||
GError **error);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GListModel * gtk_file_chooser_get_files (GtkFileChooser *chooser);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
gboolean gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
|
||||
GFile *file,
|
||||
GError **error);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GFile * gtk_file_chooser_get_current_folder (GtkFileChooser *chooser);
|
||||
|
||||
/* List of user selectable filters */
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_file_chooser_add_filter (GtkFileChooser *chooser,
|
||||
GtkFileFilter *filter);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
|
||||
GtkFileFilter *filter);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GListModel * gtk_file_chooser_get_filters (GtkFileChooser *chooser);
|
||||
|
||||
/* Current filter */
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_file_chooser_set_filter (GtkFileChooser *chooser,
|
||||
GtkFileFilter *filter);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkFileFilter * gtk_file_chooser_get_filter (GtkFileChooser *chooser);
|
||||
|
||||
/* Per-application shortcut folders */
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
gboolean gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
|
||||
GFile *folder,
|
||||
GError **error);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
gboolean gtk_file_chooser_remove_shortcut_folder
|
||||
(GtkFileChooser *chooser,
|
||||
GFile *folder,
|
||||
GError **error);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GListModel * gtk_file_chooser_get_shortcut_folders (GtkFileChooser *chooser);
|
||||
|
||||
/* Custom widgets */
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_file_chooser_add_choice (GtkFileChooser *chooser,
|
||||
const char *id,
|
||||
const char *label,
|
||||
const char **options,
|
||||
const char **option_labels);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_file_chooser_remove_choice (GtkFileChooser *chooser,
|
||||
const char *id);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_file_chooser_set_choice (GtkFileChooser *chooser,
|
||||
const char *id,
|
||||
const char *option);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
const char * gtk_file_chooser_get_choice (GtkFileChooser *chooser,
|
||||
const char *id);
|
||||
|
@ -24,7 +24,7 @@
|
||||
#endif
|
||||
|
||||
#include <gtk/gtkdialog.h>
|
||||
#include <gtk/gtkfilechooser.h>
|
||||
#include <gtk/deprecated/gtkfilechooser.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -36,7 +36,7 @@ typedef struct _GtkFileChooserDialog GtkFileChooserDialog;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_file_chooser_dialog_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkWidget *gtk_file_chooser_dialog_new (const char *title,
|
||||
GtkWindow *parent,
|
||||
GtkFileChooserAction action,
|
@ -23,7 +23,7 @@
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtkfilechooser.h>
|
||||
#include <gtk/deprecated/gtkfilechooser.h>
|
||||
#include <gtk/gtknativedialog.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@ -33,21 +33,21 @@ G_BEGIN_DECLS
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkFileChooserNative, gtk_file_chooser_native, GTK, FILE_CHOOSER_NATIVE, GtkNativeDialog)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkFileChooserNative *gtk_file_chooser_native_new (const char *title,
|
||||
GtkWindow *parent,
|
||||
GtkFileChooserAction action,
|
||||
const char *accept_label,
|
||||
const char *cancel_label);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
const char *gtk_file_chooser_native_get_accept_label (GtkFileChooserNative *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_file_chooser_native_set_accept_label (GtkFileChooserNative *self,
|
||||
const char *accept_label);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
const char *gtk_file_chooser_native_get_cancel_label (GtkFileChooserNative *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_file_chooser_native_set_cancel_label (GtkFileChooserNative *self,
|
||||
const char *cancel_label);
|
||||
|
@ -23,7 +23,7 @@
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtkfilechooser.h>
|
||||
#include <gtk/deprecated/gtkfilechooser.h>
|
||||
#include <gtk/gtkbox.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@ -36,7 +36,7 @@ typedef struct _GtkFileChooserWidget GtkFileChooserWidget;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_file_chooser_widget_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkWidget *gtk_file_chooser_widget_new (GtkFileChooserAction action);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFileChooserWidget, g_object_unref)
|
@ -45,6 +45,8 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/**
|
||||
* GtkFontButton:
|
||||
*
|
||||
@ -65,6 +67,8 @@
|
||||
*
|
||||
* `GtkFontButton` has a single CSS node with name fontbutton which
|
||||
* contains a button node with the .font style class.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
|
||||
*/
|
||||
|
||||
typedef struct _GtkFontButtonClass GtkFontButtonClass;
|
||||
@ -744,6 +748,8 @@ gtk_font_button_get_property (GObject *object,
|
||||
* Creates a new font picker widget.
|
||||
*
|
||||
* Returns: a new font picker widget.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_font_button_new (void)
|
||||
@ -758,6 +764,8 @@ gtk_font_button_new (void)
|
||||
* Creates a new font picker widget showing the given font.
|
||||
*
|
||||
* Returns: a new font picker widget.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_font_button_new_with_font (const char *fontname)
|
||||
@ -771,6 +779,8 @@ gtk_font_button_new_with_font (const char *fontname)
|
||||
* @title: a string containing the font chooser dialog title
|
||||
*
|
||||
* Sets the title for the font chooser dialog.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
|
||||
*/
|
||||
void
|
||||
gtk_font_button_set_title (GtkFontButton *font_button,
|
||||
@ -797,6 +807,8 @@ gtk_font_button_set_title (GtkFontButton *font_button,
|
||||
*
|
||||
* Returns: an internal copy of the title string
|
||||
* which must not be freed.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
|
||||
*/
|
||||
const char *
|
||||
gtk_font_button_get_title (GtkFontButton *font_button)
|
||||
@ -812,6 +824,8 @@ gtk_font_button_get_title (GtkFontButton *font_button)
|
||||
* @modal: %TRUE to make the dialog modal
|
||||
*
|
||||
* Sets whether the dialog should be modal.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
|
||||
*/
|
||||
void
|
||||
gtk_font_button_set_modal (GtkFontButton *font_button,
|
||||
@ -837,6 +851,8 @@ gtk_font_button_set_modal (GtkFontButton *font_button,
|
||||
* Gets whether the dialog is modal.
|
||||
*
|
||||
* Returns: %TRUE if the dialog is modal
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
|
||||
*/
|
||||
gboolean
|
||||
gtk_font_button_get_modal (GtkFontButton *font_button)
|
||||
@ -853,6 +869,8 @@ gtk_font_button_get_modal (GtkFontButton *font_button)
|
||||
* Returns whether the selected font is used in the label.
|
||||
*
|
||||
* Returns: whether the selected font is used in the label.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
|
||||
*/
|
||||
gboolean
|
||||
gtk_font_button_get_use_font (GtkFontButton *font_button)
|
||||
@ -869,6 +887,8 @@ gtk_font_button_get_use_font (GtkFontButton *font_button)
|
||||
*
|
||||
* If @use_font is %TRUE, the font name will be written
|
||||
* using the selected font.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
|
||||
*/
|
||||
void
|
||||
gtk_font_button_set_use_font (GtkFontButton *font_button,
|
||||
@ -896,6 +916,8 @@ gtk_font_button_set_use_font (GtkFontButton *font_button,
|
||||
* Returns whether the selected size is used in the label.
|
||||
*
|
||||
* Returns: whether the selected size is used in the label.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
|
||||
*/
|
||||
gboolean
|
||||
gtk_font_button_get_use_size (GtkFontButton *font_button)
|
||||
@ -913,6 +935,8 @@ gtk_font_button_get_use_size (GtkFontButton *font_button)
|
||||
*
|
||||
* If @use_size is %TRUE, the font name will be written using
|
||||
* the selected size.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
|
||||
*/
|
||||
void
|
||||
gtk_font_button_set_use_size (GtkFontButton *font_button,
|
@ -43,29 +43,29 @@ typedef struct _GtkFontButton GtkFontButton;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_font_button_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkWidget *gtk_font_button_new (void);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkWidget *gtk_font_button_new_with_font (const char *fontname);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
const char * gtk_font_button_get_title (GtkFontButton *font_button);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_font_button_set_title (GtkFontButton *font_button,
|
||||
const char *title);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
gboolean gtk_font_button_get_modal (GtkFontButton *font_button);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_font_button_set_modal (GtkFontButton *font_button,
|
||||
gboolean modal);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
gboolean gtk_font_button_get_use_font (GtkFontButton *font_button);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_font_button_set_use_font (GtkFontButton *font_button,
|
||||
gboolean use_font);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
gboolean gtk_font_button_get_use_size (GtkFontButton *font_button);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_font_button_set_use_size (GtkFontButton *font_button,
|
||||
gboolean use_size);
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/**
|
||||
* GtkFontChooser:
|
||||
*
|
||||
@ -34,6 +36,9 @@
|
||||
* In GTK, the main objects that implement this interface are
|
||||
* [class@Gtk.FontChooserWidget], [class@Gtk.FontChooserDialog] and
|
||||
* [class@Gtk.FontButton].
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
|
||||
enum
|
||||
@ -167,6 +172,9 @@ gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
|
||||
*
|
||||
* Returns: (nullable) (transfer none): A `PangoFontFamily` representing the
|
||||
* selected font family
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
PangoFontFamily *
|
||||
gtk_font_chooser_get_font_family (GtkFontChooser *fontchooser)
|
||||
@ -187,6 +195,9 @@ gtk_font_chooser_get_font_family (GtkFontChooser *fontchooser)
|
||||
*
|
||||
* Returns: (nullable) (transfer none): A `PangoFontFace` representing the
|
||||
* selected font group details
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
PangoFontFace *
|
||||
gtk_font_chooser_get_font_face (GtkFontChooser *fontchooser)
|
||||
@ -204,6 +215,9 @@ gtk_font_chooser_get_font_face (GtkFontChooser *fontchooser)
|
||||
*
|
||||
* Returns: A n integer representing the selected font size,
|
||||
* or -1 if no font size is selected.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
int
|
||||
gtk_font_chooser_get_font_size (GtkFontChooser *fontchooser)
|
||||
@ -230,6 +244,9 @@ gtk_font_chooser_get_font_size (GtkFontChooser *fontchooser)
|
||||
*
|
||||
* Returns: (nullable) (transfer full): A string with the name
|
||||
* of the current font
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
char *
|
||||
gtk_font_chooser_get_font (GtkFontChooser *fontchooser)
|
||||
@ -250,6 +267,9 @@ gtk_font_chooser_get_font (GtkFontChooser *fontchooser)
|
||||
* @fontname: a font name like “Helvetica 12” or “Times Bold 18”
|
||||
*
|
||||
* Sets the currently-selected font.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
gtk_font_chooser_set_font (GtkFontChooser *fontchooser,
|
||||
@ -278,6 +298,9 @@ gtk_font_chooser_set_font (GtkFontChooser *fontchooser,
|
||||
*
|
||||
* Returns: (nullable) (transfer full): A `PangoFontDescription` for the
|
||||
* current font
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
PangoFontDescription *
|
||||
gtk_font_chooser_get_font_desc (GtkFontChooser *fontchooser)
|
||||
@ -297,6 +320,9 @@ gtk_font_chooser_get_font_desc (GtkFontChooser *fontchooser)
|
||||
* @font_desc: a `PangoFontDescription`
|
||||
*
|
||||
* Sets the currently-selected font from @font_desc.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
gtk_font_chooser_set_font_desc (GtkFontChooser *fontchooser,
|
||||
@ -315,6 +341,9 @@ gtk_font_chooser_set_font_desc (GtkFontChooser *fontchooser,
|
||||
* Gets the text displayed in the preview area.
|
||||
*
|
||||
* Returns: (transfer full): the text displayed in the preview area
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
char *
|
||||
gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser)
|
||||
@ -336,6 +365,9 @@ gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser)
|
||||
* Sets the text displayed in the preview area.
|
||||
*
|
||||
* The @text is used to show how the selected font looks.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
|
||||
@ -354,6 +386,9 @@ gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
|
||||
* Returns whether the preview entry is shown or not.
|
||||
*
|
||||
* Returns: %TRUE if the preview entry is shown or %FALSE if it is hidden.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
gboolean
|
||||
gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser)
|
||||
@ -373,6 +408,9 @@ gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser)
|
||||
* @show_preview_entry: whether to show the editable preview entry or not
|
||||
*
|
||||
* Shows or hides the editable preview entry.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser,
|
||||
@ -393,6 +431,9 @@ gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser,
|
||||
*
|
||||
* Adds a filter function that decides which fonts to display
|
||||
* in the font chooser.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser,
|
||||
@ -447,6 +488,9 @@ _gtk_font_chooser_font_activated (GtkFontChooser *chooser,
|
||||
* context = gtk_widget_get_pango_context (label);
|
||||
* pango_context_set_font_map (context, fontmap);
|
||||
* ```
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
gtk_font_chooser_set_font_map (GtkFontChooser *fontchooser,
|
||||
@ -467,6 +511,9 @@ gtk_font_chooser_set_font_map (GtkFontChooser *fontchooser,
|
||||
* or %NULL if it does not have one.
|
||||
*
|
||||
* Returns: (nullable) (transfer full): a `PangoFontMap`
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
PangoFontMap *
|
||||
gtk_font_chooser_get_font_map (GtkFontChooser *fontchooser)
|
||||
@ -487,6 +534,9 @@ gtk_font_chooser_get_font_map (GtkFontChooser *fontchooser)
|
||||
* @level: the desired level of granularity
|
||||
*
|
||||
* Sets the desired level of granularity for selecting fonts.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
gtk_font_chooser_set_level (GtkFontChooser *fontchooser,
|
||||
@ -504,6 +554,9 @@ gtk_font_chooser_set_level (GtkFontChooser *fontchooser,
|
||||
* Returns the current level of granularity for selecting fonts.
|
||||
*
|
||||
* Returns: the current granularity level
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
GtkFontChooserLevel
|
||||
gtk_font_chooser_get_level (GtkFontChooser *fontchooser)
|
||||
@ -528,6 +581,9 @@ gtk_font_chooser_get_level (GtkFontChooser *fontchooser)
|
||||
* It can be passed to [func@Pango.AttrFontFeatures.new].
|
||||
*
|
||||
* Returns: the currently selected font features
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
char *
|
||||
gtk_font_chooser_get_font_features (GtkFontChooser *fontchooser)
|
||||
@ -548,6 +604,9 @@ gtk_font_chooser_get_font_features (GtkFontChooser *fontchooser)
|
||||
* Gets the language that is used for font features.
|
||||
*
|
||||
* Returns: the currently selected language
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
char *
|
||||
gtk_font_chooser_get_language (GtkFontChooser *fontchooser)
|
||||
@ -567,6 +626,9 @@ gtk_font_chooser_get_language (GtkFontChooser *fontchooser)
|
||||
* @language: a language
|
||||
*
|
||||
* Sets the language to use for font features.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
|
||||
* instead
|
||||
*/
|
||||
void
|
||||
gtk_font_chooser_set_language (GtkFontChooser *fontchooser,
|
@ -107,57 +107,57 @@ struct _GtkFontChooserIface
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_font_chooser_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
PangoFontFamily *gtk_font_chooser_get_font_family (GtkFontChooser *fontchooser);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
PangoFontFace *gtk_font_chooser_get_font_face (GtkFontChooser *fontchooser);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
int gtk_font_chooser_get_font_size (GtkFontChooser *fontchooser);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
PangoFontDescription *
|
||||
gtk_font_chooser_get_font_desc (GtkFontChooser *fontchooser);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_font_chooser_set_font_desc (GtkFontChooser *fontchooser,
|
||||
const PangoFontDescription *font_desc);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
char * gtk_font_chooser_get_font (GtkFontChooser *fontchooser);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_font_chooser_set_font (GtkFontChooser *fontchooser,
|
||||
const char *fontname);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
char * gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
|
||||
const char *text);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
gboolean gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser,
|
||||
gboolean show_preview_entry);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser,
|
||||
GtkFontFilterFunc filter,
|
||||
gpointer user_data,
|
||||
GDestroyNotify destroy);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_font_chooser_set_font_map (GtkFontChooser *fontchooser,
|
||||
PangoFontMap *fontmap);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
PangoFontMap * gtk_font_chooser_get_font_map (GtkFontChooser *fontchooser);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_font_chooser_set_level (GtkFontChooser *fontchooser,
|
||||
GtkFontChooserLevel level);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkFontChooserLevel
|
||||
gtk_font_chooser_get_level (GtkFontChooser *fontchooser);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
char * gtk_font_chooser_get_font_features (GtkFontChooser *fontchooser);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
char * gtk_font_chooser_get_language (GtkFontChooser *fontchooser);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_font_chooser_set_language (GtkFontChooser *fontchooser,
|
||||
const char *language);
|
||||
|
@ -34,7 +34,7 @@ typedef struct _GtkFontChooserDialog GtkFontChooserDialog;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_font_chooser_dialog_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkWidget* gtk_font_chooser_dialog_new (const char *title,
|
||||
GtkWindow *parent);
|
||||
|
@ -35,7 +35,7 @@ typedef struct _GtkFontChooserWidget GtkFontChooserWidget;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_font_chooser_widget_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkWidget* gtk_font_chooser_widget_new (void);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFontChooserWidget, g_object_unref)
|
@ -78,7 +78,7 @@ typedef enum
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_message_dialog_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkWidget* gtk_message_dialog_new (GtkWindow *parent,
|
||||
GtkDialogFlags flags,
|
||||
GtkMessageType type,
|
||||
@ -86,7 +86,7 @@ GtkWidget* gtk_message_dialog_new (GtkWindow *parent,
|
||||
const char *message_format,
|
||||
...) G_GNUC_PRINTF (5, 6);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkWidget* gtk_message_dialog_new_with_markup (GtkWindow *parent,
|
||||
GtkDialogFlags flags,
|
||||
GtkMessageType type,
|
||||
@ -94,21 +94,21 @@ GtkWidget* gtk_message_dialog_new_with_markup (GtkWindow *parent,
|
||||
const char *message_format,
|
||||
...) G_GNUC_PRINTF (5, 6);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog,
|
||||
const char *str);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog,
|
||||
const char *message_format,
|
||||
...) G_GNUC_PRINTF (2, 3);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
void gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog,
|
||||
const char *message_format,
|
||||
...) G_GNUC_PRINTF (2, 3);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_10
|
||||
GtkWidget *gtk_message_dialog_get_message_area (GtkMessageDialog *message_dialog);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkMessageDialog, g_object_unref)
|
@ -19,9 +19,14 @@ gtk_deprecated_sources = [
|
||||
'deprecated/gtkcellrenderertext.c',
|
||||
'deprecated/gtkcellrenderertoggle.c',
|
||||
'deprecated/gtkcellview.c',
|
||||
'deprecated/gtkcolorbutton.c',
|
||||
'deprecated/gtkcolorchooser.c',
|
||||
'deprecated/gtkcombobox.c',
|
||||
'deprecated/gtkcomboboxtext.c',
|
||||
'deprecated/gtkentrycompletion.c',
|
||||
'deprecated/gtkfilechooser.c',
|
||||
'deprecated/gtkfontbutton.c',
|
||||
'deprecated/gtkfontchooser.c',
|
||||
'deprecated/gtkiconview.c',
|
||||
'deprecated/gtkliststore.c',
|
||||
'deprecated/gtkrender.c',
|
||||
@ -60,11 +65,24 @@ gtk_deprecated_headers = [
|
||||
'deprecated/gtkcellrenderertext.h',
|
||||
'deprecated/gtkcellrenderertoggle.h',
|
||||
'deprecated/gtkcellview.h',
|
||||
'deprecated/gtkcolorbutton.h',
|
||||
'deprecated/gtkcolorchooser.h',
|
||||
'deprecated/gtkcolorchooserdialog.h',
|
||||
'deprecated/gtkcolorchooserwidget.h',
|
||||
'deprecated/gtkcombobox.h',
|
||||
'deprecated/gtkcomboboxtext.h',
|
||||
'deprecated/gtkentrycompletion.h',
|
||||
'deprecated/gtkfilechooser.h',
|
||||
'deprecated/gtkfilechooserdialog.h',
|
||||
'deprecated/gtkfilechoosernative.h',
|
||||
'deprecated/gtkfilechooserwidget.h',
|
||||
'deprecated/gtkfontbutton.h',
|
||||
'deprecated/gtkfontchooser.h',
|
||||
'deprecated/gtkfontchooserdialog.h',
|
||||
'deprecated/gtkfontchooserwidget.h',
|
||||
'deprecated/gtkiconview.h',
|
||||
'deprecated/gtkliststore.h',
|
||||
'deprecated/gtkmessagedialog.h',
|
||||
'deprecated/gtkrender.h',
|
||||
'deprecated/gtkstylecontext.h',
|
||||
'deprecated/gtktreednd.h',
|
||||
|
33
gtk/gtk.h
33
gtk/gtk.h
@ -38,6 +38,7 @@
|
||||
#include <gtk/gtkactionable.h>
|
||||
#include <gtk/gtkactionbar.h>
|
||||
#include <gtk/gtkadjustment.h>
|
||||
#include <gtk/gtkalertdialog.h>
|
||||
#include <gtk/deprecated/gtkappchooser.h>
|
||||
#include <gtk/deprecated/gtkappchooserdialog.h>
|
||||
#include <gtk/deprecated/gtkappchooserwidget.h>
|
||||
@ -78,10 +79,12 @@
|
||||
#include <gtk/gtkcenterbox.h>
|
||||
#include <gtk/gtkcenterlayout.h>
|
||||
#include <gtk/gtkcheckbutton.h>
|
||||
#include <gtk/gtkcolorbutton.h>
|
||||
#include <gtk/gtkcolorchooser.h>
|
||||
#include <gtk/gtkcolorchooserdialog.h>
|
||||
#include <gtk/gtkcolorchooserwidget.h>
|
||||
#include <gtk/deprecated/gtkcolorbutton.h>
|
||||
#include <gtk/deprecated/gtkcolorchooser.h>
|
||||
#include <gtk/deprecated/gtkcolorchooserdialog.h>
|
||||
#include <gtk/deprecated/gtkcolorchooserwidget.h>
|
||||
#include <gtk/gtkcolordialog.h>
|
||||
#include <gtk/gtkcolordialogbutton.h>
|
||||
#include <gtk/gtkcolorutils.h>
|
||||
#include <gtk/gtkcolumnview.h>
|
||||
#include <gtk/gtkcolumnviewcolumn.h>
|
||||
@ -95,6 +98,7 @@
|
||||
#include <gtk/gtkcustomsorter.h>
|
||||
#include <gtk/gtkdebug.h>
|
||||
#include <gtk/gtkdialog.h>
|
||||
#include <gtk/gtkdialogerror.h>
|
||||
#include <gtk/gtkdirectorylist.h>
|
||||
#include <gtk/gtkdragicon.h>
|
||||
#include <gtk/gtkdragsource.h>
|
||||
@ -120,20 +124,23 @@
|
||||
#include <gtk/gtkexpression.h>
|
||||
#include <gtk/gtkfixed.h>
|
||||
#include <gtk/gtkfixedlayout.h>
|
||||
#include <gtk/gtkfilechooser.h>
|
||||
#include <gtk/gtkfilechooserdialog.h>
|
||||
#include <gtk/gtkfilechoosernative.h>
|
||||
#include <gtk/gtkfilechooserwidget.h>
|
||||
#include <gtk/deprecated/gtkfilechooser.h>
|
||||
#include <gtk/deprecated/gtkfilechooserdialog.h>
|
||||
#include <gtk/deprecated/gtkfilechoosernative.h>
|
||||
#include <gtk/deprecated/gtkfilechooserwidget.h>
|
||||
#include <gtk/gtkfiledialog.h>
|
||||
#include <gtk/gtkfilefilter.h>
|
||||
#include <gtk/gtkfilter.h>
|
||||
#include <gtk/gtkfilterlistmodel.h>
|
||||
#include <gtk/gtkcustomfilter.h>
|
||||
#include <gtk/gtkflattenlistmodel.h>
|
||||
#include <gtk/gtkflowbox.h>
|
||||
#include <gtk/gtkfontbutton.h>
|
||||
#include <gtk/gtkfontchooser.h>
|
||||
#include <gtk/gtkfontchooserdialog.h>
|
||||
#include <gtk/gtkfontchooserwidget.h>
|
||||
#include <gtk/deprecated/gtkfontbutton.h>
|
||||
#include <gtk/deprecated/gtkfontchooser.h>
|
||||
#include <gtk/deprecated/gtkfontchooserdialog.h>
|
||||
#include <gtk/deprecated/gtkfontchooserwidget.h>
|
||||
#include <gtk/gtkfontdialog.h>
|
||||
#include <gtk/gtkfontdialogbutton.h>
|
||||
#include <gtk/gtkframe.h>
|
||||
#include <gtk/gtkgesture.h>
|
||||
#include <gtk/gtkgestureclick.h>
|
||||
@ -176,7 +183,7 @@
|
||||
#include <gtk/gtkmediafile.h>
|
||||
#include <gtk/gtkmediastream.h>
|
||||
#include <gtk/gtkmenubutton.h>
|
||||
#include <gtk/gtkmessagedialog.h>
|
||||
#include <gtk/deprecated/gtkmessagedialog.h>
|
||||
#include <gtk/gtkmountoperation.h>
|
||||
#include <gtk/gtkmultifilter.h>
|
||||
#include <gtk/gtkmultiselection.h>
|
||||
|
752
gtk/gtkalertdialog.c
Normal file
752
gtk/gtkalertdialog.c
Normal file
@ -0,0 +1,752 @@
|
||||
/*
|
||||
* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkalertdialog.h"
|
||||
|
||||
#include "gtkbutton.h"
|
||||
#include "deprecated/gtkmessagedialog.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
/**
|
||||
* GtkAlertDialog:
|
||||
*
|
||||
* A `GtkAlertDialog` object collects the arguments that
|
||||
* are needed to present a message to the user.
|
||||
*
|
||||
* The message is shown with the [method@Gtk.AlertDialog.choose]
|
||||
* function. This API follows the GIO async pattern, and the result can
|
||||
* be obtained by calling [method@Gtk.AlertDialog.choose_finish].
|
||||
*
|
||||
* If you don't need to wait for a button to be clicked, you can use
|
||||
* [method@Gtk.AlertDialog.show].
|
||||
*
|
||||
* `GtkAlertDialog was added in GTK 4.10.
|
||||
*/
|
||||
|
||||
/* {{{ GObject implementation */
|
||||
|
||||
struct _GtkAlertDialog
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
char *message;
|
||||
char *detail;
|
||||
char **buttons;
|
||||
|
||||
int cancel_button;
|
||||
int default_button;
|
||||
|
||||
int cancel_return;
|
||||
|
||||
unsigned int modal : 1;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_MODAL = 1,
|
||||
PROP_MESSAGE,
|
||||
PROP_DETAIL,
|
||||
PROP_BUTTONS,
|
||||
PROP_CANCEL_BUTTON,
|
||||
PROP_DEFAULT_BUTTON,
|
||||
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *properties[NUM_PROPERTIES];
|
||||
|
||||
G_DEFINE_TYPE (GtkAlertDialog, gtk_alert_dialog, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_alert_dialog_init (GtkAlertDialog *self)
|
||||
{
|
||||
self->modal = TRUE;
|
||||
self->cancel_button = -1;
|
||||
self->default_button = -1;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_alert_dialog_finalize (GObject *object)
|
||||
{
|
||||
GtkAlertDialog *self = GTK_ALERT_DIALOG (object);
|
||||
|
||||
g_free (self->message);
|
||||
g_free (self->detail);
|
||||
g_strfreev (self->buttons);
|
||||
|
||||
G_OBJECT_CLASS (gtk_alert_dialog_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_alert_dialog_get_property (GObject *object,
|
||||
unsigned int property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAlertDialog *self = GTK_ALERT_DIALOG (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_MODAL:
|
||||
g_value_set_boolean (value, self->modal);
|
||||
break;
|
||||
|
||||
case PROP_MESSAGE:
|
||||
g_value_set_string (value, self->message);
|
||||
break;
|
||||
|
||||
case PROP_DETAIL:
|
||||
g_value_set_string (value, self->detail);
|
||||
break;
|
||||
|
||||
case PROP_BUTTONS:
|
||||
g_value_set_boxed (value, self->buttons);
|
||||
break;
|
||||
|
||||
case PROP_CANCEL_BUTTON:
|
||||
g_value_set_int (value, self->cancel_button);
|
||||
break;
|
||||
|
||||
case PROP_DEFAULT_BUTTON:
|
||||
g_value_set_int (value, self->default_button);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_alert_dialog_set_property (GObject *object,
|
||||
unsigned int prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAlertDialog *self = GTK_ALERT_DIALOG (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_MODAL:
|
||||
gtk_alert_dialog_set_modal (self, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_MESSAGE:
|
||||
gtk_alert_dialog_set_message (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_DETAIL:
|
||||
gtk_alert_dialog_set_detail (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_BUTTONS:
|
||||
gtk_alert_dialog_set_buttons (self, g_value_get_boxed (value));
|
||||
break;
|
||||
|
||||
case PROP_CANCEL_BUTTON:
|
||||
gtk_alert_dialog_set_cancel_button (self, g_value_get_int (value));
|
||||
break;
|
||||
|
||||
case PROP_DEFAULT_BUTTON:
|
||||
gtk_alert_dialog_set_default_button (self, g_value_get_int (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_alert_dialog_class_init (GtkAlertDialogClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->finalize = gtk_alert_dialog_finalize;
|
||||
object_class->get_property = gtk_alert_dialog_get_property;
|
||||
object_class->set_property = gtk_alert_dialog_set_property;
|
||||
|
||||
/**
|
||||
* GtkAlertDialog:modal: (attributes org.gtk.Property.get=gtk_alert_dialog_get_modal org.gtk.Property.set=gtk_alert_dialog_set_modal)
|
||||
*
|
||||
* Whether the alert is modal.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_MODAL] =
|
||||
g_param_spec_boolean ("modal", NULL, NULL,
|
||||
TRUE,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkAlertDialog:message: (attributes org.gtk.Property.get=gtk_alert_dialog_get_message org.gtk.Property.set=gtk_alert_dialog_set_message)
|
||||
*
|
||||
* The message for the alert.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_MESSAGE] =
|
||||
g_param_spec_string ("message", NULL, NULL,
|
||||
NULL,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkAlertDialog:detail: (attributes org.gtk.Property.get=gtk_alert_dialog_get_detail org.gtk.Property.set=gtk_alert_dialog_set_detail)
|
||||
*
|
||||
* The detail text for the alert.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_DETAIL] =
|
||||
g_param_spec_string ("detail", NULL, NULL,
|
||||
NULL,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkAlertDialog:buttons: (attributes org.gtk.Property.get=gtk_alert_dialog_get_buttons org.gtk.Property.set=gtk_alert_dialog_set_buttons)
|
||||
*
|
||||
* Labels for buttons to show in the alert.
|
||||
*
|
||||
* The labels should be translated and may contain
|
||||
* a _ to indicate the mnemonic character.
|
||||
*
|
||||
* If this property is not set, then a 'Close' button is
|
||||
* automatically created.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_BUTTONS] =
|
||||
g_param_spec_boxed ("buttons", NULL, NULL,
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkAlertDialog:cancel-button: (attributes org.gtk.Property.get=gtk_alert_dialog_get_cancel_button org.gtk.Property.set=gtk_alert_dialog_set_cancel_button)
|
||||
*
|
||||
* This property determines what happens when the Escape key is
|
||||
* pressed while the alert is shown.
|
||||
*
|
||||
* If this property holds the index of a button in [property@Gtk.AlertDialog:buttons],
|
||||
* then pressing Escape is treated as if that button was pressed. If it is -1
|
||||
* or not a valid index for the `buttons` array, then an error is returned.
|
||||
*
|
||||
* If `buttons` is `NULL`, then the automatically created 'Close' button
|
||||
* is treated as both cancel and default button, so 0 is returned.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_CANCEL_BUTTON] =
|
||||
g_param_spec_int ("cancel-button", NULL, NULL,
|
||||
-1, G_MAXINT, -1,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkAlertDialog:default-button: (attributes org.gtk.Property.get=gtk_alert_dialog_get_default_button org.gtk.Property.set=gtk_alert_dialog_set_default_button)
|
||||
*
|
||||
* This property determines what happens when the Return key is
|
||||
* pressed while the alert is shown.
|
||||
*
|
||||
* If this property holds the index of a button in [property@Gtk.AlertDialog:buttons],
|
||||
* then pressing Return is treated as if that button was pressed. If it is -1
|
||||
* or not a valid index for the `buttons` array, then nothing happens.
|
||||
*
|
||||
* If `buttons` is `NULL`, then the automatically created 'Close' button
|
||||
* is treated as both cancel and default button, so 0 is returned.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_DEFAULT_BUTTON] =
|
||||
g_param_spec_int ("default-button", NULL, NULL,
|
||||
-1, G_MAXINT, -1,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ API: Constructor */
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_new:
|
||||
* @format: printf()-style format string
|
||||
* @...: arguments for @format
|
||||
*
|
||||
* Creates a new `GtkAlertDialog` object.
|
||||
*
|
||||
* The message will be set to the formatted string
|
||||
* resulting from the arguments.
|
||||
*
|
||||
* Returns: the new `GtkAlertDialog`
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
GtkAlertDialog *
|
||||
gtk_alert_dialog_new (const char *format,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
char *message;
|
||||
GtkAlertDialog *dialog;
|
||||
|
||||
va_start (args, format);
|
||||
message = g_strdup_vprintf (format, args);
|
||||
va_end (args);
|
||||
|
||||
dialog = g_object_new (GTK_TYPE_ALERT_DIALOG,
|
||||
"message", message,
|
||||
NULL);
|
||||
g_free (message);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ API: Getters and setters */
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_get_modal:
|
||||
* @self: a `GtkAlertDialog`
|
||||
*
|
||||
* Returns whether the alert blocks interaction
|
||||
* with the parent window while it is presented.
|
||||
*
|
||||
* Returns: `TRUE` if the alert is modal
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
gboolean
|
||||
gtk_alert_dialog_get_modal (GtkAlertDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_ALERT_DIALOG (self), TRUE);
|
||||
|
||||
return self->modal;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_set_modal:
|
||||
* @self: a `GtkAlertDialog`
|
||||
* @modal: the new value
|
||||
*
|
||||
* Sets whether the alert blocks interaction
|
||||
* with the parent window while it is presented.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_alert_dialog_set_modal (GtkAlertDialog *self,
|
||||
gboolean modal)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_ALERT_DIALOG (self));
|
||||
|
||||
if (self->modal == modal)
|
||||
return;
|
||||
|
||||
self->modal = modal;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODAL]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_get_message:
|
||||
* @self: a `GtkAlertDialog`
|
||||
*
|
||||
* Returns the message that will be shown in the alert.
|
||||
*
|
||||
* Returns: the message
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
const char *
|
||||
gtk_alert_dialog_get_message (GtkAlertDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_ALERT_DIALOG (self), NULL);
|
||||
|
||||
return self->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_set_message:
|
||||
* @self: a `GtkAlertDialog`
|
||||
* @message: the new message
|
||||
*
|
||||
* Sets the message that will be shown in the alert.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_alert_dialog_set_message (GtkAlertDialog *self,
|
||||
const char *message)
|
||||
{
|
||||
char *new_message;
|
||||
|
||||
g_return_if_fail (GTK_IS_ALERT_DIALOG (self));
|
||||
g_return_if_fail (message != NULL);
|
||||
|
||||
if (g_strcmp0 (self->message, message) == 0)
|
||||
return;
|
||||
|
||||
new_message = g_strdup (message);
|
||||
g_free (self->message);
|
||||
self->message = new_message;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MESSAGE]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_get_detail:
|
||||
* @self: a `GtkAlertDialog`
|
||||
*
|
||||
* Returns the detail text that will be shown in the alert.
|
||||
*
|
||||
* Returns: the detail text
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
const char *
|
||||
gtk_alert_dialog_get_detail (GtkAlertDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_ALERT_DIALOG (self), NULL);
|
||||
|
||||
return self->detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_set_detail:
|
||||
* @self: a `GtkAlertDialog`
|
||||
* @detail: the new detail text
|
||||
*
|
||||
* Sets the detail text that will be shown in the alert.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_alert_dialog_set_detail (GtkAlertDialog *self,
|
||||
const char *detail)
|
||||
{
|
||||
char *new_detail;
|
||||
|
||||
g_return_if_fail (GTK_IS_ALERT_DIALOG (self));
|
||||
g_return_if_fail (detail != NULL);
|
||||
|
||||
if (g_strcmp0 (self->detail, detail) == 0)
|
||||
return;
|
||||
|
||||
new_detail = g_strdup (detail);
|
||||
g_free (self->detail);
|
||||
self->detail = new_detail;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DETAIL]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_get_buttons:
|
||||
* @self: a `GtkAlertDialog`
|
||||
*
|
||||
* Returns the button labels for the alert.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the button labels
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
const char * const *
|
||||
gtk_alert_dialog_get_buttons (GtkAlertDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_ALERT_DIALOG (self), NULL);
|
||||
|
||||
return (const char * const *) self->buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_set_buttons:
|
||||
* @self: a `GtkAlertDialog`
|
||||
* @labels: the new button labels
|
||||
*
|
||||
* Sets the button labels for the alert.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_alert_dialog_set_buttons (GtkAlertDialog *self,
|
||||
const char * const *labels)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_ALERT_DIALOG (self));
|
||||
g_return_if_fail (labels != NULL);
|
||||
|
||||
g_strfreev (self->buttons);
|
||||
self->buttons = g_strdupv ((char **)labels);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_BUTTONS]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_get_cancel_button:
|
||||
* @self: a `GtkAlertDialog`
|
||||
*
|
||||
* Returns the index of the cancel button.
|
||||
*
|
||||
* Returns: the index of the cancel button, or -1
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
int
|
||||
gtk_alert_dialog_get_cancel_button (GtkAlertDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_ALERT_DIALOG (self), -1);
|
||||
|
||||
return self->cancel_button;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_set_cancel_button:
|
||||
* @self: a `GtkAlertDialog`
|
||||
* @button: the new cancel button
|
||||
*
|
||||
* Sets the index of the cancel button.
|
||||
*
|
||||
* See [property@Gtk.AlertDialog:cancel-button] for
|
||||
* details of how this value is used.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_alert_dialog_set_cancel_button (GtkAlertDialog *self,
|
||||
int button)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_ALERT_DIALOG (self));
|
||||
|
||||
if (self->cancel_button == button)
|
||||
return;
|
||||
|
||||
self->cancel_button = button;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CANCEL_BUTTON]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_get_default_button:
|
||||
* @self: a `GtkAlertDialog`
|
||||
*
|
||||
* Returns the index of the default button.
|
||||
*
|
||||
* Returns: the index of the default button, or -1
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
int
|
||||
gtk_alert_dialog_get_default_button (GtkAlertDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_ALERT_DIALOG (self), -1);
|
||||
|
||||
return self->default_button;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_set_default_button:
|
||||
* @self: a `GtkAlertDialog`
|
||||
* @button: the new default button
|
||||
*
|
||||
* Sets the index of the default button.
|
||||
*
|
||||
* See [property@Gtk.AlertDialog:default-button] for
|
||||
* details of how this value is used.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_alert_dialog_set_default_button (GtkAlertDialog *self,
|
||||
int button)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_ALERT_DIALOG (self));
|
||||
|
||||
if (self->default_button == button)
|
||||
return;
|
||||
|
||||
self->default_button = button;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DEFAULT_BUTTON]);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Async implementation */
|
||||
|
||||
static void response_cb (GTask *task,
|
||||
int response);
|
||||
|
||||
static void
|
||||
cancelled_cb (GCancellable *cancellable,
|
||||
GTask *task)
|
||||
{
|
||||
response_cb (task, GTK_RESPONSE_CLOSE);
|
||||
}
|
||||
|
||||
static void
|
||||
response_cb (GTask *task,
|
||||
int response)
|
||||
{
|
||||
GCancellable *cancellable;
|
||||
|
||||
cancellable = g_task_get_cancellable (task);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_handlers_disconnect_by_func (cancellable, cancelled_cb, task);
|
||||
|
||||
if (response >= 0)
|
||||
{
|
||||
g_task_return_int (task, response);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkAlertDialog *self = GTK_ALERT_DIALOG (g_task_get_source_object (task));
|
||||
|
||||
g_task_return_int (task, self->cancel_return);
|
||||
}
|
||||
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_response (GtkDialog *dialog,
|
||||
int response,
|
||||
GTask *task)
|
||||
{
|
||||
response_cb (task, response);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Async API */
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_choose:
|
||||
* @self: a `GtkAlertDialog`
|
||||
* @parent: (nullable): the parent `GtkWindow`
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (nullable) (scope async): a callback to call when the operation is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
*
|
||||
* This function shows the alert to the user.
|
||||
*
|
||||
* The @callback will be called when the alert is dismissed.
|
||||
* It should call [method@Gtk.AlertDialog.choose_finish]
|
||||
* to obtain the result.
|
||||
*
|
||||
* It is ok to pass `NULL` for the callback if the alert
|
||||
* does not have more than one button. A simpler API for
|
||||
* this case is [method@Gtk.AlertDialog.show].
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_alert_dialog_choose (GtkAlertDialog *self,
|
||||
GtkWindow *parent,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkMessageDialog *window;
|
||||
GTask *task;
|
||||
|
||||
g_return_if_fail (GTK_IS_ALERT_DIALOG (self));
|
||||
|
||||
window = g_object_new (GTK_TYPE_MESSAGE_DIALOG,
|
||||
"transient-for", parent,
|
||||
"destroy-with-parent", TRUE,
|
||||
"modal", self->modal,
|
||||
"text", self->message,
|
||||
"secondary-text", self->detail,
|
||||
NULL);
|
||||
|
||||
if (self->buttons && self->buttons[0])
|
||||
{
|
||||
self->cancel_return = -1;
|
||||
for (int i = 0; self->buttons[i]; i++)
|
||||
{
|
||||
gtk_dialog_add_button (GTK_DIALOG (window), self->buttons[i], i);
|
||||
if (self->default_button == i)
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (window), i);
|
||||
if (self->cancel_button == i)
|
||||
self->cancel_return = i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_dialog_add_button (GTK_DIALOG (window), _("_Close"), 0);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (window), 0);
|
||||
self->cancel_return = 0;
|
||||
}
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, gtk_alert_dialog_choose);
|
||||
g_task_set_task_data (task, window, (GDestroyNotify) gtk_window_destroy);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
|
||||
|
||||
g_signal_connect (window, "response", G_CALLBACK (dialog_response), task);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_choose_finish:
|
||||
* @self: a `GtkAlertDialog`
|
||||
* @result: a `GAsyncResult`
|
||||
*
|
||||
* Finishes the [method@Gtk.AlertDialog.choose] call
|
||||
* and returns the index of the button that was clicked.
|
||||
*
|
||||
* Returns: the index of the button that was clicked, or -1 if
|
||||
* the dialog was cancelled and `[property@Gtk.AlertDialog:cancel-button]
|
||||
* is not set
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
int
|
||||
gtk_alert_dialog_choose_finish (GtkAlertDialog *self,
|
||||
GAsyncResult *result)
|
||||
{
|
||||
GTask *task = G_TASK (result);
|
||||
|
||||
g_return_val_if_fail (g_task_get_source_tag (task) == gtk_alert_dialog_choose, -1);
|
||||
|
||||
return (int) g_task_propagate_int (task, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alert_dialog_show:
|
||||
* @self: a `GtkAlertDialog`
|
||||
* @parent: (nullable): the parent `GtkWindow`
|
||||
*
|
||||
* This function shows the alert to the user.
|
||||
*
|
||||
* If the alert has more than one button, you should use
|
||||
* [method@Gtk.AlertDialog.choose] instead and provide
|
||||
* a callback that can react to the button that was clicked.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_alert_dialog_show (GtkAlertDialog *self,
|
||||
GtkWindow *parent)
|
||||
{
|
||||
gtk_alert_dialog_choose (self, parent, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* vim:set foldmethod=marker expandtab: */
|
96
gtk/gtkalertdialog.h
Normal file
96
gtk/gtkalertdialog.h
Normal file
@ -0,0 +1,96 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
*
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtkwindow.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_ALERT_DIALOG (gtk_alert_dialog_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
G_DECLARE_FINAL_TYPE (GtkAlertDialog, gtk_alert_dialog, GTK, ALERT_DIALOG, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GtkAlertDialog *gtk_alert_dialog_new (const char *format,
|
||||
...) G_GNUC_PRINTF (1, 2);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
gboolean gtk_alert_dialog_get_modal (GtkAlertDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_alert_dialog_set_modal (GtkAlertDialog *self,
|
||||
gboolean modal);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
const char * gtk_alert_dialog_get_message (GtkAlertDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_alert_dialog_set_message (GtkAlertDialog *self,
|
||||
const char *message);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
const char * gtk_alert_dialog_get_detail (GtkAlertDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_alert_dialog_set_detail (GtkAlertDialog *self,
|
||||
const char *detail);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
const char * const *
|
||||
gtk_alert_dialog_get_buttons (GtkAlertDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_alert_dialog_set_buttons (GtkAlertDialog *self,
|
||||
const char * const *labels);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
int gtk_alert_dialog_get_cancel_button (GtkAlertDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_alert_dialog_set_cancel_button (GtkAlertDialog *self,
|
||||
int button);
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
int gtk_alert_dialog_get_default_button (GtkAlertDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_alert_dialog_set_default_button (GtkAlertDialog *self,
|
||||
int button);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_alert_dialog_choose (GtkAlertDialog *self,
|
||||
GtkWindow *parent,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
int gtk_alert_dialog_choose_finish (GtkAlertDialog *self,
|
||||
GAsyncResult *result);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_alert_dialog_show (GtkAlertDialog *self,
|
||||
GtkWindow *parent);
|
||||
|
||||
G_END_DECLS
|
@ -28,7 +28,9 @@
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include "gtkbookmarksmanagerprivate.h"
|
||||
#include "gtkfilechooser.h" /* for the GError types */
|
||||
#include "deprecated/gtkfilechooser.h" /* for the GError types */
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static void
|
||||
_gtk_bookmark_free (gpointer data)
|
||||
|
@ -24,9 +24,11 @@
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksettings.h"
|
||||
|
||||
#include "gtkcolorchooserprivate.h"
|
||||
#include "gtkcolorchooserdialog.h"
|
||||
#include "gtkcolorchooserwidget.h"
|
||||
#include "deprecated/gtkcolorchooserprivate.h"
|
||||
#include "deprecated/gtkcolorchooserdialog.h"
|
||||
#include "deprecated/gtkcolorchooserwidget.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/**
|
||||
* GtkColorChooserDialog:
|
||||
@ -43,6 +45,10 @@
|
||||
* To change the initially selected color, use
|
||||
* [method@Gtk.ColorChooser.set_rgba]. To get the selected color use
|
||||
* [method@Gtk.ColorChooser.get_rgba].
|
||||
*
|
||||
* `GtkColorChooserDialog` has been deprecated in favor of [class@Gtk.ColorDialog].
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.ColorDialog] instead
|
||||
*/
|
||||
|
||||
typedef struct _GtkColorChooserDialogClass GtkColorChooserDialogClass;
|
||||
@ -281,6 +287,8 @@ gtk_color_chooser_dialog_iface_init (GtkColorChooserInterface *iface)
|
||||
* Creates a new `GtkColorChooserDialog`.
|
||||
*
|
||||
* Returns: a new `GtkColorChooserDialog`
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.ColorDialog] instead
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_color_chooser_dialog_new (const char *title,
|
||||
|
@ -18,8 +18,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcolorchooserprivate.h"
|
||||
#include "gtkcolorchooserwidget.h"
|
||||
#include "deprecated/gtkcolorchooserprivate.h"
|
||||
#include "deprecated/gtkcolorchooserwidget.h"
|
||||
#include "gtkcoloreditorprivate.h"
|
||||
#include "gtkcolorswatchprivate.h"
|
||||
#include "gtkgrid.h"
|
||||
@ -34,6 +34,8 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/**
|
||||
* GtkColorChooserWidget:
|
||||
*
|
||||
@ -61,6 +63,8 @@
|
||||
* # CSS names
|
||||
*
|
||||
* `GtkColorChooserWidget` has a single CSS node with name colorchooser.
|
||||
*
|
||||
* Deprecated: 4.10: Direct use of `GtkColorChooserWidget` is deprecated.
|
||||
*/
|
||||
|
||||
typedef struct _GtkColorChooserWidgetClass GtkColorChooserWidgetClass;
|
||||
|
497
gtk/gtkcolordialog.c
Normal file
497
gtk/gtkcolordialog.c
Normal file
@ -0,0 +1,497 @@
|
||||
/*
|
||||
* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcolordialog.h"
|
||||
|
||||
#include "deprecated/gtkcolorchooserdialog.h"
|
||||
#include "deprecated/gtkcolorchooser.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkdialogerror.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
/**
|
||||
* GtkColorDialog:
|
||||
*
|
||||
* A `GtkColorDialog` object collects the arguments that
|
||||
* are needed to present a color chooser dialog to the
|
||||
* user, such as a title for the dialog and whether it
|
||||
* should be modal.
|
||||
*
|
||||
* The dialog is shown with the [method@Gtk.ColorDialog.choose_rgba]
|
||||
* function. This API follows the GIO async pattern, and the
|
||||
* result can be obtained by calling
|
||||
* [method@Gtk.ColorDialog.choose_rgba_finish].
|
||||
*
|
||||
* See [class@Gtk.ColorDialogButton] for a convenient control
|
||||
* that uses `GtkColorDialog` and presents the results.
|
||||
*
|
||||
* `GtkColorDialog was added in GTK 4.10.
|
||||
*/
|
||||
/* {{{ GObject implementation */
|
||||
|
||||
struct _GtkColorDialog
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
char *title;
|
||||
|
||||
unsigned int modal : 1;
|
||||
unsigned int with_alpha : 1;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_TITLE = 1,
|
||||
PROP_MODAL,
|
||||
PROP_WITH_ALPHA,
|
||||
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *properties[NUM_PROPERTIES];
|
||||
|
||||
G_DEFINE_TYPE (GtkColorDialog, gtk_color_dialog, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_color_dialog_init (GtkColorDialog *self)
|
||||
{
|
||||
self->modal = TRUE;
|
||||
self->with_alpha = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_dialog_finalize (GObject *object)
|
||||
{
|
||||
GtkColorDialog *self = GTK_COLOR_DIALOG (object);
|
||||
|
||||
g_free (self->title);
|
||||
|
||||
G_OBJECT_CLASS (gtk_color_dialog_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_dialog_get_property (GObject *object,
|
||||
unsigned int property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkColorDialog *self = GTK_COLOR_DIALOG (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_TITLE:
|
||||
g_value_set_string (value, self->title);
|
||||
break;
|
||||
|
||||
case PROP_MODAL:
|
||||
g_value_set_boolean (value, self->modal);
|
||||
break;
|
||||
|
||||
case PROP_WITH_ALPHA:
|
||||
g_value_set_boolean (value, self->with_alpha);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_dialog_set_property (GObject *object,
|
||||
unsigned int prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkColorDialog *self = GTK_COLOR_DIALOG (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TITLE:
|
||||
gtk_color_dialog_set_title (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_MODAL:
|
||||
gtk_color_dialog_set_modal (self, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_WITH_ALPHA:
|
||||
gtk_color_dialog_set_with_alpha (self, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_dialog_class_init (GtkColorDialogClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->finalize = gtk_color_dialog_finalize;
|
||||
object_class->get_property = gtk_color_dialog_get_property;
|
||||
object_class->set_property = gtk_color_dialog_set_property;
|
||||
|
||||
/**
|
||||
* GtkColorDialog:title: (attributes org.gtk.Property.get=gtk_color_dialog_get_title org.gtk.Property.set=gtk_color_dialog_set_title)
|
||||
*
|
||||
* A title that may be shown on the color chooser
|
||||
* dialog that is presented by [method@Gtk.ColorDialog.choose_rgba].
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_TITLE] =
|
||||
g_param_spec_string ("title", NULL, NULL,
|
||||
NULL,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkColorDialog:modal: (attributes org.gtk.Property.get=gtk_color_dialog_get_modal org.gtk.Property.set=gtk_color_dialog_set_modal)
|
||||
*
|
||||
* Whether the color chooser dialog is modal.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_MODAL] =
|
||||
g_param_spec_boolean ("modal", NULL, NULL,
|
||||
TRUE,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkColorDialog:with-alpha: (attributes org.gtk.Property.get=gtk_color_dialog_get_with_alpha org.gtk.Property.set=gtk_color_dialog_set_with_alpha)
|
||||
*
|
||||
* Whether colors may have alpha (translucency).
|
||||
*
|
||||
* When with-alpha is %FALSE, the color that is selected
|
||||
* will be forced to have alpha == 1.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_WITH_ALPHA] =
|
||||
g_param_spec_boolean ("with-alpha", NULL, NULL,
|
||||
TRUE,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ API: Constructor */
|
||||
|
||||
/**
|
||||
* gtk_color_dialog_new:
|
||||
*
|
||||
* Creates a new `GtkColorDialog` object.
|
||||
*
|
||||
* Returns: the new `GtkColorDialog`
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
GtkColorDialog *
|
||||
gtk_color_dialog_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_COLOR_DIALOG, NULL);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ API: Getters and setters */
|
||||
|
||||
/**
|
||||
* gtk_color_dialog_get_title:
|
||||
* @self: a `GtkColorDialog`
|
||||
*
|
||||
* Returns the title that will be shown on the
|
||||
* color chooser dialog.
|
||||
*
|
||||
* Returns: the title
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
const char *
|
||||
gtk_color_dialog_get_title (GtkColorDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_COLOR_DIALOG (self), NULL);
|
||||
|
||||
return self->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_color_dialog_set_title:
|
||||
* @self: a `GtkColorDialog`
|
||||
* @title: the new title
|
||||
*
|
||||
* Sets the title that will be shown on the
|
||||
* color chooser dialog.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_color_dialog_set_title (GtkColorDialog *self,
|
||||
const char *title)
|
||||
{
|
||||
char *new_title;
|
||||
|
||||
g_return_if_fail (GTK_IS_COLOR_DIALOG (self));
|
||||
g_return_if_fail (title != NULL);
|
||||
|
||||
if (g_strcmp0 (self->title, title) == 0)
|
||||
return;
|
||||
|
||||
new_title = g_strdup (title);
|
||||
g_free (self->title);
|
||||
self->title = new_title;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_color_dialog_get_modal:
|
||||
* @self: a `GtkColorDialog`
|
||||
*
|
||||
* Returns whether the color chooser dialog
|
||||
* blocks interaction with the parent window
|
||||
* while it is presented.
|
||||
*
|
||||
* Returns: `TRUE` if the color chooser dialog is modal
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
gboolean
|
||||
gtk_color_dialog_get_modal (GtkColorDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_COLOR_DIALOG (self), TRUE);
|
||||
|
||||
return self->modal;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_color_dialog_set_modal:
|
||||
* @self: a `GtkColorDialog`
|
||||
* @modal: the new value
|
||||
*
|
||||
* Sets whether the color chooser dialog
|
||||
* blocks interaction with the parent window
|
||||
* while it is presented.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_color_dialog_set_modal (GtkColorDialog *self,
|
||||
gboolean modal)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_COLOR_DIALOG (self));
|
||||
|
||||
if (self->modal == modal)
|
||||
return;
|
||||
|
||||
self->modal = modal;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODAL]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_color_dialog_get_with_alpha:
|
||||
* @self: a `GtkColorDialog`
|
||||
*
|
||||
* Returns whether colors may have alpha.
|
||||
*
|
||||
* Returns: `TRUE` if colors may have alpha
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
gboolean
|
||||
gtk_color_dialog_get_with_alpha (GtkColorDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_COLOR_DIALOG (self), TRUE);
|
||||
|
||||
return self->with_alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_color_dialog_set_with_alpha:
|
||||
* @self: a `GtkColorDialog`
|
||||
* @with_alpha: the new value
|
||||
*
|
||||
* Sets whether colors may have alpha.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_color_dialog_set_with_alpha (GtkColorDialog *self,
|
||||
gboolean with_alpha)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_COLOR_DIALOG (self));
|
||||
|
||||
if (self->with_alpha == with_alpha)
|
||||
return;
|
||||
|
||||
self->with_alpha = with_alpha;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_WITH_ALPHA]);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Async implementation */
|
||||
|
||||
static void response_cb (GTask *task,
|
||||
int response);
|
||||
|
||||
static void
|
||||
cancelled_cb (GCancellable *cancellable,
|
||||
GTask *task)
|
||||
{
|
||||
response_cb (task, GTK_RESPONSE_CLOSE);
|
||||
}
|
||||
|
||||
static void
|
||||
response_cb (GTask *task,
|
||||
int response)
|
||||
{
|
||||
GCancellable *cancellable;
|
||||
|
||||
cancellable = g_task_get_cancellable (task);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_handlers_disconnect_by_func (cancellable, cancelled_cb, task);
|
||||
|
||||
if (response == GTK_RESPONSE_OK)
|
||||
{
|
||||
GtkColorChooserDialog *window;
|
||||
GdkRGBA color;
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
window = GTK_COLOR_CHOOSER_DIALOG (g_task_get_task_data (task));
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (window), &color);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
g_task_return_pointer (task, gdk_rgba_copy (&color), (GDestroyNotify) gdk_rgba_free);
|
||||
}
|
||||
else if (response == GTK_RESPONSE_CLOSE)
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_ABORTED, "Aborted by application");
|
||||
else if (response == GTK_RESPONSE_CANCEL)
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED, "Cancelled by user");
|
||||
else
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_FAILED, "Unknown failure (%d)", response);
|
||||
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_color_chooser (GtkColorDialog *self,
|
||||
GtkWindow *parent,
|
||||
const GdkRGBA *initial_color)
|
||||
{
|
||||
GtkWidget *window;
|
||||
char *title;
|
||||
|
||||
if (self->title)
|
||||
title = self->title;
|
||||
else
|
||||
title = _("Pick a Color");
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
window = gtk_color_chooser_dialog_new (title, parent);
|
||||
if (initial_color)
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (window), initial_color);
|
||||
gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (window), self->with_alpha);
|
||||
gtk_window_set_modal (GTK_WINDOW (window), self->modal);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Async API */
|
||||
|
||||
/**
|
||||
* gtk_color_dialog_choose_rgba:
|
||||
* @self: a `GtkColorDialog`
|
||||
* @parent: (nullable): the parent `GtkWindow`
|
||||
* @initial_color: (nullable): the color to select initially
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (scope async): a callback to call when the operation is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
*
|
||||
* This function initiates a color choice operation by
|
||||
* presenting a color chooser dialog to the user.
|
||||
*
|
||||
* The @callback will be called when the dialog is dismissed.
|
||||
* It should call [method@Gtk.ColorDialog.choose_rgba_finish]
|
||||
* to obtain the result.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_color_dialog_choose_rgba (GtkColorDialog *self,
|
||||
GtkWindow *parent,
|
||||
const GdkRGBA *initial_color,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GTask *task;
|
||||
|
||||
g_return_if_fail (GTK_IS_COLOR_DIALOG (self));
|
||||
|
||||
window = create_color_chooser (self, parent, initial_color);
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, gtk_color_dialog_choose_rgba);
|
||||
g_task_set_task_data (task, window, (GDestroyNotify) gtk_window_destroy);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
|
||||
g_signal_connect_swapped (window, "response", G_CALLBACK (response_cb), task);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_color_dialog_choose_rgba_finish:
|
||||
* @self: a `GtkColorDialog`
|
||||
* @result: a `GAsyncResult`
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Finishes the [method@Gtk.ColorDialog.choose_rgba] call and
|
||||
* returns the resulting color.
|
||||
*
|
||||
* Returns: (nullable) (transfer full): the selected color, or
|
||||
* `NULL` and @error is set
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
GdkRGBA *
|
||||
gtk_color_dialog_choose_rgba_finish (GtkColorDialog *self,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_COLOR_DIALOG (self), NULL);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_color_dialog_choose_rgba, NULL);
|
||||
|
||||
return g_task_propagate_pointer (G_TASK (result), error);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* vim:set foldmethod=marker expandtab: */
|
72
gtk/gtkcolordialog.h
Normal file
72
gtk/gtkcolordialog.h
Normal file
@ -0,0 +1,72 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
*
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtkwindow.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_COLOR_DIALOG (gtk_color_dialog_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
G_DECLARE_FINAL_TYPE (GtkColorDialog, gtk_color_dialog, GTK, COLOR_DIALOG, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GtkColorDialog *gtk_color_dialog_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
const char * gtk_color_dialog_get_title (GtkColorDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_color_dialog_set_title (GtkColorDialog *self,
|
||||
const char *title);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
gboolean gtk_color_dialog_get_modal (GtkColorDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_color_dialog_set_modal (GtkColorDialog *self,
|
||||
gboolean modal);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
gboolean gtk_color_dialog_get_with_alpha (GtkColorDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_color_dialog_set_with_alpha (GtkColorDialog *self,
|
||||
gboolean with_alpha);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_color_dialog_choose_rgba (GtkColorDialog *self,
|
||||
GtkWindow *parent,
|
||||
const GdkRGBA *initial_color,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GdkRGBA * gtk_color_dialog_choose_rgba_finish (GtkColorDialog *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
517
gtk/gtkcolordialogbutton.c
Normal file
517
gtk/gtkcolordialogbutton.c
Normal file
@ -0,0 +1,517 @@
|
||||
/*
|
||||
* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcolordialogbutton.h"
|
||||
|
||||
#include "gtkbinlayout.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkcolorswatchprivate.h"
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtkdroptarget.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gdk/gdkrgbaprivate.h"
|
||||
|
||||
|
||||
static gboolean drop (GtkDropTarget *dest,
|
||||
const GValue *value,
|
||||
double x,
|
||||
double y,
|
||||
GtkColorDialogButton *self);
|
||||
static GdkContentProvider *
|
||||
drag_prepare (GtkDragSource *source,
|
||||
double x,
|
||||
double y,
|
||||
GtkColorDialogButton *self);
|
||||
static void button_clicked (GtkColorDialogButton *self);
|
||||
static void update_button_sensitivity
|
||||
(GtkColorDialogButton *self);
|
||||
|
||||
/**
|
||||
* GtkColorDialogButton:
|
||||
*
|
||||
* The `GtkColorDialogButton` is a wrapped around a [class@Gtk.ColorDialog]
|
||||
* and allows to open a color chooser dialog to change the color.
|
||||
*
|
||||
* ![An example GtkColorDialogButton](color-button.png)
|
||||
*
|
||||
* It is suitable widget for selecting a color in a preference dialog.
|
||||
*
|
||||
* # CSS nodes
|
||||
*
|
||||
* ```
|
||||
* colorbutton
|
||||
* ╰── button.color
|
||||
* ╰── [content]
|
||||
* ```
|
||||
*
|
||||
* `GtkColorDialogButton` has a single CSS node with name colorbutton which
|
||||
* contains a button node. To differentiate it from a plain `GtkButton`,
|
||||
* it gets the .color style class.
|
||||
*/
|
||||
|
||||
/* {{{ GObject implementation */
|
||||
|
||||
struct _GtkColorDialogButton
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GtkWidget *button;
|
||||
GtkWidget *swatch;
|
||||
|
||||
GtkColorDialog *dialog;
|
||||
GCancellable *cancellable;
|
||||
GdkRGBA color;
|
||||
};
|
||||
|
||||
/* Properties */
|
||||
enum
|
||||
{
|
||||
PROP_DIALOG = 1,
|
||||
PROP_RGBA,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *properties[NUM_PROPERTIES];
|
||||
|
||||
G_DEFINE_TYPE (GtkColorDialogButton, gtk_color_dialog_button, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
gtk_color_dialog_button_init (GtkColorDialogButton *self)
|
||||
{
|
||||
PangoLayout *layout;
|
||||
PangoRectangle rect;
|
||||
GtkDragSource *source;
|
||||
GtkDropTarget *dest;
|
||||
|
||||
self->color = GDK_RGBA ("00000000");
|
||||
|
||||
self->button = gtk_button_new ();
|
||||
g_signal_connect_swapped (self->button, "clicked", G_CALLBACK (button_clicked), self);
|
||||
gtk_widget_set_parent (self->button, GTK_WIDGET (self));
|
||||
|
||||
self->swatch = g_object_new (GTK_TYPE_COLOR_SWATCH,
|
||||
"accessible-role", GTK_ACCESSIBLE_ROLE_IMG,
|
||||
"selectable", FALSE,
|
||||
"has-menu", FALSE,
|
||||
"can-drag", FALSE,
|
||||
NULL);
|
||||
gtk_widget_set_can_focus (self->swatch, FALSE);
|
||||
gtk_widget_remove_css_class (self->swatch, "activatable");
|
||||
|
||||
layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), "Black");
|
||||
pango_layout_get_pixel_extents (layout, NULL, &rect);
|
||||
g_object_unref (layout);
|
||||
|
||||
gtk_widget_set_size_request (self->swatch, rect.width, rect.height);
|
||||
|
||||
gtk_button_set_child (GTK_BUTTON (self->button), self->swatch);
|
||||
|
||||
dest = gtk_drop_target_new (GDK_TYPE_RGBA, GDK_ACTION_COPY);
|
||||
g_signal_connect (dest, "drop", G_CALLBACK (drop), self);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self->button), GTK_EVENT_CONTROLLER (dest));
|
||||
|
||||
source = gtk_drag_source_new ();
|
||||
g_signal_connect (source, "prepare", G_CALLBACK (drag_prepare), self);
|
||||
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (source),
|
||||
GTK_PHASE_CAPTURE);
|
||||
gtk_widget_add_controller (self->button, GTK_EVENT_CONTROLLER (source));
|
||||
gtk_widget_add_css_class (self->button, "color");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_dialog_button_unroot (GtkWidget *widget)
|
||||
{
|
||||
GtkColorDialogButton *self = GTK_COLOR_DIALOG_BUTTON (widget);
|
||||
|
||||
if (self->cancellable)
|
||||
{
|
||||
g_cancellable_cancel (self->cancellable);
|
||||
g_clear_object (&self->cancellable);
|
||||
update_button_sensitivity (self);
|
||||
}
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_color_dialog_button_parent_class)->unroot (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_dialog_button_set_property (GObject *object,
|
||||
unsigned int param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkColorDialogButton *self = GTK_COLOR_DIALOG_BUTTON (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_DIALOG:
|
||||
gtk_color_dialog_button_set_dialog (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_RGBA:
|
||||
gtk_color_dialog_button_set_rgba (self, g_value_get_boxed (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_dialog_button_get_property (GObject *object,
|
||||
unsigned int param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkColorDialogButton *self = GTK_COLOR_DIALOG_BUTTON (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_DIALOG:
|
||||
g_value_set_object (value, self->dialog);
|
||||
break;
|
||||
|
||||
case PROP_RGBA:
|
||||
g_value_set_boxed (value, &self->color);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_dialog_button_dispose (GObject *object)
|
||||
{
|
||||
GtkColorDialogButton *self = GTK_COLOR_DIALOG_BUTTON (object);
|
||||
|
||||
g_clear_pointer (&self->button, gtk_widget_unparent);
|
||||
|
||||
G_OBJECT_CLASS (gtk_color_dialog_button_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_dialog_button_finalize (GObject *object)
|
||||
{
|
||||
GtkColorDialogButton *self = GTK_COLOR_DIALOG_BUTTON (object);
|
||||
|
||||
g_assert (self->cancellable == NULL);
|
||||
g_clear_object (&self->dialog);
|
||||
|
||||
G_OBJECT_CLASS (gtk_color_dialog_button_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_dialog_button_class_init (GtkColorDialogButtonClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
|
||||
object_class->get_property = gtk_color_dialog_button_get_property;
|
||||
object_class->set_property = gtk_color_dialog_button_set_property;
|
||||
object_class->dispose = gtk_color_dialog_button_dispose;
|
||||
object_class->finalize = gtk_color_dialog_button_finalize;
|
||||
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_child;
|
||||
widget_class->focus = gtk_widget_focus_child;
|
||||
widget_class->unroot = gtk_color_dialog_button_unroot;
|
||||
|
||||
/**
|
||||
* GtkColorDialogButton:dialog: (attributes org.gtk.Property.get=gtk_color_dialog_button_get_dialog org.gtk.Property.set=gtk_color_dialog_button_set_dialog)
|
||||
*
|
||||
* The `GtkColorDialog` that contains parameters for
|
||||
* the color chooser dialog.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_DIALOG] =
|
||||
g_param_spec_object ("dialog", NULL, NULL,
|
||||
GTK_TYPE_COLOR_DIALOG,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkColorDialogButton:rgba: (attributes org.gtk.Property.get=gtk_color_dialog_button_get_rgba org.gtk.Property.set=gtk_color_dialog_button_set_rgba)
|
||||
*
|
||||
* The selected color.
|
||||
*
|
||||
* This property can be set to give the button its initial
|
||||
* color, and it will be updated to reflect the users choice
|
||||
* in the color chooser dialog.
|
||||
*
|
||||
* Listen to `notify::rgba` to get informed about changes
|
||||
* to the buttons color.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_RGBA] =
|
||||
g_param_spec_boxed ("rgba", NULL, NULL,
|
||||
GDK_TYPE_RGBA,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
|
||||
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
gtk_widget_class_set_css_name (widget_class, "colorbutton");
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Private API, callbacks */
|
||||
|
||||
static guint
|
||||
scale_round (double value,
|
||||
double scale)
|
||||
{
|
||||
value = floor (value * scale + 0.5);
|
||||
value = CLAMP (value, 0, scale);
|
||||
return (guint)value;
|
||||
}
|
||||
|
||||
static char *
|
||||
accessible_color_name (const GdkRGBA *color)
|
||||
{
|
||||
if (color->alpha < 1.0)
|
||||
return g_strdup_printf (_("Red %d%%, Green %d%%, Blue %d%%, Alpha %d%%"),
|
||||
scale_round (color->red, 100),
|
||||
scale_round (color->green, 100),
|
||||
scale_round (color->blue, 100),
|
||||
scale_round (color->alpha, 100));
|
||||
else
|
||||
return g_strdup_printf (_("Red %d%%, Green %d%%, Blue %d%%"),
|
||||
scale_round (color->red, 100),
|
||||
scale_round (color->green, 100),
|
||||
scale_round (color->blue, 100));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
drop (GtkDropTarget *dest,
|
||||
const GValue *value,
|
||||
double x,
|
||||
double y,
|
||||
GtkColorDialogButton *self)
|
||||
{
|
||||
GdkRGBA *color = g_value_get_boxed (value);
|
||||
|
||||
gtk_color_dialog_button_set_rgba (self, color);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GdkContentProvider *
|
||||
drag_prepare (GtkDragSource *source,
|
||||
double x,
|
||||
double y,
|
||||
GtkColorDialogButton *self)
|
||||
{
|
||||
GdkRGBA color;
|
||||
|
||||
gtk_color_swatch_get_rgba (GTK_COLOR_SWATCH (self->swatch), &color);
|
||||
|
||||
return gdk_content_provider_new_typed (GDK_TYPE_RGBA, &color);
|
||||
}
|
||||
|
||||
static void
|
||||
update_button_sensitivity (GtkColorDialogButton *self)
|
||||
{
|
||||
gtk_widget_set_sensitive (self->button,
|
||||
self->dialog != NULL && self->cancellable == NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
color_chosen (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GtkColorDialogButton *self = data;
|
||||
GdkRGBA *color;
|
||||
|
||||
color = gtk_color_dialog_choose_rgba_finish (self->dialog, result, NULL);
|
||||
if (color)
|
||||
{
|
||||
gtk_color_dialog_button_set_rgba (self, color);
|
||||
gdk_rgba_free (color);
|
||||
}
|
||||
|
||||
g_clear_object (&self->cancellable);
|
||||
update_button_sensitivity (self);
|
||||
}
|
||||
|
||||
static void
|
||||
button_clicked (GtkColorDialogButton *self)
|
||||
{
|
||||
GtkRoot *root = gtk_widget_get_root (GTK_WIDGET (self));
|
||||
GtkWindow *parent = NULL;
|
||||
|
||||
g_assert (self->cancellable == NULL);
|
||||
self->cancellable = g_cancellable_new ();
|
||||
|
||||
update_button_sensitivity (self);
|
||||
|
||||
if (GTK_IS_WINDOW (root))
|
||||
parent = GTK_WINDOW (root);
|
||||
|
||||
gtk_color_dialog_choose_rgba (self->dialog, parent, &self->color,
|
||||
self->cancellable, color_chosen, self);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Constructor */
|
||||
|
||||
/**
|
||||
* gtk_color_dialog_button_new:
|
||||
* @dialog: (nullable) (transfer full): the `GtkColorDialog` to use
|
||||
*
|
||||
* Creates a new `GtkColorDialogButton` with the
|
||||
* given `GtkColorDialog`.
|
||||
*
|
||||
* You can pass `NULL` to this function and set a `GtkColorDialog`
|
||||
* later. The button will be insensitive until that happens.
|
||||
*
|
||||
* Returns: the new `GtkColorDialogButton`
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_color_dialog_button_new (GtkColorDialog *dialog)
|
||||
{
|
||||
GtkWidget *self;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_COLOR_DIALOG (dialog), NULL);
|
||||
|
||||
self = g_object_new (GTK_TYPE_COLOR_DIALOG_BUTTON,
|
||||
"dialog", dialog,
|
||||
NULL);
|
||||
|
||||
g_clear_object (&dialog);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Getters and setters */
|
||||
|
||||
/**
|
||||
* gtk_color_dialog_button_get_dialog:
|
||||
* @self: a `GtkColorDialogButton`
|
||||
*
|
||||
* Returns the `GtkColorDialog` of @self.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the `GtkColorDialog`
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
GtkColorDialog *
|
||||
gtk_color_dialog_button_get_dialog (GtkColorDialogButton *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_COLOR_DIALOG_BUTTON (self), NULL);
|
||||
|
||||
return self->dialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_color_dialog_button_set_dialog:
|
||||
* @self: a `GtkColorDialogButton`
|
||||
* @dialog: the new `GtkColorDialog`
|
||||
*
|
||||
* Sets a `GtkColorDialog` object to use for
|
||||
* creating the color chooser dialog that is
|
||||
* presented when the user clicks the button.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_color_dialog_button_set_dialog (GtkColorDialogButton *self,
|
||||
GtkColorDialog *dialog)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_COLOR_DIALOG_BUTTON (self));
|
||||
g_return_if_fail (GTK_IS_COLOR_DIALOG (dialog));
|
||||
|
||||
if (!g_set_object (&self->dialog, dialog))
|
||||
return;
|
||||
|
||||
update_button_sensitivity (self);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DIALOG]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_color_dialog_button_get_rgba:
|
||||
* @self: a `GtkColorDialogButton`
|
||||
*
|
||||
* Returns the color of the button.
|
||||
*
|
||||
* This function is what should be used to obtain
|
||||
* the color that was choosen by the user. To get
|
||||
* informed about changes, listen to "notify::color".
|
||||
*
|
||||
* Returns: the color
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
const GdkRGBA *
|
||||
gtk_color_dialog_button_get_rgba (GtkColorDialogButton *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_COLOR_DIALOG_BUTTON (self), NULL);
|
||||
|
||||
return &self->color;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_color_dialog_button_set_rgba:
|
||||
* @self: a `GtkColorDialogButton`
|
||||
* @color: the new color
|
||||
*
|
||||
* Sets the color of the button.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_color_dialog_button_set_rgba (GtkColorDialogButton *self,
|
||||
const GdkRGBA *color)
|
||||
{
|
||||
char *text;
|
||||
|
||||
g_return_if_fail (GTK_IS_COLOR_DIALOG_BUTTON (self));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
if (gdk_rgba_equal (&self->color, color))
|
||||
return;
|
||||
|
||||
self->color = *color;
|
||||
gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (self->swatch), color);
|
||||
|
||||
text = accessible_color_name (color);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (self->swatch),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, text,
|
||||
-1);
|
||||
g_free (text);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_RGBA]);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* vim:set foldmethod=marker expandtab: */
|
53
gtk/gtkcolordialogbutton.h
Normal file
53
gtk/gtkcolordialogbutton.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtkbutton.h>
|
||||
#include <gtk/gtkcolordialog.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_COLOR_DIALOG_BUTTON (gtk_color_dialog_button_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
G_DECLARE_FINAL_TYPE (GtkColorDialogButton, gtk_color_dialog_button, GTK, COLOR_DIALOG_BUTTON, GtkWidget)
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GtkWidget * gtk_color_dialog_button_new (GtkColorDialog *dialog);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GtkColorDialog *gtk_color_dialog_button_get_dialog (GtkColorDialogButton *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_color_dialog_button_set_dialog (GtkColorDialogButton *self,
|
||||
GtkColorDialog *dialog);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
const GdkRGBA * gtk_color_dialog_button_get_rgba (GtkColorDialogButton *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_color_dialog_button_set_rgba (GtkColorDialogButton *self,
|
||||
const GdkRGBA *color);
|
||||
|
||||
G_END_DECLS
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "gtkcoloreditorprivate.h"
|
||||
|
||||
#include "gtkcolorchooserprivate.h"
|
||||
#include "deprecated/gtkcolorchooserprivate.h"
|
||||
#include "gtkcolorplaneprivate.h"
|
||||
#include "gtkcolorscaleprivate.h"
|
||||
#include "gtkcolorswatchprivate.h"
|
||||
@ -38,6 +38,8 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
typedef struct _GtkColorEditorClass GtkColorEditorClass;
|
||||
|
||||
struct _GtkColorEditor
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "gtkcolorscaleprivate.h"
|
||||
|
||||
#include "gtkcolorchooserprivate.h"
|
||||
#include "deprecated/gtkcolorchooserprivate.h"
|
||||
#include "gtkgesturelongpress.h"
|
||||
#include "gtkgestureclick.h"
|
||||
#include "gtkcolorutils.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "gtkcolorswatchprivate.h"
|
||||
|
||||
#include "gtkbox.h"
|
||||
#include "gtkcolorchooserprivate.h"
|
||||
#include "deprecated/gtkcolorchooserprivate.h"
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtkdroptarget.h"
|
||||
#include "gtkgesturelongpress.h"
|
||||
|
27
gtk/gtkdialogerror.c
Normal file
27
gtk/gtkdialogerror.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
*
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtk/gtkdialogerror.h"
|
||||
|
||||
GQuark
|
||||
gtk_dialog_error_quark (void)
|
||||
{
|
||||
return g_quark_from_static_string ("gtk-dialog-error-quark");
|
||||
}
|
62
gtk/gtkdialogerror.h
Normal file
62
gtk/gtkdialogerror.h
Normal file
@ -0,0 +1,62 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
*
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* GTK_DIALOG_ERROR:
|
||||
*
|
||||
* The error domain for errors returned by async dialog functions.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
#define GTK_DIALOG_ERROR (gtk_dialog_error_quark ())
|
||||
|
||||
/**
|
||||
* GtkDialogError:
|
||||
* @GTK_DIALOG_ERROR_FAILED: Generic error condition for when
|
||||
* an operation fails and no more specific code is applicable
|
||||
* @GTK_DIALOG_ERROR_ABORTED: The async function call was aborted
|
||||
* programmatically (via its `GCancellable`)
|
||||
* @GTK_DIALOG_ERROR_CANCELLED: The async operation was cancelled
|
||||
* by the user (via a Close button)
|
||||
*
|
||||
* Error codes in the `GTK_DIALOG_ERROR` domain that can be returned
|
||||
* by async dialog functions.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GTK_DIALOG_ERROR_FAILED,
|
||||
GTK_DIALOG_ERROR_ABORTED,
|
||||
GTK_DIALOG_ERROR_CANCELLED
|
||||
} GtkDialogError;
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GQuark gtk_dialog_error_quark (void);
|
||||
|
||||
G_END_DECLS
|
@ -30,7 +30,6 @@
|
||||
#include "gtklistitem.h"
|
||||
#include "gtkselectionmodel.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtkfilechooserwidget.h"
|
||||
#include "gtkfilechooserwidgetprivate.h"
|
||||
|
||||
struct _GtkFileChooserCell
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkfilechooserdialog.h"
|
||||
#include "deprecated/gtkfilechooserdialog.h"
|
||||
|
||||
#include "gtkfilechooserprivate.h"
|
||||
#include "gtkfilechooserwidget.h"
|
||||
#include "deprecated/gtkfilechooserwidget.h"
|
||||
#include "gtkfilechooserwidgetprivate.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtksizerequest.h"
|
||||
@ -39,6 +39,8 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/**
|
||||
* GtkFileChooserDialog:
|
||||
*
|
||||
@ -209,6 +211,8 @@
|
||||
*
|
||||
* To summarize, make sure you use a predefined response code
|
||||
* when you use `GtkFileChooserDialog` to ensure proper operation.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
|
||||
typedef struct _GtkFileChooserDialogPrivate GtkFileChooserDialogPrivate;
|
||||
@ -716,6 +720,8 @@ gtk_file_chooser_dialog_new_valist (const char *title,
|
||||
* This function is analogous to [ctor@Gtk.Dialog.new_with_buttons].
|
||||
*
|
||||
* Returns: a new `GtkFileChooserDialog`
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_file_chooser_dialog_new (const char *title,
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef __GTK_FILE_CHOOSER_ENTRY_H__
|
||||
#define __GTK_FILE_CHOOSER_ENTRY_H__
|
||||
|
||||
#include "gtkfilechooser.h"
|
||||
#include "deprecated/gtkfilechooser.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -23,9 +23,8 @@
|
||||
#include "gtknativedialogprivate.h"
|
||||
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkfilechooserdialog.h"
|
||||
#include "gtkfilechooserprivate.h"
|
||||
#include "gtkfilechooserwidget.h"
|
||||
#include "deprecated/gtkfilechooserdialog.h"
|
||||
#include "gtkfilechooserwidgetprivate.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtksizerequest.h"
|
||||
@ -37,6 +36,8 @@
|
||||
#include "gtklabel.h"
|
||||
#include "gtkfilefilterprivate.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/**
|
||||
* GtkFileChooserNative:
|
||||
*
|
||||
@ -186,6 +187,8 @@
|
||||
* are not supported:
|
||||
*
|
||||
* * Shortcut folders.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
|
||||
enum {
|
||||
@ -218,6 +221,8 @@ G_DEFINE_TYPE_WITH_CODE (GtkFileChooserNative, gtk_file_chooser_native, GTK_TYPE
|
||||
* Retrieves the custom label text for the accept button.
|
||||
*
|
||||
* Returns: (nullable): The custom label
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
const char *
|
||||
gtk_file_chooser_native_get_accept_label (GtkFileChooserNative *self)
|
||||
@ -240,6 +245,8 @@ gtk_file_chooser_native_get_accept_label (GtkFileChooserNative *self)
|
||||
* a keyboard accelerator called a mnemonic.
|
||||
*
|
||||
* Pressing Alt and that key should activate the button.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_file_chooser_native_set_accept_label (GtkFileChooserNative *self,
|
||||
@ -260,6 +267,8 @@ gtk_file_chooser_native_set_accept_label (GtkFileChooserNative *self,
|
||||
* Retrieves the custom label text for the cancel button.
|
||||
*
|
||||
* Returns: (nullable): The custom label
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
const char *
|
||||
gtk_file_chooser_native_get_cancel_label (GtkFileChooserNative *self)
|
||||
@ -282,6 +291,8 @@ gtk_file_chooser_native_get_cancel_label (GtkFileChooserNative *self)
|
||||
* a keyboard accelerator called a mnemonic.
|
||||
*
|
||||
* Pressing Alt and that key should activate the button.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_file_chooser_native_set_cancel_label (GtkFileChooserNative *self,
|
||||
@ -527,6 +538,8 @@ gtk_file_chooser_native_init (GtkFileChooserNative *self)
|
||||
* Creates a new `GtkFileChooserNative`.
|
||||
*
|
||||
* Returns: a new `GtkFileChooserNative`
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
|
||||
*/
|
||||
GtkFileChooserNative *
|
||||
gtk_file_chooser_native_new (const char *title,
|
||||
|
@ -23,11 +23,8 @@
|
||||
#include "gtknativedialogprivate.h"
|
||||
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkfilechooserdialog.h"
|
||||
#include "gtkdialog.h"
|
||||
#include "gtkfilechooserprivate.h"
|
||||
#include "gtkfilechooserwidget.h"
|
||||
#include "gtkfilechooserwidgetprivate.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtksettings.h"
|
||||
@ -39,6 +36,8 @@
|
||||
#include "gtkwindowprivate.h"
|
||||
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
typedef struct {
|
||||
GtkFileChooserNative *self;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef __GTK_FILE_CHOOSER_NATIVE_PRIVATE_H__
|
||||
#define __GTK_FILE_CHOOSER_NATIVE_PRIVATE_H__
|
||||
|
||||
#include <gtk/gtkfilechoosernative.h>
|
||||
#include <gtk/deprecated/gtkfilechoosernative.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -24,9 +24,8 @@
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkfilechooserdialog.h"
|
||||
#include "deprecated/gtkfilechooserdialog.h"
|
||||
#include "gtkfilechooserprivate.h"
|
||||
#include "gtkfilechooserwidget.h"
|
||||
#include "gtkfilechooserwidgetprivate.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtksizerequest.h"
|
||||
@ -42,6 +41,8 @@
|
||||
#include "macos/gdkmacosdisplay-private.h"
|
||||
#include "macos/gdkmacossurface-private.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
typedef struct {
|
||||
GtkFileChooserNative *self;
|
||||
|
||||
|
@ -29,9 +29,8 @@
|
||||
#include "gtknativedialogprivate.h"
|
||||
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkfilechooserdialog.h"
|
||||
#include "deprecated/gtkfilechooserdialog.h"
|
||||
#include "gtkfilechooserprivate.h"
|
||||
#include "gtkfilechooserwidget.h"
|
||||
#include "gtkfilechooserwidgetprivate.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtksizerequest.h"
|
||||
@ -48,6 +47,8 @@
|
||||
#include <shlobj.h>
|
||||
#include <windows.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
typedef struct {
|
||||
GtkFileChooserNative *self;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef __GTK_FILE_CHOOSER_PRIVATE_H__
|
||||
#define __GTK_FILE_CHOOSER_PRIVATE_H__
|
||||
|
||||
#include "gtkfilechooser.h"
|
||||
#include "deprecated/gtkfilechooser.h"
|
||||
#include "gtkfilesystemmodel.h"
|
||||
#include "deprecated/gtkliststore.h"
|
||||
#include "gtkrecentmanager.h"
|
||||
|
@ -19,12 +19,14 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtkfilechooser.h"
|
||||
#include "deprecated/gtkfilechooser.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkprivate.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static gboolean delegate_set_current_folder (GtkFileChooser *chooser,
|
||||
GFile *file,
|
||||
GError **error);
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkfilechooserwidget.h"
|
||||
#include "deprecated/gtkfilechooserwidget.h"
|
||||
#include "gtkfilechooserwidgetprivate.h"
|
||||
|
||||
#include "gtkbitset.h"
|
||||
@ -32,10 +32,10 @@
|
||||
#include "gtkdroptarget.h"
|
||||
#include "gtkentry.h"
|
||||
#include "gtkfilechooserprivate.h"
|
||||
#include "gtkfilechooserdialog.h"
|
||||
#include "deprecated/gtkfilechooserdialog.h"
|
||||
#include "deprecated/gtkfilechooser.h"
|
||||
#include "gtkfilechooserentry.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtkfilechooser.h"
|
||||
#include "gtkfilesystemmodel.h"
|
||||
#include "gtkfilethumbnail.h"
|
||||
#include "gtkgestureclick.h"
|
||||
@ -44,7 +44,7 @@
|
||||
#include "gtklabel.h"
|
||||
#include "gtklistitem.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkmessagedialog.h"
|
||||
#include "gtkalertdialog.h"
|
||||
#include "gtkmountoperation.h"
|
||||
#include "gtkmultiselection.h"
|
||||
#include "gtkpaned.h"
|
||||
@ -107,6 +107,8 @@
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/**
|
||||
* GtkFileChooserWidget:
|
||||
*
|
||||
@ -119,6 +121,8 @@
|
||||
* # CSS nodes
|
||||
*
|
||||
* `GtkFileChooserWidget` has a single CSS node with name filechooser.
|
||||
*
|
||||
* Deprecated: 4.10: Direct use of `GtkFileChooserWidget` is deprecated
|
||||
*/
|
||||
|
||||
/* 150 mseconds of delay */
|
||||
@ -665,26 +669,12 @@ error_message (GtkFileChooserWidget *impl,
|
||||
const char *detail)
|
||||
{
|
||||
GtkWindow *parent = get_toplevel (GTK_WIDGET (impl));
|
||||
GtkWidget *dialog;
|
||||
GtkAlertDialog *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (parent,
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_OK,
|
||||
"%s",
|
||||
msg);
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"%s", detail);
|
||||
|
||||
if (parent && gtk_window_has_group (parent))
|
||||
gtk_window_group_add_window (gtk_window_get_group (parent),
|
||||
GTK_WINDOW (dialog));
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy),
|
||||
NULL);
|
||||
dialog = gtk_alert_dialog_new ("%s", msg);
|
||||
gtk_alert_dialog_set_detail (dialog, detail);
|
||||
gtk_alert_dialog_show (dialog, parent);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
/* Shows a simple error dialog relative to a path. Frees the GError as well. */
|
||||
@ -1125,15 +1115,16 @@ typedef struct {
|
||||
} ConfirmDeleteData;
|
||||
|
||||
static void
|
||||
on_confirm_delete_response (GtkWidget *dialog,
|
||||
int response,
|
||||
gpointer user_data)
|
||||
on_confirm_delete_response (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
{
|
||||
ConfirmDeleteData *data = user_data;
|
||||
int button;
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
button = gtk_alert_dialog_choose_finish (GTK_ALERT_DIALOG (source), result);
|
||||
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
if (button == 1)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
@ -1150,7 +1141,7 @@ confirm_delete (GtkFileChooserWidget *impl,
|
||||
GFileInfo *info)
|
||||
{
|
||||
GtkWindow *toplevel;
|
||||
GtkWidget *dialog;
|
||||
GtkAlertDialog *dialog;
|
||||
const char *name;
|
||||
ConfirmDeleteData *data;
|
||||
|
||||
@ -1158,30 +1149,16 @@ confirm_delete (GtkFileChooserWidget *impl,
|
||||
|
||||
toplevel = get_toplevel (GTK_WIDGET (impl));
|
||||
|
||||
dialog = gtk_message_dialog_new (toplevel,
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_NONE,
|
||||
_("Are you sure you want to permanently delete “%s”?"),
|
||||
name);
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
_("If you delete an item, it will be permanently lost."));
|
||||
gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Cancel"), GTK_RESPONSE_CANCEL);
|
||||
gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Delete"), GTK_RESPONSE_ACCEPT);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
||||
|
||||
if (gtk_window_has_group (toplevel))
|
||||
gtk_window_group_add_window (gtk_window_get_group (toplevel), GTK_WINDOW (dialog));
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
data = g_new (ConfirmDeleteData, 1);
|
||||
data->impl = impl;
|
||||
data->file = file;
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (on_confirm_delete_response),
|
||||
data);
|
||||
dialog = gtk_alert_dialog_new (_("Are you sure you want to permanently delete “%s”?"), name);
|
||||
gtk_alert_dialog_set_detail (dialog, _("If you delete an item, it will be permanently lost."));
|
||||
gtk_alert_dialog_set_buttons (dialog, (const char *[]) { _("_Cancel"), _("_Delete"), NULL });
|
||||
gtk_alert_dialog_set_cancel_button (dialog, 0);
|
||||
gtk_alert_dialog_set_default_button (dialog, 1);
|
||||
gtk_alert_dialog_choose (dialog, toplevel, NULL, on_confirm_delete_response, data);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -4928,18 +4905,6 @@ get_display_name_from_file_list (GtkFileChooserWidget *impl)
|
||||
return g_file_info_get_display_name (info);
|
||||
}
|
||||
|
||||
static void
|
||||
add_custom_button_to_dialog (GtkDialog *dialog,
|
||||
const char *mnemonic_label,
|
||||
int response_id)
|
||||
{
|
||||
GtkWidget *button;
|
||||
|
||||
button = gtk_button_new_with_mnemonic (mnemonic_label);
|
||||
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, response_id);
|
||||
}
|
||||
|
||||
/* Every time we request a response explicitly, we need to save the selection to
|
||||
* the recently-used list, as requesting a response means, “the dialog is confirmed”.
|
||||
*/
|
||||
@ -4951,13 +4916,16 @@ request_response_and_add_to_recent_list (GtkFileChooserWidget *impl)
|
||||
}
|
||||
|
||||
static void
|
||||
on_confirm_overwrite_response (GtkWidget *dialog,
|
||||
int response,
|
||||
gpointer user_data)
|
||||
on_confirm_overwrite_response (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
{
|
||||
GtkFileChooserWidget *impl = user_data;
|
||||
int button;
|
||||
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
button = gtk_alert_dialog_choose_finish (GTK_ALERT_DIALOG (source), result);
|
||||
|
||||
if (button == 1)
|
||||
{
|
||||
/* Dialog is now going to be closed, so prevent any button/key presses to
|
||||
* file list (will be restablished on next map()). Fixes data loss bug #2288 */
|
||||
@ -4965,8 +4933,6 @@ on_confirm_overwrite_response (GtkWidget *dialog,
|
||||
|
||||
request_response_and_add_to_recent_list (impl);
|
||||
}
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
/* Presents an overwrite confirmation dialog */
|
||||
@ -4976,33 +4942,24 @@ confirm_dialog_should_accept_filename (GtkFileChooserWidget *impl,
|
||||
const char *folder_display_name)
|
||||
{
|
||||
GtkWindow *toplevel;
|
||||
GtkWidget *dialog;
|
||||
GtkAlertDialog *dialog;
|
||||
char *detail;
|
||||
|
||||
toplevel = get_toplevel (GTK_WIDGET (impl));
|
||||
|
||||
dialog = gtk_message_dialog_new (toplevel,
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_NONE,
|
||||
_("A file named “%s” already exists. Do you want to replace it?"),
|
||||
file_part);
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
_("The file already exists in “%s”. Replacing it will "
|
||||
"overwrite its contents."),
|
||||
folder_display_name);
|
||||
dialog = gtk_alert_dialog_new (_("A file named “%s” already exists. Do you want to replace it?"),
|
||||
file_part);
|
||||
detail = g_strdup_printf (_("The file already exists in “%s”. Replacing it will "
|
||||
"overwrite its contents."),
|
||||
folder_display_name);
|
||||
gtk_alert_dialog_set_detail (dialog, detail);
|
||||
g_free (detail);
|
||||
|
||||
gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Cancel"), GTK_RESPONSE_CANCEL);
|
||||
add_custom_button_to_dialog (GTK_DIALOG (dialog), _("_Replace"), GTK_RESPONSE_ACCEPT);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
||||
|
||||
if (gtk_window_has_group (toplevel))
|
||||
gtk_window_group_add_window (gtk_window_get_group (toplevel), GTK_WINDOW (dialog));
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (on_confirm_overwrite_response),
|
||||
impl);
|
||||
gtk_alert_dialog_set_buttons (dialog, (const char *[]) { _("_Cancel"), _("_Replace"), NULL });
|
||||
gtk_alert_dialog_set_cancel_button (dialog, 0);
|
||||
gtk_alert_dialog_set_default_button (dialog, 1);
|
||||
gtk_alert_dialog_choose (dialog, toplevel, NULL, on_confirm_overwrite_response, impl);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
struct GetDisplayNameData
|
||||
@ -7305,6 +7262,8 @@ gtk_file_chooser_widget_init (GtkFileChooserWidget *impl)
|
||||
* `GtkFileChooserDialog`.
|
||||
*
|
||||
* Returns: a new `GtkFileChooserWidget`
|
||||
*
|
||||
* Deprecated: 4.10: Direct use of `GtkFileChooserWidget` is deprecated
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_file_chooser_widget_new (GtkFileChooserAction action)
|
||||
|
@ -22,7 +22,7 @@
|
||||
#define __GTK_FILE_CHOOSER_WIDGET_PRIVATE_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include "gtkfilechooserwidget.h"
|
||||
#include "deprecated/gtkfilechooserwidget.h"
|
||||
#include "gtkselectionmodel.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
1118
gtk/gtkfiledialog.c
Normal file
1118
gtk/gtkfiledialog.c
Normal file
File diff suppressed because it is too large
Load Diff
151
gtk/gtkfiledialog.h
Normal file
151
gtk/gtkfiledialog.h
Normal file
@ -0,0 +1,151 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
*
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtkwindow.h>
|
||||
#include <gtk/gtkfilefilter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_FILE_DIALOG (gtk_file_dialog_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
G_DECLARE_FINAL_TYPE (GtkFileDialog, gtk_file_dialog, GTK, FILE_DIALOG, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GtkFileDialog * gtk_file_dialog_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
const char * gtk_file_dialog_get_title (GtkFileDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_set_title (GtkFileDialog *self,
|
||||
const char *title);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
gboolean gtk_file_dialog_get_modal (GtkFileDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_set_modal (GtkFileDialog *self,
|
||||
gboolean modal);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GListModel * gtk_file_dialog_get_filters (GtkFileDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_set_filters (GtkFileDialog *self,
|
||||
GListModel *filters);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GtkFileFilter * gtk_file_dialog_get_current_filter (GtkFileDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_set_current_filter (GtkFileDialog *self,
|
||||
GtkFileFilter *filter);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GListModel * gtk_file_dialog_get_shortcut_folders
|
||||
(GtkFileDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_set_shortcut_folders
|
||||
(GtkFileDialog *self,
|
||||
GListModel *shortcut_folders);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GFile * gtk_file_dialog_get_current_folder (GtkFileDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_set_current_folder (GtkFileDialog *self,
|
||||
GFile *folder);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_open (GtkFileDialog *self,
|
||||
GtkWindow *parent,
|
||||
GFile *current_file,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GFile * gtk_file_dialog_open_finish (GtkFileDialog *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_select_folder (GtkFileDialog *self,
|
||||
GtkWindow *parent,
|
||||
GFile *current_folder,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GFile * gtk_file_dialog_select_folder_finish
|
||||
(GtkFileDialog *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_save (GtkFileDialog *self,
|
||||
GtkWindow *parent,
|
||||
GFile *current_file,
|
||||
const char *current_name,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GFile * gtk_file_dialog_save_finish (GtkFileDialog *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_open_multiple (GtkFileDialog *self,
|
||||
GtkWindow *parent,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GListModel * gtk_file_dialog_open_multiple_finish
|
||||
(GtkFileDialog *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_select_multiple_folders
|
||||
(GtkFileDialog *self,
|
||||
GtkWindow *parent,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GListModel * gtk_file_dialog_select_multiple_folders_finish
|
||||
(GtkFileDialog *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
@ -21,9 +21,9 @@
|
||||
#include <glib/gprintf.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gtkfontchooserdialog.h"
|
||||
#include "gtkfontchooser.h"
|
||||
#include "gtkfontchooserwidget.h"
|
||||
#include "gtkfontchooserdialogprivate.h"
|
||||
#include "deprecated/gtkfontchooser.h"
|
||||
#include "deprecated/gtkfontchooserwidget.h"
|
||||
#include "gtkfontchooserwidgetprivate.h"
|
||||
#include "gtkfontchooserutils.h"
|
||||
#include "gtkbox.h"
|
||||
@ -38,6 +38,8 @@
|
||||
#include "gtkactionable.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
typedef struct _GtkFontChooserDialogClass GtkFontChooserDialogClass;
|
||||
|
||||
struct _GtkFontChooserDialog
|
||||
@ -72,6 +74,8 @@ struct _GtkFontChooserDialogClass
|
||||
* The `GtkFontChooserDialog` implementation of the `GtkBuildable`
|
||||
* interface exposes the buttons with the names “select_button”
|
||||
* and “cancel_button”.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] instead
|
||||
*/
|
||||
|
||||
static void gtk_font_chooser_dialog_buildable_interface_init (GtkBuildableIface *iface);
|
||||
@ -288,6 +292,8 @@ gtk_font_chooser_dialog_init (GtkFontChooserDialog *dialog)
|
||||
* Creates a new `GtkFontChooserDialog`.
|
||||
*
|
||||
* Returns: a new `GtkFontChooserDialog`
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.FontDialog] instead
|
||||
*/
|
||||
GtkWidget*
|
||||
gtk_font_chooser_dialog_new (const char *title,
|
||||
@ -324,3 +330,10 @@ gtk_font_chooser_dialog_buildable_get_internal_child (GtkBuildable *buildable,
|
||||
|
||||
return parent_buildable_iface->get_internal_child (buildable, builder, childname);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_font_chooser_dialog_set_filter (GtkFontChooserDialog *dialog,
|
||||
GtkFilter *filter)
|
||||
{
|
||||
gtk_font_chooser_widget_set_filter (GTK_FONT_CHOOSER_WIDGET (dialog->fontchooser), filter);
|
||||
}
|
||||
|
31
gtk/gtkfontchooserdialogprivate.h
Normal file
31
gtk/gtkfontchooserdialogprivate.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2017 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_FONT_CHOOSER_DIALOG_PRIVATE_H__
|
||||
#define __GTK_FONT_CHOOSER_DIALOG_PRIVATE_H__
|
||||
|
||||
#include "deprecated/gtkfontchooserdialog.h"
|
||||
#include "gtkfilter.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void gtk_font_chooser_dialog_set_filter (GtkFontChooserDialog *dialog,
|
||||
GtkFilter *filter);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FONT_CHOOSER_WIDGET_PRIVATE_H__ */
|
@ -26,6 +26,8 @@
|
||||
|
||||
#include "gtkfontchooserutils.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkFontChooser *
|
||||
get_delegate (GtkFontChooser *receiver)
|
||||
{
|
||||
|
@ -25,7 +25,7 @@
|
||||
#ifndef __GTK_FONT_CHOOSER_UTILS_H__
|
||||
#define __GTK_FONT_CHOOSER_UTILS_H__
|
||||
|
||||
#include "gtkfontchooserprivate.h"
|
||||
#include "deprecated/gtkfontchooserprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <glib/gprintf.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gtkfontchooserwidget.h"
|
||||
#include "deprecated/gtkfontchooserwidget.h"
|
||||
#include "gtkfontchooserwidgetprivate.h"
|
||||
|
||||
#include "gtkadjustment.h"
|
||||
@ -34,7 +34,7 @@
|
||||
#include "gtkfilter.h"
|
||||
#include "gtkframe.h"
|
||||
#include "gtkgrid.h"
|
||||
#include "gtkfontchooser.h"
|
||||
#include "deprecated/gtkfontchooser.h"
|
||||
#include "gtkfontchooserutils.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include "gtklabel.h"
|
||||
@ -63,12 +63,15 @@
|
||||
#include "gtksortlistmodel.h"
|
||||
#include "gtkstringsorter.h"
|
||||
#include "gtkdropdown.h"
|
||||
#include "gtkmultifilter.h"
|
||||
|
||||
#include <hb-ot.h>
|
||||
|
||||
#include "language-names.h"
|
||||
#include "open-type-layout.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/**
|
||||
* GtkFontChooserWidget:
|
||||
*
|
||||
@ -89,6 +92,8 @@
|
||||
* # CSS nodes
|
||||
*
|
||||
* `GtkFontChooserWidget` has a single CSS node with name fontchooser.
|
||||
*
|
||||
* Deprecated: 4.10: Direct use of `GtkFontChooserWidget` is deprecated.
|
||||
*/
|
||||
|
||||
typedef struct _GtkFontChooserWidgetClass GtkFontChooserWidgetClass;
|
||||
@ -105,6 +110,7 @@ struct _GtkFontChooserWidget
|
||||
GtkSingleSelection *selection;
|
||||
GtkCustomFilter *custom_filter;
|
||||
GtkCustomFilter *user_filter;
|
||||
GtkCustomFilter *multi_filter;
|
||||
GtkFilterListModel *filter_model;
|
||||
|
||||
GtkWidget *preview;
|
||||
@ -144,6 +150,8 @@ struct _GtkFontChooserWidget
|
||||
gpointer filter_data;
|
||||
GDestroyNotify filter_data_destroy;
|
||||
|
||||
GtkFilter *filter;
|
||||
|
||||
guint last_fontconfig_timestamp;
|
||||
|
||||
GtkFontChooserLevel level;
|
||||
@ -1295,6 +1303,8 @@ gtk_font_chooser_widget_init (GtkFontChooserWidget *self)
|
||||
* Creates a new `GtkFontChooserWidget`.
|
||||
*
|
||||
* Returns: a new `GtkFontChooserWidget`
|
||||
*
|
||||
* Deprecated: 4.10: Direct use of `GtkFontChooserWidget` is deprecated.
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_font_chooser_widget_new (void)
|
||||
@ -1325,6 +1335,8 @@ gtk_font_chooser_widget_finalize (GObject *object)
|
||||
|
||||
g_free (fontchooser->font_features);
|
||||
|
||||
g_clear_object (&fontchooser->filter);
|
||||
|
||||
G_OBJECT_CLASS (gtk_font_chooser_widget_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@ -2976,3 +2988,14 @@ gtk_font_chooser_widget_get_tweak_action (GtkWidget *widget)
|
||||
|
||||
return fontchooser->tweak_action;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_font_chooser_widget_set_filter (GtkFontChooserWidget *widget,
|
||||
GtkFilter *filter)
|
||||
{
|
||||
if (widget->filter)
|
||||
gtk_multi_filter_remove (GTK_MULTI_FILTER (widget->multi_filter), 3);
|
||||
g_set_object (&widget->filter, filter);
|
||||
if (widget->filter)
|
||||
gtk_multi_filter_append (GTK_MULTI_FILTER (widget->multi_filter), g_object_ref (filter));
|
||||
}
|
||||
|
@ -18,12 +18,16 @@
|
||||
#ifndef __GTK_FONT_CHOOSER_WIDGET_PRIVATE_H__
|
||||
#define __GTK_FONT_CHOOSER_WIDGET_PRIVATE_H__
|
||||
|
||||
#include "gtkfontchooserwidget.h"
|
||||
#include "deprecated/gtkfontchooserwidget.h"
|
||||
#include "gtkfilter.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GAction *gtk_font_chooser_widget_get_tweak_action (GtkWidget *fontchooser);
|
||||
|
||||
void gtk_font_chooser_widget_set_filter (GtkFontChooserWidget *widget,
|
||||
GtkFilter *filter);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FONT_CHOOSER_WIDGET_PRIVATE_H__ */
|
||||
|
951
gtk/gtkfontdialog.c
Normal file
951
gtk/gtkfontdialog.c
Normal file
@ -0,0 +1,951 @@
|
||||
/*
|
||||
* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkfontdialog.h"
|
||||
|
||||
#include "deprecated/gtkfontchooser.h"
|
||||
#include "gtkfontchooserdialogprivate.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkdialogerror.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
/**
|
||||
* GtkFontDialog:
|
||||
*
|
||||
* A `GtkFontDialog` object collects the arguments that
|
||||
* are needed to present a font chooser dialog to the
|
||||
* user, such as a title for the dialog and whether it
|
||||
* should be modal.
|
||||
*
|
||||
* The dialog is shown with the [method@Gtk.FontDialog.choose_font]
|
||||
* function or its variants. This API follows the GIO async pattern,
|
||||
* and the result can be obtained by calling the corresponding
|
||||
* finish function, such as [method@Gtk.FontDialog.choose_font_finish].
|
||||
*
|
||||
* See [class@Gtk.FontDialogButton] for a convenient control
|
||||
* that uses `GtkFontDialog` and presents the results.
|
||||
*
|
||||
* `GtkFontDialog was added in GTK 4.10.
|
||||
*/
|
||||
|
||||
/* {{{ GObject implementation */
|
||||
|
||||
struct _GtkFontDialog
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
char *title;
|
||||
PangoLanguage *language;
|
||||
PangoFontMap *fontmap;
|
||||
|
||||
unsigned int modal : 1;
|
||||
|
||||
GtkFilter *filter;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_TITLE = 1,
|
||||
PROP_MODAL,
|
||||
PROP_LANGUAGE,
|
||||
PROP_FONT_MAP,
|
||||
PROP_FILTER,
|
||||
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *properties[NUM_PROPERTIES];
|
||||
|
||||
G_DEFINE_TYPE (GtkFontDialog, gtk_font_dialog, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_font_dialog_init (GtkFontDialog *self)
|
||||
{
|
||||
self->modal = TRUE;
|
||||
self->language = pango_language_get_default ();
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_dialog_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFontDialog *self = GTK_FONT_DIALOG (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_TITLE:
|
||||
g_value_set_string (value, self->title);
|
||||
break;
|
||||
|
||||
case PROP_MODAL:
|
||||
g_value_set_boolean (value, self->modal);
|
||||
break;
|
||||
|
||||
case PROP_LANGUAGE:
|
||||
g_value_set_boxed (value, self->language);
|
||||
break;
|
||||
|
||||
case PROP_FONT_MAP:
|
||||
g_value_set_object (value, self->fontmap);
|
||||
break;
|
||||
|
||||
case PROP_FILTER:
|
||||
g_value_set_object (value, self->filter);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_dialog_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFontDialog *self = GTK_FONT_DIALOG (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_TITLE:
|
||||
gtk_font_dialog_set_title (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_MODAL:
|
||||
gtk_font_dialog_set_modal (self, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_LANGUAGE:
|
||||
gtk_font_dialog_set_language (self, g_value_get_boxed (value));
|
||||
break;
|
||||
|
||||
case PROP_FONT_MAP:
|
||||
gtk_font_dialog_set_font_map (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_FILTER:
|
||||
gtk_font_dialog_set_filter (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_dialog_finalize (GObject *object)
|
||||
{
|
||||
GtkFontDialog *self = GTK_FONT_DIALOG (object);
|
||||
|
||||
g_free (self->title);
|
||||
g_clear_object (&self->fontmap);
|
||||
g_clear_object (&self->filter);
|
||||
|
||||
G_OBJECT_CLASS (gtk_font_dialog_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_dialog_class_init (GtkFontDialogClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->get_property = gtk_font_dialog_get_property;
|
||||
object_class->set_property = gtk_font_dialog_set_property;
|
||||
object_class->finalize = gtk_font_dialog_finalize;
|
||||
|
||||
/**
|
||||
* GtkFontDialog:title: (attributes org.gtk.Property.get=gtk_font_dialog_get_title org.gtk.Property.set=gtk_font_dialog_set_title)
|
||||
*
|
||||
* A title that may be shown on the font chooser
|
||||
* dialog that is presented by [method@Gtk.FontDialog.choose_font].
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_TITLE] =
|
||||
g_param_spec_string ("title", NULL, NULL,
|
||||
NULL,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkFontDialog:modal: (attributes org.gtk.Property.get=gtk_font_dialog_get_modal org.gtk.Property.set=gtk_font_dialog_set_modal)
|
||||
*
|
||||
* Whether the font chooser dialog is modal.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_MODAL] =
|
||||
g_param_spec_boolean ("modal", NULL, NULL,
|
||||
TRUE,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkFontDialog:language: (attributes org.gtk.Property.get=gtk_font_dialog_get_language org.gtk.Property.set=gtk_font_dialog_set_language)
|
||||
*
|
||||
* The language for which the font features are selected.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_LANGUAGE] =
|
||||
g_param_spec_boxed ("language", NULL, NULL,
|
||||
PANGO_TYPE_LANGUAGE,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkFontDialog:font-map: (attributes org.gtk.Property.get=gtk_font_dialog_get_font_map org.gtk.Property.set=gtk_font_dialog_set_font_map)
|
||||
*
|
||||
* Sets a custom font map to select fonts from.
|
||||
*
|
||||
* A custom font map can be used to present application-specific
|
||||
* fonts instead of or in addition to the normal system fonts.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_FONT_MAP] =
|
||||
g_param_spec_object ("font-map", NULL, NULL,
|
||||
PANGO_TYPE_FONT_MAP,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkFontDialog:filter: (attributes org.gtk.Property.get=gtk_font_dialog_get_filter org.gtk.Property.set=gtk_font_dialog_set_filter)
|
||||
*
|
||||
* Sets a filter to restrict what fonts are shown
|
||||
* in the font chooser dialog.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_FILTER] =
|
||||
g_param_spec_object ("filter", NULL, NULL,
|
||||
GTK_TYPE_FILTER,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ API: Constructor */
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_new:
|
||||
*
|
||||
* Creates a new `GtkFontDialog` object.
|
||||
*
|
||||
* Returns: the new `GtkFontDialog`
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
GtkFontDialog *
|
||||
gtk_font_dialog_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_FONT_DIALOG, NULL);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ API: Getters and setters */
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_get_title:
|
||||
* @self: a `GtkFontDialog`
|
||||
*
|
||||
* Returns the title that will be shown on the
|
||||
* font chooser dialog.
|
||||
*
|
||||
* Returns: the title
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
const char *
|
||||
gtk_font_dialog_get_title (GtkFontDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), NULL);
|
||||
|
||||
return self->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_set_title:
|
||||
* @self: a `GtkFontDialog`
|
||||
* @title: the new title
|
||||
*
|
||||
* Sets the title that will be shown on the
|
||||
* font chooser dialog.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_font_dialog_set_title (GtkFontDialog *self,
|
||||
const char *title)
|
||||
{
|
||||
char *new_title;
|
||||
|
||||
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
|
||||
g_return_if_fail (title != NULL);
|
||||
|
||||
if (g_strcmp0 (self->title, title) == 0)
|
||||
return;
|
||||
|
||||
new_title = g_strdup (title);
|
||||
g_free (self->title);
|
||||
self->title = new_title;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_get_modal:
|
||||
* @self: a `GtkFontDialog`
|
||||
*
|
||||
* Returns whether the font chooser dialog
|
||||
* blocks interaction with the parent window
|
||||
* while it is presented.
|
||||
*
|
||||
* Returns: `TRUE` if the font chooser dialog is modal
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
gboolean
|
||||
gtk_font_dialog_get_modal (GtkFontDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), TRUE);
|
||||
|
||||
return self->modal;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_set_modal:
|
||||
* @self: a `GtkFontDialog`
|
||||
* @modal: the new value
|
||||
*
|
||||
* Sets whether the font chooser dialog
|
||||
* blocks interaction with the parent window
|
||||
* while it is presented.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_font_dialog_set_modal (GtkFontDialog *self,
|
||||
gboolean modal)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
|
||||
|
||||
if (self->modal == modal)
|
||||
return;
|
||||
|
||||
self->modal = modal;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODAL]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_get_language:
|
||||
* @self: a `GtkFontDialog`
|
||||
*
|
||||
* Returns the language for which font features are applied.
|
||||
*
|
||||
* Returns: (nullable): the language for font features
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
PangoLanguage *
|
||||
gtk_font_dialog_get_language (GtkFontDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), NULL);
|
||||
|
||||
return self->language;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_set_language:
|
||||
* @self: a `GtkFontDialog`
|
||||
* @language: the language for font features
|
||||
*
|
||||
* Sets the language for which font features are applied.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_font_dialog_set_language (GtkFontDialog *self,
|
||||
PangoLanguage *language)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
|
||||
|
||||
if (self->language == language)
|
||||
return;
|
||||
|
||||
self->language = language;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LANGUAGE]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_get_font_map:
|
||||
* @self: a `GtkFontDialog`
|
||||
*
|
||||
* Returns the fontmap from which fonts are selected,
|
||||
* or `NULL` for the default fontmap.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the fontmap
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
PangoFontMap *
|
||||
gtk_font_dialog_get_font_map (GtkFontDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), NULL);
|
||||
|
||||
return self->fontmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_set_font_map:
|
||||
* @self: a `GtkFontDialog`
|
||||
* @fontmap: (nullable): the fontmap
|
||||
*
|
||||
* Sets the fontmap from which fonts are selected.
|
||||
*
|
||||
* If @fontmap is `NULL`, the default fontmap is used.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_font_dialog_set_font_map (GtkFontDialog *self,
|
||||
PangoFontMap *fontmap)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
|
||||
|
||||
if (g_set_object (&self->fontmap, fontmap))
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FONT_MAP]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_get_filter:
|
||||
* @self: a `GtkFontDialog`
|
||||
*
|
||||
* Returns the filter that decides which fonts to display
|
||||
* in the font chooser dialog.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the filter
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
GtkFilter *
|
||||
gtk_font_dialog_get_filter (GtkFontDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), NULL);
|
||||
|
||||
return self->filter;
|
||||
}
|
||||
/**
|
||||
* gtk_font_dialog_set_filter:
|
||||
* @self: a `GtkFontDialog`
|
||||
* @filter: (nullable): a `GtkFilter`
|
||||
*
|
||||
* Adds a filter that decides which fonts to display
|
||||
* in the font chooser dialog.
|
||||
*
|
||||
* The `GtkFilter` must be able to handle both `PangoFontFamily`
|
||||
* and `PangoFontFace` objects.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_font_dialog_set_filter (GtkFontDialog *self,
|
||||
GtkFilter *filter)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
|
||||
g_return_if_fail (filter == NULL || GTK_IS_FILTER (filter));
|
||||
|
||||
if (g_set_object (&self->filter, filter))
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FILTER]);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Async implementation */
|
||||
|
||||
static void response_cb (GTask *task,
|
||||
int response);
|
||||
|
||||
static void
|
||||
cancelled_cb (GCancellable *cancellable,
|
||||
GTask *task)
|
||||
{
|
||||
response_cb (task, GTK_RESPONSE_CLOSE);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PangoFontDescription *font_desc;
|
||||
char *font_features;
|
||||
PangoLanguage *language;
|
||||
} FontResult;
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
static void
|
||||
response_cb (GTask *task,
|
||||
int response)
|
||||
{
|
||||
GCancellable *cancellable;
|
||||
GtkFontChooserDialog *window;
|
||||
GtkFontChooserLevel level;
|
||||
|
||||
cancellable = g_task_get_cancellable (task);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_handlers_disconnect_by_func (cancellable, cancelled_cb, task);
|
||||
|
||||
|
||||
window = GTK_FONT_CHOOSER_DIALOG (g_task_get_task_data (task));
|
||||
level = gtk_font_chooser_get_level (GTK_FONT_CHOOSER (window));
|
||||
|
||||
if (response == GTK_RESPONSE_OK)
|
||||
{
|
||||
if (level & GTK_FONT_CHOOSER_LEVEL_FEATURES)
|
||||
{
|
||||
FontResult font_result;
|
||||
|
||||
font_result.font_desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (window));
|
||||
font_result.font_features = gtk_font_chooser_get_font_features (GTK_FONT_CHOOSER (window));
|
||||
font_result.language = pango_language_from_string (gtk_font_chooser_get_language (GTK_FONT_CHOOSER (window)));
|
||||
|
||||
g_task_return_pointer (task, &font_result, NULL);
|
||||
|
||||
g_clear_pointer (&font_result.font_desc, pango_font_description_free);
|
||||
g_clear_pointer (&font_result.font_features, g_free);
|
||||
}
|
||||
else if (level & GTK_FONT_CHOOSER_LEVEL_SIZE)
|
||||
{
|
||||
PangoFontDescription *font_desc;
|
||||
|
||||
font_desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (window));
|
||||
|
||||
g_task_return_pointer (task, font_desc, (GDestroyNotify) pango_font_description_free);
|
||||
}
|
||||
else if (level & GTK_FONT_CHOOSER_LEVEL_STYLE)
|
||||
{
|
||||
PangoFontFace *face;
|
||||
|
||||
face = gtk_font_chooser_get_font_face (GTK_FONT_CHOOSER (window));
|
||||
|
||||
g_task_return_pointer (task, g_object_ref (face), g_object_unref);
|
||||
}
|
||||
else
|
||||
{
|
||||
PangoFontFamily *family;
|
||||
|
||||
family = gtk_font_chooser_get_font_family (GTK_FONT_CHOOSER (window));
|
||||
|
||||
g_task_return_pointer (task, g_object_ref (family), g_object_unref);
|
||||
}
|
||||
}
|
||||
else if (response == GTK_RESPONSE_CLOSE)
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_ABORTED, "Aborted by application");
|
||||
else if (response == GTK_RESPONSE_CANCEL)
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED, "Cancelled by user");
|
||||
else
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_FAILED, "Unknown failure (%d)", response);
|
||||
|
||||
g_object_unref (task);
|
||||
}
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
static void
|
||||
dialog_response (GtkDialog *dialog,
|
||||
int response,
|
||||
GTask *task)
|
||||
{
|
||||
response_cb (task, response);
|
||||
}
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
static GtkWidget *
|
||||
create_font_chooser (GtkFontDialog *self,
|
||||
GtkWindow *parent,
|
||||
PangoFontDescription *initial_value,
|
||||
GtkFontChooserLevel level)
|
||||
{
|
||||
GtkWidget *window;
|
||||
const char *title;
|
||||
|
||||
if (self->title)
|
||||
title = self->title;
|
||||
else
|
||||
title = _("Pick a Font");
|
||||
|
||||
window = gtk_font_chooser_dialog_new (title, parent);
|
||||
gtk_font_chooser_set_level (GTK_FONT_CHOOSER (window), level);
|
||||
if (self->language)
|
||||
gtk_font_chooser_set_language (GTK_FONT_CHOOSER (window),
|
||||
pango_language_to_string (self->language));
|
||||
if (self->fontmap)
|
||||
gtk_font_chooser_set_font_map (GTK_FONT_CHOOSER (window), self->fontmap);
|
||||
if (self->filter)
|
||||
gtk_font_chooser_dialog_set_filter (GTK_FONT_CHOOSER_DIALOG (window), self->filter);
|
||||
if (initial_value)
|
||||
gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (window), initial_value);
|
||||
|
||||
return window;
|
||||
}
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Async API */
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_choose_family:
|
||||
* @self: a `GtkFontDialog`
|
||||
* @parent: (nullable): the parent `GtkWindow`
|
||||
* @initial_value: (nullable): the initial value
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (scope async): a callback to call when the operation is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
*
|
||||
* This function initiates a font selection operation by
|
||||
* presenting a dialog to the user for selecting a font family.
|
||||
*
|
||||
* The @callback will be called when the dialog is dismissed.
|
||||
* It should call [method@Gtk.FontDialog.choose_family_finish]
|
||||
* to obtain the result.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_font_dialog_choose_family (GtkFontDialog *self,
|
||||
GtkWindow *parent,
|
||||
PangoFontFamily *initial_value,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *window;
|
||||
PangoFontDescription *desc = NULL;
|
||||
GTask *task;
|
||||
|
||||
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
|
||||
|
||||
if (initial_value)
|
||||
{
|
||||
desc = pango_font_description_new ();
|
||||
pango_font_description_set_family (desc, pango_font_family_get_name (initial_value));
|
||||
}
|
||||
|
||||
window = create_font_chooser (self, parent, desc,
|
||||
GTK_FONT_CHOOSER_LEVEL_FAMILY);
|
||||
|
||||
g_clear_pointer (&desc, pango_font_description_free);
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, gtk_font_dialog_choose_family);
|
||||
g_task_set_task_data (task, window, (GDestroyNotify) gtk_window_destroy);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
|
||||
|
||||
g_signal_connect (window, "response", G_CALLBACK (dialog_response), task);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_choose_family_finish:
|
||||
* @self: a `GtkFontDialog`
|
||||
* @result: a `GAsyncResult`
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Finishes the [method@Gtk.FontDialog.choose_family] call
|
||||
* and returns the resulting family.
|
||||
*
|
||||
* This function never returns an error. If the operation is
|
||||
* not finished successfully, the value passed as @initial_value
|
||||
* to [method@Gtk.FontDialog.choose_family] is returned.
|
||||
|
||||
* Returns: (nullable) (transfer full): the selected family
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
PangoFontFamily *
|
||||
gtk_font_dialog_choose_family_finish (GtkFontDialog *self,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), NULL);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_font_dialog_choose_family, NULL);
|
||||
|
||||
return g_task_propagate_pointer (G_TASK (result), error);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_choose_face:
|
||||
* @self: a `GtkFontDialog`
|
||||
* @parent: (nullable): the parent `GtkWindow`
|
||||
* @initial_value: (nullable): the initial value
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (scope async): a callback to call when the operation is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
*
|
||||
* This function initiates a font selection operation by
|
||||
* presenting a dialog to the user for selecting a font face
|
||||
* (i.e. a font family and style, but not a specific font size).
|
||||
*
|
||||
* The @callback will be called when the dialog is dismissed.
|
||||
* It should call [method@Gtk.FontDialog.choose_face_finish]
|
||||
* to obtain the result.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_font_dialog_choose_face (GtkFontDialog *self,
|
||||
GtkWindow *parent,
|
||||
PangoFontFace *initial_value,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *window;
|
||||
PangoFontDescription *desc = NULL;
|
||||
GTask *task;
|
||||
|
||||
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
|
||||
|
||||
if (initial_value)
|
||||
desc = pango_font_face_describe (initial_value);
|
||||
|
||||
window = create_font_chooser (self, parent, desc,
|
||||
GTK_FONT_CHOOSER_LEVEL_FAMILY |
|
||||
GTK_FONT_CHOOSER_LEVEL_STYLE);
|
||||
|
||||
g_clear_pointer (&desc, pango_font_description_free);
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, gtk_font_dialog_choose_face);
|
||||
g_task_set_task_data (task, window, (GDestroyNotify) gtk_window_destroy);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
|
||||
|
||||
g_signal_connect (window, "response", G_CALLBACK (dialog_response), task);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_choose_face_finish:
|
||||
* @self: a `GtkFontDialog`
|
||||
* @result: a `GAsyncResult`
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Finishes the [method@Gtk.FontDialog.choose_face] call
|
||||
* and returns the resulting font face.
|
||||
*
|
||||
* Returns: (nullable) (transfer full): the selected font face
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
PangoFontFace *
|
||||
gtk_font_dialog_choose_face_finish (GtkFontDialog *self,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), NULL);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_font_dialog_choose_face, NULL);
|
||||
|
||||
return g_task_propagate_pointer (G_TASK (result), NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_choose_font:
|
||||
* @self: a `GtkFontDialog`
|
||||
* @parent: (nullable): the parent `GtkWindow`
|
||||
* @initial_value: (nullable): the font to select initially
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (scope async): a callback to call when the operation is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
*
|
||||
* This function initiates a font selection operation by
|
||||
* presenting a dialog to the user for selecting a font.
|
||||
*
|
||||
* The @callback will be called when the dialog is dismissed.
|
||||
* It should call [method@Gtk.FontDialog.choose_font_finish]
|
||||
* to obtain the result.
|
||||
*
|
||||
* If you want to let the user select font features as well,
|
||||
* use [method@Gtk.FontDialog.choose_font_and_features] instead.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_font_dialog_choose_font (GtkFontDialog *self,
|
||||
GtkWindow *parent,
|
||||
PangoFontDescription *initial_value,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GTask *task;
|
||||
|
||||
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
|
||||
|
||||
window = create_font_chooser (self, parent, initial_value,
|
||||
GTK_FONT_CHOOSER_LEVEL_FAMILY |
|
||||
GTK_FONT_CHOOSER_LEVEL_STYLE |
|
||||
GTK_FONT_CHOOSER_LEVEL_SIZE |
|
||||
GTK_FONT_CHOOSER_LEVEL_VARIATIONS);
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, gtk_font_dialog_choose_font);
|
||||
g_task_set_task_data (task, window, (GDestroyNotify) gtk_window_destroy);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
|
||||
|
||||
g_signal_connect (window, "response", G_CALLBACK (dialog_response), task);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_choose_font_finish:
|
||||
* @self: a `GtkFontDialog`
|
||||
* @result: a `GAsyncResult`
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Finishes the [method@Gtk.FontDialog.choose_font] call
|
||||
* and returns the resulting font description.
|
||||
*
|
||||
* Returns: (nullable) (transfer full): the selected font
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
PangoFontDescription *
|
||||
gtk_font_dialog_choose_font_finish (GtkFontDialog *self,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), NULL);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_font_dialog_choose_font, NULL);
|
||||
|
||||
return g_task_propagate_pointer (G_TASK (result), NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_choose_font_and_features:
|
||||
* @self: a `GtkFontDialog`
|
||||
* @parent: (nullable): the parent `GtkWindow`
|
||||
* @initial_value: (nullable): the font to select initially
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (scope async): a callback to call when the operation is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
*
|
||||
* This function initiates a font selection operation by
|
||||
* presenting a dialog to the user for selecting a font and
|
||||
* font features.
|
||||
*
|
||||
* Font features affect how the font is rendered, for example
|
||||
* enabling glyph variants or ligatures.
|
||||
*
|
||||
* The @callback will be called when the dialog is dismissed.
|
||||
* It should call [method@Gtk.FontDialog.choose_font_and_features_finish]
|
||||
* to obtain the result.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_font_dialog_choose_font_and_features (GtkFontDialog *self,
|
||||
GtkWindow *parent,
|
||||
PangoFontDescription *initial_value,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GTask *task;
|
||||
|
||||
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
|
||||
|
||||
window = create_font_chooser (self, parent, initial_value,
|
||||
GTK_FONT_CHOOSER_LEVEL_FAMILY |
|
||||
GTK_FONT_CHOOSER_LEVEL_STYLE |
|
||||
GTK_FONT_CHOOSER_LEVEL_SIZE |
|
||||
GTK_FONT_CHOOSER_LEVEL_VARIATIONS |
|
||||
GTK_FONT_CHOOSER_LEVEL_FEATURES);
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, gtk_font_dialog_choose_font_and_features);
|
||||
g_task_set_task_data (task, window, (GDestroyNotify) gtk_window_destroy);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
|
||||
|
||||
g_signal_connect (window, "response", G_CALLBACK (dialog_response), task);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_dialog_choose_font_and_features_finish:
|
||||
* @self: a `GtkFontDialog`
|
||||
* @result: a `GAsyncResult`
|
||||
* @font_desc: (out caller-allocates): return location for font description
|
||||
* @font_features: (out caller-allocates): return location for font features
|
||||
* @language: (out caller-allocates): return location for the language
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Finishes the [method@Gtk.FontDialog.choose_font_and_features]
|
||||
* call and returns the resulting font description and font features.
|
||||
*
|
||||
* Returns: `TRUE` if a font was selected. Otherwise `FALSE` is returned
|
||||
* and @error is set
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
gboolean
|
||||
gtk_font_dialog_choose_font_and_features_finish (GtkFontDialog *self,
|
||||
GAsyncResult *result,
|
||||
PangoFontDescription **font_desc,
|
||||
char **font_features,
|
||||
PangoLanguage **language,
|
||||
GError **error)
|
||||
{
|
||||
FontResult *font_result;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), FALSE);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_font_dialog_choose_font_and_features, FALSE);
|
||||
|
||||
font_result = g_task_propagate_pointer (G_TASK (result), error);
|
||||
|
||||
if (font_result)
|
||||
{
|
||||
*font_desc = g_steal_pointer (&font_result->font_desc);
|
||||
*font_features = g_steal_pointer (&font_result->font_features);
|
||||
*language = g_steal_pointer (&font_result->language);
|
||||
}
|
||||
|
||||
return font_result != NULL;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* vim:set foldmethod=marker expandtab: */
|
136
gtk/gtkfontdialog.h
Normal file
136
gtk/gtkfontdialog.h
Normal file
@ -0,0 +1,136 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
*
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtkwindow.h>
|
||||
#include <gtk/gtkfilter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_FONT_DIALOG (gtk_font_dialog_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
G_DECLARE_FINAL_TYPE (GtkFontDialog, gtk_font_dialog, GTK, FONT_DIALOG, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GtkFontDialog * gtk_font_dialog_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
const char * gtk_font_dialog_get_title (GtkFontDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_set_title (GtkFontDialog *self,
|
||||
const char *title);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
gboolean gtk_font_dialog_get_modal (GtkFontDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_set_modal (GtkFontDialog *self,
|
||||
gboolean modal);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
PangoLanguage * gtk_font_dialog_get_language (GtkFontDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_set_language (GtkFontDialog *self,
|
||||
PangoLanguage *language);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
PangoFontMap * gtk_font_dialog_get_font_map (GtkFontDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_set_font_map (GtkFontDialog *self,
|
||||
PangoFontMap *fontmap);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GtkFilter * gtk_font_dialog_get_filter (GtkFontDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_set_filter (GtkFontDialog *self,
|
||||
GtkFilter *filter);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_choose_family (GtkFontDialog *self,
|
||||
GtkWindow *parent,
|
||||
PangoFontFamily *initial_value,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
PangoFontFamily *
|
||||
gtk_font_dialog_choose_family_finish
|
||||
(GtkFontDialog *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_choose_face (GtkFontDialog *self,
|
||||
GtkWindow *parent,
|
||||
PangoFontFace *initial_value,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
PangoFontFace * gtk_font_dialog_choose_face_finish
|
||||
(GtkFontDialog *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_choose_font (GtkFontDialog *self,
|
||||
GtkWindow *parent,
|
||||
PangoFontDescription *initial_value,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
PangoFontDescription *
|
||||
gtk_font_dialog_choose_font_finish
|
||||
(GtkFontDialog *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_choose_font_and_features
|
||||
(GtkFontDialog *self,
|
||||
GtkWindow *parent,
|
||||
PangoFontDescription *initial_value,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
gboolean gtk_font_dialog_choose_font_and_features_finish
|
||||
(GtkFontDialog *self,
|
||||
GAsyncResult *result,
|
||||
PangoFontDescription **font_desc,
|
||||
char **font_features,
|
||||
PangoLanguage **language,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
1047
gtk/gtkfontdialogbutton.c
Normal file
1047
gtk/gtkfontdialogbutton.c
Normal file
File diff suppressed because it is too large
Load Diff
112
gtk/gtkfontdialogbutton.h
Normal file
112
gtk/gtkfontdialogbutton.h
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtkbutton.h>
|
||||
#include <gtk/gtkfontdialog.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_FONT_DIALOG_BUTTON (gtk_font_dialog_button_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
G_DECLARE_FINAL_TYPE (GtkFontDialogButton, gtk_font_dialog_button, GTK, FONT_DIALOG_BUTTON, GtkWidget)
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GtkWidget * gtk_font_dialog_button_new (GtkFontDialog *dialog);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GtkFontDialog * gtk_font_dialog_button_get_dialog (GtkFontDialogButton *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_button_set_dialog (GtkFontDialogButton *self,
|
||||
GtkFontDialog *dialog);
|
||||
|
||||
/**
|
||||
* GtkFontLevel:
|
||||
* @GTK_FONT_LEVEL_FAMILY: Select a font family
|
||||
* @GTK_FONT_LEVEL_FACE: Select a font face (i.e. a family and a style)
|
||||
* @GTK_FONT_LEVEL_FONT: Select a font (i.e. a face with a size, and possibly font variations)
|
||||
* @GTK_FONT_LEVEL_FEATURES: Select a font and font features
|
||||
*
|
||||
* The level of granularity for the font selection.
|
||||
*
|
||||
* Depending on this value, the `PangoFontDescription` that
|
||||
* is returned by [method@Gtk.FontDialogButton.get_font_desc]
|
||||
* will have more or less fields set.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GTK_FONT_LEVEL_FAMILY,
|
||||
GTK_FONT_LEVEL_FACE,
|
||||
GTK_FONT_LEVEL_FONT,
|
||||
GTK_FONT_LEVEL_FEATURES
|
||||
} GtkFontLevel;
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GtkFontLevel gtk_font_dialog_button_get_level (GtkFontDialogButton *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_button_set_level (GtkFontDialogButton *self,
|
||||
GtkFontLevel level);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
PangoFontDescription *
|
||||
gtk_font_dialog_button_get_font_desc (GtkFontDialogButton *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_button_set_font_desc (GtkFontDialogButton *self,
|
||||
const PangoFontDescription *font_desc);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
const char * gtk_font_dialog_button_get_font_features
|
||||
(GtkFontDialogButton *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_button_set_font_features
|
||||
(GtkFontDialogButton *self,
|
||||
const char *font_features);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
PangoLanguage * gtk_font_dialog_button_get_language (GtkFontDialogButton *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_button_set_language (GtkFontDialogButton *self,
|
||||
PangoLanguage *language);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
gboolean gtk_font_dialog_button_get_use_font (GtkFontDialogButton *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_button_set_use_font (GtkFontDialogButton *self,
|
||||
gboolean use_font);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
gboolean gtk_font_dialog_button_get_use_size (GtkFontDialogButton *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_font_dialog_button_set_use_size (GtkFontDialogButton *self,
|
||||
gboolean use_size);
|
||||
|
||||
G_END_DECLS
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkmessagedialog.h"
|
||||
#include "deprecated/gtkmessagedialog.h"
|
||||
|
||||
#include "gtkbox.h"
|
||||
#include "gtkbuildable.h"
|
||||
@ -37,6 +37,8 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/**
|
||||
* GtkMessageDialog:
|
||||
*
|
||||
@ -96,6 +98,8 @@
|
||||
*
|
||||
* The `GtkMessageDialog` implementation of the `GtkBuildable` interface exposes
|
||||
* the message area as an internal child with the name “message_area”.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.AlertDialog] instead
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
@ -227,13 +231,13 @@ gtk_message_dialog_set_property (GObject *object,
|
||||
if (txt)
|
||||
{
|
||||
priv->has_secondary_text = TRUE;
|
||||
gtk_widget_add_css_class (priv->label, "title");
|
||||
gtk_widget_add_css_class (priv->label, "title");
|
||||
gtk_widget_show (priv->secondary_label);
|
||||
}
|
||||
else
|
||||
{
|
||||
priv->has_secondary_text = FALSE;
|
||||
gtk_widget_remove_css_class (priv->label, "title");
|
||||
gtk_widget_remove_css_class (priv->label, "title");
|
||||
gtk_widget_hide (priv->secondary_label);
|
||||
}
|
||||
}
|
||||
@ -479,6 +483,8 @@ gtk_message_dialog_init (GtkMessageDialog *dialog)
|
||||
* for more details.
|
||||
*
|
||||
* Returns: (transfer none): a new `GtkMessageDialog`
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.AlertDialog] instead
|
||||
*/
|
||||
GtkWidget*
|
||||
gtk_message_dialog_new (GtkWindow *parent,
|
||||
@ -565,6 +571,8 @@ gtk_message_dialog_new (GtkWindow *parent,
|
||||
* ```
|
||||
*
|
||||
* Returns: a new `GtkMessageDialog`
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.AlertDialog] instead
|
||||
**/
|
||||
GtkWidget*
|
||||
gtk_message_dialog_new_with_markup (GtkWindow *parent,
|
||||
@ -602,6 +610,8 @@ gtk_message_dialog_new_with_markup (GtkWindow *parent,
|
||||
* @str: string with Pango markup
|
||||
*
|
||||
* Sets the text of the message dialog.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.AlertDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog,
|
||||
@ -622,6 +632,8 @@ gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog,
|
||||
* @...: arguments for @message_format
|
||||
*
|
||||
* Sets the secondary text of the message dialog.
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.AlertDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog,
|
||||
@ -679,6 +691,8 @@ gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog,
|
||||
* "%s", msg);
|
||||
* g_free (msg);
|
||||
* ```
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.AlertDialog] instead
|
||||
*/
|
||||
void
|
||||
gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog,
|
||||
@ -726,6 +740,8 @@ gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog,
|
||||
*
|
||||
* Returns: (transfer none): A `GtkBox` corresponding to the
|
||||
* “message area” in the @message_dialog
|
||||
*
|
||||
* Deprecated: 4.10: Use [class@Gtk.AlertDialog] instead
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_message_dialog_get_message_area (GtkMessageDialog *message_dialog)
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "gtkbox.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include "gtklabel.h"
|
||||
#include "gtkmessagedialog.h"
|
||||
#include "gtkalertdialog.h"
|
||||
#include "gtkmountoperation.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkcheckbutton.h"
|
||||
@ -904,27 +904,27 @@ gtk_mount_operation_ask_password (GMountOperation *mount_op,
|
||||
}
|
||||
|
||||
static void
|
||||
question_dialog_button_clicked (GtkDialog *dialog,
|
||||
int button_number,
|
||||
GMountOperation *op)
|
||||
question_dialog_button_clicked (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
{
|
||||
GtkMountOperationPrivate *priv;
|
||||
GtkAlertDialog *dialog = GTK_ALERT_DIALOG (source);
|
||||
GMountOperation *op = user_data;
|
||||
GtkMountOperation *operation;
|
||||
int button;
|
||||
|
||||
operation = GTK_MOUNT_OPERATION (op);
|
||||
priv = operation->priv;
|
||||
|
||||
if (button_number >= 0)
|
||||
button = gtk_alert_dialog_choose_finish (dialog, result);
|
||||
if (button >= 0)
|
||||
{
|
||||
g_mount_operation_set_choice (op, button_number);
|
||||
g_mount_operation_set_choice (op, button);
|
||||
g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED);
|
||||
}
|
||||
else
|
||||
g_mount_operation_reply (op, G_MOUNT_OPERATION_ABORTED);
|
||||
|
||||
priv->dialog = NULL;
|
||||
g_object_notify (G_OBJECT (operation), "is-showing");
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
g_object_unref (op);
|
||||
}
|
||||
|
||||
@ -934,10 +934,9 @@ gtk_mount_operation_ask_question_do_gtk (GtkMountOperation *op,
|
||||
const char *choices[])
|
||||
{
|
||||
GtkMountOperationPrivate *priv;
|
||||
GtkWidget *dialog;
|
||||
GtkAlertDialog *dialog;
|
||||
const char *secondary = NULL;
|
||||
char *primary;
|
||||
int count, len = 0;
|
||||
|
||||
g_return_if_fail (GTK_IS_MOUNT_OPERATION (op));
|
||||
g_return_if_fail (message != NULL);
|
||||
@ -952,36 +951,19 @@ gtk_mount_operation_ask_question_do_gtk (GtkMountOperation *op,
|
||||
primary = g_strndup (message, primary - message);
|
||||
}
|
||||
|
||||
dialog = gtk_message_dialog_new (priv->parent_window, 0,
|
||||
GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_NONE, "%s",
|
||||
primary != NULL ? primary : message);
|
||||
dialog = gtk_alert_dialog_new ("%s", primary ? primary : message);
|
||||
if (secondary)
|
||||
gtk_alert_dialog_set_detail (dialog, secondary);
|
||||
|
||||
gtk_alert_dialog_set_buttons (dialog, choices);
|
||||
|
||||
gtk_alert_dialog_choose (dialog, priv->parent_window,
|
||||
NULL,
|
||||
question_dialog_button_clicked, g_object_ref (op));
|
||||
g_object_unref (dialog);
|
||||
g_free (primary);
|
||||
|
||||
if (secondary)
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"%s", secondary);
|
||||
|
||||
/* First count the items in the list then
|
||||
* add the buttons in reverse order */
|
||||
|
||||
while (choices[len] != NULL)
|
||||
len++;
|
||||
|
||||
for (count = len - 1; count >= 0; count--)
|
||||
gtk_dialog_add_button (GTK_DIALOG (dialog), choices[count], count);
|
||||
|
||||
g_signal_connect (G_OBJECT (dialog), "response",
|
||||
G_CALLBACK (question_dialog_button_clicked), op);
|
||||
|
||||
priv->dialog = GTK_DIALOG (dialog);
|
||||
g_object_notify (G_OBJECT (op), "is-showing");
|
||||
|
||||
if (priv->parent_window == NULL && priv->display)
|
||||
gtk_window_set_display (GTK_WINDOW (dialog), priv->display);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
g_object_ref (op);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1367,18 +1349,6 @@ update_process_list_store (GtkMountOperation *mount_operation,
|
||||
g_array_unref (pid_indices_to_remove);
|
||||
}
|
||||
|
||||
static void
|
||||
on_dialog_response (GtkDialog *dialog,
|
||||
int response)
|
||||
{
|
||||
/* GTK_RESPONSE_NONE means the dialog were programmatically destroy, e.g. that
|
||||
* GTK_DIALOG_DESTROY_WITH_PARENT kicked in - so it would trigger a warning to
|
||||
* destroy the dialog in that case
|
||||
*/
|
||||
if (response != GTK_RESPONSE_NONE)
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
static void
|
||||
on_end_process_activated (GtkButton *button,
|
||||
GtkMountOperation *op)
|
||||
@ -1406,25 +1376,17 @@ on_end_process_activated (GtkButton *button,
|
||||
error = NULL;
|
||||
if (!_gtk_mount_operation_kill_process (data->pid, &error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkAlertDialog *dialog;
|
||||
|
||||
/* Use GTK_DIALOG_DESTROY_WITH_PARENT here since the parent dialog can be
|
||||
* indeed be destroyed via the GMountOperation::abort signal... for example,
|
||||
* this is triggered if the user yanks the device while we are showing
|
||||
* the dialog...
|
||||
*/
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (op->priv->dialog),
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
_("Unable to end process"));
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"%s",
|
||||
error->message);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (on_dialog_response), NULL);
|
||||
dialog = gtk_alert_dialog_new (_("Unable to end process"));
|
||||
gtk_alert_dialog_set_detail (dialog, error->message);
|
||||
gtk_alert_dialog_show (dialog, GTK_WINDOW (op->priv->dialog));
|
||||
g_object_unref (dialog);
|
||||
|
||||
g_error_free (error);
|
||||
}
|
||||
|
@ -22,11 +22,6 @@
|
||||
#include "gtknativedialogprivate.h"
|
||||
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkfilechooserdialog.h"
|
||||
#include "gtkfilechooserprivate.h"
|
||||
#include "gtkfilechooserwidget.h"
|
||||
#include "gtkfilechooserwidgetprivate.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtksettings.h"
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "gtklistitem.h"
|
||||
#include "gtksignallistitemfactory.h"
|
||||
#include "gtkentry.h"
|
||||
#include "gtkfilechooserdialog.h"
|
||||
#include "gtkfiledialog.h"
|
||||
#include "gtkimage.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkcheckbutton.h"
|
||||
@ -639,19 +639,21 @@ check_toggled_cb (GtkCheckButton *check_button,
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_response_callback (GtkDialog *dialog,
|
||||
int response_id,
|
||||
GtkPrinterOptionWidget *widget)
|
||||
dialog_response_callback (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GtkPrinterOptionWidget *widget = data;
|
||||
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
||||
GFile *new_location = NULL;
|
||||
char *uri = NULL;
|
||||
|
||||
if (response_id == GTK_RESPONSE_ACCEPT)
|
||||
new_location = gtk_file_dialog_save_finish (dialog, result, NULL);
|
||||
if (new_location)
|
||||
{
|
||||
GFileInfo *info;
|
||||
|
||||
new_location = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
info = g_file_query_info (new_location,
|
||||
"standard::display-name",
|
||||
0,
|
||||
@ -680,8 +682,6 @@ dialog_response_callback (GtkDialog *dialog,
|
||||
}
|
||||
}
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
|
||||
if (new_location)
|
||||
uri = g_file_get_uri (new_location);
|
||||
else
|
||||
@ -706,33 +706,46 @@ filesave_choose_cb (GtkWidget *button,
|
||||
GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
||||
GtkWidget *dialog;
|
||||
GtkWindow *toplevel;
|
||||
GtkFileDialog *dialog;
|
||||
GFile *current_folder = NULL;
|
||||
char *current_name = NULL;
|
||||
|
||||
/* this will be unblocked in the dialog_response_callback function */
|
||||
g_signal_handler_block (priv->source, priv->source_changed_handler);
|
||||
|
||||
toplevel = GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (widget)));
|
||||
dialog = gtk_file_chooser_dialog_new (_("Select a filename"),
|
||||
toplevel,
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
_("_Select"), GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
|
||||
/* select the current filename in the dialog */
|
||||
if (priv->source != NULL && priv->source->value != NULL)
|
||||
{
|
||||
priv->last_location = g_file_new_for_uri (priv->source->value);
|
||||
if (priv->last_location)
|
||||
gtk_file_chooser_set_file (GTK_FILE_CHOOSER (dialog), priv->last_location, NULL);
|
||||
{
|
||||
if (g_file_query_file_type (priv->last_location, 0, NULL) == G_FILE_TYPE_DIRECTORY)
|
||||
{
|
||||
current_folder = g_object_ref (priv->last_location);
|
||||
current_name = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_folder = g_file_get_parent (priv->last_location);
|
||||
current_name = g_file_get_basename (priv->last_location);
|
||||
if (strcmp (current_name, "/") == 0 ||
|
||||
!g_utf8_validate (current_name, -1, NULL))
|
||||
g_clear_pointer (¤t_name, g_free);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (dialog_response_callback),
|
||||
widget);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, _("Select a filename"));
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (widget))),
|
||||
current_folder,
|
||||
current_name,
|
||||
NULL,
|
||||
dialog_response_callback, widget);
|
||||
|
||||
g_object_unref (current_folder);
|
||||
g_free (current_name);
|
||||
}
|
||||
|
||||
static char *
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include <glib/gstdio.h>
|
||||
#include "gtkprintoperation-private.h"
|
||||
#include "gtkprintoperation-portal.h"
|
||||
#include "gtkmessagedialog.h"
|
||||
|
||||
#include <cairo-pdf.h>
|
||||
#include <cairo-ps.h>
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "gtkmarshalers.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkmessagedialog.h"
|
||||
#include "deprecated/gtkmessagedialog.h"
|
||||
#include "gtkwindowgroup.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
|
||||
@ -2848,15 +2848,17 @@ print_pages (GtkPrintOperation *op,
|
||||
{
|
||||
GtkWidget *progress;
|
||||
|
||||
progress = gtk_message_dialog_new (parent, 0,
|
||||
GTK_MESSAGE_OTHER,
|
||||
GTK_BUTTONS_CANCEL,
|
||||
_("Preparing"));
|
||||
g_signal_connect (progress, "response",
|
||||
G_CALLBACK (handle_progress_response), op);
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
progress = gtk_message_dialog_new (parent, 0,
|
||||
GTK_MESSAGE_OTHER,
|
||||
GTK_BUTTONS_CANCEL,
|
||||
_("Preparing"));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_signal_connect (progress, "response",
|
||||
G_CALLBACK (handle_progress_response), op);
|
||||
|
||||
priv->show_progress_timeout_id =
|
||||
g_timeout_add (SHOW_PROGRESS_TIME,
|
||||
priv->show_progress_timeout_id =
|
||||
g_timeout_add (SHOW_PROGRESS_TIME,
|
||||
(GSourceFunc) show_progress_timeout,
|
||||
data);
|
||||
gdk_source_set_static_name_by_id (priv->show_progress_timeout_id, "[gtk] show_progress_timeout");
|
||||
@ -2878,6 +2880,7 @@ print_pages (GtkPrintOperation *op,
|
||||
{
|
||||
GtkWidget *error_dialog;
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
error_dialog = gtk_message_dialog_new (parent,
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
@ -2886,6 +2889,7 @@ print_pages (GtkPrintOperation *op,
|
||||
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (error_dialog),
|
||||
_("The most probable reason is that a temporary file could not be created."));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
if (parent && gtk_window_has_group (parent))
|
||||
gtk_window_group_add_window (gtk_window_get_group (parent),
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include "gtkframe.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkmessagedialog.h"
|
||||
#include "deprecated/gtkmessagedialog.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkrenderbackgroundprivate.h"
|
||||
@ -637,6 +637,7 @@ error_dialogs (GtkPrintUnixDialog *dialog,
|
||||
dirname = g_file_get_parse_name (parent);
|
||||
g_object_unref (parent);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
message_dialog = gtk_message_dialog_new (toplevel,
|
||||
GTK_DIALOG_MODAL |
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
@ -658,6 +659,7 @@ error_dialogs (GtkPrintUnixDialog *dialog,
|
||||
GTK_RESPONSE_ACCEPT);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (message_dialog),
|
||||
GTK_RESPONSE_ACCEPT);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
if (gtk_window_has_group (toplevel))
|
||||
gtk_window_group_add_window (gtk_window_get_group (toplevel),
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "gtkshow.h"
|
||||
#include "gtkwindowprivate.h"
|
||||
#include "gtkmessagedialog.h"
|
||||
#include "gtkalertdialog.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
typedef struct {
|
||||
@ -165,21 +165,12 @@ show_uri_done (GObject *object,
|
||||
|
||||
if (!gtk_show_uri_full_finish (parent, result, &error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkAlertDialog *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (parent,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT |
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s", _("Could not show link"));
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"%s", error->message);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
dialog = gtk_alert_dialog_new ("%s", _("Could not show link"));
|
||||
gtk_alert_dialog_set_detail (dialog, error->message);
|
||||
gtk_alert_dialog_show (dialog, parent);
|
||||
g_object_unref (dialog);
|
||||
|
||||
g_error_free (error);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkmessagedialog.h"
|
||||
#include "deprecated/gtkmessagedialog.h"
|
||||
#include "gtkpointerfocusprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkroot.h"
|
||||
@ -6130,6 +6130,7 @@ gtk_window_set_debugging (GdkDisplay *display,
|
||||
|
||||
if (warn)
|
||||
{
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (inspector_window),
|
||||
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_QUESTION,
|
||||
@ -6141,6 +6142,7 @@ gtk_window_set_debugging (GdkDisplay *display,
|
||||
"application to break or crash."));
|
||||
|
||||
area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
check = gtk_check_button_new_with_label (_("Don’t show this message again"));
|
||||
gtk_widget_set_margin_start (check, 10);
|
||||
gtk_widget_show (check);
|
||||
|
@ -29,8 +29,8 @@
|
||||
#include "gtkcssprovider.h"
|
||||
#include "gtkstyleprovider.h"
|
||||
#include "gtktextview.h"
|
||||
#include "gtkmessagedialog.h"
|
||||
#include "gtkfilechooserdialog.h"
|
||||
#include "gtkalertdialog.h"
|
||||
#include "gtkfiledialog.h"
|
||||
#include "gtktogglebutton.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtktooltip.h"
|
||||
@ -201,17 +201,12 @@ save_to_file (GtkInspectorCssEditor *ce,
|
||||
|
||||
if (error != NULL)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkAlertDialog *alert;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (ce))),
|
||||
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK,
|
||||
_("Saving CSS failed"));
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"%s", error->message);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_widget_show (dialog);
|
||||
alert = gtk_alert_dialog_new (_("Saving CSS failed"));
|
||||
gtk_alert_dialog_set_detail (alert, error->message);
|
||||
gtk_alert_dialog_show (alert, GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (ce))));
|
||||
g_object_unref (alert);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
@ -219,39 +214,41 @@ save_to_file (GtkInspectorCssEditor *ce,
|
||||
}
|
||||
|
||||
static void
|
||||
save_response (GtkWidget *dialog,
|
||||
int response,
|
||||
GtkInspectorCssEditor *ce)
|
||||
save_response (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_widget_hide (dialog);
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GtkInspectorCssEditor *ce = data;
|
||||
GError *error = NULL;
|
||||
GFile *file;
|
||||
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
file = gtk_file_dialog_save_finish (dialog, result, &error);
|
||||
if (file)
|
||||
{
|
||||
GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
save_to_file (ce, file);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
else
|
||||
{
|
||||
g_print ("Error saving css: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
save_clicked (GtkButton *button,
|
||||
GtkInspectorCssEditor *ce)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkFileDialog *dialog;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new ("",
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (ce))),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
_("_Save"), GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), "custom.css");
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (save_response), ce);
|
||||
gtk_widget_show (dialog);
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (ce))),
|
||||
NULL, "custom.css",
|
||||
NULL,
|
||||
save_response, ce);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -27,8 +27,6 @@
|
||||
#include "window.h"
|
||||
|
||||
#include "gtktextview.h"
|
||||
#include "gtkmessagedialog.h"
|
||||
#include "gtkfilechooserdialog.h"
|
||||
#include "gtkcheckbutton.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtktooltip.h"
|
||||
|
@ -30,10 +30,8 @@
|
||||
#include "deprecated/gtkcombobox.h"
|
||||
#include "deprecated/gtkiconview.h"
|
||||
#include "deprecated/gtktreeview.h"
|
||||
#include "gtkcolorbutton.h"
|
||||
#include "gtkcolorchooser.h"
|
||||
#include "gtkfontbutton.h"
|
||||
#include "gtkfontchooser.h"
|
||||
#include "gtkcolordialogbutton.h"
|
||||
#include "gtkfontdialogbutton.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkpopover.h"
|
||||
#include "gtkscrolledwindow.h"
|
||||
@ -745,7 +743,7 @@ object_properties (GtkInspectorPropEditor *self)
|
||||
}
|
||||
|
||||
static void
|
||||
rgba_modified (GtkColorButton *cb, GParamSpec *ignored, ObjectProperty *p)
|
||||
rgba_modified (GtkColorDialogButton *cb, GParamSpec *ignored, ObjectProperty *p)
|
||||
{
|
||||
GValue val = G_VALUE_INIT;
|
||||
|
||||
@ -761,25 +759,23 @@ rgba_changed (GObject *object, GParamSpec *pspec, gpointer data)
|
||||
GtkColorChooser *cb = GTK_COLOR_CHOOSER (data);
|
||||
GValue val = G_VALUE_INIT;
|
||||
GdkRGBA *color;
|
||||
GdkRGBA cb_color;
|
||||
|
||||
g_value_init (&val, GDK_TYPE_RGBA);
|
||||
get_property_value (object, pspec, &val);
|
||||
|
||||
color = g_value_get_boxed (&val);
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (cb), &cb_color);
|
||||
|
||||
if (color != NULL && !gdk_rgba_equal (color, &cb_color))
|
||||
if (color != NULL)
|
||||
{
|
||||
block_controller (G_OBJECT (cb));
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (cb), color);
|
||||
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (cb), color);
|
||||
unblock_controller (G_OBJECT (cb));
|
||||
}
|
||||
g_value_unset (&val);
|
||||
}
|
||||
|
||||
static void
|
||||
font_modified (GtkFontChooser *fb, GParamSpec *pspec, ObjectProperty *p)
|
||||
font_modified (GtkFontDialogButton *fb, GParamSpec *pspec, ObjectProperty *p)
|
||||
{
|
||||
GValue val = G_VALUE_INIT;
|
||||
|
||||
@ -792,28 +788,20 @@ font_modified (GtkFontChooser *fb, GParamSpec *pspec, ObjectProperty *p)
|
||||
static void
|
||||
font_changed (GObject *object, GParamSpec *pspec, gpointer data)
|
||||
{
|
||||
GtkFontChooser *fb = GTK_FONT_CHOOSER (data);
|
||||
GtkFontDialogButton *fb = GTK_FONT_DIALOG_BUTTON (data);
|
||||
GValue val = G_VALUE_INIT;
|
||||
const PangoFontDescription *font_desc;
|
||||
PangoFontDescription *fb_font_desc;
|
||||
|
||||
g_value_init (&val, PANGO_TYPE_FONT_DESCRIPTION);
|
||||
get_property_value (object, pspec, &val);
|
||||
|
||||
font_desc = g_value_get_boxed (&val);
|
||||
fb_font_desc = gtk_font_chooser_get_font_desc (fb);
|
||||
|
||||
if (font_desc == NULL ||
|
||||
(fb_font_desc != NULL &&
|
||||
!pango_font_description_equal (fb_font_desc, font_desc)))
|
||||
{
|
||||
block_controller (G_OBJECT (fb));
|
||||
gtk_font_chooser_set_font_desc (fb, font_desc);
|
||||
unblock_controller (G_OBJECT (fb));
|
||||
}
|
||||
block_controller (G_OBJECT (fb));
|
||||
gtk_font_dialog_button_set_font_desc (fb, font_desc);
|
||||
unblock_controller (G_OBJECT (fb));
|
||||
|
||||
g_value_unset (&val);
|
||||
pango_font_description_free (fb_font_desc);
|
||||
}
|
||||
|
||||
static char *
|
||||
@ -1177,8 +1165,7 @@ property_editor (GObject *object,
|
||||
else if (type == G_TYPE_PARAM_BOXED &&
|
||||
G_PARAM_SPEC_VALUE_TYPE (spec) == GDK_TYPE_RGBA)
|
||||
{
|
||||
prop_edit = gtk_color_button_new ();
|
||||
gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (prop_edit), TRUE);
|
||||
prop_edit = gtk_color_dialog_button_new (gtk_color_dialog_new ());
|
||||
|
||||
g_object_connect_property (object, spec,
|
||||
G_CALLBACK (rgba_changed),
|
||||
@ -1190,7 +1177,7 @@ property_editor (GObject *object,
|
||||
else if (type == G_TYPE_PARAM_BOXED &&
|
||||
G_PARAM_SPEC_VALUE_TYPE (spec) == PANGO_TYPE_FONT_DESCRIPTION)
|
||||
{
|
||||
prop_edit = gtk_font_button_new ();
|
||||
prop_edit = gtk_font_dialog_button_new (gtk_font_dialog_new ());
|
||||
|
||||
g_object_connect_property (object, spec,
|
||||
G_CALLBACK (font_changed),
|
||||
|
@ -23,14 +23,14 @@
|
||||
#include <gtk/gtkbox.h>
|
||||
#include <gtk/gtkdragsource.h>
|
||||
#include <gtk/gtkeventcontroller.h>
|
||||
#include <gtk/gtkfilechooserdialog.h>
|
||||
#include <gtk/gtkfiledialog.h>
|
||||
#include <gtk/gtkinscription.h>
|
||||
#include <gtk/gtkimage.h>
|
||||
#include <gtk/gtklabel.h>
|
||||
#include <gtk/gtklistbox.h>
|
||||
#include <gtk/gtklistitem.h>
|
||||
#include <gtk/gtklistview.h>
|
||||
#include <gtk/gtkmessagedialog.h>
|
||||
#include <gtk/gtkalertdialog.h>
|
||||
#include <gtk/gtkpicture.h>
|
||||
#include <gtk/gtkpopover.h>
|
||||
#include <gtk/gtksignallistitemfactory.h>
|
||||
@ -1803,18 +1803,21 @@ render_node_list_selection_changed (GtkListBox *list,
|
||||
}
|
||||
|
||||
static void
|
||||
render_node_save_response (GtkWidget *dialog,
|
||||
int response,
|
||||
GskRenderNode *node)
|
||||
render_node_save_response (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_widget_hide (dialog);
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GskRenderNode *node = data;
|
||||
GFile *file;
|
||||
GError *error = NULL;
|
||||
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
file = gtk_file_dialog_save_finish (dialog, result, &error);
|
||||
if (file)
|
||||
{
|
||||
GBytes *bytes = gsk_render_node_serialize (node);
|
||||
GError *error = NULL;
|
||||
|
||||
if (!g_file_replace_contents (gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog)),
|
||||
if (!g_file_replace_contents (file,
|
||||
g_bytes_get_data (bytes, NULL),
|
||||
g_bytes_get_size (bytes),
|
||||
NULL,
|
||||
@ -1824,24 +1827,23 @@ render_node_save_response (GtkWidget *dialog,
|
||||
NULL,
|
||||
&error))
|
||||
{
|
||||
GtkWidget *message_dialog;
|
||||
GtkAlertDialog *alert;
|
||||
|
||||
message_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_window_get_transient_for (GTK_WINDOW (dialog))),
|
||||
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK,
|
||||
_("Saving RenderNode failed"));
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
|
||||
"%s", error->message);
|
||||
g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_widget_show (message_dialog);
|
||||
alert = gtk_alert_dialog_new (_("Saving RenderNode failed"));
|
||||
gtk_alert_dialog_set_detail (alert, error->message);
|
||||
gtk_alert_dialog_show (alert, GTK_WINDOW (gtk_window_get_transient_for (GTK_WINDOW (dialog))));
|
||||
g_object_unref (alert);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
g_object_unref (file);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_print ("Error saving nodes: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1849,28 +1851,23 @@ render_node_save (GtkButton *button,
|
||||
GtkInspectorRecorder *recorder)
|
||||
{
|
||||
GskRenderNode *node;
|
||||
GtkWidget *dialog;
|
||||
GtkFileDialog *dialog;
|
||||
char *filename, *nodename;
|
||||
|
||||
node = get_selected_node (recorder);
|
||||
if (node == NULL)
|
||||
return;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new ("",
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (recorder))),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
_("_Save"), GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
nodename = node_name (node);
|
||||
filename = g_strdup_printf ("%s.node", nodename);
|
||||
g_free (nodename);
|
||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filename);
|
||||
g_free (filename);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (render_node_save_response), node);
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (recorder))),
|
||||
NULL, filename,
|
||||
NULL,
|
||||
render_node_save_response, node);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user