Commit a731d3f1 authored by Victor Ananjesky's avatar Victor Ananjesky

migrate to GtkFontChooser in gtk3 build

parent 2f69df13
...@@ -28,7 +28,11 @@ static GtkWidget *font; ...@@ -28,7 +28,11 @@ static GtkWidget *font;
static void static void
realize_cb (GtkWidget * w, gpointer d) realize_cb (GtkWidget * w, gpointer d)
{ {
#if GTK_CHECK_VERSION(3,0,0)
gtk_font_chooser_set_font (GTK_FONT_CHOOSER (w), options.common_data.font);
#else
gtk_font_selection_set_font_name (GTK_FONT_SELECTION (w), options.common_data.font); gtk_font_selection_set_font_name (GTK_FONT_SELECTION (w), options.common_data.font);
#endif
} }
GtkWidget * GtkWidget *
...@@ -36,11 +40,19 @@ font_create_widget (GtkWidget * dlg) ...@@ -36,11 +40,19 @@ font_create_widget (GtkWidget * dlg)
{ {
GtkWidget *w; GtkWidget *w;
#if GTK_CHECK_VERSION(3,0,0)
w = font = gtk_font_chooser_widget_new ();
#else
w = font = gtk_font_selection_new (); w = font = gtk_font_selection_new ();
#endif
gtk_widget_set_name (w, "yad-font-widget"); gtk_widget_set_name (w, "yad-font-widget");
if (options.font_data.preview) if (options.font_data.preview)
#if GTK_CHECK_VERSION(3,0,0)
gtk_font_chooser_set_preview_text (GTK_FONT_CHOOSER (w), options.font_data.preview);
#else
gtk_font_selection_set_preview_text (GTK_FONT_SELECTION (w), options.font_data.preview); gtk_font_selection_set_preview_text (GTK_FONT_SELECTION (w), options.font_data.preview);
#endif
/* font must be set after widget inserted in toplevel */ /* font must be set after widget inserted in toplevel */
if (options.common_data.font) if (options.common_data.font)
...@@ -58,9 +70,15 @@ font_print_result (void) ...@@ -58,9 +70,15 @@ font_print_result (void)
PangoFontFamily *family; PangoFontFamily *family;
gint size; gint size;
#if GTK_CHECK_VERSION(3,0,0)
face = gtk_font_chooser_get_font_face (GTK_FONT_CHOOSER (font));
family = gtk_font_chooser_get_font_family (GTK_FONT_CHOOSER (font));
size = gtk_font_chooser_get_font_size (GTK_FONT_CHOOSER (font));
#else
face = gtk_font_selection_get_face (GTK_FONT_SELECTION (font)); face = gtk_font_selection_get_face (GTK_FONT_SELECTION (font));
family = gtk_font_selection_get_family (GTK_FONT_SELECTION (font)); family = gtk_font_selection_get_family (GTK_FONT_SELECTION (font));
size = gtk_font_selection_get_size (GTK_FONT_SELECTION (font)); size = gtk_font_selection_get_size (GTK_FONT_SELECTION (font));
#endif
if (options.common_data.quoted_output) if (options.common_data.quoted_output)
{ {
...@@ -81,7 +99,11 @@ font_print_result (void) ...@@ -81,7 +99,11 @@ font_print_result (void)
} }
else else
{ {
#if GTK_CHECK_VERSION(3,0,0)
gchar *fn = gtk_font_chooser_get_font (GTK_FONT_CHOOSER (font));
#else
gchar *fn = gtk_font_selection_get_font_name (GTK_FONT_SELECTION (font)); gchar *fn = gtk_font_selection_get_font_name (GTK_FONT_SELECTION (font));
#endif
if (options.common_data.quoted_output) if (options.common_data.quoted_output)
{ {
......
...@@ -103,7 +103,11 @@ expand_action (gchar * cmd) ...@@ -103,7 +103,11 @@ expand_action (gchar * cmd)
arg = g_shell_quote (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (g_slist_nth_data (fields, num)))); arg = g_shell_quote (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (g_slist_nth_data (fields, num))));
break; break;
case YAD_FIELD_FONT: case YAD_FIELD_FONT:
#if !GTK_CHECK_VERSION(3,0,0)
arg = g_shell_quote (gtk_font_button_get_font_name (GTK_FONT_BUTTON (g_slist_nth_data (fields, num)))); arg = g_shell_quote (gtk_font_button_get_font_name (GTK_FONT_BUTTON (g_slist_nth_data (fields, num))));
#else
arg = g_shell_quote (gtk_font_chooser_get_font (GTK_FONT_CHOOSER (g_slist_nth_data (fields, num))));
#endif
break; break;
case YAD_FIELD_COLOR: case YAD_FIELD_COLOR:
{ {
...@@ -317,7 +321,11 @@ set_field_value (guint num, gchar * value) ...@@ -317,7 +321,11 @@ set_field_value (guint num, gchar * value)
break; break;
case YAD_FIELD_FONT: case YAD_FIELD_FONT:
#if !GTK_CHECK_VERSION(3,0,0)
gtk_font_button_set_font_name (GTK_FONT_BUTTON (w), value); gtk_font_button_set_font_name (GTK_FONT_BUTTON (w), value);
#else
gtk_font_chooser_set_font (GTK_FONT_CHOOSER (w), value);
#endif
break; break;
case YAD_FIELD_SCALE: case YAD_FIELD_SCALE:
...@@ -1262,13 +1270,20 @@ form_print_field (guint fn) ...@@ -1262,13 +1270,20 @@ form_print_field (guint fn)
} }
break; break;
case YAD_FIELD_FONT: case YAD_FIELD_FONT:
{
gchar *fname;
#if !GTK_CHECK_VERSION(3,0,0)
fname = gtk_font_button_get_font_name (GTK_FONT_BUTTON (g_slist_nth_data (fields, fn)));
#else
fname = gtk_font_chooser_get_font (GTK_FONT_CHOOSER (g_slist_nth_data (fields, fn)));
#endif
if (options.common_data.quoted_output) if (options.common_data.quoted_output)
g_printf ("'%s'%s", gtk_font_button_get_font_name (GTK_FONT_BUTTON (g_slist_nth_data (fields, fn))), g_printf ("'%s'%s", fname, options.common_data.separator);
options.common_data.separator);
else else
g_printf ("%s%s", gtk_font_button_get_font_name (GTK_FONT_BUTTON (g_slist_nth_data (fields, fn))), g_printf ("%s%s", fname, options.common_data.separator);
options.common_data.separator); g_free (fname);
break; break;
}
case YAD_FIELD_COLOR: case YAD_FIELD_COLOR:
{ {
gchar *cs; gchar *cs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment