]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Avoid deprecated gtk_misc_set_alignment().
authorSimon Tatham <anakin@pobox.com>
Mon, 31 Aug 2015 12:57:34 +0000 (13:57 +0100)
committerSimon Tatham <anakin@pobox.com>
Mon, 31 Aug 2015 12:57:34 +0000 (13:57 +0100)
As of GTK 3.16 (but not in previous GTK 3 versions), there's a new
gtk_label_set_xalign which does this job.

unix/gtkdlg.c
unix/gtkfont.c
unix/unix.h

index 23e9f465c8ae58f59275e31966d33933763978a8..8f6641d8e331ab083abeba93abdd45a085be4340 100644 (file)
@@ -1072,6 +1072,15 @@ static void set_transient_window_pos(GtkWidget *parent, GtkWidget *child)
 #endif
 }
 
+void align_label_left(GtkLabel *label)
+{
+#if GTK_CHECK_VERSION(3,16,0)
+    gtk_label_set_xalign(label, 0.0);
+#else
+    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+#endif
+}
+
 void dlg_error_msg(void *dlg, const char *msg)
 {
     struct dlgparam *dp = (struct dlgparam *)dlg;
@@ -1079,7 +1088,7 @@ void dlg_error_msg(void *dlg, const char *msg)
 
     window = gtk_dialog_new();
     text = gtk_label_new(msg);
-    gtk_misc_set_alignment(GTK_MISC(text), 0.0, 0.0);
+    align_label_left(GTK_LABEL(text));
     hbox = gtk_hbox_new(FALSE, 0);
     gtk_box_pack_start(GTK_BOX(hbox), text, FALSE, FALSE, 20);
     gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(window))),
@@ -2515,7 +2524,7 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
              */
             uc->text = w = gtk_label_new(uc->ctrl->generic.label);
 #endif
-            gtk_misc_set_alignment(GTK_MISC(w), 0.0, 0.0);
+            align_label_left(GTK_LABEL(w));
             gtk_label_set_line_wrap(GTK_LABEL(w), TRUE);
             break;
         }
index 82c0dafaf7d942b6c6ee668de30ee7b841d35381..54e412f68f2978a0790357820c89182dd3472051 100644 (file)
@@ -18,6 +18,8 @@
 #include <gdk/gdkkeysyms.h>
 #endif
 
+#define MAY_REFER_TO_GTK_IN_HEADERS
+
 #include "putty.h"
 #include "gtkfont.h"
 #include "gtkcompat.h"
@@ -3071,7 +3073,7 @@ unifontsel *unifontsel_new(const char *wintitle)
 
     label = gtk_label_new_with_mnemonic("_Font:");
     gtk_widget_show(label);
-    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+    align_label_left(GTK_LABEL(label));
 #if GTK_CHECK_VERSION(3,0,0)
     gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
     g_object_set(G_OBJECT(label), "hexpand", TRUE, (const char *)NULL);
@@ -3119,7 +3121,7 @@ unifontsel *unifontsel_new(const char *wintitle)
 
     label = gtk_label_new_with_mnemonic("_Style:");
     gtk_widget_show(label);
-    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+    align_label_left(GTK_LABEL(label));
 #if GTK_CHECK_VERSION(3,0,0)
     gtk_grid_attach(GTK_GRID(table), label, 1, 0, 1, 1);
     g_object_set(G_OBJECT(label), "hexpand", TRUE, (const char *)NULL);
@@ -3166,7 +3168,7 @@ unifontsel *unifontsel_new(const char *wintitle)
 
     label = gtk_label_new_with_mnemonic("Si_ze:");
     gtk_widget_show(label);
-    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+    align_label_left(GTK_LABEL(label));
 #if GTK_CHECK_VERSION(3,0,0)
     gtk_grid_attach(GTK_GRID(table), label, 2, 0, 1, 1);
     g_object_set(G_OBJECT(label), "hexpand", TRUE, (const char *)NULL);
index 36bf02bb8b5c9c24381782f21f56495e49fe620c..e0e771393e53cfdecf579f5581fadbe9fcd09432 100644 (file)
@@ -151,8 +151,12 @@ void unix_setup_config_box(struct controlbox *b, int midsession, int protocol);
 /* gtkcfg.c */
 void gtk_setup_config_box(struct controlbox *b, int midsession, void *window);
 
-/* Helper function which happens to be in gtkfont.c at the moment */
+/* General GTK helper functions, which could be in any source file and
+ * it doesn't really matter */
 void get_label_text_dimensions(const char *text, int *width, int *height);
+#ifdef MAY_REFER_TO_GTK_IN_HEADERS
+void align_label_left(GtkLabel *label);
+#endif
 
 /*
  * In the Unix Unicode layer, DEFAULT_CODEPAGE is a special value