summaryrefslogtreecommitdiff
path: root/stickynotes
diff options
context:
space:
mode:
authorCallum McKenzie <callum@src.gnome.org>2009-01-25 06:17:24 +0000
committerCallum McKenzie <callum@src.gnome.org>2009-01-25 06:17:24 +0000
commite40f676150c98fd138c294d12714be41cdd83b1f (patch)
treee2e2f27dc09db3bbcff4138be8ebdd7ccd0e324a /stickynotes
parentd00847b0e549f6183c7600892d8858cea52815d3 (diff)
Replace gnome_popup_menu_attach(). Bug 562333.
svn path=/trunk/; revision=11217
Diffstat (limited to 'stickynotes')
-rw-r--r--stickynotes/ChangeLog6
-rw-r--r--stickynotes/stickynotes.c31
-rw-r--r--stickynotes/stickynotes_callbacks.c18
-rw-r--r--stickynotes/stickynotes_callbacks.h1
4 files changed, 50 insertions, 6 deletions
diff --git a/stickynotes/ChangeLog b/stickynotes/ChangeLog
index fdfe209bc..45d09a428 100644
--- a/stickynotes/ChangeLog
+++ b/stickynotes/ChangeLog
@@ -1,3 +1,9 @@
+2009-01-25 Callum McKenzie <callum@spooky-possum.org>
+
+ * stickynotes.c:
+ * stickynotes_callbacks.*: Replace gnome_popup_menu_attach. Patch
+ from Diego Escalante Urrelo (bug 562333).
+
2009-01-23 Callum McKenzie <callum@spooky-possum.org>
* stickynotes_applet.c: Remove use of gnome_client_*. See bug
diff --git a/stickynotes/stickynotes.c b/stickynotes/stickynotes.c
index 61133383a..860d0f74e 100644
--- a/stickynotes/stickynotes.c
+++ b/stickynotes/stickynotes.c
@@ -102,13 +102,19 @@ stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h)
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 @@ stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h)
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),
diff --git a/stickynotes/stickynotes_callbacks.c b/stickynotes/stickynotes_callbacks.c
index baef8aa6f..604e5085b 100644
--- a/stickynotes/stickynotes_callbacks.c
+++ b/stickynotes/stickynotes_callbacks.c
@@ -99,6 +99,24 @@ gboolean stickynote_delete_cb(GtkWidget *widget, GdkEvent *event, StickyNote *no
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)
{
diff --git a/stickynotes/stickynotes_callbacks.h b/stickynotes/stickynotes_callbacks.h
index fcda1e09f..686d7da28 100644
--- a/stickynotes/stickynotes_callbacks.h
+++ b/stickynotes/stickynotes_callbacks.h
@@ -30,6 +30,7 @@ gboolean stickynote_move_cb(GtkWidget *widget, GdkEventButton *event, StickyNote
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);