GTK+ 3.0 enabled G_SEAL which means direct member access is
not possible anymore. This means we should use the getters and setters provided by GTK. The good thing is that we can remove some of our custom getters/setters. In the case of GtkAllocation the API works differently to what we had so we need to add a compat call. GtkPlacer is only used with Blox and I didn't attempt to run the GTK+ version of it. 2014-05-26 Holger Hans Peter Freyther <[hidden email]> * MoreFuncs.st: Remove GtkWidget>>#setFlags:, GtkWidget>>#unsetFlags:, GtkWidget>>#getFlags, GtkScrolledWindow>>#getHscrollbarVisible and GtkScrolledWindow>>#getVscrollbarVisible. Change the return type to double in GtkAdjustment>>#getUpper, GtkAdjustment>>#getLower and GtkAdjustment>>#getPageSize. Change GtkWidget>>#getAllocation to use >>#getAllocation: on GCed memory. * example_entry.st: Use the new setters in Gtk. * gst-gtk.c: Remove gstGtkGetFlags, gstGtkSetFlags, gstGtkUnsetFlags. gstGtkWidgetGetAllocation. Map gstGtkGetState, gstGtkGetWindow, gstGtkAdjustmentGetLower, gstGtkAdjustmentGetUpper, gstGtkAdjustmentGetPageSize, gstGtkDialogGetVBox and gstGtkDialogGetActionArea directly to GTK+. * placer.c: Modernize the GTK+ api usage --- packages/gtk/ChangeLog | 19 ++++++++ packages/gtk/MoreFuncs.st | 59 +++++++----------------- packages/gtk/example_entry.st | 2 +- packages/gtk/gst-gtk.c | 101 +++--------------------------------------- packages/gtk/placer.c | 41 ++++++++--------- 5 files changed, 62 insertions(+), 160 deletions(-) diff --git a/packages/gtk/ChangeLog b/packages/gtk/ChangeLog index 25d19f8..4f11904 100644 --- a/packages/gtk/ChangeLog +++ b/packages/gtk/ChangeLog @@ -1,3 +1,22 @@ +2014-05-26 Holger Hans Peter Freyther <[hidden email]> + + * MoreFuncs.st: Remove GtkWidget>>#setFlags:, + GtkWidget>>#unsetFlags:, GtkWidget>>#getFlags, + GtkScrolledWindow>>#getHscrollbarVisible and + GtkScrolledWindow>>#getVscrollbarVisible. Change the + return type to double in GtkAdjustment>>#getUpper, + GtkAdjustment>>#getLower and GtkAdjustment>>#getPageSize. + Change GtkWidget>>#getAllocation to use >>#getAllocation: + on GCed memory. + * example_entry.st: Use the new setters in Gtk. + * gst-gtk.c: Remove gstGtkGetFlags, gstGtkSetFlags, + gstGtkUnsetFlags. gstGtkWidgetGetAllocation. + Map gstGtkGetState, gstGtkGetWindow, gstGtkAdjustmentGetLower, + gstGtkAdjustmentGetUpper, gstGtkAdjustmentGetPageSize, + gstGtkDialogGetVBox and gstGtkDialogGetActionArea + directly to GTK+. + * placer.c: Modernize the GTK+ api usage + 2013-08-24 Holger Hans Peter Freyther <[hidden email]> * mk_enums.awk: Use #ifdef/#endif around key definition. diff --git a/packages/gtk/MoreFuncs.st b/packages/gtk/MoreFuncs.st index feee6ee..58926fd 100644 --- a/packages/gtk/MoreFuncs.st +++ b/packages/gtk/MoreFuncs.st @@ -87,10 +87,20 @@ GTK.GdkDrawable extend [ GtkWidget extend [ getAllocation [ + | ba allocation | <category: 'C call-outs'> - <cCall: 'gstGtkWidgetGetAllocation' returning: #{GtkAllocation} - args: #(#self )> - + + ba := (CShortType arrayType: 4) new + at: 0 put: 0; + at: 1 put: 0; + at: 2 put: 0; + at: 3 put: 0; + yourself. + allocation := (ba castTo: GtkAllocation type) + addToBeFinalized; + yourself. + self getAllocation: allocation. + ^allocation ] getWindow [ @@ -104,25 +114,6 @@ GtkWidget extend [ <cCall: 'gstGtkGetState' returning: #int args: #(#self )> ] - - getFlags [ - <category: 'C call-outs'> - <cCall: 'gstGtkGetFlags' returning: #int args: #(#self )> - - ] - - setFlags: flags [ - <category: 'C call-outs'> - <cCall: 'gstGtkSetFlags' returning: #void args: #(#self #int )> - - ] - - unsetFlags: flags [ - <category: 'C call-outs'> - <cCall: 'gstGtkUnsetFlags' returning: #void args: #(#self #int )> - - ] - ] @@ -205,41 +196,23 @@ GtkDialog extend [ -GtkScrolledWindow extend [ - - getHscrollbarVisible [ - <category: 'C call-outs'> - <cCall: 'gstGtkGetHscrollbarVisible' returning: #boolean args: #(#self )> - - ] - - getVscrollbarVisible [ - <category: 'C call-outs'> - <cCall: 'gstGtkGetVscrollbarVisible' returning: #boolean args: #(#self )> - - ] - -] - - - GtkAdjustment extend [ getLower [ <category: 'C call-outs'> - <cCall: 'gstGtkAdjustmentGetLower' returning: #int args: #(#self )> + <cCall: 'gstGtkAdjustmentGetLower' returning: #double args: #(#self )> ] getUpper [ <category: 'C call-outs'> - <cCall: 'gstGtkAdjustmentGetUpper' returning: #int args: #(#self )> + <cCall: 'gstGtkAdjustmentGetUpper' returning: #double args: #(#self )> ] getPageSize [ <category: 'C call-outs'> - <cCall: 'gstGtkAdjustmentGetPageSize' returning: #int args: #(#self )> + <cCall: 'gstGtkAdjustmentGetPageSize' returning: #double args: #(#self )> ] diff --git a/packages/gtk/example_entry.st b/packages/gtk/example_entry.st index dd6eece..d25741e 100644 --- a/packages/gtk/example_entry.st +++ b/packages/gtk/example_entry.st @@ -145,7 +145,7 @@ Object subclass: EntryExample [ expand: true fill: true padding: 0. - button setFlags: Gtk gtkCanDefault. + button setCanDefault: true. button grabDefault. button show. window show diff --git a/packages/gtk/gst-gtk.c b/packages/gtk/gst-gtk.c index 912be1d..0e456e5 100644 --- a/packages/gtk/gst-gtk.c +++ b/packages/gtk/gst-gtk.c @@ -205,87 +205,6 @@ tree_store_set_oop (GtkTreeStore *store, } -/* Wrappers for macros and missing accessor functions. */ - -static GdkWindow * -widget_get_window (GtkWidget *widget) -{ - return widget->window; -} - -static int -widget_get_state (GtkWidget *widget) -{ - return GTK_WIDGET_STATE (widget); -} - -static int -widget_get_flags (GtkWidget *widget) -{ - return GTK_WIDGET_FLAGS (widget); -} - -static void -widget_set_flags (GtkWidget *widget, int flags) -{ - GTK_WIDGET_SET_FLAGS (widget, flags); -} - -static void -widget_unset_flags (GtkWidget *widget, int flags) -{ - GTK_WIDGET_UNSET_FLAGS (widget, flags); -} - - -static GtkAllocation * -widget_get_allocation (GtkWidget *wgt) -{ - return &(GTK_WIDGET(wgt)->allocation); -} - -static GtkWidget * -dialog_get_vbox (GtkDialog *dlg) -{ - return (GTK_DIALOG(dlg)->vbox); -} - -static GtkWidget * -dialog_get_action_area (GtkDialog *dlg) -{ - return (GTK_DIALOG(dlg)->action_area); -} - -static int -scrolled_window_get_hscrollbar_visible (GtkScrolledWindow *swnd) -{ - return (GTK_SCROLLED_WINDOW(swnd)->hscrollbar_visible); -} - -static int -scrolled_window_get_vscrollbar_visible (GtkScrolledWindow *swnd) -{ - return (GTK_SCROLLED_WINDOW(swnd)->vscrollbar_visible); -} - -static int -adjustment_get_lower (GtkAdjustment *adj) -{ - return (GTK_ADJUSTMENT(adj)->lower); -} - -static int -adjustment_get_upper (GtkAdjustment *adj) -{ - return (GTK_ADJUSTMENT(adj)->upper); -} - -static int -adjustment_get_page_size (GtkAdjustment *adj) -{ - return (GTK_ADJUSTMENT(adj)->page_size); -} - /* Initialization. */ static int initialized = 0; @@ -311,22 +230,16 @@ gst_initModule (proxy) _gtk_vm_proxy->defineCFunc ("gstGtkConnectAccelGroupNoUserData", connect_accel_group_no_user_data); _gtk_vm_proxy->defineCFunc ("gstGtkGetChildProperty", container_get_child_property); _gtk_vm_proxy->defineCFunc ("gstGtkSetChildProperty", container_set_child_property); - _gtk_vm_proxy->defineCFunc ("gstGtkGetState", widget_get_state); - _gtk_vm_proxy->defineCFunc ("gstGtkGetFlags", widget_get_flags); - _gtk_vm_proxy->defineCFunc ("gstGtkSetFlags", widget_set_flags); - _gtk_vm_proxy->defineCFunc ("gstGtkUnsetFlags", widget_unset_flags); - _gtk_vm_proxy->defineCFunc ("gstGtkGetWindow", widget_get_window); - _gtk_vm_proxy->defineCFunc ("gstGtkGetHscrollbarVisible", scrolled_window_get_hscrollbar_visible); - _gtk_vm_proxy->defineCFunc ("gstGtkGetVscrollbarVisible", scrolled_window_get_vscrollbar_visible); - _gtk_vm_proxy->defineCFunc ("gstGtkAdjustmentGetLower", adjustment_get_lower); - _gtk_vm_proxy->defineCFunc ("gstGtkAdjustmentGetUpper", adjustment_get_upper); - _gtk_vm_proxy->defineCFunc ("gstGtkAdjustmentGetPageSize", adjustment_get_page_size); + _gtk_vm_proxy->defineCFunc ("gstGtkGetState", gtk_widget_get_state); + _gtk_vm_proxy->defineCFunc ("gstGtkGetWindow", gtk_widget_get_window); + _gtk_vm_proxy->defineCFunc ("gstGtkAdjustmentGetLower", gtk_adjustment_get_lower); + _gtk_vm_proxy->defineCFunc ("gstGtkAdjustmentGetUpper", gtk_adjustment_get_upper); + _gtk_vm_proxy->defineCFunc ("gstGtkAdjustmentGetPageSize", gtk_adjustment_get_page_size); _gtk_vm_proxy->defineCFunc ("gstGtkTreeModelGetOOP", tree_model_get_oop); _gtk_vm_proxy->defineCFunc ("gstGtkListStoreSetOOP", list_store_set_oop); _gtk_vm_proxy->defineCFunc ("gstGtkTreeStoreSetOOP", tree_store_set_oop); - _gtk_vm_proxy->defineCFunc ("gstGtkWidgetGetAllocation", widget_get_allocation); - _gtk_vm_proxy->defineCFunc ("gstGtkDialogGetVBox", dialog_get_vbox); - _gtk_vm_proxy->defineCFunc ("gstGtkDialogGetActionArea", dialog_get_action_area); + _gtk_vm_proxy->defineCFunc ("gstGtkDialogGetVBox", gtk_dialog_get_content_area); + _gtk_vm_proxy->defineCFunc ("gstGtkDialogGetActionArea", gtk_dialog_get_action_area); _gtk_vm_proxy->defineCFunc ("gtk_placer_get_type", gtk_placer_get_type); _gtk_vm_proxy->defineCFunc ("gtk_placer_new", gtk_placer_new); diff --git a/packages/gtk/placer.c b/packages/gtk/placer.c index 074428a..41a28f3 100644 --- a/packages/gtk/placer.c +++ b/packages/gtk/placer.c @@ -236,7 +236,7 @@ gtk_placer_child_type (GtkContainer *container) static void gtk_placer_init (GtkPlacer *placer) { - GTK_WIDGET_SET_FLAGS (placer, GTK_NO_WINDOW); + gtk_widget_set_has_window (GTK_WIDGET (placer), FALSE); placer->children = NULL; } @@ -329,7 +329,7 @@ gtk_placer_move_internal (GtkPlacer *placer, g_return_if_fail (GTK_IS_PLACER (placer)); g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (widget->parent == GTK_WIDGET (placer)); + g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (placer)); g_return_if_fail (!change_rel_x || (rel_x & ~32767) == 0); g_return_if_fail (!change_rel_y || (rel_y & ~32767) == 0); g_return_if_fail (!change_rel_width || (rel_width & ~32767) == 0); @@ -537,13 +537,15 @@ gtk_placer_realize (GtkWidget *widget) GTK_WIDGET_CLASS (parent_class)->realize (widget); else { - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + GtkAllocation allocation; + gtk_widget_set_realized (widget, TRUE); attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + gtk_widget_get_allocation (widget, &allocation); + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); @@ -552,12 +554,12 @@ gtk_placer_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, - attributes_mask); - gdk_window_set_user_data (widget->window, widget); + gtk_widget_set_window (widget, gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, + attributes_mask)); + gdk_window_set_user_data (gtk_widget_get_window (widget), widget); - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), gtk_widget_get_window (widget), GTK_STATE_NORMAL); } } @@ -573,7 +575,7 @@ gtk_placer_size_request (GtkWidget *widget, gint height, width; placer = GTK_PLACER (widget); - border_width = GTK_CONTAINER (placer)->border_width; + border_width = gtk_container_get_border_width (GTK_CONTAINER (placer)); requisition->width = 0; requisition->height = 0; @@ -638,19 +640,19 @@ gtk_placer_size_allocate (GtkWidget *widget, placer = GTK_PLACER (widget); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); if (!GTK_WIDGET_NO_WINDOW (widget)) { if (GTK_WIDGET_REALIZED (widget)) - gdk_window_move_resize (widget->window, + gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y, allocation->width, allocation->height); } - border_width = GTK_CONTAINER (placer)->border_width; + border_width = gtk_container_get_border_width (GTK_CONTAINER (placer)); rel_width_scale = (allocation->width - 2 * border_width) / 32767.0; rel_height_scale = (allocation->height - 2 * border_width) / 32767.0; @@ -779,12 +781,7 @@ gtk_placer_set_has_window (GtkPlacer *placer, g_return_if_fail (!GTK_WIDGET_REALIZED (placer)); if (!has_window != GTK_WIDGET_NO_WINDOW (placer)) - { - if (has_window) - GTK_WIDGET_UNSET_FLAGS (placer, GTK_NO_WINDOW); - else - GTK_WIDGET_SET_FLAGS (placer, GTK_NO_WINDOW); - } + gtk_widget_set_has_window (GTK_WIDGET (placer), has_window); } /** -- 2.0.0.rc2 _______________________________________________ help-smalltalk mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-smalltalk |
Free forum by Nabble | Edit this page |