Proxy show-popup-menu signal

parent 7be4e7d9
...@@ -228,18 +228,12 @@ gedit_multi_notebook_class_init (GeditMultiNotebookClass *klass) ...@@ -228,18 +228,12 @@ gedit_multi_notebook_class_init (GeditMultiNotebookClass *klass)
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
} }
static gboolean static void
notebook_button_press_event (GtkNotebook *notebook, notebook_show_popup_menu (GtkNotebook *notebook,
GdkEventButton *event, GdkEvent *event,
GeditMultiNotebook *mnb) GeditMultiNotebook *mnb)
{ {
if (GDK_BUTTON_PRESS == event->type && 3 == event->button) g_signal_emit (G_OBJECT (mnb), signals[SHOW_POPUP_MENU], 0, event);
{
g_signal_emit (G_OBJECT (mnb), signals[SHOW_POPUP_MENU], 0,
event);
}
return FALSE;
} }
static void static void
...@@ -410,8 +404,8 @@ connect_notebook_signals (GeditMultiNotebook *mnb, ...@@ -410,8 +404,8 @@ connect_notebook_signals (GeditMultiNotebook *mnb,
G_CALLBACK (notebook_tab_close_request), G_CALLBACK (notebook_tab_close_request),
mnb); mnb);
g_signal_connect (notebook, g_signal_connect (notebook,
"button-press-event", "show-popup-menu",
G_CALLBACK (notebook_button_press_event), G_CALLBACK (notebook_show_popup_menu),
mnb); mnb);
} }
...@@ -433,7 +427,7 @@ disconnect_notebook_signals (GeditMultiNotebook *mnb, ...@@ -433,7 +427,7 @@ disconnect_notebook_signals (GeditMultiNotebook *mnb,
mnb); mnb);
g_signal_handlers_disconnect_by_func (notebook, notebook_tab_close_request, g_signal_handlers_disconnect_by_func (notebook, notebook_tab_close_request,
mnb); mnb);
g_signal_handlers_disconnect_by_func (notebook, notebook_button_press_event, g_signal_handlers_disconnect_by_func (notebook, notebook_show_popup_menu,
mnb); mnb);
} }
......
...@@ -81,6 +81,7 @@ enum ...@@ -81,6 +81,7 @@ enum
enum enum
{ {
TAB_CLOSE_REQUEST, TAB_CLOSE_REQUEST,
SHOW_POPUP_MENU,
LAST_SIGNAL LAST_SIGNAL
}; };
...@@ -251,7 +252,7 @@ find_tab_num_at_pos (GtkNotebook *notebook, ...@@ -251,7 +252,7 @@ find_tab_num_at_pos (GtkNotebook *notebook,
} }
static gboolean static gboolean
gedit_notebook_button_press (GtkWidget *widget, gedit_notebook_button_press (GtkWidget *widget,
GdkEventButton *event) GdkEventButton *event)
{ {
GtkNotebook *nb = GTK_NOTEBOOK (widget); GtkNotebook *nb = GTK_NOTEBOOK (widget);
...@@ -268,9 +269,10 @@ gedit_notebook_button_press (GtkWidget *widget, ...@@ -268,9 +269,10 @@ gedit_notebook_button_press (GtkWidget *widget,
/* switch to the page the mouse is over */ /* switch to the page the mouse is over */
gtk_notebook_set_current_page (nb, tab_clicked); gtk_notebook_set_current_page (nb, tab_clicked);
g_signal_emit (G_OBJECT (widget), signals[SHOW_POPUP_MENU], 0, event);
return TRUE; return TRUE;
} }
} }
return GTK_WIDGET_CLASS (gedit_notebook_parent_class)->button_press_event (widget, event); return GTK_WIDGET_CLASS (gedit_notebook_parent_class)->button_press_event (widget, event);
...@@ -527,6 +529,17 @@ gedit_notebook_class_init (GeditNotebookClass *klass) ...@@ -527,6 +529,17 @@ gedit_notebook_class_init (GeditNotebookClass *klass)
1, 1,
GEDIT_TYPE_TAB); GEDIT_TYPE_TAB);
signals[SHOW_POPUP_MENU] =
g_signal_new ("show-popup-menu",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GeditNotebookClass, show_popup_menu),
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE,
1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
g_type_class_add_private (object_class, sizeof (GeditNotebookPrivate)); g_type_class_add_private (object_class, sizeof (GeditNotebookPrivate));
} }
......
...@@ -74,7 +74,7 @@ struct _GeditNotebook ...@@ -74,7 +74,7 @@ struct _GeditNotebook
GtkNotebook notebook; GtkNotebook notebook;
/*< private >*/ /*< private >*/
GeditNotebookPrivate *priv; GeditNotebookPrivate *priv;
}; };
/* /*
...@@ -84,11 +84,13 @@ typedef struct _GeditNotebookClass GeditNotebookClass; ...@@ -84,11 +84,13 @@ typedef struct _GeditNotebookClass GeditNotebookClass;
struct _GeditNotebookClass struct _GeditNotebookClass
{ {
GtkNotebookClass parent_class; GtkNotebookClass parent_class;
/* Signals */ /* Signals */
void (* tab_close_request) (GeditNotebook *notebook, void (* tab_close_request) (GeditNotebook *notebook,
GeditTab *tab); GeditTab *tab);
void (* show_popup_menu) (GeditNotebook *notebook,
GdkEvent *event);
}; };
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment