[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33513 - gnunet-gtk/src/conversation
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33513 - gnunet-gtk/src/conversation |
Date: |
Wed, 4 Jun 2014 15:10:59 +0200 |
Author: grothoff
Date: 2014-06-04 15:10:59 +0200 (Wed, 04 Jun 2014)
New Revision: 33513
Modified:
gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
gnunet-gtk/src/conversation/gnunet-conversation-gtk_use_current.c
Log:
-towards implementing paste button
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
2014-06-04 12:45:58 UTC (rev 33512)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
2014-06-04 13:10:59 UTC (rev 33513)
@@ -28,6 +28,7 @@
*/
#include "gnunet-conversation-gtk.h"
#include "gnunet-conversation-gtk_contacts.h"
+#include "gnunet-conversation-gtk_get_label.h"
#include "gnunet-conversation-gtk_phone.h"
#include "gnunet-conversation-gtk_zones.h"
@@ -276,6 +277,66 @@
/**
+ * User clicked the "paste" button. Handle data from the clipboard,
+ * if it is a "gnunet://gns/"-URI, import it into our current zone /
+ * address book.
+ *
+ * @param clipboard the clipboard
+ * @param text the text from the board
+ * @param user_data NULL
+ */
+static void
+handle_paste_data (GtkClipboard *clipboard,
+ const gchar *text,
+ gpointer data)
+{
+ char *name;
+ char *slash;
+ const char *label;
+
+ if (NULL == text)
+ return; /* clipboard empty */
+ if (0 != strncasecmp ("gnunet://gns/",
+ text,
+ strlen ("gnunet://gns/")))
+ {
+ GCG_log (_("Invalid URI `%s'\n"),
+ text);
+ return;
+ }
+ name = GNUNET_strdup (&text[strlen ("gnunet://gns/")]);
+ slash = strchr (name, '/');
+ if ( (NULL != slash) &&
+ ('\0' != slash[1]) )
+ {
+ *slash = '\0';
+ label = &slash[1];
+ if (GNUNET_OK !=
+ GNUNET_DNSPARSER_check_label (label))
+ {
+ GCG_log (_("Invalid label `%s' in URI `%s'\n"),
+ label,
+ text);
+ GNUNET_free (name);
+ return;
+ }
+ else
+ {
+ /* got a label already, try to use it */
+ GSC_get_label_for_name (name,
+ label);
+ GNUNET_free (name);
+ return;
+ }
+ }
+ /* don't have a label yet, need to prompt! */
+ GSC_get_label_for_name (name,
+ NULL);
+ GNUNET_free (name);
+}
+
+
+/**
* User clicked the "paste" button. Copy address information
* from the clipboard into our current zone / address book.
*
@@ -286,7 +347,13 @@
gnunet_conversation_gtk_contacts_paste_button_clicked_cb (GtkButton *button,
gpointer user_data)
{
- GNUNET_break (0); // FIXME: not implemented
+ GtkClipboard *cb;
+
+
+ cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+ gtk_clipboard_request_text (cb,
+ &handle_paste_data,
+ NULL);
}
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_use_current.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_use_current.c
2014-06-04 12:45:58 UTC (rev 33512)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_use_current.c
2014-06-04 13:10:59 UTC (rev 33513)
@@ -26,6 +26,7 @@
#include "gnunet-conversation-gtk.h"
#include "gnunet-conversation-gtk_egos.h"
#include "gnunet-conversation-gtk_history.h"
+#include "gnunet-conversation-gtk_get_label.h"
#include "gnunet-conversation-gtk_import.h"
#include "gnunet-conversation-gtk_log.h"
#include "gnunet-conversation-gtk_phone.h"
@@ -37,7 +38,12 @@
*/
static struct GNUNET_NAMESTORE_QueueEntry *qe;
+/**
+ * What is the value we want to publish in the namestore?
+ */
+static char *target;
+
/**
* Process a record that was stored in the namestore.
*
@@ -133,19 +139,16 @@
{
GtkBuilder *builder = GTK_BUILDER (user_data);
GtkWidget *dialog;
- const gchar *target;
const gchar *label;
- GtkEntry *address_entry;
GtkEntry *label_entry;
- address_entry = GTK_ENTRY (GCG_get_main_window_object
- ("gnunet_conversation_gtk_address_entry"));
- target = gtk_entry_get_text (address_entry);
label_entry = GTK_ENTRY (gtk_builder_get_object
(builder,
("gnunet_conversation_gtk_enter_label_entry")));
label = gtk_entry_get_text (label_entry);
GSC_add_contact (label, target);
+ GNUNET_free (target);
+ target = NULL;
dialog = GTK_WIDGET (gtk_builder_get_object
(builder,
"gnunet_conversation_gtk_enter_label_window"));
@@ -171,6 +174,8 @@
dialog = GTK_WIDGET (gtk_builder_get_object
(builder,
"gnunet_conversation_gtk_enter_label_window"));
+ GNUNET_free (target);
+ target = NULL;
gtk_widget_destroy (GTK_WIDGET (dialog));
g_object_unref (G_OBJECT (builder));
}
@@ -192,24 +197,29 @@
GtkBuilder *builder = GTK_BUILDER (user_data);
g_object_unref (G_OBJECT (builder));
+ GNUNET_free_non_null (target);
+ target = NULL;
return FALSE;
}
/**
- * User clicked the '> contact' button to move the selected
- * caller's information into our address book.
+ * Obtain the label the user wants to use for a given
+ * name and (if successful) add the name to the
+ * address book usnig #GSC_add_contact().
*
- * @param button the button
- * @param user_data main loop context (unused)
+ * @param name value to publish (corresponds to CNAME or PKEY record)
+ * @param label suggested label (user can change)
*/
void
-gnunet_conversation_gtk_add_contact_button_clicked_cb (GtkButton *button,
- gpointer *user_data)
+GSC_get_label_for_name (const char *name,
+ const char *label)
{
GtkBuilder *builder;
GtkWidget *dialog;
GtkWidget *toplevel;
+ GtkEntry *label_entry;
+ GtkWidget *address_entry;
builder =
GNUNET_GTK_get_new_builder ("gnunet_conversation_gtk_enter_label.glade",
@@ -219,15 +229,47 @@
GNUNET_break (0);
return;
}
+ target = GNUNET_strdup (name);
+ label_entry = GTK_ENTRY (gtk_builder_get_object
+ (builder,
+ ("gnunet_conversation_gtk_enter_label_entry")));
+ gtk_entry_set_text (label_entry,
+ label);
dialog = GTK_WIDGET (gtk_builder_get_object
(builder,
"gnunet_conversation_gtk_enter_label_window"));
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
+
+ /* just pick ANY widget from the main window here... */
+ address_entry = GTK_WIDGET (GCG_get_main_window_object
+ ("gnunet_conversation_gtk_address_entry"));
+ toplevel = gtk_widget_get_toplevel (address_entry);
if (GTK_IS_WINDOW (toplevel))
gtk_window_set_transient_for (GTK_WINDOW (dialog),
GTK_WINDOW (toplevel));
+
gtk_widget_show (dialog);
}
+/**
+ * User clicked the '> contact' button to move the selected
+ * caller's information into our address book.
+ *
+ * @param button the button
+ * @param user_data main loop context (unused)
+ */
+void
+gnunet_conversation_gtk_add_contact_button_clicked_cb (GtkButton *button,
+ gpointer *user_data)
+{
+ GtkEntry *address_entry;
+
+ address_entry = GTK_ENTRY (GCG_get_main_window_object
+ ("gnunet_conversation_gtk_address_entry"));
+ GSC_get_label_for_name (gtk_entry_get_text (address_entry),
+ "");
+}
+
+
+
/* end of gnunet-conversation-gtk_use_current.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33513 - gnunet-gtk/src/conversation,
gnunet <=