mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-05-30 16:30:29 -05:00
Compile fixes for GTK1 after recent work.
The whole of get_label_text_dimensions() should have been outside the GTK 2 ifdef; I'd left a gtk_label_set_width_chars() unconditional; and GDK1's gdk_window_set_background() lacks a const in its prototype. Serves me right for not test-compiling in all three versions!
This commit is contained in:
parent
43a18df156
commit
7193e930de
@ -2443,7 +2443,9 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
|
|||||||
GtkWidget *label, *container;
|
GtkWidget *label, *container;
|
||||||
|
|
||||||
label = gtk_label_new(ctrl->generic.label);
|
label = gtk_label_new(ctrl->generic.label);
|
||||||
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
gtk_label_set_width_chars(GTK_LABEL(label), 3);
|
gtk_label_set_width_chars(GTK_LABEL(label), 3);
|
||||||
|
#endif
|
||||||
|
|
||||||
shortcut_add(scs, label, ctrl->listbox.shortcut,
|
shortcut_add(scs, label, ctrl->listbox.shortcut,
|
||||||
SHORTCUT_FOCUS, w);
|
SHORTCUT_FOCUS, w);
|
||||||
|
@ -1988,6 +1988,46 @@ static void multifont_draw_text(unifont_drawctx *ctx, unifont *font, int x,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Utility routine used by the code below, and also gtkdlg.c.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void get_label_text_dimensions(const char *text, int *width, int *height)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Determine the dimensions of a piece of text in the standard
|
||||||
|
* font used in GTK interface elements like labels. We do this by
|
||||||
|
* instantiating an actual GtkLabel, and then querying its size.
|
||||||
|
*
|
||||||
|
* But GTK2 and GTK3 require us to query the size completely
|
||||||
|
* differently. I'm sure there ought to be an easier approach than
|
||||||
|
* the way I'm doing this in GTK3, too!
|
||||||
|
*/
|
||||||
|
GtkWidget *label = gtk_label_new(text);
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
|
PangoLayout *layout = gtk_label_get_layout(GTK_LABEL(label));
|
||||||
|
PangoRectangle logrect;
|
||||||
|
pango_layout_get_extents(layout, NULL, &logrect);
|
||||||
|
if (width)
|
||||||
|
*width = logrect.width / PANGO_SCALE;
|
||||||
|
if (height)
|
||||||
|
*height = logrect.height / PANGO_SCALE;
|
||||||
|
#else
|
||||||
|
GtkRequisition req;
|
||||||
|
gtk_widget_size_request(label, &req);
|
||||||
|
if (width)
|
||||||
|
*width = req.width;
|
||||||
|
if (height)
|
||||||
|
*height = req.height;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
g_object_ref_sink(G_OBJECT(label));
|
||||||
|
#if GTK_CHECK_VERSION(2,10,0)
|
||||||
|
g_object_unref(label);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if GTK_CHECK_VERSION(2,0,0)
|
#if GTK_CHECK_VERSION(2,0,0)
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -2958,42 +2998,6 @@ static gint unifontsel_configure_area(GtkWidget *widget,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_label_text_dimensions(const char *text, int *width, int *height)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Determine the dimensions of a piece of text in the standard
|
|
||||||
* font used in GTK interface elements like labels. We do this by
|
|
||||||
* instantiating an actual GtkLabel, and then querying its size.
|
|
||||||
*
|
|
||||||
* But GTK2 and GTK3 require us to query the size completely
|
|
||||||
* differently. I'm sure there ought to be an easier approach than
|
|
||||||
* the way I'm doing this in GTK3, too!
|
|
||||||
*/
|
|
||||||
GtkWidget *label = gtk_label_new(text);
|
|
||||||
|
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
|
||||||
PangoLayout *layout = gtk_label_get_layout(GTK_LABEL(label));
|
|
||||||
PangoRectangle logrect;
|
|
||||||
pango_layout_get_extents(layout, NULL, &logrect);
|
|
||||||
if (width)
|
|
||||||
*width = logrect.width / PANGO_SCALE;
|
|
||||||
if (height)
|
|
||||||
*height = logrect.height / PANGO_SCALE;
|
|
||||||
#else
|
|
||||||
GtkRequisition req;
|
|
||||||
gtk_widget_size_request(label, &req);
|
|
||||||
if (width)
|
|
||||||
*width = req.width;
|
|
||||||
if (height)
|
|
||||||
*height = req.height;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_object_ref_sink(G_OBJECT(label));
|
|
||||||
#if GTK_CHECK_VERSION(2,10,0)
|
|
||||||
g_object_unref(label);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
unifontsel *unifontsel_new(const char *wintitle)
|
unifontsel *unifontsel_new(const char *wintitle)
|
||||||
{
|
{
|
||||||
unifontsel_internal *fs = snew(unifontsel_internal);
|
unifontsel_internal *fs = snew(unifontsel_internal);
|
||||||
|
@ -1869,7 +1869,12 @@ void set_gdk_window_background(GdkWindow *win, const GdkColor *col)
|
|||||||
rgba.alpha = 1.0;
|
rgba.alpha = 1.0;
|
||||||
gdk_window_set_background_rgba(win, &rgba);
|
gdk_window_set_background_rgba(win, &rgba);
|
||||||
#else
|
#else
|
||||||
gdk_window_set_background(win, col);
|
{
|
||||||
|
/* For GTK1, which doesn't have a 'const' on
|
||||||
|
* gdk_window_set_background's second parameter type. */
|
||||||
|
GdkColor col_mutable = *col;
|
||||||
|
gdk_window_set_background(win, &col_mutable);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user