changes for the new accelerator stuff

-Yosh
This commit is contained in:
Manish Singh 1998-06-07 19:42:03 +00:00
parent 11269e1e69
commit b3b04d1c9d
5 changed files with 63 additions and 40 deletions

View File

@ -1,3 +1,11 @@
Sun Jun 7 12:39:56 PDT 1998 Manish Singh <yosh@gimp.org>
* plug-ins/libgck/gck/gcktypes.h
* plug-ins/libgck/gck/gckui.h
* plug-ins/libgck/gck/gckui.c
* plug-ins/ifscompose/ifscompose.c: changes for the new accelerator
stuff
Sun Jun 7 11:04:38 1998 Tim Janik <timj@gtk.org>
* app/gradient.c (cpopup_create_menu_item_with_label): use GtkAccelLabel

View File

@ -1104,16 +1104,15 @@ static void
design_op_menu_create(GtkWidget *window)
{
GtkWidget *menu_item;
GtkAcceleratorTable *accelerator_table;
GtkAccelGroup *accel_group;
ifsDesign->op_menu = gtk_menu_new();
gtk_object_ref (GTK_OBJECT (ifsDesign->op_menu));
gtk_object_sink (GTK_OBJECT (ifsDesign->op_menu));
accelerator_table = gtk_accelerator_table_new();
gtk_menu_set_accelerator_table(GTK_MENU(ifsDesign->op_menu),
accelerator_table);
gtk_window_add_accelerator_table(GTK_WINDOW(window),accelerator_table);
accel_group = gtk_accel_group_new();
gtk_menu_set_accel_group(GTK_MENU(ifsDesign->op_menu), accel_group);
gtk_window_add_accel_group(GTK_WINDOW(window),accel_group);
menu_item = gtk_menu_item_new_with_label("Move");
gtk_menu_append(GTK_MENU(ifsDesign->op_menu),menu_item);
@ -1121,9 +1120,11 @@ design_op_menu_create(GtkWidget *window)
gtk_signal_connect(GTK_OBJECT(menu_item),"activate",
(GtkSignalFunc)design_op_update_callback,
(gpointer)((long)OP_TRANSLATE));
gtk_widget_install_accelerator(menu_item,
accelerator_table,
"activate",'M',0);
gtk_widget_add_accelerator(menu_item,
"activate",
accel_group,
'M', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menu_item = gtk_menu_item_new_with_label("Rotate/Scale");
gtk_menu_append(GTK_MENU(ifsDesign->op_menu),menu_item);
@ -1131,9 +1132,11 @@ design_op_menu_create(GtkWidget *window)
gtk_signal_connect(GTK_OBJECT(menu_item),"activate",
(GtkSignalFunc)design_op_update_callback,
(gpointer)((long)OP_ROTATE));
gtk_widget_install_accelerator(menu_item,
accelerator_table,
"activate",'R',0);
gtk_widget_add_accelerator(menu_item,
"activate",
accel_group,
'R', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menu_item = gtk_menu_item_new_with_label("Stretch");
gtk_menu_append(GTK_MENU(ifsDesign->op_menu),menu_item);
@ -1141,9 +1144,11 @@ design_op_menu_create(GtkWidget *window)
gtk_signal_connect(GTK_OBJECT(menu_item),"activate",
(GtkSignalFunc)design_op_update_callback,
(gpointer)((long)OP_STRETCH));
gtk_widget_install_accelerator(menu_item,
accelerator_table,
"activate",'S',0);
gtk_widget_add_accelerator(menu_item,
"activate",
accel_group,
'S', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* A separator */
menu_item = gtk_menu_item_new();
@ -1156,9 +1161,11 @@ design_op_menu_create(GtkWidget *window)
gtk_signal_connect(GTK_OBJECT(menu_item),"activate",
(GtkSignalFunc)design_area_select_all_callback,
NULL);
gtk_widget_install_accelerator(menu_item,
accelerator_table,
"activate",'A',GDK_CONTROL_MASK);
gtk_widget_add_accelerator(menu_item,
"activate",
accel_group,
'A', GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menu_item = gtk_menu_item_new_with_label("Recompute Center");
gtk_menu_append(GTK_MENU(ifsDesign->op_menu),menu_item);
@ -1166,9 +1173,11 @@ design_op_menu_create(GtkWidget *window)
gtk_signal_connect(GTK_OBJECT(menu_item),"activate",
(GtkSignalFunc)recompute_center_cb,
NULL);
gtk_widget_install_accelerator(menu_item,
accelerator_table,
"activate",'R',GDK_MOD1_MASK);
gtk_widget_add_accelerator(menu_item,
"activate",
accel_group,
'R', GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menu_item = gtk_menu_item_new_with_label("Undo");
gtk_menu_append(GTK_MENU(ifsDesign->op_menu),menu_item);
@ -1176,9 +1185,11 @@ design_op_menu_create(GtkWidget *window)
gtk_signal_connect(GTK_OBJECT(menu_item),"activate",
(GtkSignalFunc)undo,
NULL);
gtk_widget_install_accelerator(menu_item,
accelerator_table,
"activate",'Z',GDK_CONTROL_MASK);
gtk_widget_add_accelerator(menu_item,
"activate",
accel_group,
'Z', GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menu_item = gtk_menu_item_new_with_label("Redo");
gtk_menu_append(GTK_MENU(ifsDesign->op_menu),menu_item);
@ -1186,9 +1197,11 @@ design_op_menu_create(GtkWidget *window)
gtk_signal_connect(GTK_OBJECT(menu_item),"activate",
(GtkSignalFunc)redo,
NULL);
gtk_widget_install_accelerator(menu_item,
accelerator_table,
"activate",'R',GDK_CONTROL_MASK);
gtk_widget_add_accelerator(menu_item,
"activate",
accel_group,
'R', GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
}
static void

View File

@ -119,7 +119,7 @@ typedef struct
{
GtkWidget *widget;
GtkStyle *style;
GtkAcceleratorTable *accelerator_table;
GtkAccelGroup *accel_group;
GckVisualInfo *visinfo;
} GckApplicationWindow;

View File

@ -135,8 +135,8 @@ GckApplicationWindow *gck_application_window_new(char *name)
/* Create application accelerator table */
/* ==================================== */
appwin->accelerator_table = gtk_accelerator_table_new();
gtk_window_add_accelerator_table(GTK_WINDOW(appwin->widget),appwin->accelerator_table);
appwin->accel_group = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW(appwin->widget),appwin->accel_group);
g_function_leave("gck_application_window_new");
return (appwin);
@ -1036,7 +1036,7 @@ GtkWidget *gck_option_menu_new(char *name, GtkWidget *container,
/******************/
GtkWidget *gck_menu_bar_new(GtkWidget *container,GckMenuItem menu_items[],
GtkAcceleratorTable *acc_table)
GtkAccelGroup *acc_group)
{
GtkWidget *menubar,*menu_item;
gint container_type;
@ -1069,7 +1069,7 @@ GtkWidget *gck_menu_bar_new(GtkWidget *container,GckMenuItem menu_items[],
if (menu_items->subitems!=NULL)
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item),
gck_menu_new(menu_items->subitems,acc_table));
gck_menu_new(menu_items->subitems,acc_group));
gtk_widget_show(menu_item);
menu_items->widget = menu_item;
@ -1089,7 +1089,7 @@ GtkWidget *gck_menu_bar_new(GtkWidget *container,GckMenuItem menu_items[],
/* Create menu */
/***************/
GtkWidget *gck_menu_new(GckMenuItem *menu_items,GtkAcceleratorTable *acc_table)
GtkWidget *gck_menu_new(GckMenuItem *menu_items,GtkAccelGroup *acc_group)
{
GtkWidget *menu,*menu_item;
gint i=0;
@ -1105,11 +1105,13 @@ GtkWidget *gck_menu_new(GckMenuItem *menu_items,GtkAcceleratorTable *acc_table)
else
{
menu_item = gtk_menu_item_new_with_label(menu_items[i].label);
if (menu_items->accelerator_key && acc_table)
gtk_widget_install_accelerator(menu_item,acc_table,
menu_items[i].label,
menu_items[i].accelerator_key,
menu_items[i].accelerator_mods);
if (menu_items->accelerator_key && acc_group)
gtk_widget_add_accelerator(menu_item,
menu_items[i].label,
acc_group,
menu_items[i].accelerator_key,
menu_items[i].accelerator_mods,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
gtk_object_set_data(GTK_OBJECT(menu_item),"_GckMenuItem",(gpointer)&menu_items[i]);
@ -1122,7 +1124,7 @@ GtkWidget *gck_menu_new(GckMenuItem *menu_items,GtkAcceleratorTable *acc_table)
if (menu_items[i].subitems!=NULL)
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item),
gck_menu_new(menu_items[i].subitems,acc_table));
gck_menu_new(menu_items[i].subitems,acc_group));
gtk_widget_show(menu_item);
menu_items[i].widget = menu_item;

View File

@ -126,10 +126,10 @@ GtkWidget *gck_hbox_new (GtkWidget *container,
GtkWidget *gck_menu_bar_new (GtkWidget *container,
GckMenuItem menu_items[],
GtkAcceleratorTable *acc_table);
GtkAccelGroup *acc_group);
GtkWidget *gck_menu_new (GckMenuItem *menu_items,
GtkAcceleratorTable *acc_table);
GtkAccelGroup *acc_group);
GtkWidget *gck_option_menu_new (char *name,GtkWidget *container,
gint expand,gint fill,