[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28489 - in gnunet-gtk: contrib src/fs src/identity
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28489 - in gnunet-gtk: contrib src/fs src/identity |
Date: |
Sat, 10 Aug 2013 23:06:01 +0200 |
Author: grothoff
Date: 2013-08-10 23:06:01 +0200 (Sat, 10 Aug 2013)
New Revision: 28489
Modified:
gnunet-gtk/contrib/gnunet_identity_gtk_main_window.glade
gnunet-gtk/src/fs/gnunet-fs-gtk.c
gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
gnunet-gtk/src/identity/gnunet-identity-gtk.c
Log:
-more work on identity event handling
Modified: gnunet-gtk/contrib/gnunet_identity_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_identity_gtk_main_window.glade 2013-08-10
19:55:22 UTC (rev 28488)
+++ gnunet-gtk/contrib/gnunet_identity_gtk_main_window.glade 2013-08-10
21:06:01 UTC (rev 28489)
@@ -14,7 +14,9 @@
</object>
<object class="GtkWindow" id="GNUNET_GTK_identity_window">
<property name="can_focus">False</property>
+ <property name="events">GDK_BUTTON_PRESS_MASK |
GDK_STRUCTURE_MASK</property>
<property name="icon_name">contact-new</property>
+ <signal name="delete-event" handler="GNUNET_GTK_identity_quit_cb"
swapped="no"/>
<child>
<object class="GtkVBox" id="GNUNET_GTK_identityvbox">
<property name="visible">True</property>
@@ -44,7 +46,7 @@
</object>
</child>
</object>
- </child>_
+ </child>
</object>
</child>
<child>
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.c 2013-08-10 19:55:22 UTC (rev 28488)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.c 2013-08-10 21:06:01 UTC (rev 28489)
@@ -342,8 +342,8 @@
GdkEventButton *event_button = (GdkEventButton *) event;
GtkClipboard *cb;
- if ( (event->type != GDK_BUTTON_PRESS) ||
- (event_button->button != 2) )
+ if ( (GDK_BUTTON_PRESS != event->type) ||
+ (2 != event_button->button) )
return FALSE;
cb = gtk_clipboard_get (gdk_atom_intern ("PRIMARY", FALSE));
gtk_clipboard_request_text (cb, &process_paste, NULL);
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2013-08-10 19:55:22 UTC
(rev 28488)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2013-08-10 21:06:01 UTC
(rev 28489)
@@ -657,6 +657,7 @@
GNUNET_free (spc);
}
+
/**
* Selected row has changed in search result tree view, update preview
* and metadata areas.
@@ -1273,8 +1274,8 @@
GtkTreePath *path;
GtkTreeIter iter;
- if ( (event->type != GDK_BUTTON_PRESS) ||
- (event_button->button != 3) )
+ 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,
@@ -1285,9 +1286,9 @@
return FALSE; /* not sure how we got a path but no iter... */
gtk_tree_path_free (path);
search_list_popup (tm, tab,
- event_button->button,
- event_button->time,
- &iter);
+ event_button->button,
+ event_button->time,
+ &iter);
return FALSE;
}
Modified: gnunet-gtk/src/identity/gnunet-identity-gtk.c
===================================================================
--- gnunet-gtk/src/identity/gnunet-identity-gtk.c 2013-08-10 19:55:22 UTC
(rev 28488)
+++ gnunet-gtk/src/identity/gnunet-identity-gtk.c 2013-08-10 21:06:01 UTC
(rev 28489)
@@ -96,6 +96,40 @@
/**
+ * Head of operations.
+ */
+static struct OperationContext *oc_head;
+
+/**
+ * Tail of operations.
+ */
+static struct OperationContext *oc_tail;
+
+
+/**
+ * Get cfg.
+ */
+static const struct GNUNET_CONFIGURATION_Handle *
+get_configuration ()
+{
+ return GNUNET_GTK_main_loop_get_configuration (ml);
+}
+
+
+/**
+ * Get an object from the main window.
+ *
+ * @param name name of the object
+ * @return NULL on error
+ */
+static GObject *
+get_object (const char *name)
+{
+ return GNUNET_GTK_main_loop_get_object (ml, name);
+}
+
+
+/**
* Identity operation was finished, clean up.
*
* @param cls the 'struct OperationContext'
@@ -107,11 +141,173 @@
{
struct OperationContext *oc = cls;
+ GNUNET_CONTAINER_DLL_remove (oc_head,
+ oc_tail,
+ oc);
+ gtk_widget_set_sensitive (GTK_WIDGET (get_object
("GNUNET_GTK_identity_treeview")),
+ TRUE);
GNUNET_free (oc);
}
/**
+ * Context for the advertise popup menu.
+ */
+struct AdvertisePopupContext
+{
+ /**
+ * Ego to advertise.
+ */
+ struct GNUNET_IDENTITY_Ego *ego;
+
+ /**
+ * Row where the search list popup was created.
+ */
+ GtkTreeRowReference *rr;
+
+};
+
+
+/**
+ * "Advertise" was selected in the current context menu.
+ *
+ * @param item the 'advertise' menu item
+ * @param user_data the 'struct AdvertisePopupContext' of the menu
+ */
+static void
+advertise_ctx_menu (GtkMenuItem *item,
+ gpointer user_data)
+{
+ struct AdvertisePopupContext *apc = user_data;
+
+ fprintf (stderr, "ADVERTISE TIME!\n");
+}
+
+
+/**
+ * An item was selected from the context menu; destroy the menu shell.
+ *
+ * @param menushell menu to destroy
+ * @param user_data the 'struct AdvertisePopupContext' of the menu
+ */
+static void
+advertise_popup_selection_done (GtkMenuShell *menushell,
+ gpointer user_data)
+{
+ struct AdvertisePopupContext *apc = user_data;
+
+ gtk_widget_destroy (GTK_WIDGET (menushell));
+ gtk_tree_row_reference_free (apc->rr);
+ GNUNET_free (apc);
+}
+
+
+/**
+ * User clicked in the treeview widget. Check for right button
+ * to possibly launch advertise window.
+ *
+ * @param widget the treeview widget
+ * @param event the event, we only care about button events
+ * @param user_data unused
+ * @return FALSE if no menu could be popped up,
+ * TRUE if there is now a pop-up menu
+ */
+gboolean
+GNUNET_GTK_identity_treeview_button_press_event_cb (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;
+ GtkWidget *child;
+ struct AdvertisePopupContext *apc;
+ struct GNUNET_IDENTITY_Ego *ego;
+
+ if ( (GDK_BUTTON_PRESS != event->type) ||
+ (3 != event_button->button) )
+ return FALSE;
+ 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))
+ {
+ gtk_tree_path_free (path);
+ return FALSE; /* not sure how we got a path but no iter... */
+ }
+ gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter,
+ IDENTITY_MC_EGO, &ego,
+ -1);
+ if (NULL == ego)
+ return FALSE;
+ apc = GNUNET_new (struct AdvertisePopupContext);
+ apc->ego = ego;
+ apc->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ls), path);
+ gtk_tree_path_free (path);
+ menu = GTK_MENU (gtk_menu_new ());
+ child = gtk_menu_item_new_with_label (_("_Advertise"));
+ g_signal_connect (child, "activate",
+ G_CALLBACK (advertise_ctx_menu), apc);
+ 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 (advertise_popup_selection_done), apc);
+ gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
+ event_button->button,
+ event_button->time);
+ return FALSE;
+}
+
+
+/**
+ * User pushed a key (possibly DEL) in the treeview widget.
+ * Delete the selected entry if the key was DEL.
+ *
+ * @param widget the entry widget
+ * @param event the key stroke
+ * @param user_data the main window context
+ * @return FALSE if this was not ENTER, TRUE if it was
+ */
+gboolean
+GNUNET_GTK_identity_treeview_key_press_event_cb (GtkWidget * widget,
+ GdkEventKey * event,
+ gpointer user_data)
+{
+ gchar *old;
+ struct OperationContext *oc;
+ GtkTreeSelection *sel;
+ GtkTreeIter iter;
+
+ if (GDK_KEY_Delete != event->keyval)
+ return FALSE;
+ sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (get_object
("GNUNET_GTK_identity_treeview")));
+ if (! gtk_tree_selection_get_selected (sel, NULL, &iter))
+ return FALSE;
+ gtk_tree_model_get (GTK_TREE_MODEL (ls),
+ &iter,
+ IDENTITY_MC_NAME, &old,
+ -1);
+ oc = GNUNET_new (struct OperationContext);
+ GNUNET_CONTAINER_DLL_insert (oc_head,
+ oc_tail,
+ oc);
+ oc->op = GNUNET_IDENTITY_delete (identity,
+ old,
+ &operation_finished,
+ oc);
+ return TRUE;
+}
+
+
+/**
* The user edited one of the names of the egos. Change it
* in the IDENTITY service.
*
@@ -148,7 +344,12 @@
IDENTITY_MC_NAME, &old,
IDENTITY_MC_EGO, &ego,
-1);
+ gtk_widget_set_sensitive (GTK_WIDGET (get_object
("GNUNET_GTK_identity_treeview")),
+ FALSE);
oc = GNUNET_new (struct OperationContext);
+ GNUNET_CONTAINER_DLL_insert (oc_head,
+ oc_tail,
+ oc);
if (NULL == ego)
{
/* create operation */
@@ -177,29 +378,6 @@
/**
- * Get cfg.
- */
-static const struct GNUNET_CONFIGURATION_Handle *
-get_configuration ()
-{
- return GNUNET_GTK_main_loop_get_configuration (ml);
-}
-
-
-/**
- * Get an object from the main window.
- *
- * @param name name of the object
- * @return NULL on error
- */
-static GObject *
-get_object (const char *name)
-{
- return GNUNET_GTK_main_loop_get_object (ml, name);
-}
-
-
-/**
* Task run on shutdown.
*
* @param cls unused
@@ -208,6 +386,18 @@
static void
shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ struct OperationContext *oc;
+
+ while (NULL != (oc = oc_head))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Operation not completed due to shutdown\n"));
+ GNUNET_IDENTITY_cancel (oc->op);
+ GNUNET_CONTAINER_DLL_remove (oc_head,
+ oc_tail,
+ oc);
+ GNUNET_free (oc);
+ }
if (NULL != identity)
{
GNUNET_IDENTITY_disconnect (identity);
@@ -294,7 +484,7 @@
GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ls),
&iter, path));
gtk_list_store_set (ls,
- &iter, G_MAXINT,
+ &iter,
IDENTITY_MC_NAME, name,
-1);
gtk_tree_path_free (path);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28489 - in gnunet-gtk: contrib src/fs src/identity,
gnunet <=