replaces usage of some deprecated functions (GTK)

Sun, 19 Nov 2017 09:38:23 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 19 Nov 2017 09:38:23 +0100
changeset 148
4e0b38bbd6c4
parent 147
2e384acc89a6
child 149
479209198de3

replaces usage of some deprecated functions (GTK)

ui/gtk/container.c file | annotate | diff | comparison | revisions
ui/gtk/label.c file | annotate | diff | comparison | revisions
ui/gtk/menu.c file | annotate | diff | comparison | revisions
ui/gtk/menu.h file | annotate | diff | comparison | revisions
ui/gtk/range.c file | annotate | diff | comparison | revisions
ui/gtk/window.c file | annotate | diff | comparison | revisions
--- a/ui/gtk/container.c	Sun Nov 19 09:00:16 2017 +0100
+++ b/ui/gtk/container.c	Sun Nov 19 09:38:23 2017 +0100
@@ -451,7 +451,8 @@
 }
 
 UiObject* ui_document_tab(UiTabbedPane *view) {
-    GtkWidget *frame = gtk_alignment_new(0.5, 0.5, 1, 1);
+    GtkWidget *frame = gtk_frame_new(NULL);
+    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
     // TODO: label
     gtk_notebook_append_page(GTK_NOTEBOOK(view->widget), frame, NULL);
     
--- a/ui/gtk/label.c	Sun Nov 19 09:00:16 2017 +0100
+++ b/ui/gtk/label.c	Sun Nov 19 09:38:23 2017 +0100
@@ -35,6 +35,15 @@
 #include "../common/context.h"
 #include "../common/object.h"
 
+static void set_alignment(GtkWidget *widget, float xalign, float yalign) {
+#if GTK_MAJOR_VERSION >= 3 && GTK_MINOR_VERSION >= 16
+    gtk_label_set_xalign(GTK_LABEL(widget), xalign);
+    gtk_label_set_yalign(GTK_LABEL(widget), yalign);
+#else
+    gtk_misc_set_alignment(GTK_MISC(widget), xalign, yalign);
+#endif
+}
+
 UIWIDGET ui_label(UiObject *obj, char *label) { 
     GtkWidget *widget = gtk_label_new(label);
     
@@ -46,14 +55,15 @@
 
 UIWIDGET ui_llabel(UiObject *obj, char *label) {
     UIWIDGET widget = ui_label(obj, label);
-    gtk_misc_set_alignment(GTK_MISC(widget), 0, .5);
+    set_alignment(widget, 0, .5);
     return widget;
 }
 
 UIWIDGET ui_rlabel(UiObject *obj, char *label) {
     UIWIDGET widget = ui_label(obj, label);
     //gtk_label_set_justify(GTK_LABEL(widget), GTK_JUSTIFY_RIGHT);
-    gtk_misc_set_alignment(GTK_MISC(widget), 1, .5);
+    
+    set_alignment(widget, 1, .5);
     return widget;
 }
 
--- a/ui/gtk/menu.c	Sun Nov 19 09:00:16 2017 +0100
+++ b/ui/gtk/menu.c	Sun Nov 19 09:38:23 2017 +0100
@@ -457,13 +457,13 @@
     event->callback(&evt, event->userdata);    
 }
 
-int ui_checkitem_get(UiInteger *i) {
+int64_t ui_checkitem_get(UiInteger *i) {
     int state = gtk_check_menu_item_get_active(i->obj);
     i->value = state;
     return state;
 }
 
-void ui_checkitem_set(UiInteger *i, int value) {
+void ui_checkitem_set(UiInteger *i, int64_t value) {
     i->value = value;
     gtk_check_menu_item_set_active(i->obj, value);
 }
@@ -478,7 +478,7 @@
         GdkEventButton *e = (GdkEventButton*)event;
         if(e->button == 3) {
             gtk_widget_show_all(GTK_WIDGET(menu));
-            gtk_menu_popup(menu, NULL, NULL, NULL, NULL, e->button, e->time);
+            ui_contextmenu_popup(menu);
             return TRUE;
         }
     }
@@ -501,7 +501,11 @@
 }
 
 void ui_contextmenu_popup(UIMENU menu) {
+#if GTK_MAJOR_VERSION >= 3 && GTK_MINOR_VERSION >= 16
+    gtk_menu_popup_at_pointer(menu, NULL);
+#else
     gtk_menu_popup(menu, NULL, NULL, 0, 0, 0, gtk_get_current_event_time());
+#endif
 }
 
 void ui_widget_menuitem(UiObject *obj, char *label, ui_callback f, void *userdata) {
--- a/ui/gtk/menu.h	Sun Nov 19 09:00:16 2017 +0100
+++ b/ui/gtk/menu.h	Sun Nov 19 09:38:23 2017 +0100
@@ -119,8 +119,8 @@
 void ui_update_menuitem_list(UiEvent *event, UiActiveMenuItemList *list);
 void ui_menu_event_wrapper(GtkMenuItem *item, UiEventData *event);
 void ui_menu_event_toggled(GtkCheckMenuItem *ci, UiEventData *event);
-int ui_checkitem_get(UiInteger *i);
-void ui_checkitem_set(UiInteger *i, int value);
+int64_t ui_checkitem_get(UiInteger *i);
+void ui_checkitem_set(UiInteger *i, int64_t value);
 
 #ifdef	__cplusplus
 }
--- a/ui/gtk/range.c	Sun Nov 19 09:00:16 2017 +0100
+++ b/ui/gtk/range.c	Sun Nov 19 09:38:23 2017 +0100
@@ -124,6 +124,8 @@
 #else
     gtk_adjustment_set_page_size(a, extent);
 #endif
+#if !(GTK_MAJOR_VERSION >= 3 && GTK_MINOR_VERSION >= 18)
     gtk_adjustment_changed(a);
+#endif
     range->extent = extent;
 }
--- a/ui/gtk/window.c	Sun Nov 19 09:00:16 2017 +0100
+++ b/ui/gtk/window.c	Sun Nov 19 09:38:23 2017 +0100
@@ -122,7 +122,8 @@
     
     // window content
     // the content has a (TODO: not yet) configurable frame
-    GtkWidget *frame = gtk_alignment_new(0.5, 0.5, 1, 1);
+    GtkWidget *frame = gtk_frame_new(NULL);
+    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
     gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
     
     // content vbox

mercurial