[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19648 - gnunet-gtk/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19648 - gnunet-gtk/src/fs |
Date: |
Thu, 2 Feb 2012 19:29:19 +0100 |
Author: grothoff
Date: 2012-02-02 19:29:18 +0100 (Thu, 02 Feb 2012)
New Revision: 19648
Added:
gnunet-gtk/src/fs/gnunet-fs-gtk_open-uri.c
Removed:
gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_download.c
Modified:
gnunet-gtk/src/fs/Makefile.am
Log:
-renaming and using our own builder in the open-URI dialog
Modified: gnunet-gtk/src/fs/Makefile.am
===================================================================
--- gnunet-gtk/src/fs/Makefile.am 2012-02-02 18:20:57 UTC (rev 19647)
+++ gnunet-gtk/src/fs/Makefile.am 2012-02-02 18:29:18 UTC (rev 19648)
@@ -12,9 +12,9 @@
gnunet_fs_gtk_SOURCES = \
gnunet-fs-gtk.c gnunet-fs-gtk.h \
gnunet-fs-gtk_about.c \
+ gnunet-fs-gtk_advertise-pseudonym.c \
gnunet-fs-gtk_anonymity-widgets.c gnunet-fs-gtk_anonymity-widgets.h \
gnunet-fs-gtk_common.c gnunet-fs-gtk_common.h \
- gnunet-fs-gtk_advertise-pseudonym.c \
gnunet-fs-gtk_create-pseudonym.c \
gnunet-fs-gtk_download-save-as.c gnunet-fs-gtk_download-save-as.h \
gnunet-fs-gtk_event-handler.c gnunet-fs-gtk_event-handler.h \
@@ -22,9 +22,9 @@
gnunet-fs-gtk_main-window-search.c \
gnunet-fs-gtk_main-window-view-toggles.c \
gnunet-fs-gtk_open-directory.c \
+ gnunet-fs-gtk_open-uri.c \
gnunet-fs-gtk_publish-dialog.c \
gnunet-fs-gtk_publish-edit-dialog.c gnunet-fs-gtk_publish-edit-dialog.h \
- gnunet-fs-gtk-main_window_file_download.c \
gnunet-fs-gtk-main_window_namespace.c
gnunet_fs_gtk_LDADD = \
$(top_builddir)/src/lib/libgnunetgtk.la \
Deleted: gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_download.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_download.c 2012-02-02
18:20:57 UTC (rev 19647)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_download.c 2012-02-02
18:29:18 UTC (rev 19648)
@@ -1,250 +0,0 @@
-/*
- This file is part of GNUnet
- (C) 2005, 2006, 2010, 2012 Christian Grothoff (and other contributing
authors)
-
- GNUnet 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 2, or (at your
- option) any later version.
-
- GNUnet 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 GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @file src/fs/gnunet-fs-gtk-main_window_file_download.c
- * @author Christian Grothoff
- * @brief code for the 'Open URI' dialog.
- *
- * TODO:
- * - automatically populate dialog from clipboard?
- * - use our own builder instead of the main builder?
- */
-#include "gnunet-fs-gtk_common.h"
-#include "gnunet-fs-gtk_download-save-as.h"
-#include "gnunet-fs-gtk.h"
-#include <gdk/gdkkeysyms.h>
-
-/**
- * User selected "Open URI" in main window.
- *
- * @param dummy some widget
- * @param user_data unused
- */
-void
-GNUNET_GTK_main_menu_file_download_uri_activate_cb (GtkWidget * dummy,
- gpointer user_data)
-{
- GtkBuilder *builder = GTK_BUILDER (user_data);
- GtkWidget *dialog;
- GtkTextBuffer *tb;
- GtkTextIter ti_start;
- GtkTextIter ti_end;
-
- dialog = GTK_WIDGET (gtk_builder_get_object
- (builder,
- "GNUNET_GTK_open_url_window"));
- tb = GTK_TEXT_BUFFER (gtk_builder_get_object
- (builder,
- "GNUNET_GTK_open_url_dialog_url_textview_buffer"));
- gtk_text_buffer_get_iter_at_offset (tb, &ti_start, 0);
- gtk_text_buffer_get_iter_at_offset (tb, &ti_end, -1);
- gtk_text_buffer_delete (tb, &ti_start, &ti_end);
-
- /* TODO: query the clipboard, maybe there's valid URI in there?
- * If so, get it. */
- gtk_widget_show (dialog);
-}
-
-
-/**
- * User selected "execute" in the open-URI dialog.
- *
- * @param button the execute button
- * @param user_data the 'GtkBuilder' of the URI dialog
- */
-void
-GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GtkButton * button,
- gpointer user_data)
-{
- GtkBuilder *builder;
- GtkWidget *dialog;
- GtkTextBuffer *tb;
- GtkTextIter ti_start, ti_end;
- guint anonymity_level;
- char *perr;
- char *uris;
- struct GNUNET_FS_Uri *uri;
-
- builder = GTK_BUILDER (user_data);
-
- dialog =
- GTK_WIDGET (gtk_builder_get_object
- (builder, "GNUNET_GTK_open_url_window"));
-
- gtk_widget_hide (dialog);
-
- tb = GTK_TEXT_BUFFER (gtk_builder_get_object
- (builder,
- "GNUNET_GTK_open_url_dialog_url_textview_buffer"));
- gtk_text_buffer_get_iter_at_offset (tb, &ti_start, 0);
- gtk_text_buffer_get_iter_at_offset (tb, &ti_end, -1);
-
- uris = gtk_text_buffer_get_text (tb, &ti_start, &ti_end, FALSE);
-
- if (!GNUNET_GTK_get_selected_anonymity_level
- (builder, "main_window_search_anonymity_combobox", &anonymity_level))
- return;
-
- uri = GNUNET_FS_uri_parse (uris, &perr);
- g_free (uris);
- if (uri == NULL)
- {
- GNUNET_free (perr);
- /* Why was "execute" button sensitive!? */
- GNUNET_break (0);
- return;
- }
- if (GNUNET_FS_uri_test_sks (uri) || GNUNET_FS_uri_test_ksk (uri))
- {
- fprintf (stderr, "Starting search!\n");
- GNUNET_break (NULL !=
- GNUNET_FS_search_start (GNUNET_FS_GTK_get_fs_handle (), uri,
- anonymity_level,
- GNUNET_FS_SEARCH_OPTION_NONE, NULL));
- GNUNET_FS_uri_destroy (uri);
- return;
- }
- if (GNUNET_FS_uri_test_chk (uri) || GNUNET_FS_uri_test_loc (uri))
- {
- struct DownloadContext *dc;
-
- dc = GNUNET_malloc (sizeof (struct DownloadContext));
- dc->uri = uri;
- dc->anonymity = anonymity_level;
- GNUNET_FS_GTK_open_download_as_dialog (dc);
- return;
- }
- GNUNET_break (0);
- GNUNET_FS_uri_destroy (uri);
-}
-
-
-/**
- * User selected "cancel" in the open-URI dialog.
- *
- * @param button the cancel button
- * @param user_data the 'GtkBuilder' of the URI dialog
- */
-void
-GNUNET_GTK_open_url_dialog_cancel_button_clicked_cb (GtkButton * button,
- gpointer user_data)
-{
- GtkBuilder *builder = GTK_BUILDER (user_data);
-
- gtk_widget_hide (GTK_WIDGET
- (gtk_builder_get_object
- (builder, "GNUNET_GTK_open_url_window")));
-}
-
-
-/**
- * User closed the window of the open-URI dialog.
- *
- * @param widget the window
- * @param event the deletion event
- * @param user_data the 'GtkBuilder' of the URI dialog
- */
-gboolean
-GNUNET_GTK_open_url_window_delete_event_cb (GtkWidget * widget,
- GdkEvent * event,
- gpointer user_data)
-{
- GtkBuilder *builder = GTK_BUILDER (user_data);
-
- gtk_widget_hide (GTK_WIDGET
- (gtk_builder_get_object
- (builder, "GNUNET_GTK_open_url_window")));
- return TRUE;
-}
-
-
-
-/**
- * User pushed a key in the open-URI dialog, check if we currently
- * have valid URI and if the key was 'RETURN', run the action.
- *
- * @param widget the window
- * @param event the deletion event
- * @param user_data the 'GtkBuilder' of the URI dialog
- */
-gboolean
-GNUNET_GTK_open_url_dialog_url_textview_key_press_event_cb (GtkWidget * widget,
- GdkEventKey *
event,
- gpointer user_data)
-{
- GtkBuilder *builder = GTK_BUILDER (user_data);
- GtkWidget *execute;
-
- if (event->keyval != GDK_KEY_Return)
- return FALSE;
- execute = GTK_WIDGET (gtk_builder_get_object (builder,
-
"GNUNET_GTK_open_url_dialog_execute_button"));
- if (gtk_widget_get_sensitive (execute))
- GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GTK_BUTTON (execute),
- user_data);
- return TRUE;
-}
-
-
-/**
- * User edited the URI of the open-URI dialog, check if it is currently
- * a valid URI and update the sensitivity of the 'execute' button accordingly.
- *
- * @param textbuffer the updated buffer
- * @param user_data the 'GtkBuilder' of the URI dialog
- */
-void
-GNUNET_GTK_open_url_dialog_url_textview_buffer_changed_cb (GtkTextBuffer *
- textbuffer,
- gpointer user_data)
-{
- GtkBuilder *builder = GTK_BUILDER (user_data);
- struct GNUNET_FS_Uri *uri;
- GtkTextBuffer *tb;
- GtkTextIter ti_start;
- GtkTextIter ti_end;
- char *perr;
- char *uris;
-
- perr = NULL;
- tb = GTK_TEXT_BUFFER (gtk_builder_get_object
- (builder,
- "GNUNET_GTK_open_url_dialog_url_textview_buffer"));
- gtk_text_buffer_get_iter_at_offset (tb, &ti_start, 0);
- gtk_text_buffer_get_iter_at_offset (tb, &ti_end, -1);
- uris = gtk_text_buffer_get_text (tb, &ti_start, &ti_end, FALSE);
- if (uris != NULL)
- uri = GNUNET_FS_uri_parse (uris, &perr);
- else
- uri = NULL;
- g_free (uris);
- gtk_widget_set_sensitive (GTK_WIDGET
- (gtk_builder_get_object
- (builder,
- "GNUNET_GTK_open_url_dialog_execute_button")),
- (uri == NULL) ? FALSE : TRUE);
- if (uri != NULL)
- GNUNET_FS_uri_destroy (uri);
- GNUNET_free_non_null (perr);
-}
-
-
-/* end of gnunet-fs-gtk-main_window_file_download.c */
Copied: gnunet-gtk/src/fs/gnunet-fs-gtk_open-uri.c (from rev 19630,
gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_download.c)
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_open-uri.c (rev 0)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_open-uri.c 2012-02-02 18:29:18 UTC (rev
19648)
@@ -0,0 +1,270 @@
+/*
+ This file is part of GNUnet
+ (C) 2005, 2006, 2010, 2012 Christian Grothoff (and other contributing
authors)
+
+ GNUnet 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 2, or (at your
+ option) any later version.
+
+ GNUnet 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 GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/fs/gnunet-fs-gtk_open-uri.c
+ * @author Christian Grothoff
+ * @brief code for the 'Open URI' dialog.
+ *
+ * TODO:
+ * - automatically populate dialog from clipboard?
+ */
+#include "gnunet-fs-gtk_common.h"
+#include "gnunet-fs-gtk_download-save-as.h"
+#include "gnunet-fs-gtk.h"
+#include <gdk/gdkkeysyms.h>
+
+
+/**
+ * User selected "execute" in the open-URI dialog.
+ *
+ * @param button the execute button
+ * @param user_data the 'GtkBuilder' of the URI dialog
+ */
+void
+GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GtkButton * button,
+ gpointer user_data)
+{
+ GtkBuilder *builder;
+ GtkWidget *dialog;
+ GtkTextBuffer *tb;
+ GtkTextIter ti_start, ti_end;
+ guint anonymity_level;
+ char *perr;
+ char *uris;
+ struct GNUNET_FS_Uri *uri;
+
+ builder = GTK_BUILDER (user_data);
+ dialog =
+ GTK_WIDGET (gtk_builder_get_object
+ (builder, "GNUNET_GTK_open_url_window"));
+ tb = GTK_TEXT_BUFFER (gtk_builder_get_object
+ (builder,
+ "GNUNET_GTK_open_url_dialog_url_textview_buffer"));
+ gtk_text_buffer_get_iter_at_offset (tb, &ti_start, 0);
+ gtk_text_buffer_get_iter_at_offset (tb, &ti_end, -1);
+
+ uris = gtk_text_buffer_get_text (tb, &ti_start, &ti_end, FALSE);
+
+ if (!GNUNET_GTK_get_selected_anonymity_level
+ (builder, "main_window_search_anonymity_combobox", &anonymity_level))
+ {
+ GNUNET_break (0);
+ gtk_widget_destroy (dialog);
+ g_object_unref (G_OBJECT (builder));
+ return;
+ }
+ uri = GNUNET_FS_uri_parse (uris, &perr);
+ g_free (uris);
+ if (uri == NULL)
+ {
+ /* Why was "execute" button sensitive!? */
+ GNUNET_break (0);
+ GNUNET_free (perr);
+ gtk_widget_destroy (dialog);
+ g_object_unref (G_OBJECT (builder));
+ return;
+ }
+ if (GNUNET_FS_uri_test_sks (uri) || GNUNET_FS_uri_test_ksk (uri))
+ {
+ GNUNET_break (NULL !=
+ GNUNET_FS_search_start (GNUNET_FS_GTK_get_fs_handle (), uri,
+ anonymity_level,
+ GNUNET_FS_SEARCH_OPTION_NONE, NULL));
+ GNUNET_FS_uri_destroy (uri);
+ gtk_widget_destroy (dialog);
+ g_object_unref (G_OBJECT (builder));
+ return;
+ }
+ if (GNUNET_FS_uri_test_chk (uri) || GNUNET_FS_uri_test_loc (uri))
+ {
+ struct DownloadContext *dc;
+
+ dc = GNUNET_malloc (sizeof (struct DownloadContext));
+ dc->uri = uri;
+ dc->anonymity = anonymity_level;
+ GNUNET_FS_GTK_open_download_as_dialog (dc);
+ gtk_widget_destroy (dialog);
+ g_object_unref (G_OBJECT (builder));
+ return;
+ }
+ GNUNET_break (0);
+ GNUNET_FS_uri_destroy (uri);
+ gtk_widget_destroy (dialog);
+ g_object_unref (G_OBJECT (builder));
+}
+
+
+/**
+ * User selected "cancel" in the open-URI dialog.
+ *
+ * @param button the cancel button
+ * @param user_data the 'GtkBuilder' of the URI dialog
+ */
+void
+GNUNET_GTK_open_url_dialog_cancel_button_clicked_cb (GtkButton * button,
+ gpointer user_data)
+{
+ GtkBuilder *builder = GTK_BUILDER (user_data);
+ GtkWidget *dialog;
+
+ dialog = GTK_WIDGET (gtk_builder_get_object
+ (builder,
+ "GNUNET_GTK_open_url_window"));
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_object_unref (G_OBJECT (builder));
+}
+
+
+/**
+ * User closed the window of the open-URI dialog.
+ *
+ * @param widget the window
+ * @param event the deletion event
+ * @param user_data the 'GtkBuilder' of the URI dialog
+ * @return TRUE (allow destruction)
+ */
+gboolean
+GNUNET_GTK_open_url_window_delete_event_cb (GtkWidget * widget,
+ GdkEvent * event,
+ gpointer user_data)
+{
+ GtkBuilder *builder = GTK_BUILDER (user_data);
+
+ g_object_unref (G_OBJECT (builder));
+ return TRUE;
+}
+
+
+/**
+ * User pushed a key in the open-URI dialog, check if we currently
+ * have valid URI and if the key was 'RETURN', run the action.
+ *
+ * @param widget the window
+ * @param event the deletion event
+ * @param user_data the 'GtkBuilder' of the URI dialog
+ */
+gboolean
+GNUNET_GTK_open_url_dialog_url_textview_key_press_event_cb (GtkWidget * widget,
+ GdkEventKey *
event,
+ gpointer user_data)
+{
+ GtkBuilder *builder = GTK_BUILDER (user_data);
+ GtkWidget *execute;
+
+ if (event->keyval != GDK_KEY_Return)
+ return FALSE;
+ execute = GTK_WIDGET (gtk_builder_get_object (builder,
+
"GNUNET_GTK_open_url_dialog_execute_button"));
+ if (gtk_widget_get_sensitive (execute))
+ GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GTK_BUTTON (execute),
+ user_data);
+ return TRUE;
+}
+
+
+/**
+ * User edited the URI of the open-URI dialog, check if it is currently
+ * a valid URI and update the sensitivity of the 'execute' button accordingly.
+ *
+ * @param textbuffer the updated buffer
+ * @param user_data the 'GtkBuilder' of the URI dialog
+ */
+void
+GNUNET_GTK_open_url_dialog_url_textview_buffer_changed_cb (GtkTextBuffer *
+ textbuffer,
+ gpointer user_data)
+{
+ GtkBuilder *builder = GTK_BUILDER (user_data);
+ struct GNUNET_FS_Uri *uri;
+ GtkTextBuffer *tb;
+ GtkTextIter ti_start;
+ GtkTextIter ti_end;
+ char *perr;
+ char *uris;
+
+ perr = NULL;
+ tb = GTK_TEXT_BUFFER (gtk_builder_get_object
+ (builder,
+ "GNUNET_GTK_open_url_dialog_url_textview_buffer"));
+ gtk_text_buffer_get_iter_at_offset (tb, &ti_start, 0);
+ gtk_text_buffer_get_iter_at_offset (tb, &ti_end, -1);
+ uris = gtk_text_buffer_get_text (tb, &ti_start, &ti_end, FALSE);
+ if (uris != NULL)
+ uri = GNUNET_FS_uri_parse (uris, &perr);
+ else
+ uri = NULL;
+ g_free (uris);
+ gtk_widget_set_sensitive (GTK_WIDGET
+ (gtk_builder_get_object
+ (builder,
+ "GNUNET_GTK_open_url_dialog_execute_button")),
+ (uri == NULL) ? FALSE : TRUE);
+ if (uri != NULL)
+ GNUNET_FS_uri_destroy (uri);
+ GNUNET_free_non_null (perr);
+}
+
+
+/**
+ * User selected "Open URI" in main window.
+ *
+ * @param dummy the menu entry
+ * @param user_data unused
+ */
+void
+GNUNET_GTK_main_menu_file_download_uri_activate_cb (GtkWidget * dummy,
+ gpointer user_data)
+{
+ GtkBuilder *builder;
+ GtkWidget *dialog;
+ GtkTextBuffer *tb;
+ GtkTextIter ti_start;
+ GtkTextIter ti_end;
+ GtkWidget *toplevel;
+
+ builder =
+ GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_open_url_dialog.glade", NULL);
+ if (NULL == builder)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ dialog = GTK_WIDGET (gtk_builder_get_object
+ (builder,
+ "GNUNET_GTK_open_url_window"));
+ tb = GTK_TEXT_BUFFER (gtk_builder_get_object
+ (builder,
+ "GNUNET_GTK_open_url_dialog_url_textview_buffer"));
+ gtk_text_buffer_get_iter_at_offset (tb, &ti_start, 0);
+ gtk_text_buffer_get_iter_at_offset (tb, &ti_end, -1);
+ gtk_text_buffer_delete (tb, &ti_start, &ti_end);
+
+ /* FIXME-FEATURE: query the clipboard, maybe there's valid URI in there?
+ * If so, get it. */
+
+ toplevel = gtk_widget_get_toplevel (dummy);
+ if (GTK_IS_WINDOW (toplevel))
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel));
+ gtk_widget_show (dialog);
+}
+
+
+/* end of gnunet-fs-gtk_open-uri.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19648 - gnunet-gtk/src/fs,
gnunet <=