diff --git a/Recipe b/Recipe index 9f047781..521e47b5 100644 --- a/Recipe +++ b/Recipe @@ -234,7 +234,7 @@ GUITERM = TERMINAL window windlg winctrls sizetip winucs winprint # Same thing on Unix. UXTERM = TERMINAL uxcfg sercfg uxucs uxprint timing -GTKTERM = UXTERM gtkwin gtkcfg gtkdlg gtkcols gtkpanel xkeysym +GTKTERM = UXTERM gtkwin gtkcfg gtkdlg gtkcols xkeysym OSXTERM = UXTERM osxwin osxdlg osxctrls # Non-SSH back ends (putty, puttytel, plink). diff --git a/unix/gtkdlg.c b/unix/gtkdlg.c index b5b75ef3..08474313 100644 --- a/unix/gtkdlg.c +++ b/unix/gtkdlg.c @@ -22,7 +22,6 @@ #include #include "gtkcols.h" -#include "gtkpanel.h" #ifdef TESTMODE #define PUTTY_DO_GLOBALS /* actually _define_ globals */ @@ -1741,7 +1740,7 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs, struct selparam { struct dlgparam *dp; - Panels *panels; + GtkNotebook *panels; GtkWidget *panel, *treeitem; struct Shortcuts shortcuts; }; @@ -1749,8 +1748,10 @@ struct selparam { static void treeitem_sel(GtkItem *item, gpointer data) { struct selparam *sp = (struct selparam *)data; + gint page_num; - panels_switch_to(sp->panels, sp->panel); + page_num = gtk_notebook_page_num(sp->panels, sp->panel); + gtk_notebook_set_page(sp->panels, page_num); dlg_refresh(NULL, sp->dp); @@ -2090,7 +2091,9 @@ int do_config_box(const char *title, Config *cfg, int midsession, gtk_widget_show(tree); gtk_widget_show(treescroll); gtk_box_pack_start(GTK_BOX(vbox), treescroll, TRUE, TRUE, 0); - panels = panels_new(); + panels = gtk_notebook_new(); + gtk_notebook_set_show_tabs(GTK_NOTEBOOK(panels), FALSE); + gtk_notebook_set_show_border(GTK_NOTEBOOK(panels), FALSE); gtk_box_pack_start(GTK_BOX(hbox), panels, TRUE, TRUE, 0); gtk_widget_show(panels); @@ -2160,9 +2163,15 @@ int do_config_box(const char *title, Config *cfg, int midsession, first = (panelvbox == NULL); panelvbox = gtk_vbox_new(FALSE, 4); - gtk_container_add(GTK_CONTAINER(panels), panelvbox); + gtk_widget_show(panelvbox); + gtk_notebook_append_page(GTK_NOTEBOOK(panels), panelvbox, + NULL); if (first) { - panels_switch_to(PANELS(panels), panelvbox); + gint page_num; + + page_num = gtk_notebook_page_num(GTK_NOTEBOOK(panels), + panelvbox); + gtk_notebook_set_page(GTK_NOTEBOOK(panels), page_num); gtk_tree_select_child(GTK_TREE(tree), treeitem); } @@ -2172,7 +2181,7 @@ int do_config_box(const char *title, Config *cfg, int midsession, struct selparam); } selparams[nselparams].dp = &dp; - selparams[nselparams].panels = PANELS(panels); + selparams[nselparams].panels = GTK_NOTEBOOK(panels); selparams[nselparams].panel = panelvbox; selparams[nselparams].shortcuts = scs; /* structure copy */ selparams[nselparams].treeitem = treeitem; diff --git a/unix/gtkpanel.c b/unix/gtkpanel.c deleted file mode 100644 index 591c8608..00000000 --- a/unix/gtkpanel.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - * gtkpanel.c - implementation of the `Panels' GTK layout container. - */ - -#include "gtkpanel.h" - -static void panels_init(Panels *panels); -static void panels_class_init(PanelsClass *klass); -static void panels_map(GtkWidget *widget); -static void panels_unmap(GtkWidget *widget); -static void panels_draw(GtkWidget *widget, GdkRectangle *area); -static gint panels_expose(GtkWidget *widget, GdkEventExpose *event); -static void panels_base_add(GtkContainer *container, GtkWidget *widget); -static void panels_remove(GtkContainer *container, GtkWidget *widget); -static void panels_forall(GtkContainer *container, gboolean include_internals, - GtkCallback callback, gpointer callback_data); -static GtkType panels_child_type(GtkContainer *container); -static void panels_size_request(GtkWidget *widget, GtkRequisition *req); -static void panels_size_allocate(GtkWidget *widget, GtkAllocation *alloc); - -static GtkContainerClass *parent_class = NULL; - -GtkType panels_get_type(void) -{ - static GtkType panels_type = 0; - - if (!panels_type) { - static const GtkTypeInfo panels_info = { - "Panels", - sizeof(Panels), - sizeof(PanelsClass), - (GtkClassInitFunc) panels_class_init, - (GtkObjectInitFunc) panels_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - panels_type = gtk_type_unique(GTK_TYPE_CONTAINER, &panels_info); - } - - return panels_type; -} - -static void panels_class_init(PanelsClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - object_class = (GtkObjectClass *)klass; - widget_class = (GtkWidgetClass *)klass; - container_class = (GtkContainerClass *)klass; - - parent_class = gtk_type_class(GTK_TYPE_CONTAINER); - - /* - * FIXME: do we have to do all this faffing with set_arg, - * get_arg and child_arg_type? Ick. - */ - - widget_class->map = panels_map; - widget_class->unmap = panels_unmap; - widget_class->draw = panels_draw; - widget_class->expose_event = panels_expose; - widget_class->size_request = panels_size_request; - widget_class->size_allocate = panels_size_allocate; - - container_class->add = panels_base_add; - container_class->remove = panels_remove; - container_class->forall = panels_forall; - container_class->child_type = panels_child_type; -} - -static void panels_init(Panels *panels) -{ - GTK_WIDGET_SET_FLAGS(panels, GTK_NO_WINDOW); - - panels->children = NULL; -} - -/* - * These appear to be thoroughly tedious functions; the only reason - * we have to reimplement them at all is because we defined our own - * format for our GList of children... - */ -static void panels_map(GtkWidget *widget) -{ - Panels *panels; - GtkWidget *child; - GList *children; - - g_return_if_fail(widget != NULL); - g_return_if_fail(IS_PANELS(widget)); - - panels = PANELS(widget); - GTK_WIDGET_SET_FLAGS(panels, GTK_MAPPED); - - for (children = panels->children; - children && (child = children->data); - children = children->next) { - if (child && - GTK_WIDGET_VISIBLE(child) && - !GTK_WIDGET_MAPPED(child)) - gtk_widget_map(child); - } -} -static void panels_unmap(GtkWidget *widget) -{ - Panels *panels; - GtkWidget *child; - GList *children; - - g_return_if_fail(widget != NULL); - g_return_if_fail(IS_PANELS(widget)); - - panels = PANELS(widget); - GTK_WIDGET_UNSET_FLAGS(panels, GTK_MAPPED); - - for (children = panels->children; - children && (child = children->data); - children = children->next) { - if (child && - GTK_WIDGET_VISIBLE(child) && - GTK_WIDGET_MAPPED(child)) - gtk_widget_unmap(child); - } -} -static void panels_draw(GtkWidget *widget, GdkRectangle *area) -{ - Panels *panels; - GtkWidget *child; - GList *children; - GdkRectangle child_area; - - g_return_if_fail(widget != NULL); - g_return_if_fail(IS_PANELS(widget)); - - if (GTK_WIDGET_DRAWABLE(widget)) { - panels = PANELS(widget); - - for (children = panels->children; - children && (child = children->data); - children = children->next) { - if (child && - GTK_WIDGET_DRAWABLE(child) && - gtk_widget_intersect(child, area, &child_area)) - gtk_widget_draw(child, &child_area); - } - } -} -static gint panels_expose(GtkWidget *widget, GdkEventExpose *event) -{ - Panels *panels; - GtkWidget *child; - GList *children; - GdkEventExpose child_event; - - g_return_val_if_fail(widget != NULL, FALSE); - g_return_val_if_fail(IS_PANELS(widget), FALSE); - g_return_val_if_fail(event != NULL, FALSE); - - if (GTK_WIDGET_DRAWABLE(widget)) { - panels = PANELS(widget); - child_event = *event; - - for (children = panels->children; - children && (child = children->data); - children = children->next) { - if (child && - GTK_WIDGET_DRAWABLE(child) && - GTK_WIDGET_NO_WINDOW(child) && - gtk_widget_intersect(child, &event->area, - &child_event.area)) - gtk_widget_event(child, (GdkEvent *)&child_event); - } - } - return FALSE; -} - -static void panels_base_add(GtkContainer *container, GtkWidget *widget) -{ - Panels *panels; - - g_return_if_fail(container != NULL); - g_return_if_fail(IS_PANELS(container)); - g_return_if_fail(widget != NULL); - - panels = PANELS(container); - - panels_add(panels, widget); -} - -static void panels_remove(GtkContainer *container, GtkWidget *widget) -{ - Panels *panels; - GtkWidget *child; - GList *children; - gboolean was_visible; - - g_return_if_fail(container != NULL); - g_return_if_fail(IS_PANELS(container)); - g_return_if_fail(widget != NULL); - - panels = PANELS(container); - - for (children = panels->children; - children && (child = children->data); - children = children->next) { - if (child != widget) - continue; - - was_visible = GTK_WIDGET_VISIBLE(widget); - gtk_widget_unparent(widget); - panels->children = g_list_remove_link(panels->children, children); - g_list_free(children); - if (was_visible) - gtk_widget_queue_resize(GTK_WIDGET(container)); - break; - } -} - -static void panels_forall(GtkContainer *container, gboolean include_internals, - GtkCallback callback, gpointer callback_data) -{ - Panels *panels; - GtkWidget *child; - GList *children, *next; - - g_return_if_fail(container != NULL); - g_return_if_fail(IS_PANELS(container)); - g_return_if_fail(callback != NULL); - - panels = PANELS(container); - - for (children = panels->children; - children && (child = children->data); - children = next) { - /* - * We can't wait until after the callback to assign - * `children = children->next', because the callback might - * be gtk_widget_destroy, which would remove the link - * `children' from the list! So instead we must get our - * hands on the value of the `next' pointer _before_ the - * callback. - */ - next = children->next; - if (child) - callback(child, callback_data); - } -} - -static GtkType panels_child_type(GtkContainer *container) -{ - return GTK_TYPE_WIDGET; -} - -GtkWidget *panels_new(void) -{ - Panels *panels; - - panels = gtk_type_new(panels_get_type()); - - return GTK_WIDGET(panels); -} - -void panels_add(Panels *panels, GtkWidget *child) -{ - g_return_if_fail(panels != NULL); - g_return_if_fail(IS_PANELS(panels)); - g_return_if_fail(child != NULL); - g_return_if_fail(child->parent == NULL); - - panels->children = g_list_append(panels->children, child); - - gtk_widget_set_parent(child, GTK_WIDGET(panels)); - - if (GTK_WIDGET_REALIZED(panels)) - gtk_widget_realize(child); - - if (GTK_WIDGET_VISIBLE(panels)) { - if (GTK_WIDGET_MAPPED(panels)) - gtk_widget_map(child); - gtk_widget_queue_resize(child); - } -} - -void panels_switch_to(Panels *panels, GtkWidget *target) -{ - GtkWidget *child = NULL; - GList *children; - gboolean changed = FALSE; - - g_return_if_fail(panels != NULL); - g_return_if_fail(IS_PANELS(panels)); - g_return_if_fail(target != NULL); - g_return_if_fail(target->parent == GTK_WIDGET(panels)); - - for (children = panels->children; - children && (child = children->data); - children = children->next) { - - if (!child) - continue; - - if (child == target) { - if (!GTK_WIDGET_VISIBLE(child)) { - gtk_widget_show(child); - changed = TRUE; - } - } else { - if (GTK_WIDGET_VISIBLE(child)) { - gtk_widget_hide(child); - changed = TRUE; - } - } - } - if (changed) - gtk_widget_queue_resize(child); -} - -/* - * Now here comes the interesting bit. The actual layout part is - * done in the following two functions: - * - * panels_size_request() examines the list of widgets held in the - * Panels, and returns a requisition stating the absolute minimum - * size it can bear to be. - * - * panels_size_allocate() is given an allocation telling it what - * size the whole container is going to be, and it calls - * gtk_widget_size_allocate() on all of its (visible) children to - * set their size and position relative to the top left of the - * container. - */ - -static void panels_size_request(GtkWidget *widget, GtkRequisition *req) -{ - Panels *panels; - GtkWidget *child; - GList *children; - - g_return_if_fail(widget != NULL); - g_return_if_fail(IS_PANELS(widget)); - g_return_if_fail(req != NULL); - - panels = PANELS(widget); - - req->width = 0; - req->height = 0; - - for (children = panels->children; - children && (child = children->data); - children = children->next) { - GtkRequisition creq; - - gtk_widget_size_request(child, &creq); - if (req->width < creq.width) - req->width = creq.width; - if (req->height < creq.height) - req->height = creq.height; - } - - req->width += 2*GTK_CONTAINER(panels)->border_width; - req->height += 2*GTK_CONTAINER(panels)->border_width; -} - -static void panels_size_allocate(GtkWidget *widget, GtkAllocation *alloc) -{ - Panels *panels; - GtkWidget *child; - GList *children; - gint border; - - g_return_if_fail(widget != NULL); - g_return_if_fail(IS_PANELS(widget)); - g_return_if_fail(alloc != NULL); - - panels = PANELS(widget); - widget->allocation = *alloc; - border = GTK_CONTAINER(panels)->border_width; - - for (children = panels->children; - children && (child = children->data); - children = children->next) { - GtkAllocation call; - - call.x = alloc->x + border; - call.width = alloc->width - 2*border; - call.y = alloc->y + border; - call.height = alloc->height - 2*border; - - gtk_widget_size_allocate(child, &call); - } -} diff --git a/unix/gtkpanel.h b/unix/gtkpanel.h deleted file mode 100644 index 2b7b2c5b..00000000 --- a/unix/gtkpanel.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * gtkpanel.h - header file for a panel-based widget container, - * which holds a number of widgets of which at most one is ever - * visible at a time, and sizes itself to the maximum of its - * children's potential size requests. - */ - -#ifndef PANELS_H -#define PANELS_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define TYPE_PANELS (panels_get_type()) -#define PANELS(obj) (GTK_CHECK_CAST((obj), TYPE_PANELS, Panels)) -#define PANELS_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST((klass), TYPE_PANELS, PanelsClass)) -#define IS_PANELS(obj) (GTK_CHECK_TYPE((obj), TYPE_PANELS)) -#define IS_PANELS_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), TYPE_PANELS)) - -typedef struct Panels_tag Panels; -typedef struct PanelsClass_tag PanelsClass; -typedef struct PanelsChild_tag PanelsChild; - -struct Panels_tag { - GtkContainer container; - /* private after here */ - GList *children; /* this just holds GtkWidgets */ -}; - -struct PanelsClass_tag { - GtkContainerClass parent_class; -}; - -GtkType panels_get_type(void); -GtkWidget *panels_new(void); -void panels_add(Panels *panels, GtkWidget *child); -void panels_switch_to(Panels *panels, GtkWidget *child); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* PANELS_H */