tSupport for GtkCheckMenuItem widgets added to Win32 code. - vaccinewars - be a doctor and try to vaccinate the world
git clone git://src.adamsgaard.dk/vaccinewars
Log
Files
Refs
README
LICENSE
---
commit c795650908325428891e79717b576cc229033089
parent 871c2a7df6c23611b037055e2f43ed4178327e49
Author: Ben Webb 
Date:   Mon, 19 Aug 2002 12:51:39 +0000

Support for GtkCheckMenuItem widgets added to Win32 code.


Diffstat:
  M src/gtkport/gtkport.c               |      26 ++++++++++++++++++++++++++
  M src/gtkport/gtkport.h               |       4 ++++

2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/src/gtkport/gtkport.c b/src/gtkport/gtkport.c
t@@ -944,6 +944,10 @@ gboolean gtk_window_wndproc(GtkWidget *widget, UINT msg, WPARAM wParam,
     if (HIWORD(wParam) == 0 || HIWORD(wParam) == 1) {
       menu = gtk_window_get_menu_ID(GTK_WINDOW(widget), LOWORD(wParam));
       if (menu) {
+        if (GTK_MENU_ITEM(menu)->check) {
+          gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu),
+                                         !GTK_CHECK_MENU_ITEM(menu)->active);
+        }
         gtk_signal_emit(GTK_OBJECT(menu), "activate");
         return FALSE;
       }
t@@ -3563,6 +3567,9 @@ void gtk_item_factory_create_item(GtkItemFactory *ifactory,
                                    menu_title, &accel);
 
   menu_item = gtk_menu_item_new_with_label(menu_title->str);
+  if (entry->item_type && strcmp(entry->item_type, "") == 0) {
+    GTK_CHECK_MENU_ITEM(menu_item)->check = 1;
+  }
   new_child->widget = menu_item;
   if (entry->callback) {
     gtk_signal_connect(GTK_OBJECT(menu_item), "activate",
t@@ -3699,6 +3706,8 @@ GtkWidget *gtk_menu_item_new_with_label(const gchar *label)
   menu_item = GTK_MENU_ITEM(GtkNewObject(&GtkMenuItemClass));
   menu_item->accelind = -1;
   menu_item->text = g_strdup(label);
+  menu_item->check = 0;
+  menu_item->active = 0;
   for (i = 0; i < strlen(menu_item->text); i++) {
     if (menu_item->text[i] == '_')
       menu_item->text[i] = '&';
t@@ -3712,6 +3721,23 @@ void gtk_menu_item_set_submenu(GtkMenuItem *menu_item, GtkWidget *submenu)
   submenu->parent = GTK_WIDGET(menu_item);
 }
 
+void gtk_check_menu_item_set_active(GtkMenuItem *menu_item, gboolean active)
+{
+  GtkWidget *widget = GTK_WIDGET(menu_item);
+  menu_item->active = active;
+
+  if (GTK_WIDGET_REALIZED(widget)) {
+    MENUITEMINFO mii;
+    HMENU parent_menu;
+
+    parent_menu = GTK_MENU_SHELL(widget->parent)->menu;
+    mii.cbSize = sizeof(MENUITEMINFO);
+    mii.fMask = MIIM_STATE;
+    mii.fState = active ? MFS_CHECKED : MFS_UNCHECKED;
+    SetMenuItemInfo(parent_menu, menu_item->ID, FALSE, &mii);
+  }
+}
+
 static GtkWidget *gtk_menu_item_get_menu_ID(GtkMenuItem *menu_item,
                                             gint ID)
 {
diff --git a/src/gtkport/gtkport.h b/src/gtkport/gtkport.h
t@@ -202,6 +202,8 @@ struct _GtkMenuItem {
   gint ID;
   gint accelind;
   gchar *text;
+  gint check:1;
+  gint active:1;
 };
 
 struct _GtkMenuShell {
t@@ -461,6 +463,7 @@ extern HINSTANCE hInst;
 #define GTK_MENU_SHELL(obj) ((GtkMenuShell *)(obj))
 #define GTK_MENU_BAR(obj) ((GtkMenuBar *)(obj))
 #define GTK_MENU_ITEM(obj) ((GtkMenuItem *)(obj))
+#define GTK_CHECK_MENU_ITEM(obj) ((GtkMenuItem *)(obj))
 #define GTK_MENU(obj) ((GtkMenu *)(obj))
 #define GTK_MISC(obj) ((GtkMisc *)(obj))
 #define GTK_PROGRESS_BAR(obj) ((GtkProgressBar *)(obj))
t@@ -590,6 +593,7 @@ void gtk_menu_append(GtkMenu *menu, GtkWidget *child);
 void gtk_menu_prepend(GtkMenu *menu, GtkWidget *child);
 GtkWidget *gtk_menu_item_new_with_label(const gchar *label);
 void gtk_menu_item_set_submenu(GtkMenuItem *menu_item, GtkWidget *submenu);
+void gtk_check_menu_item_set_active(GtkMenuItem *menu_item, gboolean active);
 void gtk_menu_set_active(GtkMenu *menu, guint index);
 GtkWidget *gtk_notebook_new();
 void gtk_notebook_append_page(GtkNotebook *notebook, GtkWidget *child,