aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Linux_C_12/cCrossCallMenus_121.c70
-rw-r--r--osmenu.icl3
2 files changed, 24 insertions, 49 deletions
diff --git a/Linux_C_12/cCrossCallMenus_121.c b/Linux_C_12/cCrossCallMenus_121.c
index 745adef..e8f92bc 100644
--- a/Linux_C_12/cCrossCallMenus_121.c
+++ b/Linux_C_12/cCrossCallMenus_121.c
@@ -10,6 +10,7 @@
********************************************************************************************/
#include "cCrossCallMenus_121.h"
#include "cCrossCall_121.h"
+#include "util_121.h"
/* Cross call procedure implementations.
@@ -77,7 +78,9 @@ static void menuitem_activate_handler(GtkMenuItem *menu_item)
{
in_handler_flag = 1;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), !(GTK_CHECK_MENU_ITEM(menu_item)->active));
- SendMessage2ToClean (CcWmCOMMAND, GTK_WIDGET(menu_item), GetModifiers ());
+ GdkEvent* event = gtk_get_current_event();
+ if (!event || event->key.type != GDK_KEY_RELEASE) // We only look for key presses, otherwise every shortcut fires twice
+ SendMessage2ToClean (CcWmCOMMAND, GTK_WIDGET(menu_item), GetModifiers ());
in_handler_flag = 0;
}
}
@@ -120,9 +123,6 @@ void EvalCcRqINSERTMENUITEM (CrossCallInfo *pcci)
printf("Creating new menu item\n");
menu_item = gtk_menu_item_new_with_mnemonic(title);
gtk_menu_shell_insert( GTK_MENU_SHELL (menu), menu_item, (gint) pcci->p5);
- //gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), menu_item);
- //gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), ((pcci->p1 & 1) != 0));
- //gtk_widget_set_sensitive(menu_item, ((pcci->p1 & 2) != 0));
gtk_signal_connect_object (GTK_OBJECT (menu_item), "activate",
GTK_SIGNAL_FUNC (menuitem_activate_handler), menu_item);
@@ -133,34 +133,6 @@ void EvalCcRqINSERTMENUITEM (CrossCallInfo *pcci)
rfree(title);
printf("Freed title\n");
-
-/* if (key != 0)
- {
- printf("Creating accellerators\n");
- accel_group = ((GtkAccelGroup *) gtk_accel_groups_from_object (G_OBJECT(frame))->data);
-
- gtk_widget_add_accelerator(menu_item, "activate",
- accel_group,
- key,
- GDK_CONTROL_MASK,
- GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator(menu_item, "activate",
- accel_group,
- key,
- GDK_CONTROL_MASK | GDK_SHIFT_MASK,
- 0);
- gtk_widget_add_accelerator(menu_item, "activate",
- accel_group,
- key,
- GDK_CONTROL_MASK | GDK_MOD1_MASK,
- 0);
- gtk_widget_add_accelerator(menu_item, "activate",
- accel_group,
- key,
- GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK,
- 0);
- }
-*/
printf("Creating return Cci\n");
MakeReturn1Cci (pcci, (int64_t) menu_item);
}
@@ -172,23 +144,29 @@ void EvalCcRqINSERTMENUITEM (CrossCallInfo *pcci)
/* Add a shortkey to a framewindow shortkey table. */
void EvalCcRqADDMENUSHORTKEY (CrossCallInfo *pcci) /* frameptr, cmd, key; no result. */
{
-/* ProcessShortcutTable table;
- HWND frameptr;
- int cmd, key;
+ GtkAccelGroup* accel_group;
+ GObject* frame;
+ GtkWidget* menu_item;
+ guint key;
+
+ printf("EvalCcRqADDMENUSHORTKEY\n");
- frameptr = (HWND) pcci->p1;
- cmd = pcci->p2;
- key = pcci->p3;
+ frame = G_OBJECT(pcci->p1);
+ menu_item = GTK_WIDGET(pcci->p2);
+ key = (guint) pcci->p3;
- table = (ProcessShortcutTable) GetWindowLong (frameptr,0);
- table = AddProcessShortcut (key, cmd, table);
- SetWindowLong (frameptr, 0, (long)table);
+ printf("Creating accellerators\n");
+ accel_group = (GtkAccelGroup*) gtk_accel_groups_from_object(frame)->data;
+
+ printf("Accel groups: %p, %p\n", accel_group, gtk_accel_groups_from_object(frame)->next);
+
+ gtk_widget_activate(menu_item);
+ gtk_widget_add_accelerator(menu_item, "activate",
+ accel_group,
+ key,
+ GDK_CONTROL_MASK,
+ GTK_ACCEL_VISIBLE);
- if (gAcceleratorTableIsUpToDate)
- gAcceleratorTableIsUpToDate = !(ghActiveFrameWindow==frameptr);
- }
-*/
- printf("EvalCcRqADDMENUSHORTKEY\n");
MakeReturn0Cci (pcci);
}
diff --git a/osmenu.icl b/osmenu.icl
index 72e3daf..6e80ee7 100644
--- a/osmenu.icl
+++ b/osmenu.icl
@@ -120,9 +120,6 @@ osTrackPopUpMenu menu framePtr tb
// Changing (sub)menus:
osAppendMenuItem :: !OSMenuBar !Int !OSMenu !{#Char} !Bool !Bool !Char !*OSToolbox -> (!OSMenuItem,!OSMenu,!*OSToolbox)
osAppendMenuItem {menuWindow} index menu title able mark key tb
- # title = if (key <> '\0')
- (title +++ "\tCtrl+" +++ toString (toUpper key))
- title
# (item,tb) = winInsertMenuItem title able mark menu index tb
| key <> '\0'
= (item,menu,winAddMenuShortKey menuWindow item key tb)