Update of /cvsroot/htoolkit/port/src/cbits/GTK
In directory sc8-pr-cvs1:/tmp/cvs-serv26896/src/cbits/GTK
Modified Files:
Menu.c ToolBar.c
Log Message:
Implementation for popup menus and dropdown tool buttons for GNOME
Index: Menu.c
===================================================================
RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Menu.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Menu.c 17 Aug 2003 19:27:57 -0000 1.10
--- Menu.c 17 Aug 2003 22:02:45 -0000 1.11
***************
*** 19,23 ****
}
else
! parent = gtk_menu_item_get_submenu(GTK_MENU_ITEM(parent));
return parent;
--- 19,24 ----
}
else
! if (GTK_IS_MENU_ITEM(parent))
! parent = gtk_menu_item_get_submenu(GTK_MENU_ITEM(parent));
return parent;
***************
*** 72,75 ****
--- 73,116 ----
}
+ MenuHandle osCreatePopupMenu()
+ {
+ GtkWidget *popUpMenu = gtk_menu_new();
+ gtk_signal_connect (GTK_OBJECT(popUpMenu), "destroy",
+ GTK_SIGNAL_FUNC(handleMenuDestroy),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(popUpMenu), "show",
+ GTK_SIGNAL_FUNC(menu_show),
+ NULL);
+ return popUpMenu;
+ }
+
+ struct PositioningParams
+ {
+ int x, y;
+ GtkWidget *widget;
+ };
+
+ static void menu_positioning(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, struct PositioningParams *params)
+ {
+ gdk_window_get_origin(params->widget->window, x, y);
+ *x += params->x;
+ *y += params->y;
+
+ *push_in = TRUE;
+ free(params);
+ }
+
+ void osTrackPopupMenu(MenuHandle handle, WindowHandle hwnd, int x, int y)
+ {
+ struct PositioningParams *params = malloc(2*sizeof(struct PositioningParams));
+ if (params)
+ {
+ params->x = x;
+ params->y = y;
+ params->widget = hwnd;
+ gtk_menu_popup(GTK_MENU(handle), NULL, NULL, menu_positioning, params, 0, gtk_get_current_event_time());
+ }
+ }
+
MenuHandle osInsertMenu(MenuHandle parent, int pos)
{
***************
*** 227,236 ****
void osSetMenuItemEnabled(MenuHandle item, BOOL bState)
{
! gtk_widget_set_sensitive(item,bState);
};
BOOL osGetMenuItemEnabled(MenuHandle item)
{
! return GTK_WIDGET_SENSITIVE(item);
};
--- 268,281 ----
void osSetMenuItemEnabled(MenuHandle item, BOOL bState)
{
! if (GTK_IS_MENU_ITEM(item))
! gtk_widget_set_sensitive(item,bState);
};
BOOL osGetMenuItemEnabled(MenuHandle item)
{
! if (GTK_IS_MENU_ITEM(item))
! return GTK_WIDGET_SENSITIVE(item);
! else
! return TRUE;
};
***************
*** 247,258 ****
void osSetMenuLabel(MenuHandle item, char* title)
{
! gchar *szText = toMnemonicString(title);
! gtk_label_set_text_with_mnemonic(GTK_LABEL(GTK_BIN(item)->child), szText);
! rfree(szText);
}
char *osGetMenuLabel(MenuHandle item)
{
! return fromMnemonicString(gtk_label_get_text(GTK_LABEL(GTK_BIN(item)->child)));
};
--- 292,309 ----
void osSetMenuLabel(MenuHandle item, char* title)
{
! if (GTK_IS_MENU_ITEM(item))
! {
! gchar *szText = toMnemonicString(title);
! gtk_label_set_text_with_mnemonic(GTK_LABEL(GTK_BIN(item)->child), szText);
! rfree(szText);
! }
}
char *osGetMenuLabel(MenuHandle item)
{
! if (GTK_IS_MENU_ITEM(item))
! return fromMnemonicString(gtk_label_get_text(GTK_LABEL(GTK_BIN(item)->child)));
! else
! return NULL;
};
Index: ToolBar.c
===================================================================
RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/ToolBar.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ToolBar.c 16 Aug 2003 16:01:36 -0000 1.5
--- ToolBar.c 17 Aug 2003 22:02:46 -0000 1.6
***************
*** 114,117 ****
--- 114,137 ----
}
+ void tool_dropdown_button_clicked(GtkWidget *widget, gpointer user_data)
+ {
+ gtk_menu_popup(GTK_MENU(user_data), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time());
+ }
+
+ ToolHandle osInsertToolDropDownButton(WindowHandle toolbar, MenuHandle hmenu, int pos)
+ {
+ GtkToolItem *item = gtk_tool_button_new("", gtk_image_new());
+ gtk_signal_connect (GTK_OBJECT(GTK_TOOL_BUTTON(item)->button), "clicked",
+ GTK_SIGNAL_FUNC(tool_dropdown_button_clicked),
+ hmenu);
+ gtk_signal_connect (GTK_OBJECT(item), "destroy",
+ GTK_SIGNAL_FUNC(handleToolDestroy),
+ NULL);
+ gtk_tool_button_set_label_widget(GTK_TOOL_BUTTON(item), gtk_label_new(""));
+ gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos);
+ gtk_widget_show_all(GTK_WIDGET(item));
+ return GTK_WIDGET(item);
+ }
+
ToolHandle osInsertToolLine(WindowHandle toolbar, int pos)
{
|