[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19624 - gnunet-gtk/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19624 - gnunet-gtk/src/fs |
Date: |
Thu, 2 Feb 2012 01:07:29 +0100 |
Author: grothoff
Date: 2012-02-02 01:07:29 +0100 (Thu, 02 Feb 2012)
New Revision: 19624
Modified:
gnunet-gtk/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c
gnunet-gtk/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.h
gnunet-gtk/src/fs/gnunet-fs-gtk-edit_publish_dialog.c
gnunet-gtk/src/fs/gnunet-fs-gtk-edit_publish_dialog.h
gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c
gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_publish.c
Log:
-simplifying logic some
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c 2012-02-01
23:39:28 UTC (rev 19623)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c 2012-02-02
00:07:29 UTC (rev 19624)
@@ -24,6 +24,7 @@
* @brief operations to manage user's anonymity level selections
*/
#include "gnunet-fs-gtk-common.h"
+#include "gnunet-fs-gtk-anonymity_spin_buttons.h"
#include <gdk/gdk.h>
/**
@@ -71,33 +72,34 @@
}
-
+/**
+ * Obtain the numeric anonymity level selected by a GtkComboBox.
+ *
+ * @param builder builder for looking up widgets
+ * @param combo_name name of the GtkComboBox with the anonymity selection
+ * @param p_level where to store the anonymity level
+ * @return TRUE on success, FALSE on failure
+ */
gboolean
GNUNET_GTK_get_selected_anonymity_level (GtkBuilder * builder,
gchar * combo_name, guint * p_level)
{
GtkComboBox *combo;
- GtkTreeIter iter;
- GtkTreeModel *model;
- guint level;
combo = GTK_COMBO_BOX (gtk_builder_get_object (builder, combo_name));
if (!combo)
return FALSE;
-
- if (!gtk_combo_box_get_active_iter (combo, &iter))
- return FALSE;
-
- model = gtk_combo_box_get_model (combo);
- if (!model)
- return FALSE;
-
- gtk_tree_model_get (model, &iter, 1, &level, -1);
- if (p_level)
- *p_level = level;
- return TRUE;
+ return GNUNET_GTK_get_selected_anonymity_combo_level (combo, p_level);
}
+
+/**
+ * Obtain the numeric anonymity level selected by a GtkComboBox.
+ *
+ * @param combo the GtkComboBox with the anonymity selection
+ * @param p_level where to store the anonymity level
+ * @return TRUE on success, FALSE on failure
+ */
gboolean
GNUNET_GTK_get_selected_anonymity_combo_level (GtkComboBox *combo, guint
*p_level)
{
@@ -105,64 +107,44 @@
GtkTreeModel *model;
guint level;
- if (!gtk_combo_box_get_active_iter (combo, &iter))
+ if (! gtk_combo_box_get_active_iter (combo, &iter))
return FALSE;
-
model = gtk_combo_box_get_model (combo);
if (!model)
return FALSE;
-
gtk_tree_model_get (model, &iter, 1, &level, -1);
if (p_level)
*p_level = level;
return TRUE;
}
+
gboolean
GNUNET_GTK_select_anonymity_level (GtkBuilder * builder, gchar * combo_name,
guint sel_level)
{
GtkComboBox *combo;
- GtkTreeIter iter;
- GtkTreeModel *model;
- guint level;
- gboolean go_on;
combo = GTK_COMBO_BOX (gtk_builder_get_object (builder, combo_name));
if (!combo)
return FALSE;
-
- model = gtk_combo_box_get_model (combo);
- if (!model)
- return FALSE;
-
- for (go_on = gtk_tree_model_get_iter_first (model, &iter); go_on;
- go_on = gtk_tree_model_iter_next (model, &iter))
- {
- gtk_tree_model_get (model, &iter, 1, &level, -1);
- if (level == sel_level)
- {
- gtk_combo_box_set_active_iter (combo, &iter);
- return TRUE;
- }
- }
- return FALSE;
+ return GNUNET_GTK_select_anonymity_combo_level (combo, sel_level);
}
+
gboolean
GNUNET_GTK_select_anonymity_combo_level (GtkComboBox *combo, guint sel_level)
{
GtkTreeIter iter;
GtkTreeModel *model;
guint level;
- gboolean go_on;
model = gtk_combo_box_get_model (combo);
if (!model)
return FALSE;
-
- for (go_on = gtk_tree_model_get_iter_first (model, &iter); go_on;
- go_on = gtk_tree_model_iter_next (model, &iter))
+ if (! gtk_tree_model_get_iter_first (model, &iter))
+ return FALSE;
+ do
{
gtk_tree_model_get (model, &iter, 1, &level, -1);
if (level == sel_level)
@@ -170,7 +152,8 @@
gtk_combo_box_set_active_iter (combo, &iter);
return TRUE;
}
- }
+ }
+ while (gtk_tree_model_iter_next (model, &iter));
return FALSE;
}
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.h
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.h 2012-02-01
23:39:28 UTC (rev 19623)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.h 2012-02-02
00:07:29 UTC (rev 19624)
@@ -19,7 +19,7 @@
*/
/**
- * @file src/fs/gnunet-fs-gtk-anonymtiy_spin_buttons.c
+ * @file src/fs/gnunet-fs-gtk-anonymtiy_spin_buttons.h
* @author Christian Grothoff
* @brief operations to manage user's anonymity level selections
*/
@@ -30,11 +30,26 @@
#include <gdk/gdk.h>
+/**
+ * Obtain the numeric anonymity level selected by a GtkComboBox.
+ *
+ * @param builder builder for looking up widgets
+ * @param combo_name name of the GtkComboBox with the anonymity selection
+ * @param p_level where to store the anonymity level
+ * @return TRUE on success, FALSE on failure
+ */
gboolean
GNUNET_GTK_get_selected_anonymity_level (GtkBuilder * builder,
gchar * combo_name, guint * p_level);
+/**
+ * Obtain the numeric anonymity level selected by a GtkComboBox.
+ *
+ * @param combo the GtkComboBox with the anonymity selection
+ * @param p_level where to store the anonymity level
+ * @return TRUE on success, FALSE on failure
+ */
gboolean
GNUNET_GTK_get_selected_anonymity_combo_level (GtkComboBox *combo, guint
*p_level);
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk-edit_publish_dialog.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk-edit_publish_dialog.c 2012-02-01
23:39:28 UTC (rev 19623)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk-edit_publish_dialog.c 2012-02-02
00:07:29 UTC (rev 19624)
@@ -163,12 +163,6 @@
struct GNUNET_FS_FileInformation *fip;
/**
- * Overall options for the publish operation. This is also what
- * we are primarily editing.
- */
- struct GNUNET_FS_BlockOptions bo;
-
- /**
* Flag to track if we changed the preview and thus should keep/discard
* certain metadata. (FIXME: yucky!)
*/
@@ -642,14 +636,48 @@
}
+
/* ****************** handlers for closing the dialog ******************** */
+/**
+ * The user clicked the 'cancel' button. Abort the operation.
+ *
+ * @param button the cancel button
+ * @param user_data the 'struct EditPublicationDialogContext'
+ */
+void
+GNUNET_GTK_edit_publication_cancel_button_clicked_cb (GtkButton * button,
+ gpointer user_data)
+{
+ struct EditPublicationDialogContext *ctx = user_data;
+ ctx->cb (ctx->cb_cls, GNUNET_SYSERR, NULL, NULL, NULL, GTK_RESPONSE_CANCEL);
+ free_edit_dialog_context (ctx);
+}
+/**
+ * The user closed the window. Abort the operation.
+ *
+ * @param widget the window
+ * @param event the event that caused the window to close
+ * @param user_data the 'struct EditPublicationDialogContext'
+ * @return TRUE (always)
+ */
+gboolean
+GNUNET_GTK_edit_publication_window_delete_event_cb (GtkWidget * widget,
+ GdkEvent * event,
+ gpointer user_data)
+{
+ struct EditPublicationDialogContext *ctx = user_data;
+ ctx->cb (ctx->cb_cls, GNUNET_SYSERR, NULL, NULL, NULL, GTK_RESPONSE_CANCEL);
+ free_edit_dialog_context (ctx);
+ return TRUE;
+}
+
/**
* Copy binary meta data from to the new container and also
* preserve all entries that were not changed.
@@ -759,13 +787,7 @@
GFileInfo *finfo;
char *sfn;
- if (!GNUNET_GTK_get_selected_anonymity_combo_level
- (ctx->anonymity_combo, &ctx->bo.anonymity_level))
- return GNUNET_SYSERR;
- ctx->bo.content_priority = gtk_spin_button_get_value (ctx->priority_spin);
- ctx->bo.replication_level = gtk_spin_button_get_value
(ctx->replication_spin);
*do_index = gtk_toggle_button_get_active (ctx->index_checkbutton);
- ctx->bo.expiration_time = GNUNET_FS_GTK_get_expiration_time
(ctx->expiration_year_spin);
/* update URI */
if (NULL != (*uri))
@@ -792,7 +814,9 @@
/* update meta */
ctx->md = GNUNET_CONTAINER_meta_data_create ();
- GNUNET_CONTAINER_meta_data_iterate (meta, &preserve_meta_items, ctx);
+ GNUNET_CONTAINER_meta_data_iterate (meta,
+ &preserve_meta_items,
+ ctx);
GNUNET_CONTAINER_meta_data_clear (meta);
if (TRUE == gtk_tree_model_get_iter_first (GTK_TREE_MODEL
(ctx->meta_liststore), &iter))
@@ -854,57 +878,41 @@
}
+/**
+ * The user clicked the 'confirm' button. Push the edits back into the
+ * FileInformation structure and given it and the options back to the
+ * callback. Then clean up the dialog.
+ *
+ * @param button the cancel button
+ * @param user_data the 'struct EditPublicationDialogContext'
+ */
void
-GNUNET_GTK_edit_publication_cancel_button_clicked_cb (GtkButton * button,
- struct
EditPublicationDialogContext *ctx)
-{
- int do_index;
-
- /* FIXME: why are we passing half of these values here? */
- do_index = gtk_toggle_button_get_active (ctx->index_checkbutton);
- ctx->cb (ctx->cb_cls, do_index, ctx->short_fn,
- &ctx->bo, NULL, GTK_RESPONSE_CANCEL);
- free_edit_dialog_context (ctx);
-}
-
-
-
-void
GNUNET_GTK_edit_publication_confirm_button_clicked_cb (GtkButton * button,
- struct
EditPublicationDialogContext *ctx)
+ gpointer user_data)
{
+ struct EditPublicationDialogContext *ctx = user_data;
+ struct GNUNET_FS_BlockOptions bo;
gint year;
- const char *root;
- int do_index;
- GNUNET_FS_file_information_inspect (ctx->fip, &file_information_update, ctx);
- if (!GNUNET_GTK_get_selected_anonymity_combo_level (ctx->anonymity_combo,
- &ctx->bo.anonymity_level))
- ctx->bo.content_priority = gtk_spin_button_get_value (ctx->priority_spin);
- ctx->bo.replication_level = gtk_spin_button_get_value
(ctx->replication_spin);
-
- do_index = gtk_toggle_button_get_active (ctx->index_checkbutton);
+ GNUNET_FS_file_information_inspect (ctx->fip,
+ &file_information_update,
+ ctx);
+ GNUNET_break (GNUNET_GTK_get_selected_anonymity_combo_level
(ctx->anonymity_combo,
+
&bo.anonymity_level));
+ bo.content_priority = gtk_spin_button_get_value (ctx->priority_spin);
+ bo.replication_level = gtk_spin_button_get_value (ctx->replication_spin);
year = gtk_spin_button_get_value (ctx->expiration_year_spin);
- ctx->bo.expiration_time = GNUNET_FS_year_to_time (year);
- root = gtk_entry_get_text (ctx->root_entry);
- ctx->cb (ctx->cb_cls, do_index, ctx->short_fn,
- &ctx->bo, root, GTK_RESPONSE_OK);
+ bo.expiration_time = GNUNET_FS_year_to_time (year);
+ ctx->cb (ctx->cb_cls,
+ gtk_toggle_button_get_active (ctx->index_checkbutton),
+ ctx->short_fn,
+ &bo,
+ gtk_entry_get_text (ctx->root_entry),
+ GTK_RESPONSE_OK);
free_edit_dialog_context (ctx);
}
-gboolean
-GNUNET_GTK_edit_publication_window_delete_event_cb (GtkWidget * widget,
- GdkEvent * event,
- struct
EditPublicationDialogContext *ctx)
-{
- GNUNET_GTK_edit_publication_cancel_button_clicked_cb (GTK_BUTTON
(gtk_builder_get_object
-
(ctx->builder, "GNUNET_GTK_edit_publication_cancel_button")),
- ctx);
- return TRUE;
-}
-
-
/* ****************** code for initialization of the dialog
******************** */
@@ -967,12 +975,12 @@
gtk_image_set_from_pixbuf (ctx->preview_image, pixbuf);
}
}
- year = (int) GNUNET_FS_time_to_year (ctx->bo.expiration_time);
+ year = (int) GNUNET_FS_time_to_year (bo->expiration_time);
gtk_spin_button_set_value (ctx->expiration_year_spin, year);
GNUNET_GTK_select_anonymity_combo_level (ctx->anonymity_combo,
- ctx->bo.anonymity_level);
- gtk_spin_button_set_value (ctx->priority_spin, ctx->bo.content_priority);
- gtk_spin_button_set_value (ctx->replication_spin, ctx->bo.replication_level);
+ bo->anonymity_level);
+ gtk_spin_button_set_value (ctx->priority_spin, bo->content_priority);
+ gtk_spin_button_set_value (ctx->replication_spin, bo->replication_level);
gtk_toggle_button_set_active (ctx->index_checkbutton, *do_index);
return GNUNET_SYSERR; /* only visit top-level item */
}
@@ -1001,9 +1009,7 @@
*/
void
GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent,
- int do_index /* FIXME: not needed? */,
const char *short_fn,
- const struct GNUNET_FS_BlockOptions bo,
struct GNUNET_FS_FileInformation *fip,
gboolean allow_no_keywords,
GtkListStore *anon_liststore,
@@ -1117,7 +1123,6 @@
if (NULL != short_fn)
ctx->short_fn = GNUNET_strdup (short_fn);
- ctx->bo = bo;
ctx->fip = fip;
ctx->preview_changed = GNUNET_NO;
ctx->allow_no_keywords = allow_no_keywords;
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk-edit_publish_dialog.h
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk-edit_publish_dialog.h 2012-02-01
23:39:28 UTC (rev 19623)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk-edit_publish_dialog.h 2012-02-02
00:07:29 UTC (rev 19624)
@@ -54,8 +54,7 @@
*/
void
GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent,
- int do_index, const char *short_fn,
- const struct GNUNET_FS_BlockOptions bo,
+ const char *short_fn,
struct GNUNET_FS_FileInformation *fip,
gboolean allow_no_keywords, GtkListStore
*anon_liststore,
GNUNET_FS_GTK_EditPublishDialogCallback cb,
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c 2012-02-01
23:39:28 UTC (rev 19623)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c 2012-02-02
00:07:29 UTC (rev 19624)
@@ -205,8 +205,8 @@
GNUNET_FS_file_information_create_empty_directory (NULL, NULL, NULL,
meta,
&nds->bo, NULL);
GNUNET_CONTAINER_meta_data_destroy (meta);
- GNUNET_FS_GTK_edit_publish_dialog (transient, nds->do_index,
- nds->short_fn, nds->bo, nds->fip, FALSE,
anon_liststore,
+ GNUNET_FS_GTK_edit_publish_dialog (transient,
+ nds->short_fn, nds->fip, FALSE,
anon_liststore,
&adv_pseudonym_edit_publish_dialog_cb,
nds);
}
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_publish.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_publish.c 2012-02-01
23:39:28 UTC (rev 19623)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_publish.c 2012-02-02
00:07:29 UTC (rev 19624)
@@ -94,10 +94,6 @@
unsigned int total;
};
-void
-GNUNET_GTK_publish_file_dialog_response_cb (GtkDialog * dialog,
- gint response_id,
- struct MainPublishingDialogContext
*ctx);
static void
selection_changed_cb (GtkTreeSelection * ts, struct
MainPublishingDialogContext *ctx);
@@ -613,174 +609,7 @@
}
-void
-GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy,
- struct
MainPublishingDialogContext *ctx)
-{
- GtkWidget *ad;
-
- GtkComboBox *combo;
- GtkTreeModel *anon_treemodel;
-
- ctx->open_file_builder = GNUNET_GTK_get_new_builder
("gnunet_fs_gtk_publish_file_dialog.glade", ctx);
- GNUNET_FS_GTK_setup_expiration_year_adjustment (ctx->open_file_builder);
- ad = GTK_WIDGET (gtk_builder_get_object
- (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog"));
-
- /* FIXME: Use some kind of adjustable defaults instead of 1000, 0 and TRUE */
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (
- ctx->open_file_builder,
- "GNUNET_GTK_publish_file_dialog_priority_spin_button")), 1000);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (
- ctx->open_file_builder,
- "GNUNET_GTK_publish_file_dialog_replication_spin_button")), 0);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (
- ctx->open_file_builder,
- "GNUNET_GTK_publish_file_dialog_do_index_checkbutton")), TRUE);
-
- ctx->open_file_handler_id = g_signal_connect (G_OBJECT (ad), "response",
G_CALLBACK (GNUNET_GTK_publish_file_dialog_response_cb), ctx);
-
- anon_treemodel = GTK_TREE_MODEL (gtk_builder_get_object
(ctx->main_window_builder,
- "main_window_search_anonymity_liststore"));
- combo = GTK_COMBO_BOX (gtk_builder_get_object (ctx->open_file_builder,
- "GNUNET_GTK_publish_file_dialog_anonymity_combobox"));
- gtk_combo_box_set_model (combo, anon_treemodel);
-
- gtk_window_set_transient_for (GTK_WINDOW (ad), ctx->master_pubdialog);
-
- gtk_window_present (GTK_WINDOW (ad));
-}
-
-
-struct EditPublishContext
-{
- GtkTreeModel *tm;
- GtkTreeIter iter;
-};
-
-
-/**
- * Function called when the edit publish dialog has been closed.
- *
- * @param cls closure
- * @param do_index index flag set?
- * @param short_fn short filename
- * @param bo block options for publishing
- * @param root always NULL here
- * @param ret GTK_RESPONSE_OK if the dialog was closed with "OK"
- */
static void
-master_publish_edit_publish_dialog_cb (gpointer cls, int do_index,
- const char *short_fn,
- const struct GNUNET_FS_BlockOptions *bo,
- const char *root,
- gint ret)
-{
- struct EditPublishContext *cbargs = cls;
- struct GNUNET_FS_FileInformation *fi;
-
- if (ret == GTK_RESPONSE_OK)
- {
- gtk_tree_store_set (GTK_TREE_STORE (cbargs->tm), &cbargs->iter, 1,
do_index,
- 2, short_fn, 3, (guint) bo->anonymity_level, 4,
- (guint) bo->content_priority,
- 6, (guint64) bo->expiration_time.abs_value,
- 7, (guint) bo->replication_level,
- -1);
- gtk_tree_model_get (cbargs->tm, &cbargs->iter, 5, &fi, -1);
- GNUNET_FS_file_information_set_filename (fi, short_fn);
- }
- GNUNET_free (cbargs);
-}
-
-
-void
-GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy,
- struct
MainPublishingDialogContext *ctx)
-{
- struct EditPublishContext *cbargs;
- gint do_index;
- char *short_fn;
- guint anonymity_level;
- guint priority;
- struct GNUNET_FS_FileInformation *fip;
- guint64 abs_etime;
- guint replication_level;
- struct GNUNET_FS_BlockOptions bo;
- GtkListStore *anon_liststore;
-
- anon_liststore = GTK_LIST_STORE (gtk_builder_get_object
(ctx->main_window_builder, "main_window_search_anonymity_liststore"));
-
- cbargs = GNUNET_malloc (sizeof (struct EditPublishContext));
- cbargs->tm = ctx->file_info_treemodel;
- if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL,
&cbargs->iter))
- {
- GNUNET_break (0);
- GNUNET_free (cbargs);
- return;
- }
-
- gtk_tree_model_get (ctx->file_info_treemodel, &cbargs->iter, 1, &do_index,
2, &short_fn, 3,
- &anonymity_level, 4, &priority, 5, &fip,
- 6, &abs_etime,
- 7, &replication_level,
- -1);
- bo.anonymity_level = anonymity_level;
- bo.content_priority = priority;
- bo.expiration_time.abs_value = (uint64_t) abs_etime;
- bo.replication_level = replication_level;
- /* FIXME: can we just give our anon_liststore out like this? What about
- (unintended) sharing of state? */
- GNUNET_FS_GTK_edit_publish_dialog (ctx->master_pubdialog, do_index,
- short_fn, bo, fip, TRUE, anon_liststore,
- &master_publish_edit_publish_dialog_cb,
- cbargs);
-}
-
-
-/**
- * Free row reference stored in the file information's
- * client-info pointer.
- */
-static int
-free_fi_row_reference (void *cls, struct GNUNET_FS_FileInformation *fi,
- uint64_t length, struct GNUNET_CONTAINER_MetaData *meta,
- struct GNUNET_FS_Uri **uri,
- struct GNUNET_FS_BlockOptions *bo, int *do_index,
- void **client_info)
-{
- GtkTreeRowReference *row = *client_info;
-
- if (row == NULL)
- {
- GNUNET_break (0);
- return GNUNET_OK;
- }
- gtk_tree_row_reference_free (row);
- return GNUNET_OK;
-}
-
-
-void
-GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy,
- struct
MainPublishingDialogContext *ctx)
-{
- GtkTreeIter iter;
- struct GNUNET_FS_FileInformation *fip;
-
- if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL,
&iter))
- {
- GNUNET_break (0);
- return;
- }
- gtk_tree_model_get (ctx->file_info_treemodel, &iter, 5, &fip, -1);
- GNUNET_FS_file_information_destroy (fip, &free_fi_row_reference, NULL);
- gtk_tree_store_remove (GTK_TREE_STORE (ctx->file_info_treemodel), &iter);
- update_selectivity (ctx);
-}
-
-
-static void
insert_progress_dialog_text (struct AddDirClientContext *adcc,
const char *text)
{
@@ -899,32 +728,6 @@
}
-void
-GNUNET_FS_GTK_progress_dialog_cancel_button_clicked_cb (GtkButton *button,
- void *cls)
-{
- struct AddDirClientContext *adcc = cls;
-
- if (adcc->ds != NULL)
- {
- /* Still scanning - signal the scanner to finish */
- GNUNET_FS_directory_scan_abort (adcc->ds);
- adcc->ds = NULL;
- }
- close_scan (adcc);
-}
-
-
-gboolean
-GNUNET_FS_GTK_progress_dialog_delete_event_cb (GtkWidget *widget,
- GdkEvent * event,
- void *cls)
-{
- /* Don't allow GTK to kill the window, until the scan is finished */
- return GNUNET_NO;
-}
-
-
static void
directory_scan_cb (void *cls,
const char *filename, int is_directory,
@@ -1081,10 +884,10 @@
}
-void
-GNUNET_GTK_publish_directory_dialog_response_cb (GtkDialog * dialog,
- gint response_id,
- struct
MainPublishingDialogContext *ctx)
+static void
+publish_directory_dialog_response_cb (GtkDialog * dialog,
+ gint response_id,
+ struct MainPublishingDialogContext *ctx)
{
char *filename;
int do_index;
@@ -1133,7 +936,266 @@
}
+static void
+publish_file_dialog_response_cb (GtkDialog * dialog,
+ gint response_id,
+ struct MainPublishingDialogContext *ctx)
+{
+ char *filename;
+ struct GNUNET_FS_BlockOptions bo;
+ int do_index;
+ GtkSpinButton *sb;
+ GtkWidget *ad;
+
+ if (g_signal_handler_is_connected (G_OBJECT (dialog),
ctx->open_file_handler_id))
+ g_signal_handler_disconnect (G_OBJECT (dialog), ctx->open_file_handler_id);
+ ctx->open_file_handler_id = 0;
+
+ ad = GTK_WIDGET (gtk_builder_get_object
+ (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog"));
+
+ if (response_id == -5)
+ {
+ /* OK */
+ sb = GTK_SPIN_BUTTON (gtk_builder_get_object
+ (ctx->open_file_builder,
+
"GNUNET_GTK_publish_file_dialog_expiration_year_spin_button"));
+
+ if (!GNUNET_GTK_get_selected_anonymity_level
+ (ctx->open_file_builder,
"GNUNET_GTK_publish_file_dialog_anonymity_combobox",
+ &bo.anonymity_level))
+ bo.anonymity_level = 1;
+ bo.content_priority =
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON
+ (gtk_builder_get_object
+ (ctx->open_file_builder,
+
"GNUNET_GTK_publish_file_dialog_priority_spin_button")));
+ bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (sb);
+ bo.replication_level =
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON
+ (gtk_builder_get_object
+ (ctx->open_file_builder,
+
"GNUNET_GTK_publish_file_dialog_replication_spin_button")));
+ do_index =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (gtk_builder_get_object
+ (ctx->open_file_builder,
+
"GNUNET_GTK_publish_file_dialog_do_index_checkbutton")));
+
+ filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER
(ad));
+
+ scan_file_or_directory (ctx, filename, &bo, do_index);
+
+ g_free (filename);
+ }
+ else
+ {
+ /* Cancel/Escape/close/etc */
+ }
+ gtk_widget_destroy (ad);
+}
+
+
void
+GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy,
+ struct
MainPublishingDialogContext *ctx)
+{
+ GtkWidget *ad;
+
+ GtkComboBox *combo;
+ GtkTreeModel *anon_treemodel;
+
+ ctx->open_file_builder = GNUNET_GTK_get_new_builder
("gnunet_fs_gtk_publish_file_dialog.glade", ctx);
+ GNUNET_FS_GTK_setup_expiration_year_adjustment (ctx->open_file_builder);
+ ad = GTK_WIDGET (gtk_builder_get_object
+ (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog"));
+
+ /* FIXME: Use some kind of adjustable defaults instead of 1000, 0 and TRUE */
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (
+ ctx->open_file_builder,
+ "GNUNET_GTK_publish_file_dialog_priority_spin_button")), 1000);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (
+ ctx->open_file_builder,
+ "GNUNET_GTK_publish_file_dialog_replication_spin_button")), 0);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (
+ ctx->open_file_builder,
+ "GNUNET_GTK_publish_file_dialog_do_index_checkbutton")), TRUE);
+
+ ctx->open_file_handler_id = g_signal_connect (G_OBJECT (ad), "response",
G_CALLBACK (publish_file_dialog_response_cb), ctx);
+
+ anon_treemodel = GTK_TREE_MODEL (gtk_builder_get_object
(ctx->main_window_builder,
+ "main_window_search_anonymity_liststore"));
+ combo = GTK_COMBO_BOX (gtk_builder_get_object (ctx->open_file_builder,
+ "GNUNET_GTK_publish_file_dialog_anonymity_combobox"));
+ gtk_combo_box_set_model (combo, anon_treemodel);
+
+ gtk_window_set_transient_for (GTK_WINDOW (ad), ctx->master_pubdialog);
+
+ gtk_window_present (GTK_WINDOW (ad));
+}
+
+
+struct EditPublishContext
+{
+ GtkTreeModel *tm;
+ GtkTreeIter iter;
+};
+
+
+/**
+ * Function called when the edit publish dialog has been closed.
+ *
+ * @param cls closure
+ * @param do_index index flag set?
+ * @param short_fn short filename
+ * @param bo block options for publishing
+ * @param root always NULL here
+ * @param ret GTK_RESPONSE_OK if the dialog was closed with "OK"
+ */
+static void
+master_publish_edit_publish_dialog_cb (gpointer cls, int do_index,
+ const char *short_fn,
+ const struct GNUNET_FS_BlockOptions *bo,
+ const char *root,
+ gint ret)
+{
+ struct EditPublishContext *cbargs = cls;
+ struct GNUNET_FS_FileInformation *fi;
+
+ if (ret == GTK_RESPONSE_OK)
+ {
+ gtk_tree_store_set (GTK_TREE_STORE (cbargs->tm), &cbargs->iter,
+ 1, do_index,
+ 2, short_fn,
+ 3, (guint) bo->anonymity_level,
+ 4, (guint) bo->content_priority,
+ 6, (guint64) bo->expiration_time.abs_value,
+ 7, (guint) bo->replication_level,
+ -1);
+ gtk_tree_model_get (cbargs->tm, &cbargs->iter, 5, &fi, -1);
+ GNUNET_FS_file_information_set_filename (fi, short_fn);
+ }
+ GNUNET_free (cbargs);
+}
+
+
+void
+GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy,
+ struct
MainPublishingDialogContext *ctx)
+{
+ struct EditPublishContext *cbargs;
+ gint do_index;
+ char *short_fn;
+ guint anonymity_level;
+ guint priority;
+ struct GNUNET_FS_FileInformation *fip;
+ guint64 abs_etime;
+ guint replication_level;
+ struct GNUNET_FS_BlockOptions bo;
+ GtkListStore *anon_liststore;
+
+ anon_liststore = GTK_LIST_STORE (gtk_builder_get_object
(ctx->main_window_builder, "main_window_search_anonymity_liststore"));
+
+ cbargs = GNUNET_malloc (sizeof (struct EditPublishContext));
+ cbargs->tm = ctx->file_info_treemodel;
+ if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL,
&cbargs->iter))
+ {
+ GNUNET_break (0);
+ GNUNET_free (cbargs);
+ return;
+ }
+
+ gtk_tree_model_get (ctx->file_info_treemodel, &cbargs->iter,
+ 1, &do_index,
+ 2, &short_fn,
+ 3, &anonymity_level,
+ 4, &priority,
+ 5, &fip,
+ 6, &abs_etime,
+ 7, &replication_level,
+ -1);
+ bo.anonymity_level = anonymity_level;
+ bo.content_priority = priority;
+ bo.expiration_time.abs_value = (uint64_t) abs_etime;
+ bo.replication_level = replication_level;
+ /* FIXME: can we just give our anon_liststore out like this? What about
+ (unintended) sharing of state? */
+ GNUNET_FS_GTK_edit_publish_dialog (ctx->master_pubdialog,
+ short_fn, fip, TRUE, anon_liststore,
+ &master_publish_edit_publish_dialog_cb,
+ cbargs);
+}
+
+
+/**
+ * Free row reference stored in the file information's
+ * client-info pointer.
+ */
+static int
+free_fi_row_reference (void *cls, struct GNUNET_FS_FileInformation *fi,
+ uint64_t length, struct GNUNET_CONTAINER_MetaData *meta,
+ struct GNUNET_FS_Uri **uri,
+ struct GNUNET_FS_BlockOptions *bo, int *do_index,
+ void **client_info)
+{
+ GtkTreeRowReference *row = *client_info;
+
+ if (row == NULL)
+ {
+ GNUNET_break (0);
+ return GNUNET_OK;
+ }
+ gtk_tree_row_reference_free (row);
+ return GNUNET_OK;
+}
+
+
+void
+GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy,
+ struct
MainPublishingDialogContext *ctx)
+{
+ GtkTreeIter iter;
+ struct GNUNET_FS_FileInformation *fip;
+
+ if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL,
&iter))
+ {
+ GNUNET_break (0);
+ return;
+ }
+ gtk_tree_model_get (ctx->file_info_treemodel, &iter, 5, &fip, -1);
+ GNUNET_FS_file_information_destroy (fip, &free_fi_row_reference, NULL);
+ gtk_tree_store_remove (GTK_TREE_STORE (ctx->file_info_treemodel), &iter);
+ update_selectivity (ctx);
+}
+
+
+void
+GNUNET_FS_GTK_progress_dialog_cancel_button_clicked_cb (GtkButton *button,
+ void *cls)
+{
+ struct AddDirClientContext *adcc = cls;
+
+ if (adcc->ds != NULL)
+ {
+ /* Still scanning - signal the scanner to finish */
+ GNUNET_FS_directory_scan_abort (adcc->ds);
+ adcc->ds = NULL;
+ }
+ close_scan (adcc);
+}
+
+
+gboolean
+GNUNET_FS_GTK_progress_dialog_delete_event_cb (GtkWidget *widget,
+ GdkEvent * event,
+ void *cls)
+{
+ /* Don't allow GTK to kill the window, until the scan is finished */
+ return GNUNET_NO;
+}
+
+
+void
GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy,
struct
MainPublishingDialogContext *ctx)
{
@@ -1159,7 +1221,7 @@
ad = GTK_WIDGET (gtk_builder_get_object
(ctx->open_directory_builder,
"GNUNET_GTK_publish_directory_dialog"));
- ctx->open_directory_handler_id = g_signal_connect (G_OBJECT (ad),
"response", G_CALLBACK (GNUNET_GTK_publish_directory_dialog_response_cb), ctx);
+ ctx->open_directory_handler_id = g_signal_connect (G_OBJECT (ad),
"response", G_CALLBACK (publish_directory_dialog_response_cb), ctx);
anon_treemodel = GTK_TREE_MODEL (gtk_builder_get_object
(ctx->main_window_builder,
"main_window_search_anonymity_liststore"));
@@ -1502,66 +1564,6 @@
}
-void
-GNUNET_GTK_publish_file_dialog_response_cb (GtkDialog * dialog,
- gint response_id,
- struct MainPublishingDialogContext
*ctx)
-{
- char *filename;
- struct GNUNET_FS_BlockOptions bo;
- int do_index;
- GtkSpinButton *sb;
- GtkWidget *ad;
-
- if (g_signal_handler_is_connected (G_OBJECT (dialog),
ctx->open_file_handler_id))
- g_signal_handler_disconnect (G_OBJECT (dialog), ctx->open_file_handler_id);
- ctx->open_file_handler_id = 0;
-
- ad = GTK_WIDGET (gtk_builder_get_object
- (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog"));
-
- if (response_id == -5)
- {
- /* OK */
- sb = GTK_SPIN_BUTTON (gtk_builder_get_object
- (ctx->open_file_builder,
-
"GNUNET_GTK_publish_file_dialog_expiration_year_spin_button"));
-
- if (!GNUNET_GTK_get_selected_anonymity_level
- (ctx->open_file_builder,
"GNUNET_GTK_publish_file_dialog_anonymity_combobox",
- &bo.anonymity_level))
- bo.anonymity_level = 1;
- bo.content_priority =
- gtk_spin_button_get_value (GTK_SPIN_BUTTON
- (gtk_builder_get_object
- (ctx->open_file_builder,
-
"GNUNET_GTK_publish_file_dialog_priority_spin_button")));
- bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (sb);
- bo.replication_level =
- gtk_spin_button_get_value (GTK_SPIN_BUTTON
- (gtk_builder_get_object
- (ctx->open_file_builder,
-
"GNUNET_GTK_publish_file_dialog_replication_spin_button")));
- do_index =
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (gtk_builder_get_object
- (ctx->open_file_builder,
-
"GNUNET_GTK_publish_file_dialog_do_index_checkbutton")));
-
- filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER
(ad));
-
- scan_file_or_directory (ctx, filename, &bo, do_index);
-
- g_free (filename);
- }
- else
- {
- /* Cancel/Escape/close/etc */
- }
- gtk_widget_destroy (ad);
-}
-
-
/**
*/
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19624 - gnunet-gtk/src/fs,
gnunet <=