minimal working menubar (GTK) newapi

Sun, 11 Feb 2024 22:24:50 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 11 Feb 2024 22:24:50 +0100
branch
newapi
changeset 255
ebdce2bb62be
parent 254
13997c76859b
child 256
8874a68bafb0

minimal working menubar (GTK)

application/main.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/toolkit.c file | annotate | diff | comparison | revisions
--- a/application/main.c	Sun Feb 11 22:17:00 2024 +0100
+++ b/application/main.c	Sun Feb 11 22:24:50 2024 +0100
@@ -77,6 +77,9 @@
     ui_onstartup(application_startup, NULL);
     
     // menu
+    ui_menu("File") {
+        ui_menuitem(.label = "Test");
+    }
     
 
     
--- a/ui/gtk/menu.c	Sun Feb 11 22:17:00 2024 +0100
+++ b/ui/gtk/menu.c	Sun Feb 11 22:24:50 2024 +0100
@@ -45,13 +45,12 @@
 
 static ui_menu_add_f createMenuItem[] = {
     /* UI_MENU                 */ add_menu_widget,
-    /* UI_MENU_SUBMENU         */ add_menu_widget,
     /* UI_MENU_ITEM            */ add_menuitem_widget,
-    /* UI_MENU_STOCK_ITEM      */ add_menuitem_st_widget,
     /* UI_MENU_CHECK_ITEM      */ add_checkitem_widget,
-    /* UI_MENU_CHECK_ITEM_NV   */ add_checkitemnv_widget,
+    /* UI_MENU_RADIO_ITEM      */ add_radioitem_widget,
     /* UI_MENU_ITEM_LIST       */ add_menuitem_list_widget,
-    /* UI_MENU_ITEM_LIST_NV    */ NULL, // TODO
+    /* UI_MENU_CHECKITEM_LIST  */ add_menuitem_list_widget,
+    /* UI_MENU_RADIOITEM_LIST  */ add_menuitem_list_widget,
     /* UI_MENU_SEPARATOR       */ add_menuseparator_widget
 };
 
@@ -76,12 +75,6 @@
 }
 
 void add_menu_widget(GtkWidget *parent, int i, UiMenuItemI *item, UiObject *obj) {
-    // TODO
-}
-
-#ifdef DEPRECATED_TOOLKIT
-
-void add_menu_widget(GtkWidget *parent, int i, UiMenuItemI *item, UiObject *obj) {
     UiMenu *menu = (UiMenu*)item;
     
     GtkWidget *menu_widget = gtk_menu_new();
@@ -132,6 +125,7 @@
     }
 }
 
+/*
 void add_menuitem_st_widget(
         GtkWidget *parent,
         int index,
@@ -167,6 +161,7 @@
         uic_add_group_widget(obj->ctx, widget, (ui_enablefunc)ui_set_enabled, i->groups);
     }
 }
+*/
 
 void add_menuseparator_widget(
         GtkWidget *parent,
@@ -180,7 +175,7 @@
 }
 
 void add_checkitem_widget(GtkWidget *p, int index, UiMenuItemI *item, UiObject *obj) {
-    UiCheckItem *ci = (UiCheckItem*)item;
+    UiMenuCheckItem *ci = (UiMenuCheckItem*)item;
     GtkWidget *widget = gtk_check_menu_item_new_with_mnemonic(ci->label);
     gtk_menu_shell_append(GTK_MENU_SHELL(p), widget);
     
@@ -204,6 +199,11 @@
     }
 }
 
+void add_radioitem_widget(GtkWidget *p, int index, UiMenuItemI *item, UiObject *obj) {
+    // TODO
+}
+
+/*
 void add_checkitemnv_widget(GtkWidget *p, int index, UiMenuItemI *item, UiObject *obj) {
     UiCheckItemNV *ci = (UiCheckItemNV*)item;
     GtkWidget *widget = gtk_check_menu_item_new_with_mnemonic(ci->label);
@@ -220,6 +220,7 @@
         // TODO: error
     }
 }
+*/
 
 void add_menuitem_list_widget(GtkWidget *p, int index, UiMenuItemI *item, UiObject *obj) {
     UiMenuItemList *il = (UiMenuItemList*)item;
@@ -233,7 +234,10 @@
     ls->menu = GTK_MENU_SHELL(p);
     ls->index = index;
     ls->oldcount = 0;
-    ls->list = il->list;
+    
+    // TODO:
+    //ls->list = il->list;
+    
     ls->callback = il->callback;
     ls->userdata = il->userdata;
     
@@ -478,5 +482,3 @@
         cxListDestroy(groups);
     }
 }
-
-#endif
--- a/ui/gtk/menu.h	Sun Feb 11 22:17:00 2024 +0100
+++ b/ui/gtk/menu.h	Sun Feb 11 22:24:50 2024 +0100
@@ -60,6 +60,7 @@
 void add_menuitem_st_widget(GtkWidget *p, int i, UiMenuItemI *item, UiObject *obj);
 void add_menuseparator_widget(GtkWidget *p, int i, UiMenuItemI *item, UiObject *obj);
 void add_checkitem_widget(GtkWidget *p, int i, UiMenuItemI *item, UiObject *obj);
+void add_radioitem_widget(GtkWidget *p, int index, UiMenuItemI *item, UiObject *obj);
 void add_checkitemnv_widget(GtkWidget *p, int i, UiMenuItemI *item, UiObject *obj);
 void add_menuitem_list_widget(GtkWidget *p, int i, UiMenuItemI *item, UiObject *obj);
 
--- a/ui/gtk/toolkit.c	Sun Feb 11 22:17:00 2024 +0100
+++ b/ui/gtk/toolkit.c	Sun Feb 11 22:24:50 2024 +0100
@@ -71,7 +71,9 @@
     application_name = appname;
     
     uic_docmgr_init();
-    ui_toolbar_init();
+    ui_toolbar_init(); // TODO: remove
+    
+    uic_toolbar_init();
     
     // init custom types
     ui_list_init();

mercurial