[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis-gtk] branch master updated: skeleton for popup menu
From: |
gnunet |
Subject: |
[taler-anastasis-gtk] branch master updated: skeleton for popup menu |
Date: |
Tue, 29 Jun 2021 08:05:16 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis-gtk.
The following commit(s) were added to refs/heads/master by this push:
new 5af3179 skeleton for popup menu
5af3179 is described below
commit 5af31791b94bbd8752a01b588eba24a5c80d740d
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Jun 29 08:05:13 2021 +0200
skeleton for popup menu
---
src/anastasis/anastasis-gtk_handle-policy-meta.c | 170 +++++++++++++++++++++++
1 file changed, 170 insertions(+)
diff --git a/src/anastasis/anastasis-gtk_handle-policy-meta.c
b/src/anastasis/anastasis-gtk_handle-policy-meta.c
new file mode 100644
index 0000000..3b41ea4
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_handle-policy-meta.c
@@ -0,0 +1,170 @@
+/*
+ This file is part of anastasis-gtk.
+ Copyright (C) 2021 Anastasis SARL
+
+ Anastasis is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Anastasis; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+/**
+ * @file src/anastasis/anastasis-gtk_handle-policy-meta.c
+ * @brief Handle right-click context menu in policy review
+ * @author Christian Grothoff
+ */
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_util_lib.h>
+#include "anastasis-gtk_action.h"
+#include "anastasis-gtk_helper.h"
+#include <jansson.h>
+
+
+/**
+ * An item was selected from the context menu; destroy the menu shell.
+ *
+ * @param menushell menu to destroy
+ * @param user_data the 'XXX' of the menu
+ */
+static void
+context_popup_selection_done (GtkMenuShell *menushell,
+ gpointer user_data)
+{
+ void *ctx = user_data;
+
+ gtk_widget_destroy (GTK_WIDGET (menushell));
+ gtk_tree_row_reference_free (ctx->rr);
+ GNUNET_free (ctx);
+}
+
+
+/**
+ * Context menu was requested for the policy. Compute which menu
+ * items are applicable and display an appropriate menu.
+ *
+ * @param tm tree model underlying the tree view where the event happened
+ * @param iter location in the tree model selected at the time
+ * @return NULL if no menu could be created,
+ * otherwise the a pop-up menu
+ */
+static GtkMenu *
+get_popup (GtkTreeModel *tm,
+ GtkTreeIter *iter)
+{
+ GtkMenu *menu;
+ GtkWidget *child;
+ GtkTreePath *path;
+ void *ctx = NULL;
+
+ path = gtk_tree_model_get_path (tm,
+ iter);
+ ctx->rr = gtk_tree_row_reference_new (tm,
+ path);
+ gtk_tree_path_free (path);
+ gtk_tree_model_get (tm,
+ iter,
+ FIXME,
+ &FIXME,
+ -1);
+ menu = GTK_MENU (gtk_menu_new ());
+ {
+ /* only display download menus if there is a URI */
+ child = gtk_menu_item_new_with_label (_ ("_Delete"));
+ g_signal_connect (child,
+ "activate",
+ G_CALLBACK (delete_ctx_menu),
+ ctx);
+ gtk_label_set_use_underline (GTK_LABEL (
+ gtk_bin_get_child (GTK_BIN
(child))),
+ TRUE);
+ gtk_widget_show (child);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), child);
+ }
+
+ {
+ /* Insert a separator */
+ child = gtk_separator_menu_item_new ();
+ gtk_widget_show (child);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), child);
+ }
+
+ /* check for embedded URIs */
+ {
+ child = gtk_menu_item_new_with_label (_ ("_Edit policy"));
+ g_signal_connect (child,
+ "activate",
+ G_CALLBACK (edit_ctx_menu),
+ ctx);
+ gtk_label_set_use_underline (GTK_LABEL (
+ gtk_bin_get_child (GTK_BIN (child))),
+ TRUE);
+ gtk_widget_show (child);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu),
+ child);
+ }
+ g_signal_connect (menu,
+ "selection-done",
+ G_CALLBACK (context_popup_selection_done),
+ spc);
+ return menu;
+}
+
+
+/**
+ * We got a button-click on the policy treeview. If it was a
+ * right-click, display the context menu.
+ *
+ * @param widget the GtkTreeView with the search result list
+ * @param event the event, we only care about button events
+ * @param user_data NULL
+ * @return FALSE to propagate the event further,
+ * TRUE to stop the propagation
+ */
+gboolean
+anastasis_gtk_policy_treeview_button_press_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ GtkTreeView *tv = GTK_TREE_VIEW (widget);
+ GdkEventButton *event_button = (GdkEventButton *) event;
+ GtkTreeModel *tm;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ GtkMenu *menu;
+
+ if ((GDK_BUTTON_PRESS != event->type) ||
+ (3 != event_button->button))
+ return FALSE; /* not a right-click */
+ if (! gtk_tree_view_get_path_at_pos (tv,
+ event_button->x,
+ event_button->y,
+ &path,
+ NULL,
+ NULL,
+ NULL))
+ return FALSE; /* click outside of area with values, ignore */
+ tm = gtk_tree_view_get_model (tv);
+ if (! gtk_tree_model_get_iter (tm,
+ &iter,
+ path))
+ return FALSE; /* not sure how we got a path but no iter... */
+ gtk_tree_path_free (path);
+
+ menu = get_popup (tm,
+ &iter);
+ if (NULL == menu)
+ return FALSE;
+ gtk_menu_popup_at_pointer (menu,
+ event);
+ return FALSE;
+}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis-gtk] branch master updated: skeleton for popup menu,
gnunet <=