Compare commits

..

8 Commits

Author SHA1 Message Date
Matthias Clasen
35b0974000 Add GtkFileDialog
Add an async API for picking a file, together with
a builder object for it. This is meant to replace direct
use of GtkFileChooserDialog.
2022-10-26 07:59:39 -04:00
Matthias Clasen
4c18b1f345 Add GtkChoice
This is an auxiliary object for use with
file chooser choices.
2022-10-26 07:54:23 -04:00
Matthias Clasen
48aa551a72 Add GtkInfoDialog
This is replacing GtkMessageDialog with an
async API for showing informational messages.
2022-10-26 07:54:23 -04:00
Matthias Clasen
c20749e2d8 wip: builder: Accept string lists for strvs
Accept
  <property name="my-strv>
    <object class="GtkStringList">
      <items>
        <item translatable="yes">One</item>
        <item translatable="yes">Two</item>
        ...
      </items>
    </object>
  </property>

Ideally, we would want to parse this without the
<object> tag, but that is much more annoying to
implement.
2022-10-26 07:54:23 -04:00
Matthias Clasen
3e8a5bbb92 Add GtkFontDialogButton
This is like GtkColorDialogButton, but for fonts.
2022-10-26 07:54:23 -04:00
Matthias Clasen
056022a54b Add GtkFontDialog
This is similar to GtkColorDialog, but for fonts.
2022-10-26 07:54:23 -04:00
Matthias Clasen
1765bdc590 Add GtkColorDialogButton
This is a new color button implementation
built around GtkColorDialog.
2022-10-26 07:54:23 -04:00
Matthias Clasen
bcd9130548 Add GtkColorDialog
Add an async API for picking a color, together with
a builder object for it. This is meant to replace direct
use of GtkColorChooserDialog.
2022-10-26 07:54:22 -04:00
136 changed files with 2809 additions and 4077 deletions

View File

@@ -192,6 +192,7 @@ macos:
only:
- branches@GNOME/gtk
stage: build
allow_failure: true
tags:
- macos
needs: []
@@ -209,7 +210,6 @@ macos:
-Dintrospection=disabled
-Dcpp_std=c++11
-Dpixman:tests=disabled
-Dlibjpeg-turbo:simd=disabled
_build
- ninja -C _build
artifacts:

24
NEWS
View File

@@ -1,11 +1,9 @@
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. We are introducing deprecations in 4.10
as a way to give users time to adapt, and to provide
feedback on our plans.
Note that deprecations are an early outlook
at changes that will appear in an eventual
GTK 5 release, which is still far away.
* GtkTreeView, GtkIconView, GtkComboBox and
auxiliary classes have been deprecated
@@ -17,21 +15,7 @@ feedback on our plans.
* gtk_render_ and gtk_snapshot_render_ APIs
have been deprecated
* GtkAppChooser widgets have been deprecated
* GtkMessageDialog has been deprecated and
replaced by a new async dialog API
* GtkDialog has been deprecated
* 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
* GtkAppChooser widgets hae been deprecated
* GtkMountOperation:
- Fix the dialog to look reasonable

View File

@@ -202,36 +202,43 @@ constraint_editor_window_load (ConstraintEditorWindow *self,
}
static void
open_response_cb (GObject *source,
GAsyncResult *result,
void *user_data)
open_response_cb (GtkNativeDialog *dialog,
int response,
ConstraintEditorWindow *self)
{
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
ConstraintEditorWindow *self = user_data;
GFile *file;
gtk_native_dialog_hide (dialog);
file = gtk_file_dialog_open_finish (dialog, result, NULL);
if (file)
if (response == GTK_RESPONSE_ACCEPT)
{
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)
{
GtkFileDialog *dialog;
GFile *cwd;
GtkFileChooserNative *dialog;
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);
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);
g_object_unref (cwd);
gtk_file_dialog_open (dialog, GTK_WINDOW (self), NULL, NULL, open_response_cb, self);
g_object_unref (dialog);
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), self);
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
}
static void
@@ -287,23 +294,22 @@ serialize_model (GListModel *list)
static void
save_response_cb (GObject *source,
GAsyncResult *result,
void *user_data)
save_response_cb (GtkNativeDialog *dialog,
int response,
ConstraintEditorWindow *self)
{
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
ConstraintEditorWindow *self = user_data;
GFile *file;
gtk_native_dialog_hide (dialog);
file = gtk_file_dialog_save_finish (dialog, result, NULL);
if (file)
if (response == GTK_RESPONSE_ACCEPT)
{
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,
@@ -312,39 +318,46 @@ save_response_cb (GObject *source,
&error);
if (error != NULL)
{
GtkAlertDialog *alert;
GtkWidget *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);
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);
g_error_free (error);
}
g_free (text);
g_object_unref (file);
}
gtk_native_dialog_destroy (dialog);
}
static void
save_cb (GtkWidget *button,
ConstraintEditorWindow *self)
{
GtkFileDialog *dialog;
GFile *cwd;
GtkFileChooserNative *dialog;
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);
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);
g_object_unref (cwd);
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);
g_signal_connect (dialog, "response", G_CALLBACK (save_response_cb), self);
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
}
static void

View File

@@ -33,12 +33,22 @@ static void create_window (GApplication *app, const char *contents);
static void
show_action_dialog (GSimpleAction *action)
{
GtkAlertDialog *dialog;
const char *name;
GtkWidget *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);
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);
}
static void
@@ -80,19 +90,20 @@ activate_new (GSimpleAction *action,
}
static void
open_response_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
open_response_cb (GtkNativeDialog *dialog,
int response_id,
gpointer user_data)
{
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
GApplication *app = G_APPLICATION (user_data);
GtkFileChooserNative *native = user_data;
GApplication *app = g_object_get_data (G_OBJECT (native), "app");
GtkWidget *message_dialog;
GFile *file;
char *contents;
GError *error = NULL;
file = gtk_file_dialog_save_finish (dialog, result, &error);
if (file)
if (response_id == GTK_RESPONSE_ACCEPT)
{
char *contents;
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (native));
if (g_file_load_contents (file, NULL, &contents, NULL, NULL, &error))
{
@@ -101,16 +112,21 @@ open_response_cb (GObject *source,
}
else
{
GtkAlertDialog *alert;
alert = gtk_alert_dialog_new ("Error loading file: \"%s\"", error->message);
gtk_alert_dialog_show (alert, NULL);
g_object_unref (alert);
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);
g_error_free (error);
}
}
g_object_unref (app);
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (native));
g_object_unref (native);
}
@@ -120,11 +136,21 @@ activate_open (GSimpleAction *action,
gpointer user_data)
{
GApplication *app = user_data;
GtkFileDialog *dialog;
GtkFileChooserNative *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);
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));
}
static void

View File

@@ -50,10 +50,10 @@ copy_button_clicked (GtkStack *source_stack,
}
else if (strcmp (visible_child_name, "Color") == 0)
{
const GdkRGBA *color;
GdkRGBA color;
color = gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (visible_child));
gdk_clipboard_set (clipboard, GDK_TYPE_RGBA, color);
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (visible_child), &color);
gdk_clipboard_set (clipboard, GDK_TYPE_RGBA, &color);
}
else if (strcmp (visible_child_name, "File") == 0)
{
@@ -215,36 +215,37 @@ file_button_set_file (GtkButton *button,
}
static void
file_chooser_response (GObject *source,
GAsyncResult *result,
gpointer user_data)
file_chooser_response (GtkNativeDialog *dialog,
int response,
GtkButton *button)
{
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
GtkButton *button = GTK_BUTTON (user_data);
GFile *file;
gtk_native_dialog_hide (dialog);
file = gtk_file_dialog_open_finish (dialog, result, NULL);
if (file)
if (response == GTK_RESPONSE_ACCEPT)
{
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)
{
GtkFileDialog *dialog;
GtkFileChooserNative *chooser;
dialog = gtk_file_dialog_new ();
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");
gtk_file_dialog_open (dialog,
GTK_WINDOW (gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW)),
NULL,
NULL,
file_chooser_response, button);
g_signal_connect (chooser, "response", G_CALLBACK (file_chooser_response), button);
gtk_native_dialog_show (GTK_NATIVE_DIALOG (chooser));
}
static void

View File

@@ -64,11 +64,7 @@
<object class="GtkStackPage">
<property name="name">Color</property>
<property name="child">
<object class="GtkColorDialogButton" id="source_color">
<property name="dialog">
<object class="GtkColorDialog">
</object>
</property>
<object class="GtkColorButton" id="source_color">
<property name="valign">center</property>
<property name="rgba">purple</property>
</object>

View File

@@ -8,8 +8,6 @@
#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;
@@ -18,23 +16,19 @@ static void
message_dialog_clicked (GtkButton *button,
gpointer user_data)
{
GtkAlertDialog *dialog;
GtkWindow *parent;
static int count = 1;
char *detail;
GtkWidget *dialog;
static int i = 1;
parent = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW));
dialog = gtk_alert_dialog_new ("Test message");
detail = g_strdup_printf (ngettext ("Has been shown once", "Has been shown %d times", count), count);
gtk_alert_dialog_set_detail (dialog, detail);
g_free (detail);
gtk_alert_dialog_set_buttons (dialog, (const char *[]) {"_Cancel", "_OK", NULL });
gtk_alert_dialog_set_cancel_button (dialog, 0);
gtk_alert_dialog_set_default_button (dialog, 1);
gtk_alert_dialog_show (dialog, parent);
count++;
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK_CANCEL,
"Test message");
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
ngettext ("Has been shown once", "Has been shown %d times", i), i);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (dialog);
i++;
}
typedef struct {

View File

@@ -726,9 +726,7 @@ 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 ();

View File

@@ -10,8 +10,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *window = NULL;
static void

View File

@@ -68,13 +68,11 @@ 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)

View File

@@ -21,8 +21,6 @@
#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)
@@ -258,10 +256,10 @@ swap_colors (void)
GdkRGBA fg;
GdkRGBA bg;
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);
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);
}
static void
@@ -270,8 +268,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_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.});
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.});
}
static void
@@ -279,7 +277,7 @@ update_basic (void)
{
PangoFontDescription *desc;
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (demo->font));
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
gtk_adjustment_set_value (demo->size_adjustment,
pango_font_description_get_size (desc) / (double) PANGO_SCALE);
@@ -590,7 +588,7 @@ update_display (void)
end = PANGO_ATTR_INDEX_TO_TEXT_END;
}
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (demo->font));
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
value = gtk_adjustment_get_value (demo->size_adjustment);
pango_font_description_set_size (desc, value * PANGO_SCALE);
@@ -681,7 +679,7 @@ update_display (void)
GdkRGBA rgba;
char *fg, *bg, *css;
rgba = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground));
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->foreground), &rgba);
attr = pango_attr_foreground_new (65535 * rgba.red,
65535 * rgba.green,
65535 * rgba.blue);
@@ -694,7 +692,7 @@ update_display (void)
pango_attr_list_insert (attrs, attr);
fg = gdk_rgba_to_string (&rgba);
rgba = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background));
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->background), &rgba);
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));
@@ -769,6 +767,7 @@ 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);
@@ -780,7 +779,7 @@ get_pango_font (void)
PangoFontDescription *desc;
PangoContext *context;
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (demo->font));
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
context = gtk_widget_get_pango_context (demo->font);
return pango_context_load_font (context, desc);
@@ -832,17 +831,17 @@ update_script_combo (void)
GHashTable *tags;
GHashTableIter iter;
TagPair *pair;
PangoLanguage *language;
const char *lang;
char *lang;
hb_tag_t active;
language = gtk_font_dialog_button_get_language (GTK_FONT_DIALOG_BUTTON (demo->font));
lang = pango_language_to_string (language);
lang = gtk_font_chooser_get_language (GTK_FONT_CHOOSER (demo->font));
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 ();
@@ -1006,7 +1005,7 @@ update_features (void)
{
hb_tag_t tables[2] = { HB_OT_TAG_GSUB, HB_OT_TAG_GPOS };
hb_face_t *hb_face;
const char *feat;
char *feat;
hb_face = hb_font_get_face (hb_font);
@@ -1099,7 +1098,7 @@ update_features (void)
}
}
feat = gtk_font_dialog_button_get_font_features (GTK_FONT_DIALOG_BUTTON (demo->font));
feat = gtk_font_chooser_get_font_features (GTK_FONT_CHOOSER (demo->font));
if (feat)
{
for (l = demo->feature_items; l; l = l->next)
@@ -1125,6 +1124,8 @@ update_features (void)
}
}
}
g_free (feat);
}
}
@@ -1779,7 +1780,6 @@ 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);

View File

@@ -58,14 +58,11 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkFontDialogButton" id="font">
<property name="dialog">
<object class="GtkFontDialog">
</object>
</property>
<object class="GtkFontButton" id="font">
<property name="receives-default">1</property>
<property name="level">face</property>
<signal name="notify::font-desc" handler="font_features_font_changed" swapped="no"/>
<property name="font">Sans 12</property>
<property name="level">family|style</property>
<signal name="font-set" handler="font_features_font_changed" swapped="no"/>
</object>
</child>
<child>
@@ -195,11 +192,7 @@
</object>
</child>
<child>
<object class="GtkColorDialogButton" id="foreground">
<property name="dialog">
<object class="GtkColorDialog">
</object>
</property>
<object class="GtkColorButton" id="foreground">
<property name="valign">baseline</property>
<property name="rgba">black</property>
<signal name="notify::rgba" handler="color_set_cb"/>
@@ -221,11 +214,7 @@
</object>
</child>
<child>
<object class="GtkColorDialogButton" id="background">
<property name="dialog">
<object class="GtkColorDialog">
</object>
</property>
<object class="GtkColorButton" id="background">
<property name="valign">baseline</property>
<property name="rgba">white</property>
<signal name="notify::rgba" handler="color_set_cb"/>

View File

@@ -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_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (font_button));
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (font_button));
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
@@ -287,6 +287,8 @@ retry:
gtk_picture_set_pixbuf (GTK_PICTURE (image), pixbuf2);
g_object_unref (pixbuf2);
pango_font_description_free (desc);
}
static gboolean fading = FALSE;

View File

@@ -74,11 +74,7 @@
</object>
</child>
<child>
<object class="GtkFontDialogButton" id="font_button">
<property name="dialog">
<object class="GtkFontDialog">
</object>
</property>
<object class="GtkFontButton" id="font_button">
<layout>
<property name="column">2</property>
<property name="row">1</property>

View File

@@ -83,17 +83,24 @@ progressive_timeout (gpointer data)
if (bytes_read < 0)
{
GtkAlertDialog *dialog;
GtkWidget *dialog;
dialog = gtk_alert_dialog_new ("Failure reading image file 'alphatest.png': %s",
error->message);
gtk_alert_dialog_show (dialog, NULL);
g_object_unref (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);
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 */
@@ -103,17 +110,25 @@ progressive_timeout (gpointer data)
buf, bytes_read,
&error))
{
GtkAlertDialog *dialog;
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);
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 */
@@ -128,14 +143,22 @@ progressive_timeout (gpointer data)
error = NULL;
if (!g_input_stream_close (image_stream, NULL, &error))
{
GtkAlertDialog *dialog;
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);
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);
@@ -154,16 +177,25 @@ 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))
{
GtkAlertDialog *dialog;
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);
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;
@@ -184,14 +216,20 @@ progressive_timeout (gpointer data)
if (image_stream == NULL)
{
GtkAlertDialog *dialog;
GtkWidget *dialog;
dialog = gtk_alert_dialog_new ("%s",
error->message);
gtk_alert_dialog_show (dialog, NULL);
g_object_unref (dialog);
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"%s", error->message);
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 */

View File

@@ -12,8 +12,8 @@ on_bar_response (GtkInfoBar *info_bar,
int response_id,
gpointer user_data)
{
GtkAlertDialog *dialog;
char *detail;
GtkWidget *dialog;
GtkWidget *window;
if (response_id == GTK_RESPONSE_CLOSE)
{
@@ -21,12 +21,19 @@ on_bar_response (GtkInfoBar *info_bar,
return;
}
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);
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);
}
GtkWidget *

View File

@@ -7,22 +7,38 @@
#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)
{
GtkAlertDialog *dialog;
GtkWidget *dialog;
GtkWidget *parent;
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);
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);
return TRUE;
}

View File

@@ -117,16 +117,19 @@ activate_cb (GtkListView *list,
G_APP_LAUNCH_CONTEXT (context),
&error))
{
GtkAlertDialog *dialog;
GtkWidget *dialog;
/* And because error handling is important, even a simple demo has it:
* We display an error dialog that something went wrong.
*/
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);
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);
g_clear_error (&error);
gtk_widget_show (dialog);
}
g_object_unref (context);

View File

@@ -42,7 +42,7 @@ update_title_cb (GtkFilterListModel *model)
title = g_strdup_printf ("%u lines", g_list_model_get_n_items (G_LIST_MODEL (model)));
gtk_widget_set_visible (progress, pending != 0);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), total > 0 ? (total - pending) / (double) total : 0.);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), (total - pending) / (double) total);
gtk_window_set_title (GTK_WINDOW (window), title);
g_free (title);
}
@@ -141,35 +141,39 @@ load_file (GtkStringList *list,
}
static void
open_response_cb (GObject *source,
GAsyncResult *result,
void *user_data)
open_response_cb (GtkNativeDialog *dialog,
int response,
GtkStringList *stringlist)
{
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
GtkStringList *stringlist = GTK_STRING_LIST (user_data);
GFile *file;
gtk_native_dialog_hide (dialog);
file = gtk_file_dialog_open_finish (dialog, result, NULL);
if (file)
if (response == GTK_RESPONSE_ACCEPT)
{
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)
{
GtkFileDialog *dialog;
GtkFileChooserNative *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);
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));
}
GtkWidget *

View File

@@ -7,8 +7,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
enum {
COLOR_SET,
N_SIGNALS
@@ -53,8 +51,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,
const GdkRGBA *color);
static void drawing_area_set_color (DrawingArea *area,
GdkRGBA *color);
static void
drawing_area_ensure_surface (DrawingArea *area,
@@ -352,8 +350,8 @@ drawing_area_new (void)
}
static void
drawing_area_set_color (DrawingArea *area,
const GdkRGBA *color)
drawing_area_set_color (DrawingArea *area,
GdkRGBA *color)
{
if (gdk_rgba_equal (&area->draw_color, color))
return;
@@ -363,22 +361,21 @@ drawing_area_set_color (DrawingArea *area,
}
static void
color_button_color_set (GtkColorDialogButton *button,
GParamSpec *pspec,
DrawingArea *draw_area)
color_button_color_set (GtkColorButton *button,
DrawingArea *draw_area)
{
const GdkRGBA *color;
GdkRGBA color;
color = gtk_color_dialog_button_get_rgba (button);
drawing_area_set_color (draw_area, color);
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &color);
drawing_area_set_color (draw_area, &color);
}
static void
drawing_area_color_set (DrawingArea *area,
GdkRGBA *color,
GtkColorDialogButton *button)
drawing_area_color_set (DrawingArea *area,
GdkRGBA *color,
GtkColorButton *button)
{
gtk_color_dialog_button_set_rgba (button, color);
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), color);
}
GtkWidget *
@@ -397,13 +394,13 @@ do_paint (GtkWidget *toplevel)
headerbar = gtk_header_bar_new ();
colorbutton = gtk_color_dialog_button_new (gtk_color_dialog_new ());
g_signal_connect (colorbutton, "notify::rgba",
colorbutton = gtk_color_button_new ();
g_signal_connect (colorbutton, "color-set",
G_CALLBACK (color_button_color_set), draw_area);
g_signal_connect (draw_area, "color-set",
G_CALLBACK (drawing_area_color_set), colorbutton);
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (colorbutton),
&(GdkRGBA) { 0, 0, 0, 1 });
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (colorbutton),
&(GdkRGBA) { 0, 0, 0, 1 });
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), colorbutton);
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);

View File

@@ -13,24 +13,25 @@
static void
open_response_cb (GObject *source,
GAsyncResult *result,
void *data)
open_response_cb (GtkNativeDialog *dialog,
int response,
GtkPicture *picture)
{
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
GtkPicture *picture = data;
GFile *file;
gtk_native_dialog_hide (dialog);
file = gtk_file_dialog_open_finish (dialog, result, NULL);
if (file)
if (response == GTK_RESPONSE_ACCEPT)
{
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
@@ -38,25 +39,20 @@ show_file_open (GtkWidget *button,
GtkPicture *picture)
{
GtkFileFilter *filter;
GtkFileDialog *dialog;
GListStore *filters;
GtkFileChooserNative *dialog;
dialog = gtk_file_dialog_new ();
gtk_file_dialog_set_title (dialog, "Open node file");
dialog = gtk_file_chooser_native_new ("Open node file",
GTK_WINDOW (gtk_widget_get_root (button)),
GTK_FILE_CHOOSER_ACTION_OPEN,
"_Load",
"_Cancel");
filter = gtk_file_filter_new ();
gtk_file_filter_add_mime_type (filter, "image/svg+xml");
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);
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));
}
static GtkWidget *window;

View File

@@ -1,44 +1,34 @@
/* Pickers
* #Keywords: GtkColorDialog, GtkFontDialog, GtkFileDialog, GtkColorDialogButton, GtkFontDialogButton, chooser, button
* #Keywords: GtkColorChooser, GtkFontChooser, GtkApplicationChooser
*
* These widgets and async APIs are mainly intended for use in preference dialogs.
* They allow to select colors, fonts, files and applications.
* These widgets are mainly intended for use in preference dialogs.
* They allow to select colors, fonts and applications.
*
* This demo shows both the default appearance for these dialogs,
* as well as some of the customizations that are possible.
*/
#include <gtk/gtk.h>
static void
file_opened (GObject *source,
GAsyncResult *result,
void *data)
static gboolean
filter_font_cb (const PangoFontFamily *family,
const PangoFontFace *face,
gpointer data)
{
GFile *file;
const char *alias_families[] = {
"Cursive",
"Fantasy",
"Monospace",
"Sans",
"Serif",
"System-ui",
NULL
};
const char *family_name;
file = gtk_file_dialog_open_finish (GTK_FILE_DIALOG (source), result, NULL);
family_name = pango_font_family_get_name (PANGO_FONT_FAMILY (family));
if (file)
{
char *name = g_file_get_basename (file);
gtk_button_set_label (GTK_BUTTON (data), name);
g_object_set_data_full (G_OBJECT (data), "file", file, g_object_unref);
g_free (name);
}
}
static void
open_file (GtkButton *picker)
{
GtkWindow *parent = GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (picker)));
GtkFileDialog *dialog;
GFile *file;
dialog = gtk_file_dialog_new ();
file = (GFile *) g_object_get_data (G_OBJECT (picker), "file");
gtk_file_dialog_open (dialog, parent, file, NULL, file_opened, picker);
g_object_unref (dialog);
return g_strv_contains (alias_families, family_name);
}
#define COLOR(r,g,b) { r/255., g/255., b/255., 1.0 }
@@ -48,6 +38,27 @@ 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)
{
@@ -66,41 +77,55 @@ 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_dialog_button_new (gtk_color_dialog_new ());
picker = gtk_color_button_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_dialog_button_new (gtk_font_dialog_new ());
picker = gtk_font_button_new ();
gtk_grid_attach (GTK_GRID (table), picker, 1, 1, 1, 1);
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);
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);
picker = gtk_button_new_with_label ("None");
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
gtk_grid_attach (GTK_GRID (table), picker, 2, 1, 1, 1);
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);

View File

@@ -177,12 +177,19 @@ do_printing (GtkWidget *do_widget)
if (error)
{
GtkAlertDialog *dialog;
GtkWidget *dialog;
dialog = gtk_alert_dialog_new ("%s", error->message);
gtk_alert_dialog_show (dialog, GTK_WINDOW (do_widget));
g_object_unref (dialog);
dialog = gtk_message_dialog_new (GTK_WINDOW (do_widget),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"%s", error->message);
g_error_free (error);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (dialog);
}

View File

@@ -35,7 +35,6 @@ do_spinner (GtkWidget *do_widget)
if (!window)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
window = gtk_dialog_new_with_buttons ("Spinner",
GTK_WINDOW (do_widget),
0,
@@ -49,7 +48,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
G_GNUC_END_IGNORE_DEPRECATIONS
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_margin_start (vbox, 5);

View File

@@ -10,63 +10,60 @@
static GtkWidget *window = NULL;
static void
open_dialog_response_cb (GObject *source,
GAsyncResult *result,
void *user_data)
open_dialog_response_cb (GtkNativeDialog *dialog,
int response,
GtkWidget *video)
{
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
GtkWidget *video = user_data;
GFile *file;
gtk_native_dialog_hide (dialog);
file = gtk_file_dialog_open_finish (dialog, result, NULL);
if (file)
if (response == GTK_RESPONSE_ACCEPT)
{
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)
{
GtkFileDialog *dialog;
GtkFileChooserNative *dialog;
GtkFileFilter *filter;
GListStore *filters;
dialog = gtk_file_dialog_new ();
gtk_file_dialog_set_title (dialog, "Select a video");
filters = g_list_store_new (GTK_TYPE_FILE_FILTER);
dialog = gtk_file_chooser_native_new ("Select a video",
GTK_WINDOW (gtk_widget_get_root (button)),
GTK_FILE_CHOOSER_ACTION_OPEN,
"_Open",
"_Cancel");
filter = gtk_file_filter_new ();
gtk_file_filter_add_pattern (filter, "*");
gtk_file_filter_set_name (filter, "All Files");
g_list_store_append (filters, filter);
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), 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");
g_list_store_append (filters, filter);
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), 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");
g_list_store_append (filters, filter);
gtk_file_dialog_set_current_filter (dialog, filter);
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), 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_dialog_response_cb, video);
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));
}
static void

View File

@@ -548,36 +548,45 @@ node_editor_window_load (NodeEditorWindow *self,
}
static void
open_response_cb (GObject *source,
GAsyncResult *result,
void *user_data)
open_response_cb (GtkWidget *dialog,
int response,
NodeEditorWindow *self)
{
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
NodeEditorWindow *self = user_data;
GFile *file;
gtk_widget_hide (dialog);
file = gtk_file_dialog_open_finish (dialog, result, NULL);
if (file)
if (response == GTK_RESPONSE_ACCEPT)
{
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)
{
GtkFileDialog *dialog;
GFile *cwd;
GtkWidget *dialog;
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);
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);
g_object_unref (cwd);
gtk_file_dialog_open (dialog, GTK_WINDOW (self),
NULL, NULL, open_response_cb, self);
g_object_unref (dialog);
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), self);
gtk_widget_show (dialog);
}
static void
@@ -588,22 +597,21 @@ open_cb (GtkWidget *button,
}
static void
save_response_cb (GObject *source,
GAsyncResult *result,
void *user_data)
save_response_cb (GtkWidget *dialog,
int response,
NodeEditorWindow *self)
{
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
NodeEditorWindow *self = user_data;
GFile *file;
gtk_widget_hide (dialog);
file = gtk_file_dialog_save_finish (dialog, result, NULL);
if (file)
if (response == GTK_RESPONSE_ACCEPT)
{
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,
@@ -612,40 +620,49 @@ save_response_cb (GObject *source,
&error);
if (error != NULL)
{
GtkAlertDialog *alert;
GtkWidget *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);
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);
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)
{
GtkFileDialog *dialog;
GFile *cwd;
GtkWidget *dialog;
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);
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);
g_object_unref (cwd);
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);
g_signal_connect (dialog, "response", G_CALLBACK (save_response_cb), self);
gtk_widget_show (dialog);
}
static GdkTexture *
@@ -707,29 +724,34 @@ create_cairo_texture (NodeEditorWindow *self)
}
static void
export_image_response_cb (GObject *source,
GAsyncResult *result,
void *user_data)
export_image_response_cb (GtkWidget *dialog,
int response,
GdkTexture *texture)
{
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
GdkTexture *texture = user_data;
GFile *file;
gtk_widget_hide (dialog);
file = gtk_file_dialog_save_finish (dialog, result, NULL);
if (file)
if (response == GTK_RESPONSE_ACCEPT)
{
GFile *file;
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
if (!gdk_texture_save_to_png (texture, g_file_peek_path (file)))
{
GtkAlertDialog *alert;
GtkWidget *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);
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);
}
g_object_unref (file);
}
gtk_window_destroy (GTK_WINDOW (dialog));
g_object_unref (texture);
}
@@ -738,23 +760,24 @@ export_image_cb (GtkWidget *button,
NodeEditorWindow *self)
{
GdkTexture *texture;
GtkFileDialog *dialog;
GtkWidget *dialog;
texture = create_texture (self);
if (texture == NULL)
return;
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);
}
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);
}
static void
clip_image_cb (GtkWidget *button,

View File

@@ -96,10 +96,12 @@ 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)
@@ -115,28 +117,36 @@ 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);
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);
}
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);
}
}
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);
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);
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);
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);
}
}
@@ -144,6 +154,7 @@ static void
save_file (GFile *save_filename)
{
char *text = get_text ();
GtkWidget *error_dialog;
GError *error;
error = NULL;
@@ -169,12 +180,18 @@ 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;
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);
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);
g_error_free (error);
g_object_unref (info);
}
@@ -323,24 +340,21 @@ 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);
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);
font = gtk_font_button_new_with_font (data->font);
gtk_box_append (GTK_BOX (hbox), font);
gtk_widget_show (font);
data->font_button = font;
return vbox;
@@ -351,12 +365,11 @@ custom_widget_apply (GtkPrintOperation *operation,
GtkWidget *widget,
PrintData *data)
{
PangoFontDescription *desc;
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (data->font_button));
const char *selected_font;
selected_font = gtk_font_chooser_get_font (GTK_FONT_CHOOSER (data->font_button));
g_free (data->font);
data->font = pango_font_description_to_string (desc);
data->font = g_strdup (selected_font);
}
static void
@@ -364,18 +377,23 @@ print_done (GtkPrintOperation *op,
GtkPrintOperationResult res,
PrintData *print_data)
{
GError *error = NULL;
if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
{
GtkAlertDialog *alert;
GError *error = NULL;
GtkWidget *error_dialog;
gtk_print_operation_get_error (op, &error);
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);
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);
}
else if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
{
@@ -481,19 +499,17 @@ activate_preview (GSimpleAction *action,
}
static void
on_save_response (GObject *source,
GAsyncResult *result,
void *user_data)
on_save_response (GtkWidget *dialog,
int response)
{
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
GFile *file;
file = gtk_file_dialog_save_finish (dialog, result, NULL);
if (file)
if (response == GTK_RESPONSE_OK)
{
save_file (file);
g_object_unref (file);
GFile *save_filename = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
save_file (save_filename);
g_object_unref (save_filename);
}
gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -501,17 +517,21 @@ activate_save_as (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GtkFileDialog *dialog;
GtkWidget *dialog;
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);
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);
}
static void
@@ -526,19 +546,17 @@ activate_save (GSimpleAction *action,
}
static void
on_open_response (GObject *source,
GAsyncResult *result,
void *user_data)
on_open_response (GtkWidget *dialog,
int response)
{
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
GFile *file;
file = gtk_file_dialog_open_finish (dialog, result, NULL);
if (file)
if (response == GTK_RESPONSE_OK)
{
load_file (file);
g_object_unref (file);
GFile *open_filename = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
load_file (open_filename);
g_object_unref (open_filename);
}
gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -546,16 +564,21 @@ activate_open (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GtkFileDialog *dialog;
GtkWidget *dialog;
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);
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);
}
static void

View File

@@ -214,19 +214,10 @@ activate_background (GSimpleAction *action,
}
static void
file_chooser_response (GObject *source,
GAsyncResult *result,
void *user_data)
file_chooser_response (GtkNativeDialog *self,
int response)
{
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);
}
gtk_native_dialog_destroy (self);
}
static void
@@ -234,11 +225,17 @@ activate_open_file (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GtkFileDialog *dialog;
GtkFileChooserNative *chooser;
dialog = gtk_file_dialog_new ();
gtk_file_dialog_open (dialog, NULL, NULL, NULL, file_chooser_response, NULL);
g_object_unref (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));
}
static void
@@ -1096,9 +1093,7 @@ 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);
}
}
@@ -1467,9 +1462,7 @@ close_selection_dialog (GtkWidget *dialog, int response, GtkWidget *tv)
if (response == GTK_RESPONSE_CANCEL)
return;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
box = gtk_widget_get_first_child (gtk_dialog_get_content_area (GTK_DIALOG (dialog)));
G_GNUC_END_IGNORE_DEPRECATIONS
g_assert (GTK_IS_FLOW_BOX (box));
children = gtk_flow_box_get_selected_children (GTK_FLOW_BOX (box));

View File

@@ -8,7 +8,8 @@ are organized in a hierarchy. The window widget is the main container.
The user interface is then built by adding buttons, drop-down menus, input
fields, and other widgets to the window. If you are creating complex user
interfaces it is recommended to use GtkBuilder and its GTK-specific markup
description language, instead of assembling the interface manually.
description language, instead of assembling the interface manually. You can
also use a visual user interface editor, like [Glade](https://glade.gnome.org/).
GTK is event-driven. The toolkit listens for events such as a click
on a button, and passes the event to your application.
@@ -711,20 +712,11 @@ A common location to install UI descriptions and similar data is
`/usr/share/appname`.
It is also possible to embed the UI description in the source code as a
string and use [`method@Gtk.Builder.add_from_string`] to load it. But keeping
the UI description in a separate file has several advantages:
- it is possible to make minor adjustments to the UI without recompiling your
program
- it is easier to isolate the UI code from the business logic of your
application
- it is easier to restructure your UI into separate classes using composite
widget templates
Using [GResource](https://docs.gtk.org/gio/struct.Resource.html) it is possible
to combine the best of both worlds: you can keep the UI definition files
separate inside your source code repository, and then ship them embedded into
your application.
string and use [`method@Gtk.Builder.add_from_string`] to load it. But keeping the
UI description in a separate file has several advantages: It is then possible
to make minor adjustments to the UI without recompiling your program, and,
more importantly, graphical UI editors such as [Glade](http://glade.gnome.org)
can load the file and allow you to create and modify your UI by point-and-click.
## Building applications

View File

@@ -72,28 +72,3 @@ added.
GTK 5 will no longer provide this functionality. The recommendations
is to use a global stylesheet (i.e. gtk_style_context_add_provider_for_display())
and rely on style classes to make your CSS apply only where desired.
## Chooser interfaces are going away
The GtkColorChooser, GtkFontChooser, GtkFileChooser and GtkAppChooser
interfaces and their implementations as dialogs, buttons and widgets
are phased out. The are being replaced by a new family of async APIs
that will be more convenient to use from language bindings, in particular
for languages that have concepts like promises. The new APIs are
[class@Gtk.ColorDialog], [class@Gtk.FontDialog] and [class@Gtk.FileDialog],
There are also equivalents for some of the 'button' widgets:
[class@Gtk.ColorDialogButton], [class@Gtk.FontDialogButton].
## GtkMessageDialog is going away
Like the Chooser interfaces, GtkMessageDialog has been replaced by
a new async API that will be more convenient, in particular for
language binding. The new API is [class@Gtk.AlertDialog].
## GtkDialog is going away
After gtk_dialog_run() was removed, the usefulness of GtkDialog
is much reduced, and it has awkward, archaice APIs. Therefore,
it is dropped. The recommended replacement is to just create
your own window and add buttons as required, either in the header
or elsewhere.

View File

@@ -6,11 +6,19 @@ action_activated (GSimpleAction *action,
gpointer user_data)
{
GtkWindow *parent = user_data;
GtkAlertDialog *dialog;
GtkWidget *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);
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);
}
static GActionEntry doc_entries[] = {

View File

@@ -1,8 +1,6 @@
#include <stdlib.h>
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct
{
GtkApplication parent_instance;

View File

@@ -29,7 +29,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/deprecated/gtkdialog.h>
#include <gtk/gtkdialog.h>
#include <gio/gio.h>
G_BEGIN_DECLS

View File

@@ -268,7 +268,6 @@ gtk_tree_popover_init (GtkTreePopover *popover)
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_propagate_natural_width (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_scrolled_window_set_propagate_natural_height (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_popover_set_child (GTK_POPOVER (popover), sw);

View File

@@ -19,15 +19,9 @@ 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/gtkdialog.c',
'deprecated/gtkentrycompletion.c',
'deprecated/gtkfilechooser.c',
'deprecated/gtkfontbutton.c',
'deprecated/gtkfontchooser.c',
'deprecated/gtkiconview.c',
'deprecated/gtkliststore.c',
'deprecated/gtkrender.c',
@@ -66,25 +60,11 @@ 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/gtkdialog.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',

View File

@@ -38,7 +38,6 @@
#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>
@@ -79,10 +78,11 @@
#include <gtk/gtkcenterbox.h>
#include <gtk/gtkcenterlayout.h>
#include <gtk/gtkcheckbutton.h>
#include <gtk/deprecated/gtkcolorbutton.h>
#include <gtk/deprecated/gtkcolorchooser.h>
#include <gtk/deprecated/gtkcolorchooserdialog.h>
#include <gtk/deprecated/gtkcolorchooserwidget.h>
#include <gtk/gtkchoice.h>
#include <gtk/gtkcolorbutton.h>
#include <gtk/gtkcolorchooser.h>
#include <gtk/gtkcolorchooserdialog.h>
#include <gtk/gtkcolorchooserwidget.h>
#include <gtk/gtkcolordialog.h>
#include <gtk/gtkcolordialogbutton.h>
#include <gtk/gtkcolorutils.h>
@@ -91,14 +91,14 @@
#include <gtk/gtkcolumnviewsorter.h>
#include <gtk/deprecated/gtkcombobox.h>
#include <gtk/deprecated/gtkcomboboxtext.h>
#include <gtk/gtkchoice.h>
#include <gtk/gtkconstraintlayout.h>
#include <gtk/gtkconstraint.h>
#include <gtk/gtkcssprovider.h>
#include <gtk/gtkcustomlayout.h>
#include <gtk/gtkcustomsorter.h>
#include <gtk/gtkdebug.h>
#include <gtk/deprecated/gtkdialog.h>
#include <gtk/gtkdialogerror.h>
#include <gtk/gtkdialog.h>
#include <gtk/gtkdirectorylist.h>
#include <gtk/gtkdragicon.h>
#include <gtk/gtkdragsource.h>
@@ -124,10 +124,10 @@
#include <gtk/gtkexpression.h>
#include <gtk/gtkfixed.h>
#include <gtk/gtkfixedlayout.h>
#include <gtk/deprecated/gtkfilechooser.h>
#include <gtk/deprecated/gtkfilechooserdialog.h>
#include <gtk/deprecated/gtkfilechoosernative.h>
#include <gtk/deprecated/gtkfilechooserwidget.h>
#include <gtk/gtkfilechooser.h>
#include <gtk/gtkfilechooserdialog.h>
#include <gtk/gtkfilechoosernative.h>
#include <gtk/gtkfilechooserwidget.h>
#include <gtk/gtkfiledialog.h>
#include <gtk/gtkfilefilter.h>
#include <gtk/gtkfilter.h>
@@ -135,10 +135,10 @@
#include <gtk/gtkcustomfilter.h>
#include <gtk/gtkflattenlistmodel.h>
#include <gtk/gtkflowbox.h>
#include <gtk/deprecated/gtkfontbutton.h>
#include <gtk/deprecated/gtkfontchooser.h>
#include <gtk/deprecated/gtkfontchooserdialog.h>
#include <gtk/deprecated/gtkfontchooserwidget.h>
#include <gtk/gtkfontbutton.h>
#include <gtk/gtkfontchooser.h>
#include <gtk/gtkfontchooserdialog.h>
#include <gtk/gtkfontchooserwidget.h>
#include <gtk/gtkfontdialog.h>
#include <gtk/gtkfontdialogbutton.h>
#include <gtk/gtkframe.h>
@@ -164,6 +164,7 @@
#include <gtk/gtkimcontextsimple.h>
#include <gtk/gtkimmulticontext.h>
#include <gtk/gtkinfobar.h>
#include <gtk/gtkinfodialog.h>
#include <gtk/gtkinscription.h>
#include <gtk/gtklabel.h>
#include <gtk/gtklayoutmanager.h>
@@ -183,7 +184,7 @@
#include <gtk/gtkmediafile.h>
#include <gtk/gtkmediastream.h>
#include <gtk/gtkmenubutton.h>
#include <gtk/deprecated/gtkmessagedialog.h>
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtkmountoperation.h>
#include <gtk/gtkmultifilter.h>
#include <gtk/gtkmultiselection.h>

View File

@@ -1,772 +0,0 @@
/*
* 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 "gtkmessagewindowprivate.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, -1);
}
static void
response_cb (GTask *task,
int response)
{
GCancellable *cancellable;
GtkWindow *window;
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
button_response (GtkButton *button,
GTask *task)
{
int response = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "response"));
response_cb (task, response);
}
static GtkMessageWindow *
create_message_window (GtkAlertDialog *self,
GtkWindow *parent,
GTask *task)
{
GtkMessageWindow *window;
window = gtk_message_window_new ();
if (parent)
gtk_window_set_transient_for (GTK_WINDOW (window), parent);
gtk_window_set_modal (GTK_WINDOW (window), TRUE);
gtk_message_window_set_message (window, self->message);
gtk_message_window_set_detail (window, self->detail);
if (self->buttons && self->buttons[0])
{
self->cancel_return = -1;
for (int i = 0; self->buttons[i]; i++)
{
GtkWidget *button;
button = gtk_button_new_with_mnemonic (self->buttons[i]);
g_object_set_data (G_OBJECT (button), "response", GINT_TO_POINTER (i));
g_signal_connect (button, "clicked", G_CALLBACK (button_response), task);
gtk_message_window_add_button (window, button);
if (self->default_button == i)
gtk_window_set_default_widget (GTK_WINDOW (window), button);
if (self->cancel_button == i)
self->cancel_return = i;
}
}
else
{
GtkWidget *button;
button = gtk_button_new_with_mnemonic (_("_Close"));
g_signal_connect (button, "clicked", G_CALLBACK (button_response), task);
gtk_message_window_add_button (window, button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
self->cancel_return = 0;
}
return window;
}
/* }}} */
/* {{{ 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)
{
GtkWidget *window;
GTask *task;
g_return_if_fail (GTK_IS_ALERT_DIALOG (self));
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gtk_alert_dialog_choose);
if (cancellable)
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
window = GTK_WIDGET (create_message_window (self, parent, task));
g_task_set_task_data (task, window, (GDestroyNotify) gtk_window_destroy);
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: */

View File

@@ -28,9 +28,7 @@
#include <glib/gi18n-lib.h>
#include "gtkbookmarksmanagerprivate.h"
#include "deprecated/gtkfilechooser.h" /* for the GError types */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
#include "gtkfilechooser.h" /* for the GError types */
static void
_gtk_bookmark_free (gpointer data)

View File

@@ -225,6 +225,7 @@
#include "gtkicontheme.h"
#include "gtkiconthemeprivate.h"
#include "gtkdebug.h"
#include "gtkstringlist.h"
static void gtk_builder_finalize (GObject *object);
@@ -551,6 +552,19 @@ gtk_builder_get_parameters (GtkBuilder *builder,
if (G_PARAM_SPEC_VALUE_TYPE (prop->pspec) == GTK_TYPE_EXPRESSION)
gtk_value_set_expression (&property_value, prop->value);
else if (G_PARAM_SPEC_VALUE_TYPE (prop->pspec) == G_TYPE_STRV)
{
GStrvBuilder *strv = g_strv_builder_new ();
for (guint j = 0; j < g_list_model_get_n_items (G_LIST_MODEL (prop->value)); j++)
{
GtkStringObject *s = g_list_model_get_item (G_LIST_MODEL (prop->value), j);
g_strv_builder_add (strv, gtk_string_object_get_string (s));
g_object_unref (s);
}
g_value_set_boxed (&property_value, g_strv_builder_end (strv));
}
else
g_assert_not_reached ();
}

View File

@@ -1039,6 +1039,10 @@ free_property_info (PropertyInfo *info)
{
if (G_PARAM_SPEC_VALUE_TYPE (info->pspec) == GTK_TYPE_EXPRESSION)
gtk_expression_unref (info->value);
else if (G_PARAM_SPEC_VALUE_TYPE (info->pspec) == G_TYPE_STRV)
{
/* info->value is in the hash table of objects */
}
else
g_assert_not_reached();
}
@@ -1723,8 +1727,11 @@ parse_custom (GtkBuildableParseContext *context,
object = ((ObjectInfo*)child_info->parent)->object;
child = child_info->object;
}
else
return FALSE;
else if (parent_info->tag_type == TAG_PROPERTY)
{
g_print ("custom markup in <property>\n");
return FALSE;
}
if (!gtk_buildable_custom_tag_start (GTK_BUILDABLE (object),
data->builder,
@@ -1947,7 +1954,10 @@ end_element (GtkBuildableParseContext *context,
if (child_info)
child_info->object = object_info->object;
if (prop_info)
g_string_assign (prop_info->text, object_info->id);
{
g_string_assign (prop_info->text, object_info->id);
prop_info->value = object_info->object;
}
if (GTK_IS_BUILDABLE (object_info->object) &&
GTK_BUILDABLE_GET_IFACE (object_info->object)->parser_finished)
@@ -2074,7 +2084,7 @@ end_element (GtkBuildableParseContext *context,
g_set_error (error,
GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_UNHANDLED_TAG,
"Unhandled tag: <%s>", element_name);
"Unhandled end tag: </%s>", element_name);
_gtk_builder_prefix_error (data->builder, context, error);
}
}

93
gtk/gtkchoice.c Normal file
View File

@@ -0,0 +1,93 @@
/*
* 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 "gtkchoice.h"
struct _GtkChoice
{
GObject parent_instance;
char *label;
char **options;
};
G_DEFINE_TYPE (GtkChoice, gtk_choice, G_TYPE_OBJECT)
static void
gtk_choice_init (GtkChoice *self)
{
}
static void
gtk_choice_finalize (GObject *object)
{
GtkChoice *self = GTK_CHOICE (object);
g_free (self->label);
g_strfreev (self->options);
G_OBJECT_CLASS (gtk_choice_parent_class)->finalize (object);
}
static void
gtk_choice_class_init (GtkChoiceClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = gtk_choice_finalize;
}
/* }}} */
/* {{{ Public API */
GtkChoice *
gtk_choice_new (const char *label,
const char * const *options)
{
GtkChoice *self;
self = g_object_new (GTK_TYPE_CHOICE, NULL);
self->label = g_strdup (label);
self->options = g_strdupv ((char **)options);
return self;
}
const char *
gtk_choice_get_label (GtkChoice *choice)
{
g_return_val_if_fail (GTK_IS_CHOICE (choice), NULL);
return choice->label;
}
const char * const *
gtk_choice_get_options (GtkChoice *choice)
{
g_return_val_if_fail (GTK_IS_CHOICE (choice), NULL);
return (const char * const *)choice->options;
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */

View File

@@ -26,37 +26,20 @@
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;
#define GTK_TYPE_CHOICE (gtk_choice_get_type ())
GDK_AVAILABLE_IN_4_10
GQuark gtk_dialog_error_quark (void);
G_DECLARE_FINAL_TYPE (GtkChoice, gtk_choice, GTK, CHOICE, GObject)
GDK_AVAILABLE_IN_4_10
GtkChoice * gtk_choice_new (const char *label,
const char * const *options);
GDK_AVAILABLE_IN_4_10
const char * gtk_choice_get_label (GtkChoice *choice);
GDK_AVAILABLE_IN_4_10
const char * const *
gtk_choice_get_options (GtkChoice *choice);
G_END_DECLS

View File

@@ -46,8 +46,6 @@
#include "gtkwidgetprivate.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* GtkColorButton:
*
@@ -69,8 +67,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* `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;
@@ -357,8 +353,6 @@ 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)
@@ -567,8 +561,6 @@ 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,
@@ -595,8 +587,6 @@ 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)
@@ -612,8 +602,6 @@ 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,
@@ -639,8 +627,6 @@ 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)

View File

@@ -48,19 +48,19 @@ typedef struct _GtkColorButton GtkColorButton;
GDK_AVAILABLE_IN_ALL
GType gtk_color_button_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_color_button_new (void);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_color_button_new_with_rgba (const GdkRGBA *rgba);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_color_button_set_title (GtkColorButton *button,
const char *title);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
const char *gtk_color_button_get_title (GtkColorButton *button);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
gboolean gtk_color_button_get_modal (GtkColorButton *button);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_color_button_set_modal (GtkColorButton *button,
gboolean modal);

View File

@@ -36,9 +36,6 @@
* 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
@@ -119,8 +116,6 @@ _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,
@@ -137,8 +132,6 @@ 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,
@@ -158,8 +151,6 @@ 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)
@@ -179,8 +170,6 @@ 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,
@@ -218,8 +207,6 @@ 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,

View File

@@ -63,20 +63,20 @@ struct _GtkColorChooserInterface
GDK_AVAILABLE_IN_ALL
GType gtk_color_chooser_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_color_chooser_get_rgba (GtkColorChooser *chooser,
GdkRGBA *color);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_color_chooser_set_rgba (GtkColorChooser *chooser,
const GdkRGBA *color);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
gboolean gtk_color_chooser_get_use_alpha (GtkColorChooser *chooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_color_chooser_set_use_alpha (GtkColorChooser *chooser,
gboolean use_alpha);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_color_chooser_add_palette (GtkColorChooser *chooser,
GtkOrientation orientation,
int colors_per_line,

View File

@@ -17,18 +17,16 @@
#include "config.h"
#include "deprecated/gtkdialog.h"
#include "deprecated/gtkdialogprivate.h"
#include "gtkdialog.h"
#include "gtkdialogprivate.h"
#include "gtkbutton.h"
#include "gtkbox.h"
#include "gtkprivate.h"
#include "gtksettings.h"
#include "deprecated/gtkcolorchooserprivate.h"
#include "deprecated/gtkcolorchooserdialog.h"
#include "deprecated/gtkcolorchooserwidget.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
#include "gtkcolorchooserprivate.h"
#include "gtkcolorchooserdialog.h"
#include "gtkcolorchooserwidget.h"
/**
* GtkColorChooserDialog:
@@ -45,10 +43,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* 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;
@@ -287,8 +281,6 @@ 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,

View File

@@ -22,7 +22,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/deprecated/gtkdialog.h>
#include <gtk/gtkdialog.h>
G_BEGIN_DECLS
@@ -35,7 +35,7 @@ typedef struct _GtkColorChooserDialog GtkColorChooserDialog;
GDK_AVAILABLE_IN_ALL
GType gtk_color_chooser_dialog_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_color_chooser_dialog_new (const char *title,
GtkWindow *parent);

View File

@@ -18,8 +18,8 @@
#include "config.h"
#include "deprecated/gtkcolorchooserprivate.h"
#include "deprecated/gtkcolorchooserwidget.h"
#include "gtkcolorchooserprivate.h"
#include "gtkcolorchooserwidget.h"
#include "gtkcoloreditorprivate.h"
#include "gtkcolorswatchprivate.h"
#include "gtkgrid.h"
@@ -34,8 +34,6 @@
#include <math.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* GtkColorChooserWidget:
*
@@ -63,8 +61,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* # CSS names
*
* `GtkColorChooserWidget` has a single CSS node with name colorchooser.
*
* Deprecated: 4.10: Direct use of `GtkColorChooserWidget` is deprecated.
*/
typedef struct _GtkColorChooserWidgetClass GtkColorChooserWidgetClass;

View File

@@ -35,7 +35,7 @@ typedef struct _GtkColorChooserWidget GtkColorChooserWidget;
GDK_AVAILABLE_IN_ALL
GType gtk_color_chooser_widget_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_color_chooser_widget_new (void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorChooserWidget, g_object_unref)

View File

@@ -21,10 +21,9 @@
#include "gtkcolordialog.h"
#include "deprecated/gtkcolorchooserdialog.h"
#include "deprecated/gtkcolorchooser.h"
#include "gtkcolorchooserdialog.h"
#include "gtkcolorchooser.h"
#include "gtkbutton.h"
#include "gtkdialogerror.h"
#include <glib/gi18n-lib.h>
/**
@@ -35,10 +34,10 @@
* 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]
* The dialog is shown with the [function@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].
* [function@Gtk.ColorDialog.choose_rgba_finish].
*
* See [class@Gtk.ColorDialogButton] for a convenient control
* that uses `GtkColorDialog` and presents the results.
@@ -73,6 +72,7 @@ G_DEFINE_TYPE (GtkColorDialog, gtk_color_dialog, G_TYPE_OBJECT)
static void
gtk_color_dialog_init (GtkColorDialog *self)
{
self->title = g_strdup (_("Pick a Color"));
self->modal = TRUE;
self->with_alpha = TRUE;
}
@@ -156,7 +156,7 @@ gtk_color_dialog_class_init (GtkColorDialogClass *class)
* 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].
* dialog that is presented by [function@Gtk.ColorDialog.choose_rgba].
*
* Since: 4.10
*/
@@ -196,7 +196,7 @@ gtk_color_dialog_class_init (GtkColorDialogClass *class)
}
/* }}} */
/* {{{ API: Constructor */
/* {{{ Constructor */
/**
* gtk_color_dialog_new:
@@ -214,7 +214,7 @@ gtk_color_dialog_new (void)
}
/* }}} */
/* {{{ API: Getters and setters */
/* {{{ Getters and setters */
/**
* gtk_color_dialog_get_title:
@@ -254,7 +254,7 @@ gtk_color_dialog_set_title (GtkColorDialog *self,
g_return_if_fail (GTK_IS_COLOR_DIALOG (self));
g_return_if_fail (title != NULL);
if (g_strcmp0 (self->title, title) == 0)
if (g_str_equal (self->title, title))
return;
new_title = g_strdup (title);
@@ -351,7 +351,7 @@ gtk_color_dialog_set_with_alpha (GtkColorDialog *self,
}
/* }}} */
/* {{{ Async implementation */
/* {{{ Async API */
static void response_cb (GTask *task,
int response);
@@ -360,7 +360,7 @@ static void
cancelled_cb (GCancellable *cancellable,
GTask *task)
{
response_cb (task, GTK_RESPONSE_CLOSE);
response_cb (task, GTK_RESPONSE_CANCEL);
}
static void
@@ -379,50 +379,16 @@ response_cb (GTask *task,
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);
g_task_return_pointer (task, &color, NULL);
}
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_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
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`
@@ -436,7 +402,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
* 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]
* It should call [function@Gtk.ColorDialog.choose_rgba_finish]
* to obtain the result.
*
* Since: 4.10
@@ -454,7 +420,11 @@ gtk_color_dialog_choose_rgba (GtkColorDialog *self,
g_return_if_fail (GTK_IS_COLOR_DIALOG (self));
window = create_color_chooser (self, parent, initial_color);
window = gtk_color_chooser_dialog_new (self->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);
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gtk_color_dialog_choose_rgba);
@@ -471,25 +441,33 @@ gtk_color_dialog_choose_rgba (GtkColorDialog *self,
* gtk_color_dialog_choose_rgba_finish:
* @self: a `GtkColorDialog`
* @result: a `GAsyncResult`
* @color: (out caller-allocates): return location for the color
* @error: return location for an error
*
* Finishes the [method@Gtk.ColorDialog.choose_rgba] call and
* Finishes the [function@Gtk.ColorDialog.choose_rgba] call and
* returns the resulting color.
*
* Returns: (nullable) (transfer full): the selected color, or
* `NULL` and @error is set
* Returns: `TRUE` if a color was selected. Otherwise,
* `FALSE` is returned and @error is set
*
* Since: 4.10
*/
GdkRGBA *
gboolean
gtk_color_dialog_choose_rgba_finish (GtkColorDialog *self,
GAsyncResult *result,
GdkRGBA *color,
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);
GdkRGBA *ret;
return g_task_propagate_pointer (G_TASK (result), error);
ret = g_task_propagate_pointer (G_TASK (result), error);
if (ret)
{
*color = *ret;
return TRUE;
}
return FALSE;
}
/* }}} */

View File

@@ -65,8 +65,9 @@ void gtk_color_dialog_choose_rgba (GtkColorDialog *s
gpointer user_data);
GDK_AVAILABLE_IN_4_10
GdkRGBA * gtk_color_dialog_choose_rgba_finish (GtkColorDialog *self,
gboolean gtk_color_dialog_choose_rgba_finish (GtkColorDialog *self,
GAsyncResult *result,
GdkRGBA *color,
GError **error);
G_END_DECLS

View File

@@ -32,7 +32,6 @@
#include "gtkprivate.h"
#include "gtksnapshot.h"
#include "gtkwidgetprivate.h"
#include "gdk/gdkrgbaprivate.h"
static gboolean drop (GtkDropTarget *dest,
@@ -46,8 +45,6 @@ static GdkContentProvider *
double y,
GtkColorDialogButton *self);
static void button_clicked (GtkColorDialogButton *self);
static void update_button_sensitivity
(GtkColorDialogButton *self);
/**
* GtkColorDialogButton:
@@ -82,7 +79,6 @@ struct _GtkColorDialogButton
GtkWidget *swatch;
GtkColorDialog *dialog;
GCancellable *cancellable;
GdkRGBA color;
};
@@ -90,7 +86,7 @@ struct _GtkColorDialogButton
enum
{
PROP_DIALOG = 1,
PROP_RGBA,
PROP_COLOR,
NUM_PROPERTIES
};
@@ -106,8 +102,6 @@ gtk_color_dialog_button_init (GtkColorDialogButton *self)
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));
@@ -141,21 +135,6 @@ gtk_color_dialog_button_init (GtkColorDialogButton *self)
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,
@@ -170,8 +149,8 @@ gtk_color_dialog_button_set_property (GObject *object,
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));
case PROP_COLOR:
gtk_color_dialog_button_set_color (self, g_value_get_boxed (value));
break;
default:
@@ -194,7 +173,7 @@ gtk_color_dialog_button_get_property (GObject *object,
g_value_set_object (value, self->dialog);
break;
case PROP_RGBA:
case PROP_COLOR:
g_value_set_boxed (value, &self->color);
break;
@@ -219,7 +198,6 @@ 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);
@@ -238,7 +216,6 @@ gtk_color_dialog_button_class_init (GtkColorDialogButtonClass *class)
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)
@@ -254,7 +231,7 @@ gtk_color_dialog_button_class_init (GtkColorDialogButtonClass *class)
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)
* GtkColorDialogButton:color: (attributes org.gtk.Property.get=gtk_color_dialog_button_get_color org.gtk.Property.set=gtk_color_dialog_button_set_color)
*
* The selected color.
*
@@ -262,13 +239,13 @@ gtk_color_dialog_button_class_init (GtkColorDialogButtonClass *class)
* 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
* Listen to `notify::color` to get informed about changes
* to the buttons color.
*
* Since: 4.10
*/
properties[PROP_RGBA] =
g_param_spec_boxed ("rgba", NULL, NULL,
properties[PROP_COLOR] =
g_param_spec_boxed ("color", NULL, NULL,
GDK_TYPE_RGBA,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
@@ -315,7 +292,7 @@ drop (GtkDropTarget *dest,
{
GdkRGBA *color = g_value_get_boxed (value);
gtk_color_dialog_button_set_rgba (self, color);
gtk_color_dialog_button_set_color (self, color);
return TRUE;
}
@@ -333,30 +310,24 @@ drag_prepare (GtkDragSource *source,
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;
GdkRGBA color;
GError *error = NULL;
color = gtk_color_dialog_choose_rgba_finish (self->dialog, result, NULL);
if (color)
if (gtk_color_dialog_choose_rgba_finish (self->dialog, result, &color, &error))
{
gtk_color_dialog_button_set_rgba (self, color);
gdk_rgba_free (color);
gtk_color_dialog_button_set_color (self, &color);
}
else
{
g_print ("%s\n", error->message);
g_error_free (error);
}
g_clear_object (&self->cancellable);
update_button_sensitivity (self);
}
static void
@@ -365,20 +336,15 @@ 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);
NULL, color_chosen, self);
}
/* }}} */
/* {{{ Constructor */
/* {{{ Constructor */
/**
* gtk_color_dialog_button_new:
@@ -452,13 +418,13 @@ gtk_color_dialog_button_set_dialog (GtkColorDialogButton *self,
if (!g_set_object (&self->dialog, dialog))
return;
update_button_sensitivity (self);
gtk_widget_set_sensitive (self->button, dialog != NULL);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DIALOG]);
}
/**
* gtk_color_dialog_button_get_rgba:
* gtk_color_dialog_button_get_color:
* @self: a `GtkColorDialogButton`
*
* Returns the color of the button.
@@ -472,7 +438,7 @@ gtk_color_dialog_button_set_dialog (GtkColorDialogButton *self,
* Since: 4.10
*/
const GdkRGBA *
gtk_color_dialog_button_get_rgba (GtkColorDialogButton *self)
gtk_color_dialog_button_get_color (GtkColorDialogButton *self)
{
g_return_val_if_fail (GTK_IS_COLOR_DIALOG_BUTTON (self), NULL);
@@ -480,7 +446,7 @@ gtk_color_dialog_button_get_rgba (GtkColorDialogButton *self)
}
/**
* gtk_color_dialog_button_set_rgba:
* gtk_color_dialog_button_set_color:
* @self: a `GtkColorDialogButton`
* @color: the new color
*
@@ -489,8 +455,8 @@ gtk_color_dialog_button_get_rgba (GtkColorDialogButton *self)
* Since: 4.10
*/
void
gtk_color_dialog_button_set_rgba (GtkColorDialogButton *self,
const GdkRGBA *color)
gtk_color_dialog_button_set_color (GtkColorDialogButton *self,
const GdkRGBA *color)
{
char *text;
@@ -509,7 +475,7 @@ gtk_color_dialog_button_set_rgba (GtkColorDialogButton *self,
-1);
g_free (text);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_RGBA]);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLOR]);
}
/* }}} */

View File

@@ -44,10 +44,10 @@ void gtk_color_dialog_button_set_dialog (GtkColorDialogButton *s
GtkColorDialog *dialog);
GDK_AVAILABLE_IN_4_10
const GdkRGBA * gtk_color_dialog_button_get_rgba (GtkColorDialogButton *self);
const GdkRGBA * gtk_color_dialog_button_get_color (GtkColorDialogButton *self);
GDK_AVAILABLE_IN_4_10
void gtk_color_dialog_button_set_rgba (GtkColorDialogButton *self,
void gtk_color_dialog_button_set_color (GtkColorDialogButton *self,
const GdkRGBA *color);
G_END_DECLS

View File

@@ -19,7 +19,7 @@
#include "gtkcoloreditorprivate.h"
#include "deprecated/gtkcolorchooserprivate.h"
#include "gtkcolorchooserprivate.h"
#include "gtkcolorplaneprivate.h"
#include "gtkcolorscaleprivate.h"
#include "gtkcolorswatchprivate.h"
@@ -38,8 +38,6 @@
#include <math.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct _GtkColorEditorClass GtkColorEditorClass;
struct _GtkColorEditor

View File

@@ -19,7 +19,7 @@
#include "gtkcolorscaleprivate.h"
#include "deprecated/gtkcolorchooserprivate.h"
#include "gtkcolorchooserprivate.h"
#include "gtkgesturelongpress.h"
#include "gtkgestureclick.h"
#include "gtkcolorutils.h"

View File

@@ -20,7 +20,7 @@
#include "gtkcolorswatchprivate.h"
#include "gtkbox.h"
#include "deprecated/gtkcolorchooserprivate.h"
#include "gtkcolorchooserprivate.h"
#include "gtkdragsource.h"
#include "gtkdroptarget.h"
#include "gtkgesturelongpress.h"

View File

@@ -37,7 +37,7 @@
#include "gtkcustompaperunixdialog.h"
#include "gtkprintbackendprivate.h"
#include "gtkprintutils.h"
#include "deprecated/gtkdialogprivate.h"
#include "gtkdialogprivate.h"
#define LEGACY_CUSTOM_PAPER_FILENAME ".gtk-custom-papers"
#define CUSTOM_PAPER_FILENAME "custom-papers"
@@ -283,9 +283,7 @@ gtk_custom_paper_unix_dialog_init (GtkCustomPaperUnixDialog *dialog)
GListModel *full_list;
GtkFilter *filter;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_dialog_set_use_header_bar_from_setting (GTK_DIALOG (dialog));
G_GNUC_END_IGNORE_DEPRECATIONS
dialog->print_backends = NULL;
@@ -320,7 +318,6 @@ gtk_custom_paper_unix_dialog_constructed (GObject *object)
G_OBJECT_CLASS (gtk_custom_paper_unix_dialog_parent_class)->constructed (object);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
g_object_get (object, "use-header-bar", &use_header, NULL);
if (!use_header)
{
@@ -329,7 +326,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (object), GTK_RESPONSE_CLOSE);
}
G_GNUC_END_IGNORE_DEPRECATIONS
}
static void
@@ -851,10 +847,7 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog)
GtkSelectionModel *model;
GtkListItemFactory *factory;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
content_area = gtk_dialog_get_content_area (cpu_dialog);
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 18);

View File

@@ -43,8 +43,6 @@
#include "gtktypebuiltins.h"
#include "gtksizegroup.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* GtkDialog:
*

View File

@@ -127,51 +127,51 @@ struct _GtkDialogClass
GDK_AVAILABLE_IN_ALL
GType gtk_dialog_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget* gtk_dialog_new (void);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget* gtk_dialog_new_with_buttons (const char *title,
GtkWindow *parent,
GtkDialogFlags flags,
const char *first_button_text,
...) G_GNUC_NULL_TERMINATED;
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_dialog_add_action_widget (GtkDialog *dialog,
GtkWidget *child,
int response_id);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget* gtk_dialog_add_button (GtkDialog *dialog,
const char *button_text,
int response_id);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_dialog_add_buttons (GtkDialog *dialog,
const char *first_button_text,
...) G_GNUC_NULL_TERMINATED;
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_dialog_set_response_sensitive (GtkDialog *dialog,
int response_id,
gboolean setting);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_dialog_set_default_response (GtkDialog *dialog,
int response_id);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget* gtk_dialog_get_widget_for_response (GtkDialog *dialog,
int response_id);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
int gtk_dialog_get_response_for_widget (GtkDialog *dialog,
GtkWidget *widget);
/* Emit response signal */
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_dialog_response (GtkDialog *dialog,
int response_id);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_dialog_get_content_area (GtkDialog *dialog);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_dialog_get_header_bar (GtkDialog *dialog);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkDialog, g_object_unref)

View File

@@ -1,27 +0,0 @@
/* 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");
}

View File

@@ -24,8 +24,6 @@
#include "gtkmarshalers.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* GtkFileChooser:
*
@@ -69,8 +67,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* 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
*/
@@ -177,8 +173,6 @@ 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,
@@ -196,8 +190,6 @@ 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)
@@ -221,8 +213,6 @@ 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,
@@ -241,8 +231,6 @@ 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)
@@ -265,8 +253,6 @@ 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,
@@ -284,8 +270,6 @@ 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)
@@ -317,8 +301,6 @@ 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,
@@ -344,8 +326,6 @@ 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 systems encoding for
* filenames.
*
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
*/
char *
gtk_file_chooser_get_current_name (GtkFileChooser *chooser)
@@ -382,8 +362,6 @@ 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,
@@ -404,8 +382,6 @@ 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)
@@ -447,8 +423,6 @@ 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)
@@ -508,8 +482,6 @@ 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,
@@ -539,8 +511,6 @@ 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)
@@ -569,8 +539,6 @@ 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,
@@ -593,8 +561,6 @@ 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,
@@ -635,8 +601,6 @@ 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,
@@ -684,8 +648,6 @@ 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,
@@ -704,8 +666,6 @@ 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)
@@ -735,8 +695,6 @@ 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)
@@ -762,8 +720,6 @@ 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,
@@ -784,8 +740,6 @@ 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,
@@ -807,8 +761,6 @@ 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,
@@ -829,8 +781,6 @@ 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,

View File

@@ -85,101 +85,101 @@ typedef enum {
GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME
} GtkFileChooserError;
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GQuark gtk_file_chooser_error_quark (void);
/* Configuration */
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_file_chooser_set_action (GtkFileChooser *chooser,
GtkFileChooserAction action);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkFileChooserAction gtk_file_chooser_get_action (GtkFileChooser *chooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
gboolean select_multiple);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
gboolean gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
gboolean create_folders);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
gboolean gtk_file_chooser_get_create_folders (GtkFileChooser *chooser);
/* Suggested name for the Save-type actions */
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
const char *name);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
char * gtk_file_chooser_get_current_name (GtkFileChooser *chooser);
/* GFile manipulation */
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GFile * gtk_file_chooser_get_file (GtkFileChooser *chooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
gboolean gtk_file_chooser_set_file (GtkFileChooser *chooser,
GFile *file,
GError **error);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GListModel * gtk_file_chooser_get_files (GtkFileChooser *chooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
gboolean gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
GFile *file,
GError **error);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GFile * gtk_file_chooser_get_current_folder (GtkFileChooser *chooser);
/* List of user selectable filters */
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_file_chooser_add_filter (GtkFileChooser *chooser,
GtkFileFilter *filter);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
GtkFileFilter *filter);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GListModel * gtk_file_chooser_get_filters (GtkFileChooser *chooser);
/* Current filter */
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_file_chooser_set_filter (GtkFileChooser *chooser,
GtkFileFilter *filter);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkFileFilter * gtk_file_chooser_get_filter (GtkFileChooser *chooser);
/* Per-application shortcut folders */
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
gboolean gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
GFile *folder,
GError **error);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
gboolean gtk_file_chooser_remove_shortcut_folder
(GtkFileChooser *chooser,
GFile *folder,
GError **error);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GListModel * gtk_file_chooser_get_shortcut_folders (GtkFileChooser *chooser);
/* Custom widgets */
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_file_chooser_add_choice (GtkFileChooser *chooser,
const char *id,
const char *label,
const char **options,
const char **option_labels);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_file_chooser_remove_choice (GtkFileChooser *chooser,
const char *id);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_file_chooser_set_choice (GtkFileChooser *chooser,
const char *id,
const char *option);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
const char * gtk_file_chooser_get_choice (GtkFileChooser *chooser,
const char *id);

View File

@@ -30,6 +30,7 @@
#include "gtklistitem.h"
#include "gtkselectionmodel.h"
#include "gtkfilechooserutils.h"
#include "gtkfilechooserwidget.h"
#include "gtkfilechooserwidgetprivate.h"
struct _GtkFileChooserCell

View File

@@ -19,10 +19,10 @@
#include "config.h"
#include "deprecated/gtkfilechooserdialog.h"
#include "gtkfilechooserdialog.h"
#include "gtkfilechooserprivate.h"
#include "deprecated/gtkfilechooserwidget.h"
#include "gtkfilechooserwidget.h"
#include "gtkfilechooserwidgetprivate.h"
#include "gtkfilechooserutils.h"
#include "gtksizerequest.h"
@@ -31,7 +31,7 @@
#include "gtksettings.h"
#include "gtktogglebutton.h"
#include "gtkheaderbar.h"
#include "deprecated/gtkdialogprivate.h"
#include "gtkdialogprivate.h"
#include "gtklabel.h"
#include "gtkfilechooserentry.h"
#include "gtkbox.h"
@@ -39,8 +39,6 @@
#include <stdarg.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* GtkFileChooserDialog:
*
@@ -211,8 +209,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
*
* 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;
@@ -720,8 +716,6 @@ 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,

View File

@@ -23,8 +23,8 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/deprecated/gtkdialog.h>
#include <gtk/deprecated/gtkfilechooser.h>
#include <gtk/gtkdialog.h>
#include <gtk/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_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_file_chooser_dialog_new (const char *title,
GtkWindow *parent,
GtkFileChooserAction action,

View File

@@ -19,7 +19,7 @@
#ifndef __GTK_FILE_CHOOSER_ENTRY_H__
#define __GTK_FILE_CHOOSER_ENTRY_H__
#include "deprecated/gtkfilechooser.h"
#include "gtkfilechooser.h"
G_BEGIN_DECLS

View File

@@ -23,8 +23,9 @@
#include "gtknativedialogprivate.h"
#include "gtkprivate.h"
#include "gtkfilechooserdialog.h"
#include "gtkfilechooserprivate.h"
#include "deprecated/gtkfilechooserdialog.h"
#include "gtkfilechooserwidget.h"
#include "gtkfilechooserwidgetprivate.h"
#include "gtkfilechooserutils.h"
#include "gtksizerequest.h"
@@ -36,8 +37,6 @@
#include "gtklabel.h"
#include "gtkfilefilterprivate.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* GtkFileChooserNative:
*
@@ -187,8 +186,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* are not supported:
*
* * Shortcut folders.
*
* Deprecated: 4.10: Use [class@Gtk.FileDialog] instead
*/
enum {
@@ -221,8 +218,6 @@ 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)
@@ -245,8 +240,6 @@ 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,
@@ -267,8 +260,6 @@ 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)
@@ -291,8 +282,6 @@ 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,
@@ -538,8 +527,6 @@ 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,

View File

@@ -23,7 +23,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/deprecated/gtkfilechooser.h>
#include <gtk/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_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkFileChooserNative *gtk_file_chooser_native_new (const char *title,
GtkWindow *parent,
GtkFileChooserAction action,
const char *accept_label,
const char *cancel_label);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
const char *gtk_file_chooser_native_get_accept_label (GtkFileChooserNative *self);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_file_chooser_native_set_accept_label (GtkFileChooserNative *self,
const char *accept_label);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
const char *gtk_file_chooser_native_get_cancel_label (GtkFileChooserNative *self);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_file_chooser_native_set_cancel_label (GtkFileChooserNative *self,
const char *cancel_label);

View File

@@ -23,8 +23,11 @@
#include "gtknativedialogprivate.h"
#include "gtkprivate.h"
#include "deprecated/gtkdialog.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"
@@ -36,8 +39,6 @@
#include "gtkwindowprivate.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct {
GtkFileChooserNative *self;

View File

@@ -19,7 +19,7 @@
#ifndef __GTK_FILE_CHOOSER_NATIVE_PRIVATE_H__
#define __GTK_FILE_CHOOSER_NATIVE_PRIVATE_H__
#include <gtk/deprecated/gtkfilechoosernative.h>
#include <gtk/gtkfilechoosernative.h>
G_BEGIN_DECLS

View File

@@ -24,8 +24,9 @@
#include <glib/gi18n-lib.h>
#include "gtkprivate.h"
#include "deprecated/gtkfilechooserdialog.h"
#include "gtkfilechooserdialog.h"
#include "gtkfilechooserprivate.h"
#include "gtkfilechooserwidget.h"
#include "gtkfilechooserwidgetprivate.h"
#include "gtkfilechooserutils.h"
#include "gtksizerequest.h"
@@ -41,8 +42,6 @@
#include "macos/gdkmacosdisplay-private.h"
#include "macos/gdkmacossurface-private.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct {
GtkFileChooserNative *self;

View File

@@ -29,8 +29,9 @@
#include "gtknativedialogprivate.h"
#include "gtkprivate.h"
#include "deprecated/gtkfilechooserdialog.h"
#include "gtkfilechooserdialog.h"
#include "gtkfilechooserprivate.h"
#include "gtkfilechooserwidget.h"
#include "gtkfilechooserwidgetprivate.h"
#include "gtkfilechooserutils.h"
#include "gtksizerequest.h"
@@ -47,8 +48,6 @@
#include <shlobj.h>
#include <windows.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct {
GtkFileChooserNative *self;

View File

@@ -19,7 +19,7 @@
#ifndef __GTK_FILE_CHOOSER_PRIVATE_H__
#define __GTK_FILE_CHOOSER_PRIVATE_H__
#include "deprecated/gtkfilechooser.h"
#include "gtkfilechooser.h"
#include "gtkfilesystemmodel.h"
#include "deprecated/gtkliststore.h"
#include "gtkrecentmanager.h"

View File

@@ -19,14 +19,12 @@
#include "config.h"
#include "gtkfilechooserutils.h"
#include "deprecated/gtkfilechooser.h"
#include "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);

View File

@@ -19,7 +19,7 @@
#include "config.h"
#include "deprecated/gtkfilechooserwidget.h"
#include "gtkfilechooserwidget.h"
#include "gtkfilechooserwidgetprivate.h"
#include "gtkbitset.h"
@@ -32,10 +32,10 @@
#include "gtkdroptarget.h"
#include "gtkentry.h"
#include "gtkfilechooserprivate.h"
#include "deprecated/gtkfilechooserdialog.h"
#include "deprecated/gtkfilechooser.h"
#include "gtkfilechooserdialog.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 "gtkalertdialog.h"
#include "gtkmessagedialog.h"
#include "gtkmountoperation.h"
#include "gtkmultiselection.h"
#include "gtkpaned.h"
@@ -107,8 +107,6 @@
#include <io.h>
#endif
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* GtkFileChooserWidget:
*
@@ -121,8 +119,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* # CSS nodes
*
* `GtkFileChooserWidget` has a single CSS node with name filechooser.
*
* Deprecated: 4.10: Direct use of `GtkFileChooserWidget` is deprecated
*/
/* 150 mseconds of delay */
@@ -669,12 +665,26 @@ error_message (GtkFileChooserWidget *impl,
const char *detail)
{
GtkWindow *parent = get_toplevel (GTK_WIDGET (impl));
GtkAlertDialog *dialog;
GtkWidget *dialog;
dialog = gtk_alert_dialog_new ("%s", msg);
gtk_alert_dialog_set_detail (dialog, detail);
gtk_alert_dialog_show (dialog, parent);
g_object_unref (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);
}
/* Shows a simple error dialog relative to a path. Frees the GError as well. */
@@ -1115,16 +1125,15 @@ typedef struct {
} ConfirmDeleteData;
static void
on_confirm_delete_response (GObject *source,
GAsyncResult *result,
void *user_data)
on_confirm_delete_response (GtkWidget *dialog,
int response,
gpointer user_data)
{
ConfirmDeleteData *data = user_data;
int button;
button = gtk_alert_dialog_choose_finish (GTK_ALERT_DIALOG (source), result);
gtk_window_destroy (GTK_WINDOW (dialog));
if (button == 1)
if (response == GTK_RESPONSE_ACCEPT)
{
GError *error = NULL;
@@ -1141,7 +1150,7 @@ confirm_delete (GtkFileChooserWidget *impl,
GFileInfo *info)
{
GtkWindow *toplevel;
GtkAlertDialog *dialog;
GtkWidget *dialog;
const char *name;
ConfirmDeleteData *data;
@@ -1149,16 +1158,30 @@ 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;
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);
g_signal_connect (dialog, "response",
G_CALLBACK (on_confirm_delete_response),
data);
}
static void
@@ -4905,6 +4928,18 @@ 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”.
*/
@@ -4916,16 +4951,13 @@ request_response_and_add_to_recent_list (GtkFileChooserWidget *impl)
}
static void
on_confirm_overwrite_response (GObject *source,
GAsyncResult *result,
void *user_data)
on_confirm_overwrite_response (GtkWidget *dialog,
int response,
gpointer user_data)
{
GtkFileChooserWidget *impl = user_data;
int button;
button = gtk_alert_dialog_choose_finish (GTK_ALERT_DIALOG (source), result);
if (button == 1)
if (response == GTK_RESPONSE_ACCEPT)
{
/* 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 */
@@ -4933,6 +4965,8 @@ on_confirm_overwrite_response (GObject *source,
request_response_and_add_to_recent_list (impl);
}
gtk_window_destroy (GTK_WINDOW (dialog));
}
/* Presents an overwrite confirmation dialog */
@@ -4942,24 +4976,33 @@ confirm_dialog_should_accept_filename (GtkFileChooserWidget *impl,
const char *folder_display_name)
{
GtkWindow *toplevel;
GtkAlertDialog *dialog;
char *detail;
GtkWidget *dialog;
toplevel = get_toplevel (GTK_WIDGET (impl));
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);
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);
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);
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);
}
struct GetDisplayNameData
@@ -6671,13 +6714,6 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
"",
GTK_PARAM_READABLE));
/**
* GtkFileChooserWidget:show-time:
*
* Whether to show the time.
*
* Since: 4.10
*/
g_object_class_install_property (gobject_class, PROP_SHOW_TIME,
g_param_spec_boolean ("show-time", NULL, NULL,
FALSE,
@@ -7262,8 +7298,6 @@ 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)

View File

@@ -23,7 +23,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/deprecated/gtkfilechooser.h>
#include <gtk/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_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_file_chooser_widget_new (GtkFileChooserAction action);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFileChooserWidget, g_object_unref)

View File

@@ -22,7 +22,7 @@
#define __GTK_FILE_CHOOSER_WIDGET_PRIVATE_H__
#include <glib.h>
#include "deprecated/gtkfilechooserwidget.h"
#include "gtkfilechooserwidget.h"
#include "gtkselectionmodel.h"
G_BEGIN_DECLS

File diff suppressed because it is too large Load Diff

View File

@@ -24,7 +24,6 @@
#include <gdk/gdk.h>
#include <gtk/gtkwindow.h>
#include <gtk/gtkfilefilter.h>
G_BEGIN_DECLS
@@ -34,51 +33,52 @@ 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);
GtkFileDialog * gtk_file_dialog_new (void);
GDK_AVAILABLE_IN_4_10
const char * gtk_file_dialog_get_title (GtkFileDialog *self);
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);
void gtk_file_dialog_set_title (GtkFileDialog *self,
const char *title);
GDK_AVAILABLE_IN_4_10
gboolean gtk_file_dialog_get_modal (GtkFileDialog *self);
gboolean gtk_file_dialog_get_modal (GtkFileDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_set_modal (GtkFileDialog *self,
gboolean modal);
void gtk_file_dialog_set_modal (GtkFileDialog *self,
gboolean modal);
GDK_AVAILABLE_IN_4_10
GListModel * gtk_file_dialog_get_filters (GtkFileDialog *self);
gboolean gtk_file_dialog_get_select_multiple (GtkFileDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_set_filters (GtkFileDialog *self,
GListModel *filters);
void gtk_file_dialog_set_select_multiple (GtkFileDialog *self,
gboolean select_multiple);
GDK_AVAILABLE_IN_4_10
GtkFileFilter * gtk_file_dialog_get_current_filter (GtkFileDialog *self);
gboolean gtk_file_dialog_get_create_folders (GtkFileDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_set_current_filter (GtkFileDialog *self,
GtkFileFilter *filter);
void gtk_file_dialog_set_create_folders (GtkFileDialog *self,
gboolean create_folders);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_set_filters (GtkFileDialog *self,
GListModel *filters);
GDK_AVAILABLE_IN_4_10
GListModel * gtk_file_dialog_get_filters (GtkFileDialog *dialog);
GDK_AVAILABLE_IN_4_10
GListModel * gtk_file_dialog_get_shortcut_folders
(GtkFileDialog *self);
void gtk_file_dialog_set_shortcuts (GtkFileDialog *self,
GListModel *filters);
GDK_AVAILABLE_IN_4_10
GListModel * gtk_file_dialog_get_shortcuts (GtkFileDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_set_shortcut_folders
(GtkFileDialog *self,
GListModel *shortcut_folders);
void gtk_file_dialog_set_choices (GtkFileDialog *self,
GListModel *filters);
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);
GListModel * gtk_file_dialog_get_choices (GtkFileDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_open (GtkFileDialog *self,
@@ -89,8 +89,10 @@ void gtk_file_dialog_open (GtkFileDialog *self
gpointer user_data);
GDK_AVAILABLE_IN_4_10
GFile * gtk_file_dialog_open_finish (GtkFileDialog *self,
gboolean gtk_file_dialog_open_finish (GtkFileDialog *self,
GAsyncResult *result,
GListModel **files,
char ***options,
GError **error);
GDK_AVAILABLE_IN_4_10
@@ -102,50 +104,27 @@ void gtk_file_dialog_select_folder (GtkFileDialog *self
gpointer user_data);
GDK_AVAILABLE_IN_4_10
GFile * gtk_file_dialog_select_folder_finish
gboolean gtk_file_dialog_select_folder_finish
(GtkFileDialog *self,
GAsyncResult *result,
GError **error);
GAsyncResult *result,
GListModel **files,
char ***options,
GError **error);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_save (GtkFileDialog *self,
void gtk_file_dialog_save (GtkFileDialog *dialog,
GtkWindow *parent,
GFile *current_file,
GFile *current_folder,
const char *current_name,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GDK_AVAILABLE_IN_4_10
GFile * gtk_file_dialog_save_finish (GtkFileDialog *self,
gboolean gtk_file_dialog_save_finish (GtkFileDialog *self,
GAsyncResult *result,
GListModel **files,
char ***choices,
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

View File

@@ -45,8 +45,6 @@
#include <stdio.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* GtkFontButton:
*
@@ -67,8 +65,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
*
* `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;
@@ -748,8 +744,6 @@ 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)
@@ -764,8 +758,6 @@ 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)
@@ -779,8 +771,6 @@ 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,
@@ -807,8 +797,6 @@ 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)
@@ -824,8 +812,6 @@ 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,
@@ -851,8 +837,6 @@ 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)
@@ -869,8 +853,6 @@ 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)
@@ -887,8 +869,6 @@ 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,
@@ -916,8 +896,6 @@ 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)
@@ -935,8 +913,6 @@ 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,

View File

@@ -43,29 +43,29 @@ typedef struct _GtkFontButton GtkFontButton;
GDK_AVAILABLE_IN_ALL
GType gtk_font_button_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_font_button_new (void);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_font_button_new_with_font (const char *fontname);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
const char * gtk_font_button_get_title (GtkFontButton *font_button);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_font_button_set_title (GtkFontButton *font_button,
const char *title);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
gboolean gtk_font_button_get_modal (GtkFontButton *font_button);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_font_button_set_modal (GtkFontButton *font_button,
gboolean modal);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
gboolean gtk_font_button_get_use_font (GtkFontButton *font_button);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_font_button_set_use_font (GtkFontButton *font_button,
gboolean use_font);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
gboolean gtk_font_button_get_use_size (GtkFontButton *font_button);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_font_button_set_use_size (GtkFontButton *font_button,
gboolean use_size);

View File

@@ -25,8 +25,6 @@
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* GtkFontChooser:
*
@@ -36,9 +34,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* 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
@@ -172,9 +167,6 @@ 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)
@@ -195,9 +187,6 @@ 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)
@@ -215,9 +204,6 @@ 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)
@@ -244,9 +230,6 @@ 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)
@@ -267,9 +250,6 @@ 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,
@@ -298,9 +278,6 @@ 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)
@@ -320,9 +297,6 @@ 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,
@@ -341,9 +315,6 @@ 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)
@@ -365,9 +336,6 @@ 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,
@@ -386,9 +354,6 @@ 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)
@@ -408,9 +373,6 @@ 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,
@@ -431,9 +393,6 @@ 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,
@@ -488,9 +447,6 @@ _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,
@@ -511,9 +467,6 @@ 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)
@@ -534,9 +487,6 @@ 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,
@@ -554,9 +504,6 @@ 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)
@@ -581,9 +528,6 @@ 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)
@@ -604,9 +548,6 @@ 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)
@@ -626,9 +567,6 @@ 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,

View File

@@ -107,57 +107,57 @@ struct _GtkFontChooserIface
GDK_AVAILABLE_IN_ALL
GType gtk_font_chooser_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
PangoFontFamily *gtk_font_chooser_get_font_family (GtkFontChooser *fontchooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
PangoFontFace *gtk_font_chooser_get_font_face (GtkFontChooser *fontchooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
int gtk_font_chooser_get_font_size (GtkFontChooser *fontchooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
PangoFontDescription *
gtk_font_chooser_get_font_desc (GtkFontChooser *fontchooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_font_chooser_set_font_desc (GtkFontChooser *fontchooser,
const PangoFontDescription *font_desc);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
char * gtk_font_chooser_get_font (GtkFontChooser *fontchooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_font_chooser_set_font (GtkFontChooser *fontchooser,
const char *fontname);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
char * gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
const char *text);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
gboolean gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser,
gboolean show_preview_entry);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser,
GtkFontFilterFunc filter,
gpointer user_data,
GDestroyNotify destroy);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_font_chooser_set_font_map (GtkFontChooser *fontchooser,
PangoFontMap *fontmap);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
PangoFontMap * gtk_font_chooser_get_font_map (GtkFontChooser *fontchooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_font_chooser_set_level (GtkFontChooser *fontchooser,
GtkFontChooserLevel level);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkFontChooserLevel
gtk_font_chooser_get_level (GtkFontChooser *fontchooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
char * gtk_font_chooser_get_font_features (GtkFontChooser *fontchooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
char * gtk_font_chooser_get_language (GtkFontChooser *fontchooser);
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
void gtk_font_chooser_set_language (GtkFontChooser *fontchooser,
const char *language);

View File

@@ -21,9 +21,9 @@
#include <glib/gprintf.h>
#include <string.h>
#include "gtkfontchooserdialogprivate.h"
#include "deprecated/gtkfontchooser.h"
#include "deprecated/gtkfontchooserwidget.h"
#include "gtkfontchooserdialog.h"
#include "gtkfontchooser.h"
#include "gtkfontchooserwidget.h"
#include "gtkfontchooserwidgetprivate.h"
#include "gtkfontchooserutils.h"
#include "gtkbox.h"
@@ -32,14 +32,12 @@
#include "gtkprivate.h"
#include "gtkwidget.h"
#include "gtksettings.h"
#include "deprecated/gtkdialogprivate.h"
#include "gtkdialogprivate.h"
#include "gtktogglebutton.h"
#include "gtkheaderbar.h"
#include "gtkactionable.h"
#include "gtkeventcontrollerkey.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct _GtkFontChooserDialogClass GtkFontChooserDialogClass;
struct _GtkFontChooserDialog
@@ -74,8 +72,6 @@ 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);
@@ -292,8 +288,6 @@ 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,
@@ -330,10 +324,3 @@ 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);
}

View File

@@ -22,7 +22,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/deprecated/gtkdialog.h>
#include <gtk/gtkdialog.h>
G_BEGIN_DECLS
@@ -34,7 +34,7 @@ typedef struct _GtkFontChooserDialog GtkFontChooserDialog;
GDK_AVAILABLE_IN_ALL
GType gtk_font_chooser_dialog_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget* gtk_font_chooser_dialog_new (const char *title,
GtkWindow *parent);

View File

@@ -1,31 +0,0 @@
/* 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__ */

View File

@@ -26,8 +26,6 @@
#include "gtkfontchooserutils.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkFontChooser *
get_delegate (GtkFontChooser *receiver)
{

View File

@@ -25,7 +25,7 @@
#ifndef __GTK_FONT_CHOOSER_UTILS_H__
#define __GTK_FONT_CHOOSER_UTILS_H__
#include "deprecated/gtkfontchooserprivate.h"
#include "gtkfontchooserprivate.h"
G_BEGIN_DECLS

View File

@@ -21,7 +21,7 @@
#include <glib/gprintf.h>
#include <string.h>
#include "deprecated/gtkfontchooserwidget.h"
#include "gtkfontchooserwidget.h"
#include "gtkfontchooserwidgetprivate.h"
#include "gtkadjustment.h"
@@ -34,7 +34,7 @@
#include "gtkfilter.h"
#include "gtkframe.h"
#include "gtkgrid.h"
#include "deprecated/gtkfontchooser.h"
#include "gtkfontchooser.h"
#include "gtkfontchooserutils.h"
#include <glib/gi18n-lib.h>
#include "gtklabel.h"
@@ -48,7 +48,7 @@
#include "gtktextview.h"
#include "gtkwidgetprivate.h"
#include "gtksettings.h"
#include "deprecated/gtkdialog.h"
#include "gtkdialog.h"
#include "gtkgestureclick.h"
#include "gtkeventcontrollerscroll.h"
#include "gtkroot.h"
@@ -63,15 +63,12 @@
#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:
*
@@ -92,8 +89,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* # CSS nodes
*
* `GtkFontChooserWidget` has a single CSS node with name fontchooser.
*
* Deprecated: 4.10: Direct use of `GtkFontChooserWidget` is deprecated.
*/
typedef struct _GtkFontChooserWidgetClass GtkFontChooserWidgetClass;
@@ -110,7 +105,6 @@ struct _GtkFontChooserWidget
GtkSingleSelection *selection;
GtkCustomFilter *custom_filter;
GtkCustomFilter *user_filter;
GtkCustomFilter *multi_filter;
GtkFilterListModel *filter_model;
GtkWidget *preview;
@@ -150,8 +144,6 @@ struct _GtkFontChooserWidget
gpointer filter_data;
GDestroyNotify filter_data_destroy;
GtkFilter *filter;
guint last_fontconfig_timestamp;
GtkFontChooserLevel level;
@@ -1303,8 +1295,6 @@ 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)
@@ -1335,8 +1325,6 @@ 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);
}
@@ -2988,14 +2976,3 @@ 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));
}

View File

@@ -35,7 +35,7 @@ typedef struct _GtkFontChooserWidget GtkFontChooserWidget;
GDK_AVAILABLE_IN_ALL
GType gtk_font_chooser_widget_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10
GDK_AVAILABLE_IN_ALL
GtkWidget* gtk_font_chooser_widget_new (void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFontChooserWidget, g_object_unref)

View File

@@ -18,16 +18,12 @@
#ifndef __GTK_FONT_CHOOSER_WIDGET_PRIVATE_H__
#define __GTK_FONT_CHOOSER_WIDGET_PRIVATE_H__
#include "deprecated/gtkfontchooserwidget.h"
#include "gtkfilter.h"
#include "gtkfontchooserwidget.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__ */

View File

@@ -21,10 +21,8 @@
#include "gtkfontdialog.h"
#include "deprecated/gtkfontchooser.h"
#include "gtkfontchooserdialogprivate.h"
#include "gtkfontchooserdialog.h"
#include "gtkbutton.h"
#include "gtkdialogerror.h"
#include "gtktypebuiltins.h"
#include <glib/gi18n-lib.h>
@@ -36,10 +34,10 @@
* 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].
* The dialog is shown with the [function@Gtk.FontDialog.choose_font]
* function. This API follows the GIO async pattern, and the
* result can be obtained by calling
* [function@Gtk.FontDialog.choose_font_finish].
*
* See [class@Gtk.FontDialogButton] for a convenient control
* that uses `GtkFontDialog` and presents the results.
@@ -54,21 +52,24 @@ struct _GtkFontDialog
GObject parent_instance;
char *title;
GtkFontChooserLevel level;
PangoLanguage *language;
PangoFontMap *fontmap;
unsigned int modal : 1;
GtkFilter *filter;
GtkFontFilterFunc filter;
gpointer filter_data;
GDestroyNotify filter_data_destroy;
};
enum
{
PROP_TITLE = 1,
PROP_MODAL,
PROP_LEVEL,
PROP_LANGUAGE,
PROP_FONT_MAP,
PROP_FILTER,
PROP_FONTMAP,
NUM_PROPERTIES
};
@@ -77,10 +78,16 @@ static GParamSpec *properties[NUM_PROPERTIES];
G_DEFINE_TYPE (GtkFontDialog, gtk_font_dialog, G_TYPE_OBJECT)
#define DEFAULT_LEVEL (GTK_FONT_CHOOSER_LEVEL_FAMILY| \
GTK_FONT_CHOOSER_LEVEL_STYLE| \
GTK_FONT_CHOOSER_LEVEL_SIZE)
static void
gtk_font_dialog_init (GtkFontDialog *self)
{
self->title = g_strdup (_("Pick a Font"));
self->modal = TRUE;
self->level = DEFAULT_LEVEL;
self->language = pango_language_get_default ();
}
@@ -102,18 +109,18 @@ gtk_font_dialog_get_property (GObject *object,
g_value_set_boolean (value, self->modal);
break;
case PROP_LEVEL:
g_value_set_flags (value, self->level);
break;
case PROP_LANGUAGE:
g_value_set_boxed (value, self->language);
break;
case PROP_FONT_MAP:
case PROP_FONTMAP:
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;
@@ -138,16 +145,16 @@ gtk_font_dialog_set_property (GObject *object,
gtk_font_dialog_set_modal (self, g_value_get_boolean (value));
break;
case PROP_LEVEL:
gtk_font_dialog_set_level (self, g_value_get_flags (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));
case PROP_FONTMAP:
gtk_font_dialog_set_fontmap (self, g_value_get_object (value));
break;
default:
@@ -163,7 +170,7 @@ gtk_font_dialog_finalize (GObject *object)
g_free (self->title);
g_clear_object (&self->fontmap);
g_clear_object (&self->filter);
g_clear_pointer (&self->filter_data, self->filter_data_destroy);
G_OBJECT_CLASS (gtk_font_dialog_parent_class)->finalize (object);
}
@@ -181,7 +188,7 @@ gtk_font_dialog_class_init (GtkFontDialogClass *class)
* 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].
* dialog that is presented by [function@Gtk.FontDialog.choose_font].
*
* Since: 4.10
*/
@@ -202,6 +209,20 @@ gtk_font_dialog_class_init (GtkFontDialogClass *class)
TRUE,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFontDialog:level: (attributes org.gtk.Property.get=gtk_font_dialog_get_level org.gtk.Property.set=gtk_font_dialog_set_level)
*
* The level of granularity to offer for selecting fonts.
*
* Since: 4.10
*/
properties[PROP_LEVEL] =
g_param_spec_flags ("level", NULL, NULL,
GTK_TYPE_FONT_CHOOSER_LEVEL,
DEFAULT_LEVEL,
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)
*
@@ -215,7 +236,7 @@ gtk_font_dialog_class_init (GtkFontDialogClass *class)
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)
* GtkFontDialog:fontmap: (attributes org.gtk.Property.get=gtk_font_dialog_get_fontmap org.gtk.Property.set=gtk_font_dialog_set_fontmap)
*
* Sets a custom font map to select fonts from.
*
@@ -224,29 +245,16 @@ gtk_font_dialog_class_init (GtkFontDialogClass *class)
*
* Since: 4.10
*/
properties[PROP_FONT_MAP] =
g_param_spec_object ("font-map", NULL, NULL,
properties[PROP_FONTMAP] =
g_param_spec_object ("fontmap", 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 */
/* {{{ Constructor */
/**
* gtk_font_dialog_new:
@@ -264,7 +272,7 @@ gtk_font_dialog_new (void)
}
/* }}} */
/* {{{ API: Getters and setters */
/* {{{ Getters and setters */
/**
* gtk_font_dialog_get_title:
@@ -304,7 +312,7 @@ gtk_font_dialog_set_title (GtkFontDialog *self,
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
g_return_if_fail (title != NULL);
if (g_strcmp0 (self->title, title) == 0)
if (g_str_equal (self->title, title))
return;
new_title = g_strdup (title);
@@ -359,6 +367,47 @@ gtk_font_dialog_set_modal (GtkFontDialog *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODAL]);
}
/**
* gtk_font_dialog_get_level:
* @self: a `GtkFontDialog`
*
* Returns the level of granularity for selecting fonts.
*
* Returns: the level of granularity
*
* Since: 4.10
*/
GtkFontChooserLevel
gtk_font_dialog_get_level (GtkFontDialog *self)
{
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), DEFAULT_LEVEL);
return self->level;
}
/**
* gtk_font_dialog_set_level:
* @self: a `GtkFontDialog`
* @level: the new value
*
* Sets the level of granularity for selecting fonts.
*
* Since: 4.10
*/
void
gtk_font_dialog_set_level (GtkFontDialog *self,
GtkFontChooserLevel level)
{
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
if (self->level == level)
return;
self->level = level;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LEVEL]);
}
/**
* gtk_font_dialog_get_language:
* @self: a `GtkFontDialog`
@@ -401,7 +450,7 @@ gtk_font_dialog_set_language (GtkFontDialog *self,
}
/**
* gtk_font_dialog_get_font_map:
* gtk_font_dialog_get_fontmap
* @self: a `GtkFontDialog`
*
* Returns the fontmap from which fonts are selected,
@@ -412,7 +461,7 @@ gtk_font_dialog_set_language (GtkFontDialog *self,
* Since: 4.10
*/
PangoFontMap *
gtk_font_dialog_get_font_map (GtkFontDialog *self)
gtk_font_dialog_get_fontmap (GtkFontDialog *self)
{
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), NULL);
@@ -420,7 +469,7 @@ gtk_font_dialog_get_font_map (GtkFontDialog *self)
}
/**
* gtk_font_dialog_set_font_map:
* gtk_font_dialog_set_fontmap:
* @self: a `GtkFontDialog`
* @fontmap: (nullable): the fontmap
*
@@ -431,59 +480,44 @@ gtk_font_dialog_get_font_map (GtkFontDialog *self)
* Since: 4.10
*/
void
gtk_font_dialog_set_font_map (GtkFontDialog *self,
PangoFontMap *fontmap)
gtk_font_dialog_set_fontmap (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]);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FONTMAP]);
}
/**
* 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`
* @filter: (nullable): a `GtkFontFilterFunc`
* @user_data: (closure): data to pass to @filter
* @destroy: function to call to free @data when it is no longer needed
*
* Adds a filter that decides which fonts to display
* Adds a filter function 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)
gtk_font_dialog_set_filter (GtkFontDialog *self,
GtkFontFilterFunc filter,
gpointer filter_data,
GDestroyNotify filter_data_destroy)
{
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]);
g_clear_pointer (&self->filter_data, self->filter_data_destroy);
self->filter = filter;
self->filter_data = filter_data;
self->filter_data_destroy = filter_data_destroy;
}
/* }}} */
/* {{{ Async implementation */
/* {{{ Async API */
static void response_cb (GTask *task,
int response);
@@ -492,84 +526,44 @@ static void
cancelled_cb (GCancellable *cancellable,
GTask *task)
{
response_cb (task, GTK_RESPONSE_CLOSE);
response_cb (task, GTK_RESPONSE_CANCEL);
}
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;
GtkFontChooserDialog *window;
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)));
window = GTK_FONT_CHOOSER_DIALOG (g_task_get_task_data (task));
g_task_return_pointer (task, &font_result, NULL);
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));
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);
}
g_task_return_pointer (task, &font_result, NULL);
}
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_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
g_object_unref (task);
}
G_GNUC_END_IGNORE_DEPRECATIONS
static void
dialog_response (GtkDialog *dialog,
@@ -579,240 +573,50 @@ dialog_response (GtkDialog *dialog,
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
* @initial_font: (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.
* presenting a font chooser dialog to the user.
*
* The @callback will be called when the dialog is dismissed.
* It should call [method@Gtk.FontDialog.choose_font_finish]
* It should call [function@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,
PangoFontDescription *initial_font,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GtkWidget *window;
GtkFontChooserDialog *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);
window = GTK_FONT_CHOOSER_DIALOG (gtk_font_chooser_dialog_new (self->title, parent));
gtk_font_chooser_set_level (GTK_FONT_CHOOSER (window), self->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 (initial_font)
gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (window), initial_font);
if (self->filter)
gtk_font_chooser_set_filter_func (GTK_FONT_CHOOSER (window),
self->filter,
self->filter_data,
self->filter_data_destroy);
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gtk_font_dialog_choose_font);
@@ -830,120 +634,36 @@ gtk_font_dialog_choose_font (GtkFontDialog *self,
* 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.
* Finishes the [function@Gtk.FontDialog.choose_font] 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
* 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)
gtk_font_dialog_choose_font_finish (GtkFontDialog *self,
GAsyncResult *result,
PangoFontDescription **font_desc,
char **font_features,
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);
*font_desc = font_result->font_desc;
*font_features = font_result->font_features;
return TRUE;
}
return font_result != NULL;
return FALSE;
}
/* }}} */

View File

@@ -24,7 +24,7 @@
#include <gdk/gdk.h>
#include <gtk/gtkwindow.h>
#include <gtk/gtkfilter.h>
#include <gtk/gtkfontchooser.h>
G_BEGIN_DECLS
@@ -36,9 +36,6 @@ 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);
@@ -51,86 +48,50 @@ void gtk_font_dialog_set_modal (GtkFontDialog *self,
gboolean modal);
GDK_AVAILABLE_IN_4_10
PangoLanguage * gtk_font_dialog_get_language (GtkFontDialog *self);
const char * gtk_font_dialog_get_title (GtkFontDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_set_level (GtkFontDialog *self,
GtkFontChooserLevel level);
GDK_AVAILABLE_IN_4_10
GtkFontChooserLevel
gtk_font_dialog_get_level (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);
PangoLanguage * gtk_font_dialog_get_language (GtkFontDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_set_font_map (GtkFontDialog *self,
PangoFontMap * gtk_font_dialog_get_fontmap (GtkFontDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_set_fontmap (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);
GtkFontFilterFunc filter,
gpointer user_data,
GDestroyNotify destroy);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_choose_font (GtkFontDialog *self,
GtkWindow *parent,
PangoFontDescription *initial_value,
PangoFontDescription *initial_font,
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
gboolean gtk_font_dialog_choose_font_finish
(GtkFontDialog *self,
GAsyncResult *result,
PangoFontDescription **font_desc,
char **font_features,
PangoLanguage **language,
GError **error);
G_END_DECLS

View File

@@ -30,12 +30,9 @@
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtkwidgetprivate.h"
#include "gtktypebuiltins.h"
static void button_clicked (GtkFontDialogButton *self);
static void update_button_sensitivity
(GtkFontDialogButton *self);
/**
* GtkFontDialogButton:
@@ -70,16 +67,12 @@ struct _GtkFontDialogButton
GtkWidget *size_label;
GtkWidget *font_size_box;
GtkFontLevel level;
guint use_font : 1;
guint use_size : 1;
GtkFontDialog *dialog;
GCancellable *cancellable;
PangoFontDescription *font_desc;
char *font_features;
PangoLanguage *language;
PangoFontFamily *font_family;
PangoFontFace *font_face;
@@ -89,10 +82,8 @@ struct _GtkFontDialogButton
enum
{
PROP_DIALOG = 1,
PROP_LEVEL,
PROP_FONT_DESC,
PROP_FONT_FEATURES,
PROP_LANGUAGE,
PROP_USE_FONT,
PROP_USE_SIZE,
NUM_PROPERTIES
@@ -125,8 +116,6 @@ gtk_font_dialog_button_init (GtkFontDialogButton *self)
gtk_button_set_child (GTK_BUTTON (self->button), box);
gtk_widget_set_parent (self->button, GTK_WIDGET (self));
self->level = GTK_FONT_LEVEL_FONT;
self->use_font = FALSE;
self->use_size = FALSE;
@@ -137,21 +126,6 @@ gtk_font_dialog_button_init (GtkFontDialogButton *self)
gtk_widget_add_css_class (self->button, "font");
}
static void
gtk_font_dialog_button_unroot (GtkWidget *widget)
{
GtkFontDialogButton *self = GTK_FONT_DIALOG_BUTTON (widget);
if (self->cancellable)
{
g_cancellable_cancel (self->cancellable);
g_clear_object (&self->cancellable);
update_button_sensitivity (self);
}
GTK_WIDGET_CLASS (gtk_font_dialog_button_parent_class)->unroot (widget);
}
static void
gtk_font_dialog_button_set_property (GObject *object,
unsigned int param_id,
@@ -166,10 +140,6 @@ gtk_font_dialog_button_set_property (GObject *object,
gtk_font_dialog_button_set_dialog (self, g_value_get_object (value));
break;
case PROP_LEVEL:
gtk_font_dialog_button_set_level (self, g_value_get_enum (value));
break;
case PROP_FONT_DESC:
gtk_font_dialog_button_set_font_desc (self, g_value_get_boxed (value));
break;
@@ -178,10 +148,6 @@ gtk_font_dialog_button_set_property (GObject *object,
gtk_font_dialog_button_set_font_features (self, g_value_get_string (value));
break;
case PROP_LANGUAGE:
gtk_font_dialog_button_set_language (self, g_value_get_boxed (value));
break;
case PROP_USE_FONT:
gtk_font_dialog_button_set_use_font (self, g_value_get_boolean (value));
break;
@@ -210,10 +176,6 @@ gtk_font_dialog_button_get_property (GObject *object,
g_value_set_object (value, self->dialog);
break;
case PROP_LEVEL:
g_value_set_enum (value, self->level);
break;
case PROP_FONT_DESC:
g_value_set_boxed (value, self->font_desc);
break;
@@ -222,10 +184,6 @@ gtk_font_dialog_button_get_property (GObject *object,
g_value_set_string (value, self->font_features);
break;
case PROP_LANGUAGE:
g_value_set_boxed (value, self->language);
break;
case PROP_USE_FONT:
g_value_set_boolean (value, self->use_font);
break;
@@ -255,7 +213,6 @@ gtk_font_dialog_button_finalize (GObject *object)
{
GtkFontDialogButton *self = GTK_FONT_DIALOG_BUTTON (object);
g_assert (self->cancellable == NULL);
g_clear_object (&self->dialog);
pango_font_description_free (self->font_desc);
g_clear_object (&self->font_family);
@@ -278,7 +235,6 @@ gtk_font_dialog_button_class_init (GtkFontDialogButtonClass *class)
widget_class->grab_focus = gtk_widget_grab_focus_child;
widget_class->focus = gtk_widget_focus_child;
widget_class->unroot = gtk_font_dialog_button_unroot;
/**
* GtkFontDialogButton:dialog: (attributes org.gtk.Property.get=gtk_font_dialog_button_get_dialog org.gtk.Property.set=gtk_font_dialog_button_set_dialog)
@@ -293,17 +249,6 @@ gtk_font_dialog_button_class_init (GtkFontDialogButtonClass *class)
GTK_TYPE_FONT_DIALOG,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFontDialogButton:level: (attributes org.gtk.Property.get=gtk_font_dialog_button_get_level org.gtk.Property.set=gtk_font_dialog_button_set_level)
*
* The level of detail for the font chooser dialog.
*/
properties[PROP_LEVEL] =
g_param_spec_enum ("level", NULL, NULL,
GTK_TYPE_FONT_LEVEL,
GTK_FONT_LEVEL_FONT,
GTK_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFontDialogButton:font-desc: (attributes org.gtk.Property.get=gtk_font_dialog_button_get_font_desc org.gtk.Property.set=gtk_font_dialog_button_set_font_desc)
*
@@ -341,24 +286,6 @@ gtk_font_dialog_button_class_init (GtkFontDialogButtonClass *class)
NULL,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFontDialogButton:language: (attributes org.gtk.Property.get=gtk_font_dialog_button_get_language org.gtk.Property.set=gtk_font_dialog_button_set_language)
*
* The selected language for font features.
*
* This property will be updated to reflect the users choice
* in the font chooser dialog.
*
* Listen to `notify::language` to get informed about changes
* to the buttons language.
*
* 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);
/**
* GtkFontDialogButton:use-font: (attributes org.gtk.Property.get=gtk_font_dialog_button_get_use_font org.gtk.Property.set=gtk_font_dialog_button_set_use_font)
*
@@ -388,64 +315,6 @@ gtk_font_dialog_button_class_init (GtkFontDialogButtonClass *class)
/* }}} */
/* {{{ Private API, callbacks */
static void
update_button_sensitivity (GtkFontDialogButton *self)
{
gtk_widget_set_sensitive (self->button,
self->dialog != NULL && self->cancellable == NULL);
}
static void
family_chosen (GObject *source,
GAsyncResult *result,
gpointer data)
{
GtkFontDialogButton *self = data;
PangoFontFamily *family;
family = gtk_font_dialog_choose_family_finish (self->dialog, result, NULL);
if (family)
{
PangoFontDescription *desc;
desc = pango_font_description_new ();
pango_font_description_set_family (desc, pango_font_family_get_name (family));
gtk_font_dialog_button_set_font_desc (self, desc);
pango_font_description_free (desc);
g_object_unref (family);
}
g_clear_object (&self->cancellable);
update_button_sensitivity (self);
}
static void
face_chosen (GObject *source,
GAsyncResult *result,
gpointer data)
{
GtkFontDialogButton *self = data;
PangoFontFace *face;
face = gtk_font_dialog_choose_face_finish (self->dialog, result, NULL);
if (face)
{
PangoFontDescription *desc;
desc = pango_font_face_describe (face);
gtk_font_dialog_button_set_font_desc (self, desc);
pango_font_description_free (desc);
g_object_unref (face);
}
g_clear_object (&self->cancellable);
update_button_sensitivity (self);
}
static void
font_chosen (GObject *source,
GAsyncResult *result,
@@ -453,42 +322,19 @@ font_chosen (GObject *source,
{
GtkFontDialogButton *self = data;
PangoFontDescription *desc;
desc = gtk_font_dialog_choose_font_finish (self->dialog, result, NULL);
if (desc)
{
gtk_font_dialog_button_set_font_desc (self, desc);
pango_font_description_free (desc);
}
g_clear_object (&self->cancellable);
update_button_sensitivity (self);
}
static void
font_and_features_chosen (GObject *source,
GAsyncResult *result,
gpointer data)
{
GtkFontDialogButton *self = data;
PangoFontDescription *desc;
char *features;
PangoLanguage *language;
GError *error = NULL;
if (gtk_font_dialog_choose_font_and_features_finish (self->dialog, result,
&desc, &features, &language,
NULL))
if (gtk_font_dialog_choose_font_finish (self->dialog, result, &desc, &features, &error))
{
gtk_font_dialog_button_set_font_desc (self, desc);
gtk_font_dialog_button_set_font_features (self, features);
gtk_font_dialog_button_set_language (self, language);
pango_font_description_free (desc);
g_free (features);
}
g_clear_object (&self->cancellable);
update_button_sensitivity (self);
else
{
g_print ("%s\n", error->message);
g_error_free (error);
}
}
static void
@@ -497,39 +343,11 @@ button_clicked (GtkFontDialogButton *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);
switch (self->level)
{
case GTK_FONT_LEVEL_FAMILY:
gtk_font_dialog_choose_family (self->dialog, parent, self->font_family,
self->cancellable, family_chosen, self);
break;
case GTK_FONT_LEVEL_FACE:
gtk_font_dialog_choose_face (self->dialog, parent, self->font_face,
self->cancellable, face_chosen, self);
break;
case GTK_FONT_LEVEL_FONT:
gtk_font_dialog_choose_font (self->dialog, parent, self->font_desc,
self->cancellable, font_chosen, self);
break;
case GTK_FONT_LEVEL_FEATURES:
gtk_font_dialog_choose_font_and_features (self->dialog, parent, self->font_desc,
self->cancellable, font_and_features_chosen, self);
break;
default:
g_assert_not_reached ();
}
gtk_font_dialog_choose_font (self->dialog, parent, self->font_desc,
NULL, font_chosen, self);
}
static gboolean
@@ -558,7 +376,7 @@ update_font_data (GtkFontDialogButton *self)
return;
if (self->dialog)
fontmap = gtk_font_dialog_get_font_map (self->dialog);
fontmap = gtk_font_dialog_get_fontmap (self->dialog);
if (!fontmap)
fontmap = pango_cairo_font_map_get_default ();
@@ -598,7 +416,7 @@ update_font_info (GtkFontDialogButton *self)
const char *fam_name;
const char *face_name;
char *family_style;
char *size;
GtkFontChooserLevel level;
if (self->font_family)
fam_name = pango_font_family_get_name (self->font_family);
@@ -609,23 +427,30 @@ update_font_info (GtkFontDialogButton *self)
else
face_name = "";
if (self->level == GTK_FONT_LEVEL_FAMILY)
family_style = g_strdup (fam_name);
if (self->dialog)
level = gtk_font_dialog_get_level (self->dialog);
else
level = GTK_FONT_CHOOSER_LEVEL_STYLE|GTK_FONT_CHOOSER_LEVEL_SIZE;
if ((level & GTK_FONT_CHOOSER_LEVEL_STYLE) != 0)
family_style = g_strconcat (fam_name, " ", face_name, NULL);
else
family_style = g_strdup (fam_name);
gtk_label_set_text (GTK_LABEL (self->font_label), family_style);
g_free (family_style);
if (self->level >= GTK_FONT_LEVEL_FONT)
if ((level & GTK_FONT_CHOOSER_LEVEL_SIZE) != 0)
{
/* mirror Pango, which doesn't translate this either */
size = g_strdup_printf ("%2.4g%s",
pango_font_description_get_size (self->font_desc) / (double)PANGO_SCALE,
pango_font_description_get_size_is_absolute (self->font_desc) ? "px" : "");
char *size = g_strdup_printf ("%2.4g%s",
pango_font_description_get_size (self->font_desc) / (double)PANGO_SCALE,
pango_font_description_get_size_is_absolute (self->font_desc) ? "px" : "");
gtk_label_set_text (GTK_LABEL (self->size_label), size);
g_free (size);
gtk_widget_show (self->font_size_box);
}
else
@@ -641,7 +466,7 @@ apply_use_font (GtkFontDialogButton *self)
{
PangoFontDescription *desc;
PangoAttrList *attrs;
PangoLanguage *language;
PangoLanguage *language = NULL;
desc = pango_font_description_copy (self->font_desc);
@@ -657,12 +482,8 @@ apply_use_font (GtkFontDialogButton *self)
pango_attr_list_insert (attrs, pango_attr_font_desc_new (desc));
if (self->font_features)
pango_attr_list_insert (attrs, pango_attr_font_features_new (self->font_features));
if (self->language)
language = self->language;
else if (self->dialog)
if (self->dialog)
language = gtk_font_dialog_get_language (self->dialog);
else
language = NULL;
if (language)
pango_attr_list_insert (attrs, pango_attr_language_new (language));
@@ -674,7 +495,8 @@ apply_use_font (GtkFontDialogButton *self)
}
/* }}} */
/* {{{ Constructor */
/* {{{ Public API */
/* {{{ Constructor */
/**
* gtk_font_dialog_button_new:
@@ -707,7 +529,7 @@ gtk_font_dialog_button_new (GtkFontDialog *dialog)
}
/* }}} */
/* {{{ Getters and setters */
/* {{{ Setters and Getters */
/**
* gtk_font_dialog_button_set_dialog:
@@ -730,7 +552,7 @@ gtk_font_dialog_button_set_dialog (GtkFontDialogButton *self,
if (!g_set_object (&self->dialog, dialog))
return;
update_button_sensitivity (self);
gtk_widget_set_sensitive (self->button, dialog != NULL);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DIALOG]);
}
@@ -753,49 +575,6 @@ gtk_font_dialog_button_get_dialog (GtkFontDialogButton *self)
return self->dialog;
}
/**
* gtk_font_dialog_button_get_level:
* @self: a `GtkFontDialogButton
*
* Returns the level of detail at which this dialog
* lets the user select fonts.
*
* Returns: the level of detail
*
* Since: 4.10
*/
GtkFontLevel
gtk_font_dialog_button_get_level (GtkFontDialogButton *self)
{
g_return_val_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self), GTK_FONT_LEVEL_FONT);
return self->level;
}
/**
* gtk_font_dialog_button_set_level:
* @self: a `GtkFontDialogButton`
* @level: the level of detail
*
* Sets the level of detail at which this dialog
* lets the user select fonts.
*
* Since: 4.10
*/
void
gtk_font_dialog_button_set_level (GtkFontDialogButton *self,
GtkFontLevel level)
{
g_return_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self));
if (self->level == level)
return;
self->level = level;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LEVEL]);
}
/**
* gtk_font_dialog_button_set_font_desc:
* @self: a `GtkFontDialogButton`
@@ -806,8 +585,8 @@ gtk_font_dialog_button_set_level (GtkFontDialogButton *self,
* Since: 4.10
*/
void
gtk_font_dialog_button_set_font_desc (GtkFontDialogButton *self,
const PangoFontDescription *font_desc)
gtk_font_dialog_button_set_font_desc (GtkFontDialogButton *self,
PangoFontDescription *font_desc)
{
g_return_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self));
g_return_if_fail (font_desc != NULL);
@@ -886,13 +665,10 @@ gtk_font_dialog_button_set_font_features (GtkFontDialogButton *self,
*
* Returns the font features of the button.
*
* This function is what should be used to obtain the font features
* that were choosen by the user. To get informed about changes, listen
* to "notify::font-features".
*
* Note that the button will only let users choose font features
* if [property@Gtk.FontDialogButton:level] is set to
* `GTK_FONT_LEVEL_FEATURES`.
* This function is what should be used to obtain
* the font features that were choosen by the user.
* To get informed about changes, listen to
* "notify::font-features".
*
* Returns: (transfer none) (nullable): the font features
*
@@ -906,52 +682,6 @@ gtk_font_dialog_button_get_font_features (GtkFontDialogButton *self)
return self->font_features;
}
/**
* gtk_font_dialog_button_set_language:
* @self: a `GtkFontDialogButton`
* @language: (nullable): the new language
*
* Sets the language to use for font features.
*
* Since: 4.10
*/
void
gtk_font_dialog_button_set_language (GtkFontDialogButton *self,
PangoLanguage *language)
{
g_return_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self));
if (self->language == language)
return;
self->language = language;
apply_use_font (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LANGUAGE]);
}
/**
* gtk_font_dialog_button_get_language:
* @self: a `GtkFontDialogButton`
*
* Returns the language that is used for font features.
*
* Returns: (nullable): the language
*
* Since: 4.10
*/
PangoLanguage *
gtk_font_dialog_button_get_language (GtkFontDialogButton *self)
{
g_return_val_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self), NULL);
return self->language;
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */
/**
* gtk_font_dialog_button_set_use_font:
* @self: a `GtkFontDialogButton`
@@ -1042,6 +772,7 @@ gtk_font_dialog_button_get_use_size (GtkFontDialogButton *self)
return self->use_size;
}
/* }}} */
/* }}} */
/* vim:set foldmethod=marker expandtab: */

View File

@@ -34,79 +34,43 @@ 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);
GtkWidget * gtk_font_dialog_button_new (GtkFontDialog *dialog);
GDK_AVAILABLE_IN_4_10
GtkFontDialog * gtk_font_dialog_button_get_dialog (GtkFontDialogButton *self);
void gtk_font_dialog_button_set_dialog (GtkFontDialogButton *self,
GtkFontDialog *dialog);
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;
GtkFontDialog * gtk_font_dialog_button_get_dialog (GtkFontDialogButton *self);
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);
void gtk_font_dialog_button_set_font_desc (GtkFontDialogButton *self,
PangoFontDescription *font_desc);
GDK_AVAILABLE_IN_4_10
PangoFontDescription *
gtk_font_dialog_button_get_font_desc (GtkFontDialogButton *self);
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);
void gtk_font_dialog_button_set_font_features
(GtkFontDialogButton *self,
const char *font_features);
GDK_AVAILABLE_IN_4_10
const char * gtk_font_dialog_button_get_font_features
(GtkFontDialogButton *self);
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,
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);
gboolean gtk_font_dialog_button_get_use_font (GtkFontDialogButton *self);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_button_set_use_size (GtkFontDialogButton *self,
void gtk_font_dialog_button_set_use_size (GtkFontDialogButton *self,
gboolean use_size);
GDK_AVAILABLE_IN_4_10
gboolean gtk_font_dialog_button_get_use_size (GtkFontDialogButton *self);
G_END_DECLS

View File

@@ -38,7 +38,7 @@
#include "gtklabel.h"
#include "gtkbutton.h"
#include "gtkenums.h"
#include "deprecated/gtkdialog.h"
#include "gtkdialog.h"
#include "gtkrevealer.h"
#include "gtkprivate.h"
#include "gtktypebuiltins.h"

Some files were not shown because too many files have changed in this diff Show More