gnome-applets r11217 - trunk/stickynotes
- From: callum svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-applets r11217 - trunk/stickynotes
- Date: Sun, 25 Jan 2009 06:17:25 +0000 (UTC)
Author: callum
Date: Sun Jan 25 06:17:24 2009
New Revision: 11217
URL: http://svn.gnome.org/viewvc/gnome-applets?rev=11217&view=rev
Log:
Replace gnome_popup_menu_attach(). Bug 562333.
Modified:
trunk/stickynotes/ChangeLog
trunk/stickynotes/stickynotes.c
trunk/stickynotes/stickynotes_callbacks.c
trunk/stickynotes/stickynotes_callbacks.h
Modified: trunk/stickynotes/stickynotes.c
==============================================================================
--- trunk/stickynotes/stickynotes.c (original)
+++ trunk/stickynotes/stickynotes.c Sun Jan 25 06:17:24 2009
@@ -102,13 +102,19 @@
gtk_window_set_decorated (GTK_WINDOW (note->w_window), FALSE);
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (note->w_window), TRUE);
gtk_window_set_skip_pager_hint (GTK_WINDOW (note->w_window), TRUE);
+ gtk_widget_add_events (note->w_window, GDK_BUTTON_PRESS_MASK);
note->w_title = GTK_WIDGET (gtk_builder_get_object (builder, "title_label"));
note->w_body = GTK_WIDGET (gtk_builder_get_object (builder, "body_text"));
note->w_lock = GTK_WIDGET (gtk_builder_get_object (builder, "lock_button"));
+ gtk_widget_add_events (note->w_lock, GDK_BUTTON_PRESS_MASK);
+
note->w_close = GTK_WIDGET (gtk_builder_get_object (builder, "close_button"));
+ gtk_widget_add_events (note->w_close, GDK_BUTTON_PRESS_MASK);
note->w_resize_se = GTK_WIDGET (gtk_builder_get_object (builder, "resize_se_box"));
+ gtk_widget_add_events (note->w_resize_se, GDK_BUTTON_PRESS_MASK);
note->w_resize_sw = GTK_WIDGET (gtk_builder_get_object (builder, "resize_sw_box"));
+ gtk_widget_add_events (note->w_resize_sw, GDK_BUTTON_PRESS_MASK);
note->img_lock = GTK_IMAGE (gtk_builder_get_object (builder,
"lock_img"));
@@ -196,13 +202,26 @@
gtk_widget_realize (note->w_window);
- /* gnome_popup_menu_*() are deprecated. Rewrite to use gtk_menu_popup_*()? */
/* Connect a popup menu to all buttons and title */
- gnome_popup_menu_attach(note->w_menu, note->w_window, note);
- gnome_popup_menu_attach(note->w_menu, note->w_lock, note);
- gnome_popup_menu_attach(note->w_menu, note->w_close, note);
- gnome_popup_menu_attach(note->w_menu, note->w_resize_se, note);
- gnome_popup_menu_attach(note->w_menu, note->w_resize_sw, note);
+ /* GtkBuilder holds and drops the references to all the widgets it
+ * creates for as long as it exist (GtkBuilder). Hence in our callback
+ * we would have an invalid GtkMenu. We need to ref it.
+ */
+ g_object_ref (note->w_menu);
+ g_signal_connect (G_OBJECT (note->w_window), "button-press-event",
+ G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
+
+ g_signal_connect (G_OBJECT (note->w_lock), "button-press-event",
+ G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
+
+ g_signal_connect (G_OBJECT (note->w_close), "button-press-event",
+ G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
+
+ g_signal_connect (G_OBJECT (note->w_resize_se), "button-press-event",
+ G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
+
+ g_signal_connect (G_OBJECT (note->w_resize_sw), "button-press-event",
+ G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
/* Connect a properties dialog to the note */
gtk_window_set_transient_for (GTK_WINDOW(note->w_properties),
Modified: trunk/stickynotes/stickynotes_callbacks.c
==============================================================================
--- trunk/stickynotes/stickynotes_callbacks.c (original)
+++ trunk/stickynotes/stickynotes_callbacks.c Sun Jan 25 06:17:24 2009
@@ -99,6 +99,24 @@
return TRUE;
}
+/* Sticky Window Callback : Popup the right click menu. */
+gboolean
+stickynote_show_popup_menu (GtkWidget *widget, GdkEventButton *event, GtkWidget *popup_menu)
+{
+
+
+ if (event->type == GDK_BUTTON_PRESS && event->button == 3)
+ {
+ gtk_menu_popup (GTK_MENU (popup_menu),
+ NULL, NULL,
+ NULL, NULL,
+ event->button, event->time);
+ }
+
+ return FALSE;
+}
+
+
/* Popup Menu Callback : Create a new sticky note */
void popup_create_cb(GtkWidget *widget, StickyNote *note)
{
Modified: trunk/stickynotes/stickynotes_callbacks.h
==============================================================================
--- trunk/stickynotes/stickynotes_callbacks.h (original)
+++ trunk/stickynotes/stickynotes_callbacks.h Sun Jan 25 06:17:24 2009
@@ -30,6 +30,7 @@
gboolean stickynote_expose_cb(GtkWidget *widget, GdkEventExpose *event, StickyNote *note);
gboolean stickynote_configure_cb(GtkWidget *widget, GdkEventConfigure *event, StickyNote *note);
gboolean stickynote_delete_cb(GtkWidget *widget, GdkEvent *event, StickyNote *note);
+gboolean stickynote_show_popup_menu(GtkWidget *widget, GdkEventButton *event, GtkWidget *popup_menu);
/* Callbacks for the sticky notes popup menu */
void popup_create_cb(GtkWidget *widget, StickyNote *note);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]