1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-04 21:12:47 -05:00

Stop using GtkDialog (for most purposes) in GTK 3!

They've now deprecated gtk_dialog_get_action_area, because they really
want a dialog box's action area to be filled with nothing but buttons
controlled by GTK which end the dialog with a response code. But we're
accustomed to putting all sorts of other things in our action area -
non-buttons, buttons that don't end the dialog, and sub-widgets that
do layout - and so I think it's no longer sensible to be trying to
coerce our use cases into GtkDialog.

Hence, I'm introducing a set of wrapper functions which equivocate
between a GtkDialog for GTK1 and GTK2, and a GtkWindow with a vbox in
it for GTK3, and I'll lay out the action area by hand.

(Not everything has sensible layout and margins in the new GTK3 system
yet, but I can sort that out later.)

Because the new functions are needed by gtkask.c, which doesn't link
against gtkdlg.c or include putty.h, I've put them in a new source
file and header file pair gtkmisc.[ch] which is common to gtkask and
the main GTK edifice.
This commit is contained in:
Simon Tatham
2015-08-31 15:45:18 +01:00
parent 749b0fdda0
commit dc11417aee
5 changed files with 193 additions and 116 deletions

View File

@ -16,6 +16,7 @@
#include "gtkfont.h"
#include "gtkcompat.h"
#include "gtkmisc.h"
#include "misc.h"
@ -289,6 +290,7 @@ static const char *gtk_askpass_setup(struct askpass_ctx *ctx,
const char *prompt_text)
{
int i;
GtkBox *action_area;
ctx->passlen = 0;
ctx->passsize = 2048;
@ -297,13 +299,13 @@ static const char *gtk_askpass_setup(struct askpass_ctx *ctx,
/*
* Create widgets.
*/
ctx->dialog = gtk_dialog_new();
ctx->dialog = our_dialog_new();
gtk_window_set_title(GTK_WINDOW(ctx->dialog), window_title);
gtk_window_set_position(GTK_WINDOW(ctx->dialog), GTK_WIN_POS_CENTER);
ctx->promptlabel = gtk_label_new(prompt_text);
gtk_label_set_line_wrap(GTK_LABEL(ctx->promptlabel), TRUE);
gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area
(GTK_DIALOG(ctx->dialog))),
ctx->promptlabel);
our_dialog_add_to_content_area(GTK_WINDOW(ctx->dialog),
ctx->promptlabel, TRUE, TRUE, 0);
#if GTK_CHECK_VERSION(2,0,0)
ctx->imc = gtk_im_multicontext_new();
#endif
@ -319,6 +321,9 @@ static const char *gtk_askpass_setup(struct askpass_ctx *ctx,
return "unable to allocate colours";
}
#endif
action_area = our_dialog_make_action_hbox(GTK_WINDOW(ctx->dialog));
for (i = 0; i < N_DRAWING_AREAS; i++) {
ctx->drawingareas[i].area = gtk_drawing_area_new();
#ifndef DRAW_DEFAULT_CAIRO
@ -330,9 +335,8 @@ static const char *gtk_askpass_setup(struct askpass_ctx *ctx,
* context-sensitive way, like measuring the size of some
* piece of template text. */
gtk_widget_set_size_request(ctx->drawingareas[i].area, 32, 32);
gtk_container_add(GTK_CONTAINER(gtk_dialog_get_action_area
(GTK_DIALOG(ctx->dialog))),
ctx->drawingareas[i].area);
gtk_box_pack_end(action_area, ctx->drawingareas[i].area,
TRUE, TRUE, 5);
g_signal_connect(G_OBJECT(ctx->drawingareas[i].area),
"configure_event",
G_CALLBACK(configure_area),