Avoid deprecated gtk_misc_set_alignment().

As of GTK 3.16 (but not in previous GTK 3 versions), there's a new
gtk_label_set_xalign which does this job.
This commit is contained in:
Simon Tatham 2015-08-31 13:57:34 +01:00
Родитель 4e243ae9a4
Коммит 0b5a0c4da1
3 изменённых файлов: 21 добавлений и 6 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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