aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-08 17:15:00 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-08 17:15:00 +0100
commit827c2128a33fc28c5f291b709eae515eae3f20c0 (patch)
treed58c20336fe72ab0316f0fc34c3a9cd166c6a156 /src/fs
parent9fa06ac818a0b479778a77261fbdb5e5eb53e73f (diff)
downloadgnunet-gtk-827c2128a33fc28c5f291b709eae515eae3f20c0.tar.gz
gnunet-gtk-827c2128a33fc28c5f291b709eae515eae3f20c0.zip
replace gtk_menu_popup by non-deprecated versions
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/gnunet-fs-gtk_event-handler.c102
-rw-r--r--src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c60
2 files changed, 87 insertions, 75 deletions
diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c
index 8660ba90..5015e6ca 100644
--- a/src/fs/gnunet-fs-gtk_event-handler.c
+++ b/src/fs/gnunet-fs-gtk_event-handler.c
@@ -1301,18 +1301,14 @@ populate_popup_with_uri_items (void *cls,
1301 * 1301 *
1302 * @param tm tree model underlying the tree view where the event happened 1302 * @param tm tree model underlying the tree view where the event happened
1303 * @param tab tab where the event happened, NULL for download tab 1303 * @param tab tab where the event happened, NULL for download tab
1304 * @param init_button which button triggered the popup, or 0 for none
1305 * @param event_time at what time was the popup triggered
1306 * @param iter location in the tree model selected at the time 1304 * @param iter location in the tree model selected at the time
1307 * @return FALSE if no menu could be popped up, 1305 * @return NULL if no menu could be created,
1308 * TRUE if there is now a pop-up menu 1306 * otherwise the a pop-up menu
1309 */ 1307 */
1310static gboolean 1308static GtkMenu *
1311search_list_popup (GtkTreeModel *tm, 1309search_list_get_popup (GtkTreeModel *tm,
1312 struct SearchTab *tab, 1310 struct SearchTab *tab,
1313 gint init_button, 1311 GtkTreeIter *iter)
1314 guint32 event_time,
1315 GtkTreeIter *iter)
1316{ 1312{
1317 GtkMenu *menu; 1313 GtkMenu *menu;
1318 GtkWidget *child; 1314 GtkWidget *child;
@@ -1333,7 +1329,7 @@ search_list_popup (GtkTreeModel *tm,
1333 if (NULL == sr) 1329 if (NULL == sr)
1334 { 1330 {
1335 GNUNET_break (0); 1331 GNUNET_break (0);
1336 return FALSE; 1332 return NULL;
1337 } 1333 }
1338 if (NULL != sr->meta) 1334 if (NULL != sr->meta)
1339 is_directory = GNUNET_FS_meta_data_test_for_directory (sr->meta); 1335 is_directory = GNUNET_FS_meta_data_test_for_directory (sr->meta);
@@ -1420,8 +1416,7 @@ search_list_popup (GtkTreeModel *tm,
1420 } 1416 }
1421 g_signal_connect (menu, "selection-done", 1417 g_signal_connect (menu, "selection-done",
1422 G_CALLBACK (search_list_popup_selection_done), spc); 1418 G_CALLBACK (search_list_popup_selection_done), spc);
1423 gtk_menu_popup (menu, NULL, NULL, NULL, NULL, init_button, event_time); 1419 return menu;
1424 return TRUE;
1425} 1420}
1426 1421
1427 1422
@@ -1442,11 +1437,20 @@ GNUNET_FS_GTK_search_treeview_popup_menu (GtkWidget *widget,
1442 GtkTreeSelection *sel; 1437 GtkTreeSelection *sel;
1443 GtkTreeIter iter; 1438 GtkTreeIter iter;
1444 GtkTreeModel *tm; 1439 GtkTreeModel *tm;
1440 GtkMenu *menu;
1445 1441
1446 sel = gtk_tree_view_get_selection (tv); 1442 sel = gtk_tree_view_get_selection (tv);
1447 if (! gtk_tree_selection_get_selected (sel, &tm, &iter)) 1443 if (! gtk_tree_selection_get_selected (sel, &tm, &iter))
1448 return FALSE; /* nothing selected */ 1444 return FALSE; /* nothing selected */
1449 return search_list_popup (tm, tab, 0, gtk_get_current_event_time (), &iter); 1445 menu = search_list_get_popup (tm, tab, &iter);
1446 if (NULL == menu)
1447 return FALSE;
1448 gtk_menu_popup_at_widget (menu,
1449 widget,
1450 GDK_GRAVITY_CENTER,
1451 GDK_GRAVITY_CENTER,
1452 NULL);
1453 return TRUE;
1450} 1454}
1451 1455
1452 1456
@@ -1471,6 +1475,7 @@ GNUNET_FS_GTK_search_treeview_button_press_event (GtkWidget * widget,
1471 GtkTreeModel *tm; 1475 GtkTreeModel *tm;
1472 GtkTreePath *path; 1476 GtkTreePath *path;
1473 GtkTreeIter iter; 1477 GtkTreeIter iter;
1478 GtkMenu *menu;
1474 1479
1475 if ( (GDK_BUTTON_PRESS != event->type) || 1480 if ( (GDK_BUTTON_PRESS != event->type) ||
1476 (3 != event_button->button) ) 1481 (3 != event_button->button) )
@@ -1483,10 +1488,13 @@ GNUNET_FS_GTK_search_treeview_button_press_event (GtkWidget * widget,
1483 if (! gtk_tree_model_get_iter (tm, &iter, path)) 1488 if (! gtk_tree_model_get_iter (tm, &iter, path))
1484 return FALSE; /* not sure how we got a path but no iter... */ 1489 return FALSE; /* not sure how we got a path but no iter... */
1485 gtk_tree_path_free (path); 1490 gtk_tree_path_free (path);
1486 search_list_popup (tm, tab, 1491 menu = search_list_get_popup (tm,
1487 event_button->button, 1492 tab,
1488 event_button->time, 1493 &iter);
1489 &iter); 1494 if (NULL == menu)
1495 return FALSE;
1496 gtk_menu_popup_at_pointer (menu,
1497 event);
1490 return FALSE; 1498 return FALSE;
1491} 1499}
1492 1500
@@ -1511,6 +1519,7 @@ GNUNET_GTK_download_frame_button_press_event_cb (GtkWidget * widget,
1511 GtkTreeModel *tm; 1519 GtkTreeModel *tm;
1512 GtkTreePath *path; 1520 GtkTreePath *path;
1513 GtkTreeIter iter; 1521 GtkTreeIter iter;
1522 GtkMenu *menu;
1514 1523
1515 if ( (GDK_BUTTON_PRESS != event->type) || 1524 if ( (GDK_BUTTON_PRESS != event->type) ||
1516 (3 != event_button->button) ) 1525 (3 != event_button->button) )
@@ -1523,10 +1532,13 @@ GNUNET_GTK_download_frame_button_press_event_cb (GtkWidget * widget,
1523 if (! gtk_tree_model_get_iter (tm, &iter, path)) 1532 if (! gtk_tree_model_get_iter (tm, &iter, path))
1524 return FALSE; /* not sure how we got a path but no iter... */ 1533 return FALSE; /* not sure how we got a path but no iter... */
1525 gtk_tree_path_free (path); 1534 gtk_tree_path_free (path);
1526 search_list_popup (tm, NULL, 1535 menu = search_list_get_popup (tm,
1527 event_button->button, 1536 NULL,
1528 event_button->time, 1537 &iter);
1529 &iter); 1538 if (NULL == menu)
1539 return FALSE;
1540 gtk_menu_popup_at_pointer (menu,
1541 event);
1530 return FALSE; 1542 return FALSE;
1531} 1543}
1532 1544
@@ -3722,23 +3734,19 @@ copy_publish_uri_to_clipboard_ctx_menu (GtkMenuItem *item, gpointer user_data)
3722 3734
3723/** 3735/**
3724 * Context menu was requested for a publish result list. 3736 * Context menu was requested for a publish result list.
3725 * Compute which menu items are applicable and display 3737 * Compute which menu items are applicable and generate
3726 * an appropriate menu. 3738 * an appropriate menu.
3727 * 3739 *
3728 * @param tm tree model underlying the tree view where the event happened 3740 * @param tm tree model underlying the tree view where the event happened
3729 * @param tab tab where the event happened 3741 * @param tab tab where the event happened
3730 * @param init_button number of the button that triggered the popup
3731 * @param event_time GTK time when the event was generated
3732 * @param iter selected element in @a tm for the popup 3742 * @param iter selected element in @a tm for the popup
3733 * @return FALSE if no menu could be popped up, 3743 * @return NULL if no menu could be created,
3734 * TRUE if there is now a pop-up menu 3744 * otherwise the pop-up menu
3735 */ 3745 */
3736static gboolean 3746static GtkMenu *
3737publish_list_popup (GtkTreeModel *tm, 3747publish_list_get_popup (GtkTreeModel *tm,
3738 struct PublishTab *tab, 3748 struct PublishTab *tab,
3739 gint init_button, 3749 GtkTreeIter *iter)
3740 guint32 event_time,
3741 GtkTreeIter *iter)
3742{ 3750{
3743 GtkMenu *menu; 3751 GtkMenu *menu;
3744 GtkWidget *child; 3752 GtkWidget *child;
@@ -3754,7 +3762,7 @@ publish_list_popup (GtkTreeModel *tm,
3754 (GNUNET_NO == pe->is_top) ) ) 3762 (GNUNET_NO == pe->is_top) ) )
3755 { 3763 {
3756 /* no actions available, refuse to pop up */ 3764 /* no actions available, refuse to pop up */
3757 return FALSE; 3765 return NULL;
3758 } 3766 }
3759 3767
3760 ppc = GNUNET_new (struct PublishListPopupContext); 3768 ppc = GNUNET_new (struct PublishListPopupContext);
@@ -3787,8 +3795,7 @@ publish_list_popup (GtkTreeModel *tm,
3787 } 3795 }
3788 g_signal_connect (menu, "selection-done", 3796 g_signal_connect (menu, "selection-done",
3789 G_CALLBACK (publish_list_popup_selection_done), ppc); 3797 G_CALLBACK (publish_list_popup_selection_done), ppc);
3790 gtk_menu_popup (menu, NULL, NULL, NULL, NULL, init_button, event_time); 3798 return menu;
3791 return TRUE;
3792} 3799}
3793 3800
3794 3801
@@ -3809,11 +3816,20 @@ GNUNET_FS_GTK_publish_treeview_popup_menu (GtkWidget *widget,
3809 GtkTreeSelection *sel; 3816 GtkTreeSelection *sel;
3810 GtkTreeIter iter; 3817 GtkTreeIter iter;
3811 GtkTreeModel *tm; 3818 GtkTreeModel *tm;
3819 GtkMenu *menu;
3812 3820
3813 sel = gtk_tree_view_get_selection (tv); 3821 sel = gtk_tree_view_get_selection (tv);
3814 if (! gtk_tree_selection_get_selected (sel, &tm, &iter)) 3822 if (! gtk_tree_selection_get_selected (sel, &tm, &iter))
3815 return FALSE; /* nothing selected */ 3823 return FALSE; /* nothing selected */
3816 return publish_list_popup (tm, tab, 0, gtk_get_current_event_time (), &iter); 3824 menu = publish_list_get_popup (tm, tab, &iter);
3825 if (NULL == menu)
3826 return FALSE;
3827 gtk_menu_popup_at_widget (menu,
3828 widget,
3829 GDK_GRAVITY_CENTER,
3830 GDK_GRAVITY_CENTER,
3831 NULL);
3832 return TRUE;
3817} 3833}
3818 3834
3819 3835
@@ -3838,6 +3854,7 @@ GNUNET_FS_GTK_publish_treeview_button_press_event (GtkWidget * widget,
3838 GtkTreeModel *tm; 3854 GtkTreeModel *tm;
3839 GtkTreePath *path; 3855 GtkTreePath *path;
3840 GtkTreeIter iter; 3856 GtkTreeIter iter;
3857 GtkMenu *menu;
3841 3858
3842 if ( (GDK_BUTTON_PRESS != event->type) || 3859 if ( (GDK_BUTTON_PRESS != event->type) ||
3843 (3 != event_button->button) ) 3860 (3 != event_button->button) )
@@ -3850,10 +3867,13 @@ GNUNET_FS_GTK_publish_treeview_button_press_event (GtkWidget * widget,
3850 if (! gtk_tree_model_get_iter (tm, &iter, path)) 3867 if (! gtk_tree_model_get_iter (tm, &iter, path))
3851 return FALSE; /* not sure how we got a path but no iter... */ 3868 return FALSE; /* not sure how we got a path but no iter... */
3852 gtk_tree_path_free (path); 3869 gtk_tree_path_free (path);
3853 publish_list_popup (tm, tab, 3870 menu = publish_list_get_popup (tm,
3854 event_button->button, 3871 tab,
3855 event_button->time, 3872 &iter);
3856 &iter); 3873 if (NULL == menu)
3874 return FALSE;
3875 gtk_menu_popup_at_pointer (menu,
3876 event);
3857 return FALSE; /* propagate further, to focus on the item (for example) */ 3877 return FALSE; /* propagate further, to focus on the item (for example) */
3858} 3878}
3859 3879
diff --git a/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c b/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
index fb794700..88a72335 100644
--- a/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
+++ b/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
@@ -127,27 +127,6 @@ GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem,
127 127
128 128
129/** 129/**
130 * Got asked to pop up the context menu in the metadata treeview in
131 * the main window. Do it.
132 *
133 * @param button which button caused the event (0 for none)
134 * @param event_time time of the event (current time or 'event->time')
135 * @param user_data the context of the main window
136 */
137static void
138do_metadata_popup_menu (int button,
139 int event_time,
140 gpointer user_data)
141{
142 GtkMenu *menu;
143 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
144
145 menu = GTK_MENU (gtk_builder_get_object (main_ctx->builder, "metadata_popup_menu"));
146 gtk_menu_popup (menu, NULL, NULL, NULL, main_ctx, button, event_time);
147}
148
149
150/**
151 * Got a button press event on the metadata treeview in the main window. 130 * Got a button press event on the metadata treeview in the main window.
152 * If it was a right click, pop up the context menu. 131 * If it was a right click, pop up the context menu.
153 * 132 *
@@ -156,19 +135,24 @@ do_metadata_popup_menu (int button,
156 * @param user_data the gtk builder of the main window 135 * @param user_data the gtk builder of the main window
157 */ 136 */
158gboolean 137gboolean
159GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb (GtkWidget * 138GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb (GtkWidget * widget,
160 widget, 139 GdkEvent * event,
161 GdkEventButton * 140 gpointer user_data)
162 event,
163 gpointer
164 user_data)
165{ 141{
142 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
143 GdkEventButton *event_button = (GdkEventButton *) event;
144 GtkMenu *menu;
145
166 /* Ignore double-clicks and triple-clicks */ 146 /* Ignore double-clicks and triple-clicks */
167 if ( (event->button != 3) || (event->type != GDK_BUTTON_PRESS) ) 147 if ( (event_button->button != 3) ||
148 (event_button->type != GDK_BUTTON_PRESS) )
149 return FALSE;
150 menu = GTK_MENU (gtk_builder_get_object (main_ctx->builder,
151 "metadata_popup_menu"));
152 if (NULL == menu)
168 return FALSE; 153 return FALSE;
169 do_metadata_popup_menu (event->button, 154 gtk_menu_popup_at_pointer (menu,
170 event->time, 155 event);
171 user_data);
172 return FALSE; 156 return FALSE;
173} 157}
174 158
@@ -185,9 +169,17 @@ gboolean
185GNUNET_GTK_main_window_metadata_treeview_popup_menu_cb (GtkWidget * widget, 169GNUNET_GTK_main_window_metadata_treeview_popup_menu_cb (GtkWidget * widget,
186 gpointer user_data) 170 gpointer user_data)
187{ 171{
188 do_metadata_popup_menu (0 /* no button */, 172 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
189 gtk_get_current_event_time (), 173 GtkMenu *menu;
190 user_data); 174
175 menu = GTK_MENU (gtk_builder_get_object (main_ctx->builder, "metadata_popup_menu"));
176 if (NULL == menu)
177 return FALSE;
178 gtk_menu_popup_at_widget (menu,
179 widget,
180 GDK_GRAVITY_CENTER,
181 GDK_GRAVITY_CENTER,
182 NULL);
191 return TRUE; 183 return TRUE;
192} 184}
193 185