mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 18:30:08 +00:00
gtk-demo: Port to async dialog API
This commit is contained in:
parent
99e1643cdd
commit
756888a53d
@ -33,22 +33,12 @@ static void create_window (GApplication *app, const char *contents);
|
|||||||
static void
|
static void
|
||||||
show_action_dialog (GSimpleAction *action)
|
show_action_dialog (GSimpleAction *action)
|
||||||
{
|
{
|
||||||
const char *name;
|
GtkAlertDialog *dialog;
|
||||||
GtkWidget *dialog;
|
|
||||||
|
|
||||||
name = g_action_get_name (G_ACTION (action));
|
dialog = gtk_alert_dialog_new ("You activated action: \"%s\n",
|
||||||
|
g_action_get_name (G_ACTION (action)));
|
||||||
dialog = gtk_message_dialog_new (NULL,
|
gtk_alert_dialog_show (dialog, NULL);
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
g_object_unref (dialog);
|
||||||
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
|
static void
|
||||||
@ -90,20 +80,19 @@ activate_new (GSimpleAction *action,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
open_response_cb (GtkNativeDialog *dialog,
|
open_response_cb (GObject *source,
|
||||||
int response_id,
|
GAsyncResult *result,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkFileChooserNative *native = user_data;
|
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||||
GApplication *app = g_object_get_data (G_OBJECT (native), "app");
|
GApplication *app = G_APPLICATION (user_data);
|
||||||
GtkWidget *message_dialog;
|
|
||||||
GFile *file;
|
GFile *file;
|
||||||
char *contents;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (response_id == GTK_RESPONSE_ACCEPT)
|
file = gtk_file_dialog_save_finish (dialog, result, &error);
|
||||||
|
if (file)
|
||||||
{
|
{
|
||||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (native));
|
char *contents;
|
||||||
|
|
||||||
if (g_file_load_contents (file, NULL, &contents, NULL, NULL, &error))
|
if (g_file_load_contents (file, NULL, &contents, NULL, NULL, &error))
|
||||||
{
|
{
|
||||||
@ -112,21 +101,16 @@ open_response_cb (GtkNativeDialog *dialog,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
message_dialog = gtk_message_dialog_new (NULL,
|
GtkAlertDialog *alert;
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
||||||
GTK_MESSAGE_ERROR,
|
alert = gtk_alert_dialog_new ("Error loading file: \"%s\"", error->message);
|
||||||
GTK_BUTTONS_CLOSE,
|
gtk_alert_dialog_show (alert, NULL);
|
||||||
"Error loading file: \"%s\"",
|
g_object_unref (alert);
|
||||||
error->message);
|
|
||||||
g_signal_connect (message_dialog, "response",
|
|
||||||
G_CALLBACK (gtk_window_destroy), NULL);
|
|
||||||
gtk_widget_show (message_dialog);
|
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (native));
|
g_object_unref (app);
|
||||||
g_object_unref (native);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -136,21 +120,11 @@ activate_open (GSimpleAction *action,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GApplication *app = user_data;
|
GApplication *app = user_data;
|
||||||
GtkFileChooserNative *native;
|
GtkFileDialog *dialog;
|
||||||
|
|
||||||
native = gtk_file_chooser_native_new ("Open File",
|
dialog = gtk_file_dialog_new ();
|
||||||
NULL,
|
gtk_file_dialog_open (dialog, NULL, NULL, NULL, open_response_cb, g_object_ref (app));
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
g_object_unref (dialog);
|
||||||
"_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
|
static void
|
||||||
|
@ -50,10 +50,10 @@ copy_button_clicked (GtkStack *source_stack,
|
|||||||
}
|
}
|
||||||
else if (strcmp (visible_child_name, "Color") == 0)
|
else if (strcmp (visible_child_name, "Color") == 0)
|
||||||
{
|
{
|
||||||
GdkRGBA color;
|
const GdkRGBA *color;
|
||||||
|
|
||||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (visible_child), &color);
|
color = gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (visible_child));
|
||||||
gdk_clipboard_set (clipboard, GDK_TYPE_RGBA, &color);
|
gdk_clipboard_set (clipboard, GDK_TYPE_RGBA, color);
|
||||||
}
|
}
|
||||||
else if (strcmp (visible_child_name, "File") == 0)
|
else if (strcmp (visible_child_name, "File") == 0)
|
||||||
{
|
{
|
||||||
@ -215,37 +215,36 @@ file_button_set_file (GtkButton *button,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
file_chooser_response (GtkNativeDialog *dialog,
|
file_chooser_response (GObject *source,
|
||||||
int response,
|
GAsyncResult *result,
|
||||||
GtkButton *button)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
gtk_native_dialog_hide (dialog);
|
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||||
|
GtkButton *button = GTK_BUTTON (user_data);
|
||||||
|
GFile *file;
|
||||||
|
|
||||||
if (response == GTK_RESPONSE_ACCEPT)
|
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||||
|
if (file)
|
||||||
{
|
{
|
||||||
GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
|
||||||
file_button_set_file (button, file);
|
file_button_set_file (button, file);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
|
|
||||||
update_copy_button_sensitivity (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_STACK));
|
update_copy_button_sensitivity (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_STACK));
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_native_dialog_destroy (dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
open_file_cb (GtkWidget *button)
|
open_file_cb (GtkWidget *button)
|
||||||
{
|
{
|
||||||
GtkFileChooserNative *chooser;
|
GtkFileDialog *dialog;
|
||||||
|
|
||||||
chooser = gtk_file_chooser_native_new ("Choose a file",
|
dialog = gtk_file_dialog_new ();
|
||||||
GTK_WINDOW (gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW)),
|
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
|
||||||
"_Open",
|
|
||||||
"_Cancel");
|
|
||||||
|
|
||||||
g_signal_connect (chooser, "response", G_CALLBACK (file_chooser_response), button);
|
gtk_file_dialog_open (dialog,
|
||||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (chooser));
|
GTK_WINDOW (gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW)),
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
file_chooser_response, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -64,7 +64,11 @@
|
|||||||
<object class="GtkStackPage">
|
<object class="GtkStackPage">
|
||||||
<property name="name">Color</property>
|
<property name="name">Color</property>
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="GtkColorButton" id="source_color">
|
<object class="GtkColorDialogButton" id="source_color">
|
||||||
|
<property name="dialog">
|
||||||
|
<object class="GtkColorDialog">
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<property name="rgba">purple</property>
|
<property name="rgba">purple</property>
|
||||||
</object>
|
</object>
|
||||||
|
@ -256,10 +256,10 @@ swap_colors (void)
|
|||||||
GdkRGBA fg;
|
GdkRGBA fg;
|
||||||
GdkRGBA bg;
|
GdkRGBA bg;
|
||||||
|
|
||||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->foreground), &fg);
|
fg = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground));
|
||||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->background), &bg);
|
bg = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background));
|
||||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (demo->foreground), &bg);
|
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground), &bg);
|
||||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (demo->background), &fg);
|
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background), &fg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -268,8 +268,8 @@ font_features_reset_basic (void)
|
|||||||
gtk_adjustment_set_value (demo->size_adjustment, 20);
|
gtk_adjustment_set_value (demo->size_adjustment, 20);
|
||||||
gtk_adjustment_set_value (demo->letterspacing_adjustment, 0);
|
gtk_adjustment_set_value (demo->letterspacing_adjustment, 0);
|
||||||
gtk_adjustment_set_value (demo->line_height_adjustment, 1);
|
gtk_adjustment_set_value (demo->line_height_adjustment, 1);
|
||||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (demo->foreground), &(GdkRGBA){0.,0.,0.,1.});
|
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground), &(GdkRGBA){0.,0.,0.,1.});
|
||||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (demo->background), &(GdkRGBA){1.,1.,1.,1.});
|
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background), &(GdkRGBA){1.,1.,1.,1.});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -277,7 +277,7 @@ update_basic (void)
|
|||||||
{
|
{
|
||||||
PangoFontDescription *desc;
|
PangoFontDescription *desc;
|
||||||
|
|
||||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
|
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||||
|
|
||||||
gtk_adjustment_set_value (demo->size_adjustment,
|
gtk_adjustment_set_value (demo->size_adjustment,
|
||||||
pango_font_description_get_size (desc) / (double) PANGO_SCALE);
|
pango_font_description_get_size (desc) / (double) PANGO_SCALE);
|
||||||
@ -588,7 +588,7 @@ update_display (void)
|
|||||||
end = PANGO_ATTR_INDEX_TO_TEXT_END;
|
end = PANGO_ATTR_INDEX_TO_TEXT_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
|
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||||
|
|
||||||
value = gtk_adjustment_get_value (demo->size_adjustment);
|
value = gtk_adjustment_get_value (demo->size_adjustment);
|
||||||
pango_font_description_set_size (desc, value * PANGO_SCALE);
|
pango_font_description_set_size (desc, value * PANGO_SCALE);
|
||||||
@ -679,7 +679,7 @@ update_display (void)
|
|||||||
GdkRGBA rgba;
|
GdkRGBA rgba;
|
||||||
char *fg, *bg, *css;
|
char *fg, *bg, *css;
|
||||||
|
|
||||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->foreground), &rgba);
|
rgba = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground));
|
||||||
attr = pango_attr_foreground_new (65535 * rgba.red,
|
attr = pango_attr_foreground_new (65535 * rgba.red,
|
||||||
65535 * rgba.green,
|
65535 * rgba.green,
|
||||||
65535 * rgba.blue);
|
65535 * rgba.blue);
|
||||||
@ -692,7 +692,7 @@ update_display (void)
|
|||||||
pango_attr_list_insert (attrs, attr);
|
pango_attr_list_insert (attrs, attr);
|
||||||
|
|
||||||
fg = gdk_rgba_to_string (&rgba);
|
fg = gdk_rgba_to_string (&rgba);
|
||||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->background), &rgba);
|
rgba = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background));
|
||||||
bg = gdk_rgba_to_string (&rgba);
|
bg = gdk_rgba_to_string (&rgba);
|
||||||
css = g_strdup_printf (".font_features_background { caret-color: %s; background-color: %s; }", fg, bg);
|
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));
|
gtk_css_provider_load_from_data (demo->provider, css, strlen (css));
|
||||||
@ -767,7 +767,6 @@ update_display (void)
|
|||||||
gtk_label_set_attributes (GTK_LABEL (demo->the_label), attrs);
|
gtk_label_set_attributes (GTK_LABEL (demo->the_label), attrs);
|
||||||
|
|
||||||
g_free (font_desc);
|
g_free (font_desc);
|
||||||
pango_font_description_free (desc);
|
|
||||||
g_free (features);
|
g_free (features);
|
||||||
pango_attr_list_unref (attrs);
|
pango_attr_list_unref (attrs);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
@ -779,7 +778,7 @@ get_pango_font (void)
|
|||||||
PangoFontDescription *desc;
|
PangoFontDescription *desc;
|
||||||
PangoContext *context;
|
PangoContext *context;
|
||||||
|
|
||||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
|
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||||
context = gtk_widget_get_pango_context (demo->font);
|
context = gtk_widget_get_pango_context (demo->font);
|
||||||
|
|
||||||
return pango_context_load_font (context, desc);
|
return pango_context_load_font (context, desc);
|
||||||
@ -831,17 +830,17 @@ update_script_combo (void)
|
|||||||
GHashTable *tags;
|
GHashTable *tags;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
TagPair *pair;
|
TagPair *pair;
|
||||||
char *lang;
|
PangoLanguage *language;
|
||||||
|
const char *lang;
|
||||||
hb_tag_t active;
|
hb_tag_t active;
|
||||||
|
|
||||||
lang = gtk_font_chooser_get_language (GTK_FONT_CHOOSER (demo->font));
|
language = gtk_font_dialog_button_get_language (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||||
|
lang = pango_language_to_string (language);
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
active = hb_ot_tag_from_language (hb_language_from_string (lang, -1));
|
active = hb_ot_tag_from_language (hb_language_from_string (lang, -1));
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
g_free (lang);
|
|
||||||
|
|
||||||
store = g_list_store_new (script_lang_get_type ());
|
store = g_list_store_new (script_lang_get_type ());
|
||||||
|
|
||||||
pango_font = get_pango_font ();
|
pango_font = get_pango_font ();
|
||||||
@ -1005,7 +1004,7 @@ update_features (void)
|
|||||||
{
|
{
|
||||||
hb_tag_t tables[2] = { HB_OT_TAG_GSUB, HB_OT_TAG_GPOS };
|
hb_tag_t tables[2] = { HB_OT_TAG_GSUB, HB_OT_TAG_GPOS };
|
||||||
hb_face_t *hb_face;
|
hb_face_t *hb_face;
|
||||||
char *feat;
|
const char *feat;
|
||||||
|
|
||||||
hb_face = hb_font_get_face (hb_font);
|
hb_face = hb_font_get_face (hb_font);
|
||||||
|
|
||||||
@ -1098,7 +1097,7 @@ update_features (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
feat = gtk_font_chooser_get_font_features (GTK_FONT_CHOOSER (demo->font));
|
feat = gtk_font_dialog_button_get_font_features (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||||
if (feat)
|
if (feat)
|
||||||
{
|
{
|
||||||
for (l = demo->feature_items; l; l = l->next)
|
for (l = demo->feature_items; l; l = l->next)
|
||||||
@ -1124,8 +1123,6 @@ update_features (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (feat);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1780,6 +1777,7 @@ do_font_features (GtkWidget *do_widget)
|
|||||||
demo->description = GTK_WIDGET (gtk_builder_get_object (builder, "description"));
|
demo->description = GTK_WIDGET (gtk_builder_get_object (builder, "description"));
|
||||||
demo->font = GTK_WIDGET (gtk_builder_get_object (builder, "font"));
|
demo->font = GTK_WIDGET (gtk_builder_get_object (builder, "font"));
|
||||||
demo->script_lang = GTK_WIDGET (gtk_builder_get_object (builder, "script_lang"));
|
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);
|
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_drop_down_set_expression (GTK_DROP_DOWN (demo->script_lang), expression);
|
||||||
gtk_expression_unref (expression);
|
gtk_expression_unref (expression);
|
||||||
|
@ -58,11 +58,14 @@
|
|||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">6</property>
|
<property name="spacing">6</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFontButton" id="font">
|
<object class="GtkFontDialogButton" id="font">
|
||||||
|
<property name="dialog">
|
||||||
|
<object class="GtkFontDialog">
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
<property name="receives-default">1</property>
|
<property name="receives-default">1</property>
|
||||||
<property name="font">Sans 12</property>
|
<property name="level">face</property>
|
||||||
<property name="level">family|style</property>
|
<signal name="notify::font-desc" handler="font_features_font_changed" swapped="no"/>
|
||||||
<signal name="font-set" handler="font_features_font_changed" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@ -192,7 +195,11 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkColorButton" id="foreground">
|
<object class="GtkColorDialogButton" id="foreground">
|
||||||
|
<property name="dialog">
|
||||||
|
<object class="GtkColorDialog">
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
<property name="rgba">black</property>
|
<property name="rgba">black</property>
|
||||||
<signal name="notify::rgba" handler="color_set_cb"/>
|
<signal name="notify::rgba" handler="color_set_cb"/>
|
||||||
@ -214,7 +221,11 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkColorButton" id="background">
|
<object class="GtkColorDialogButton" id="background">
|
||||||
|
<property name="dialog">
|
||||||
|
<object class="GtkColorDialog">
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
<property name="rgba">white</property>
|
<property name="rgba">white</property>
|
||||||
<signal name="notify::rgba" handler="color_set_cb"/>
|
<signal name="notify::rgba" handler="color_set_cb"/>
|
||||||
|
@ -53,7 +53,7 @@ update_image (void)
|
|||||||
context = gtk_widget_create_pango_context (image);
|
context = gtk_widget_create_pango_context (image);
|
||||||
|
|
||||||
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (font_button));
|
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (font_button));
|
||||||
|
|
||||||
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
|
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
|
||||||
|
|
||||||
@ -287,8 +287,6 @@ retry:
|
|||||||
gtk_picture_set_pixbuf (GTK_PICTURE (image), pixbuf2);
|
gtk_picture_set_pixbuf (GTK_PICTURE (image), pixbuf2);
|
||||||
|
|
||||||
g_object_unref (pixbuf2);
|
g_object_unref (pixbuf2);
|
||||||
|
|
||||||
pango_font_description_free (desc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean fading = FALSE;
|
static gboolean fading = FALSE;
|
||||||
|
@ -74,7 +74,11 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFontButton" id="font_button">
|
<object class="GtkFontDialogButton" id="font_button">
|
||||||
|
<property name="dialog">
|
||||||
|
<object class="GtkFontDialog">
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">2</property>
|
<property name="column">2</property>
|
||||||
<property name="row">1</property>
|
<property name="row">1</property>
|
||||||
|
@ -83,24 +83,17 @@ progressive_timeout (gpointer data)
|
|||||||
|
|
||||||
if (bytes_read < 0)
|
if (bytes_read < 0)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkAlertDialog *dialog;
|
||||||
|
|
||||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
dialog = gtk_alert_dialog_new ("Failure reading image file 'alphatest.png': %s",
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
error->message);
|
||||||
GTK_MESSAGE_ERROR,
|
gtk_alert_dialog_show (dialog, NULL);
|
||||||
GTK_BUTTONS_CLOSE,
|
g_object_unref (dialog);
|
||||||
"Failure reading image file 'alphatest.png': %s",
|
|
||||||
error->message);
|
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
|
||||||
g_signal_connect (dialog, "response",
|
|
||||||
G_CALLBACK (gtk_window_destroy), NULL);
|
|
||||||
|
|
||||||
g_object_unref (image_stream);
|
g_object_unref (image_stream);
|
||||||
image_stream = NULL;
|
image_stream = NULL;
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
|
||||||
|
|
||||||
load_timeout = 0;
|
load_timeout = 0;
|
||||||
|
|
||||||
return FALSE; /* uninstall the timeout */
|
return FALSE; /* uninstall the timeout */
|
||||||
@ -110,25 +103,17 @@ progressive_timeout (gpointer data)
|
|||||||
buf, bytes_read,
|
buf, bytes_read,
|
||||||
&error))
|
&error))
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkAlertDialog *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_error_free (error);
|
||||||
|
|
||||||
g_signal_connect (dialog, "response",
|
|
||||||
G_CALLBACK (gtk_window_destroy), NULL);
|
|
||||||
|
|
||||||
g_object_unref (image_stream);
|
g_object_unref (image_stream);
|
||||||
image_stream = NULL;
|
image_stream = NULL;
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
|
||||||
|
|
||||||
load_timeout = 0;
|
load_timeout = 0;
|
||||||
|
|
||||||
return FALSE; /* uninstall the timeout */
|
return FALSE; /* uninstall the timeout */
|
||||||
@ -143,22 +128,14 @@ progressive_timeout (gpointer data)
|
|||||||
error = NULL;
|
error = NULL;
|
||||||
if (!g_input_stream_close (image_stream, NULL, &error))
|
if (!g_input_stream_close (image_stream, NULL, &error))
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkAlertDialog *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_error_free (error);
|
||||||
|
|
||||||
g_signal_connect (dialog, "response",
|
|
||||||
G_CALLBACK (gtk_window_destroy), NULL);
|
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
|
||||||
|
|
||||||
g_object_unref (image_stream);
|
g_object_unref (image_stream);
|
||||||
image_stream = NULL;
|
image_stream = NULL;
|
||||||
g_object_unref (pixbuf_loader);
|
g_object_unref (pixbuf_loader);
|
||||||
@ -177,25 +154,16 @@ progressive_timeout (gpointer data)
|
|||||||
* it was incomplete.
|
* it was incomplete.
|
||||||
*/
|
*/
|
||||||
error = NULL;
|
error = NULL;
|
||||||
if (!gdk_pixbuf_loader_close (pixbuf_loader,
|
if (!gdk_pixbuf_loader_close (pixbuf_loader, &error))
|
||||||
&error))
|
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkAlertDialog *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_error_free (error);
|
||||||
|
|
||||||
g_signal_connect (dialog, "response",
|
|
||||||
G_CALLBACK (gtk_window_destroy), NULL);
|
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
|
||||||
|
|
||||||
g_object_unref (pixbuf_loader);
|
g_object_unref (pixbuf_loader);
|
||||||
pixbuf_loader = NULL;
|
pixbuf_loader = NULL;
|
||||||
|
|
||||||
@ -216,20 +184,14 @@ progressive_timeout (gpointer data)
|
|||||||
|
|
||||||
if (image_stream == NULL)
|
if (image_stream == NULL)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkAlertDialog *dialog;
|
||||||
|
|
||||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
dialog = gtk_alert_dialog_new ("%s",
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
error->message);
|
||||||
GTK_MESSAGE_ERROR,
|
gtk_alert_dialog_show (dialog, NULL);
|
||||||
GTK_BUTTONS_CLOSE,
|
g_object_unref (dialog);
|
||||||
"%s", error->message);
|
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
|
||||||
g_signal_connect (dialog, "response",
|
|
||||||
G_CALLBACK (gtk_window_destroy), NULL);
|
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
|
||||||
|
|
||||||
load_timeout = 0;
|
load_timeout = 0;
|
||||||
|
|
||||||
return FALSE; /* uninstall the timeout */
|
return FALSE; /* uninstall the timeout */
|
||||||
|
@ -12,8 +12,8 @@ on_bar_response (GtkInfoBar *info_bar,
|
|||||||
int response_id,
|
int response_id,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkAlertDialog *dialog;
|
||||||
GtkWidget *window;
|
char *detail;
|
||||||
|
|
||||||
if (response_id == GTK_RESPONSE_CLOSE)
|
if (response_id == GTK_RESPONSE_CLOSE)
|
||||||
{
|
{
|
||||||
@ -21,19 +21,12 @@ on_bar_response (GtkInfoBar *info_bar,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
window = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (info_bar)));
|
dialog = gtk_alert_dialog_new ("You clicked a button on an info bar");
|
||||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
detail = g_strdup_printf ("Your response has been %d", response_id);
|
||||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
gtk_alert_dialog_set_detail (dialog, detail);
|
||||||
GTK_MESSAGE_INFO,
|
g_free (detail);
|
||||||
GTK_BUTTONS_OK,
|
gtk_alert_dialog_show (dialog, GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (info_bar))));
|
||||||
"You clicked a button on an info bar");
|
g_object_unref (dialog);
|
||||||
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 *
|
GtkWidget *
|
||||||
|
@ -7,38 +7,22 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
static void
|
|
||||||
response_cb (GtkWidget *dialog,
|
|
||||||
int response_id,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
activate_link (GtkWidget *label,
|
activate_link (GtkWidget *label,
|
||||||
const char *uri,
|
const char *uri,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
if (g_strcmp0 (uri, "keynav") == 0)
|
if (g_strcmp0 (uri, "keynav") == 0)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkAlertDialog *dialog;
|
||||||
GtkWidget *parent;
|
|
||||||
|
|
||||||
parent = GTK_WIDGET (gtk_widget_get_root (label));
|
dialog = gtk_alert_dialog_new ("Keyboard navigation");
|
||||||
dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (parent),
|
gtk_alert_dialog_set_detail (dialog,
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
"The term ‘keynav’ is a shorthand for "
|
||||||
GTK_MESSAGE_INFO,
|
"keyboard navigation and refers to the process of using "
|
||||||
GTK_BUTTONS_OK,
|
"a program (exclusively) via keyboard input.");
|
||||||
"Keyboard navigation");
|
gtk_alert_dialog_show (dialog, GTK_WINDOW (gtk_widget_get_root (label)));
|
||||||
gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
|
g_object_unref (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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -117,19 +117,16 @@ activate_cb (GtkListView *list,
|
|||||||
G_APP_LAUNCH_CONTEXT (context),
|
G_APP_LAUNCH_CONTEXT (context),
|
||||||
&error))
|
&error))
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkAlertDialog *dialog;
|
||||||
|
|
||||||
/* And because error handling is important, even a simple demo has it:
|
/* And because error handling is important, even a simple demo has it:
|
||||||
* We display an error dialog that something went wrong.
|
* We display an error dialog that something went wrong.
|
||||||
*/
|
*/
|
||||||
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (list))),
|
dialog = gtk_alert_dialog_new ("Could not launch %s", g_app_info_get_display_name (app_info));
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
|
gtk_alert_dialog_set_detail (dialog, error->message);
|
||||||
GTK_MESSAGE_ERROR,
|
gtk_alert_dialog_show (dialog, GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (list))));
|
||||||
GTK_BUTTONS_CLOSE,
|
g_object_unref (dialog);
|
||||||
"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);
|
g_clear_error (&error);
|
||||||
gtk_widget_show (dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (context);
|
g_object_unref (context);
|
||||||
|
@ -141,39 +141,35 @@ load_file (GtkStringList *list,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
open_response_cb (GtkNativeDialog *dialog,
|
open_response_cb (GObject *source,
|
||||||
int response,
|
GAsyncResult *result,
|
||||||
GtkStringList *stringlist)
|
void *user_data)
|
||||||
{
|
{
|
||||||
gtk_native_dialog_hide (dialog);
|
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||||
|
GtkStringList *stringlist = GTK_STRING_LIST (user_data);
|
||||||
|
GFile *file;
|
||||||
|
|
||||||
if (response == GTK_RESPONSE_ACCEPT)
|
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||||
|
if (file)
|
||||||
{
|
{
|
||||||
GFile *file;
|
|
||||||
|
|
||||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
|
||||||
load_file (stringlist, file);
|
load_file (stringlist, file);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_native_dialog_destroy (dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
file_open_cb (GtkWidget *button,
|
file_open_cb (GtkWidget *button,
|
||||||
GtkStringList *stringlist)
|
GtkStringList *stringlist)
|
||||||
{
|
{
|
||||||
GtkFileChooserNative *dialog;
|
GtkFileDialog *dialog;
|
||||||
|
|
||||||
dialog = gtk_file_chooser_native_new ("Open file",
|
dialog = gtk_file_dialog_new ();
|
||||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
gtk_file_dialog_open (dialog,
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||||
"_Load",
|
NULL,
|
||||||
"_Cancel");
|
NULL,
|
||||||
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
|
open_response_cb, stringlist);
|
||||||
|
g_object_unref (dialog);
|
||||||
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), stringlist);
|
|
||||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
|
@ -51,8 +51,8 @@ static const char *pad_colors[] = {
|
|||||||
static GType drawing_area_get_type (void);
|
static GType drawing_area_get_type (void);
|
||||||
G_DEFINE_TYPE (DrawingArea, drawing_area, GTK_TYPE_WIDGET)
|
G_DEFINE_TYPE (DrawingArea, drawing_area, GTK_TYPE_WIDGET)
|
||||||
|
|
||||||
static void drawing_area_set_color (DrawingArea *area,
|
static void drawing_area_set_color (DrawingArea *area,
|
||||||
GdkRGBA *color);
|
const GdkRGBA *color);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
drawing_area_ensure_surface (DrawingArea *area,
|
drawing_area_ensure_surface (DrawingArea *area,
|
||||||
@ -350,8 +350,8 @@ drawing_area_new (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
drawing_area_set_color (DrawingArea *area,
|
drawing_area_set_color (DrawingArea *area,
|
||||||
GdkRGBA *color)
|
const GdkRGBA *color)
|
||||||
{
|
{
|
||||||
if (gdk_rgba_equal (&area->draw_color, color))
|
if (gdk_rgba_equal (&area->draw_color, color))
|
||||||
return;
|
return;
|
||||||
@ -361,21 +361,22 @@ drawing_area_set_color (DrawingArea *area,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
color_button_color_set (GtkColorButton *button,
|
color_button_color_set (GtkColorDialogButton *button,
|
||||||
DrawingArea *draw_area)
|
GParamSpec *pspec,
|
||||||
|
DrawingArea *draw_area)
|
||||||
{
|
{
|
||||||
GdkRGBA color;
|
const GdkRGBA *color;
|
||||||
|
|
||||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &color);
|
color = gtk_color_dialog_button_get_rgba (button);
|
||||||
drawing_area_set_color (draw_area, &color);
|
drawing_area_set_color (draw_area, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
drawing_area_color_set (DrawingArea *area,
|
drawing_area_color_set (DrawingArea *area,
|
||||||
GdkRGBA *color,
|
GdkRGBA *color,
|
||||||
GtkColorButton *button)
|
GtkColorDialogButton *button)
|
||||||
{
|
{
|
||||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), color);
|
gtk_color_dialog_button_set_rgba (button, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
@ -394,13 +395,13 @@ do_paint (GtkWidget *toplevel)
|
|||||||
|
|
||||||
headerbar = gtk_header_bar_new ();
|
headerbar = gtk_header_bar_new ();
|
||||||
|
|
||||||
colorbutton = gtk_color_button_new ();
|
colorbutton = gtk_color_dialog_button_new (gtk_color_dialog_new ());
|
||||||
g_signal_connect (colorbutton, "color-set",
|
g_signal_connect (colorbutton, "notify::rgba",
|
||||||
G_CALLBACK (color_button_color_set), draw_area);
|
G_CALLBACK (color_button_color_set), draw_area);
|
||||||
g_signal_connect (draw_area, "color-set",
|
g_signal_connect (draw_area, "color-set",
|
||||||
G_CALLBACK (drawing_area_color_set), colorbutton);
|
G_CALLBACK (drawing_area_color_set), colorbutton);
|
||||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (colorbutton),
|
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (colorbutton),
|
||||||
&(GdkRGBA) { 0, 0, 0, 1 });
|
&(GdkRGBA) { 0, 0, 0, 1 });
|
||||||
|
|
||||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), colorbutton);
|
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), colorbutton);
|
||||||
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
|
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
|
||||||
|
@ -13,25 +13,24 @@
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
open_response_cb (GtkNativeDialog *dialog,
|
open_response_cb (GObject *source,
|
||||||
int response,
|
GAsyncResult *result,
|
||||||
GtkPicture *picture)
|
void *data)
|
||||||
{
|
{
|
||||||
gtk_native_dialog_hide (dialog);
|
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||||
|
GtkPicture *picture = data;
|
||||||
|
GFile *file;
|
||||||
|
|
||||||
if (response == GTK_RESPONSE_ACCEPT)
|
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||||
|
if (file)
|
||||||
{
|
{
|
||||||
GFile *file;
|
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
|
|
||||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
|
||||||
paintable = svg_paintable_new (file);
|
paintable = svg_paintable_new (file);
|
||||||
gtk_picture_set_paintable (GTK_PICTURE (picture), paintable);
|
gtk_picture_set_paintable (GTK_PICTURE (picture), paintable);
|
||||||
g_object_unref (paintable);
|
g_object_unref (paintable);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_native_dialog_destroy (dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -39,20 +38,25 @@ show_file_open (GtkWidget *button,
|
|||||||
GtkPicture *picture)
|
GtkPicture *picture)
|
||||||
{
|
{
|
||||||
GtkFileFilter *filter;
|
GtkFileFilter *filter;
|
||||||
GtkFileChooserNative *dialog;
|
GtkFileDialog *dialog;
|
||||||
|
GListStore *filters;
|
||||||
|
|
||||||
dialog = gtk_file_chooser_native_new ("Open node file",
|
dialog = gtk_file_dialog_new ();
|
||||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
gtk_file_dialog_set_title (dialog, "Open node file");
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
|
||||||
"_Load",
|
|
||||||
"_Cancel");
|
|
||||||
|
|
||||||
filter = gtk_file_filter_new ();
|
filter = gtk_file_filter_new ();
|
||||||
gtk_file_filter_add_mime_type (filter, "image/svg+xml");
|
gtk_file_filter_add_mime_type (filter, "image/svg+xml");
|
||||||
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
|
filters = g_list_store_new (GTK_TYPE_FILE_FILTER);
|
||||||
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
|
g_list_store_append (filters, filter);
|
||||||
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), picture);
|
g_object_unref (filter);
|
||||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
|
gtk_file_dialog_set_filters (dialog, G_LIST_MODEL (filters));
|
||||||
|
g_object_unref (filters);
|
||||||
|
|
||||||
|
gtk_file_dialog_open (dialog,
|
||||||
|
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
open_response_cb, picture);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *window;
|
static GtkWidget *window;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Pickers
|
/* Pickers
|
||||||
* #Keywords: GtkColorChooser, GtkFontChooser, GtkApplicationChooser
|
* #Keywords: GtkColorDialog, GtkFontDialog, GtkFileDialog
|
||||||
*
|
*
|
||||||
* These widgets are mainly intended for use in preference dialogs.
|
* These widgets are mainly intended for use in preference dialogs.
|
||||||
* They allow to select colors, fonts and applications.
|
* They allow to select colors, fonts and applications.
|
||||||
|
@ -177,19 +177,12 @@ do_printing (GtkWidget *do_widget)
|
|||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkAlertDialog *dialog;
|
||||||
|
|
||||||
dialog = gtk_message_dialog_new (GTK_WINDOW (do_widget),
|
dialog = gtk_alert_dialog_new ("%s", error->message);
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
gtk_alert_dialog_show (dialog, GTK_WINDOW (do_widget));
|
||||||
GTK_MESSAGE_ERROR,
|
g_object_unref (dialog);
|
||||||
GTK_BUTTONS_CLOSE,
|
|
||||||
"%s", error->message);
|
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
|
||||||
g_signal_connect (dialog, "response",
|
|
||||||
G_CALLBACK (gtk_window_destroy), NULL);
|
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,60 +10,63 @@
|
|||||||
static GtkWidget *window = NULL;
|
static GtkWidget *window = NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
open_dialog_response_cb (GtkNativeDialog *dialog,
|
open_dialog_response_cb (GObject *source,
|
||||||
int response,
|
GAsyncResult *result,
|
||||||
GtkWidget *video)
|
void *user_data)
|
||||||
{
|
{
|
||||||
gtk_native_dialog_hide (dialog);
|
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||||
|
GtkWidget *video = user_data;
|
||||||
|
GFile *file;
|
||||||
|
|
||||||
if (response == GTK_RESPONSE_ACCEPT)
|
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||||
|
if (file)
|
||||||
{
|
{
|
||||||
GFile *file;
|
|
||||||
|
|
||||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
|
||||||
gtk_video_set_file (GTK_VIDEO (video), file);
|
gtk_video_set_file (GTK_VIDEO (video), file);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_native_dialog_destroy (dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
open_clicked_cb (GtkWidget *button,
|
open_clicked_cb (GtkWidget *button,
|
||||||
GtkWidget *video)
|
GtkWidget *video)
|
||||||
{
|
{
|
||||||
GtkFileChooserNative *dialog;
|
GtkFileDialog *dialog;
|
||||||
GtkFileFilter *filter;
|
GtkFileFilter *filter;
|
||||||
|
GListStore *filters;
|
||||||
|
|
||||||
dialog = gtk_file_chooser_native_new ("Select a video",
|
dialog = gtk_file_dialog_new ();
|
||||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
gtk_file_dialog_set_title (dialog, "Select a video");
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
|
||||||
"_Open",
|
filters = g_list_store_new (GTK_TYPE_FILE_FILTER);
|
||||||
"_Cancel");
|
|
||||||
|
|
||||||
filter = gtk_file_filter_new ();
|
filter = gtk_file_filter_new ();
|
||||||
gtk_file_filter_add_pattern (filter, "*");
|
gtk_file_filter_add_pattern (filter, "*");
|
||||||
gtk_file_filter_set_name (filter, "All Files");
|
gtk_file_filter_set_name (filter, "All Files");
|
||||||
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
g_list_store_append (filters, filter);
|
||||||
g_object_unref (filter);
|
g_object_unref (filter);
|
||||||
|
|
||||||
filter = gtk_file_filter_new ();
|
filter = gtk_file_filter_new ();
|
||||||
gtk_file_filter_add_mime_type (filter, "image/*");
|
gtk_file_filter_add_mime_type (filter, "image/*");
|
||||||
gtk_file_filter_set_name (filter, "Images");
|
gtk_file_filter_set_name (filter, "Images");
|
||||||
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
g_list_store_append (filters, filter);
|
||||||
g_object_unref (filter);
|
g_object_unref (filter);
|
||||||
|
|
||||||
filter = gtk_file_filter_new ();
|
filter = gtk_file_filter_new ();
|
||||||
gtk_file_filter_add_mime_type (filter, "video/*");
|
gtk_file_filter_add_mime_type (filter, "video/*");
|
||||||
gtk_file_filter_set_name (filter, "Video");
|
gtk_file_filter_set_name (filter, "Video");
|
||||||
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
g_list_store_append (filters, filter);
|
||||||
|
|
||||||
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
|
gtk_file_dialog_set_current_filter (dialog, filter);
|
||||||
g_object_unref (filter);
|
g_object_unref (filter);
|
||||||
|
|
||||||
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
|
gtk_file_dialog_set_filters (dialog, G_LIST_MODEL (filters));
|
||||||
g_signal_connect (dialog, "response", G_CALLBACK (open_dialog_response_cb), video);
|
g_object_unref (filters);
|
||||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
|
|
||||||
|
gtk_file_dialog_open (dialog,
|
||||||
|
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
open_dialog_response_cb, video);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user