Commit 365d8ec0be403c9fcf1dacdf5f079715966b7a77
1 parent
c3f43bd3
Exists in
master
and in
4 other branches
Implementing popup menu on tab labels.
Showing
1 changed file
with
21 additions
and
2 deletions
Show diff stats
src/objects/window/page.c
| @@ -35,6 +35,7 @@ | @@ -35,6 +35,7 @@ | ||
| 35 | #include <v3270/print.h> | 35 | #include <v3270/print.h> |
| 36 | 36 | ||
| 37 | //---[ Gtk Label with customized popup-menu ]--------------------------------------------------------------------------------------- | 37 | //---[ Gtk Label with customized popup-menu ]--------------------------------------------------------------------------------------- |
| 38 | + | ||
| 38 | typedef struct _pw3270TabLabel { | 39 | typedef struct _pw3270TabLabel { |
| 39 | 40 | ||
| 40 | GtkLabel parent; | 41 | GtkLabel parent; |
| @@ -50,10 +51,28 @@ | @@ -50,10 +51,28 @@ | ||
| 50 | G_DEFINE_TYPE(pw3270TabLabel, pw3270TabLabel, GTK_TYPE_LABEL); | 51 | G_DEFINE_TYPE(pw3270TabLabel, pw3270TabLabel, GTK_TYPE_LABEL); |
| 51 | 52 | ||
| 52 | 53 | ||
| 53 | - static gboolean tab_label_button_press(GtkWidget *widget, GdkEventButton *event) { | 54 | + static void popup_menu_detach(GtkWidget G_GNUC_UNUSED(*label), GtkMenu *menu) { |
| 55 | + | ||
| 56 | + debug("%s",__FUNCTION__) | ||
| 57 | + | ||
| 58 | + gtk_widget_destroy(GTK_WIDGET(menu)); | ||
| 59 | + | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + static gboolean tab_label_button_press(GtkWidget *label, GdkEventButton *event) { | ||
| 63 | + | ||
| 64 | + if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | ||
| 65 | + | ||
| 66 | + GtkWidget * menu = gtk_menu_new(); | ||
| 54 | 67 | ||
| 55 | - debug("%s(%u)",__FUNCTION__,event->button); | 68 | + debug("menu=%p",menu); |
| 56 | 69 | ||
| 70 | + gtk_menu_attach_to_widget(GTK_MENU(menu), GTK_WIDGET(label), popup_menu_detach); | ||
| 71 | + g_signal_emit_by_name(GTK_LABEL(label),"populate-popup",menu); | ||
| 72 | + gtk_menu_popup_at_widget(GTK_MENU(menu),label,GDK_GRAVITY_SOUTH_WEST,GDK_GRAVITY_NORTH_WEST,(GdkEvent *) event); | ||
| 73 | + | ||
| 74 | + return TRUE; | ||
| 75 | + } | ||
| 57 | 76 | ||
| 58 | return FALSE; | 77 | return FALSE; |
| 59 | } | 78 | } |