aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk-main_window_file_publish.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-02-02 12:57:54 +0000
committerChristian Grothoff <christian@grothoff.org>2012-02-02 12:57:54 +0000
commitdc9fe68695fa56344344cfb3549c6155dfb51ea0 (patch)
tree70fb838aed4c3560a8708175c1decf2932137c5d /src/fs/gnunet-fs-gtk-main_window_file_publish.c
parente6bff053a9a1b8e84e92b5c2615075391b2bcb11 (diff)
downloadgnunet-gtk-dc9fe68695fa56344344cfb3549c6155dfb51ea0.tar.gz
gnunet-gtk-dc9fe68695fa56344344cfb3549c6155dfb51ea0.zip
-more code clean up in edit dialog
Diffstat (limited to 'src/fs/gnunet-fs-gtk-main_window_file_publish.c')
-rw-r--r--src/fs/gnunet-fs-gtk-main_window_file_publish.c75
1 files changed, 48 insertions, 27 deletions
diff --git a/src/fs/gnunet-fs-gtk-main_window_file_publish.c b/src/fs/gnunet-fs-gtk-main_window_file_publish.c
index 29435940..57a5eb6a 100644
--- a/src/fs/gnunet-fs-gtk-main_window_file_publish.c
+++ b/src/fs/gnunet-fs-gtk-main_window_file_publish.c
@@ -1037,44 +1037,66 @@ GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy,
1037 1037
1038struct EditPublishContext 1038struct EditPublishContext
1039{ 1039{
1040 struct GNUNET_FS_FileInformation *fip;
1041
1040 GtkTreeModel *tm; 1042 GtkTreeModel *tm;
1043
1041 GtkTreeIter iter; 1044 GtkTreeIter iter;
1042}; 1045};
1043 1046
1044 1047
1045/** 1048/**
1049 * Update tree view based on the information from the
1050 * GNUNET_FS_FileInformation publish-structure.
1051 *
1052 * @param cls closure, a 'struct EditPublishContext *'
1053 * @param fi the entry in the publish-structure
1054 * @param length length of the file or directory
1055 * @param meta metadata for the file or directory (can be modified)
1056 * @param uri pointer to the keywords that will be used for this entry (can be modified)
1057 * @param bo block options (can be modified)
1058 * @param do_index should we index (can be modified)
1059 * @param client_info pointer to client context set upon creation (can be modified)
1060 * @return GNUNET_OK to continue, GNUNET_NO to remove
1061 * this entry from the directory, GNUNET_SYSERR
1062 * to abort the iteration
1063 */
1064static int
1065update_treeview_after_edit (void *cls, struct GNUNET_FS_FileInformation *fi,
1066 uint64_t length, struct GNUNET_CONTAINER_MetaData *meta,
1067 struct GNUNET_FS_Uri **uri,
1068 struct GNUNET_FS_BlockOptions *bo, int *do_index,
1069 void **client_info)
1070{
1071 struct EditPublishContext *epc = cls;
1072
1073 gtk_tree_store_set (GTK_TREE_STORE (epc->tm), &epc->iter,
1074 1, *do_index,
1075 3, (guint) bo->anonymity_level,
1076 4, (guint) bo->content_priority,
1077 6, (guint64) bo->expiration_time.abs_value,
1078 7, (guint) bo->replication_level,
1079 -1);
1080 return GNUNET_SYSERR;
1081}
1082
1083
1084/**
1046 * Function called when the edit publish dialog has been closed. 1085 * Function called when the edit publish dialog has been closed.
1047 * 1086 *
1048 * @param cls closure 1087 * @param cls closure
1049 * @param do_index index flag set?
1050 * @param short_fn short filename
1051 * @param bo block options for publishing
1052 * @param root always NULL here
1053 * @param ret GTK_RESPONSE_OK if the dialog was closed with "OK" 1088 * @param ret GTK_RESPONSE_OK if the dialog was closed with "OK"
1089 * @param root unused (namespace root name)
1054 */ 1090 */
1055static void 1091static void
1056master_publish_edit_publish_dialog_cb (gpointer cls, int do_index, 1092master_publish_edit_publish_dialog_cb (gpointer cls,
1057 const char *short_fn, 1093 gint ret,
1058 const struct GNUNET_FS_BlockOptions *bo, 1094 const char *root)
1059 const char *root,
1060 gint ret)
1061{ 1095{
1062 struct EditPublishContext *cbargs = cls; 1096 struct EditPublishContext *cbargs = cls;
1063 struct GNUNET_FS_FileInformation *fi;
1064 1097
1065 if (ret == GTK_RESPONSE_OK) 1098 if (ret == GTK_RESPONSE_OK)
1066 { 1099 GNUNET_FS_file_information_inspect (cbargs->fip, &update_treeview_after_edit, cbargs);
1067 gtk_tree_store_set (GTK_TREE_STORE (cbargs->tm), &cbargs->iter,
1068 1, do_index,
1069 2, short_fn,
1070 3, (guint) bo->anonymity_level,
1071 4, (guint) bo->content_priority,
1072 6, (guint64) bo->expiration_time.abs_value,
1073 7, (guint) bo->replication_level,
1074 -1);
1075 gtk_tree_model_get (cbargs->tm, &cbargs->iter, 5, &fi, -1);
1076 GNUNET_FS_file_information_set_filename (fi, short_fn);
1077 }
1078 GNUNET_free (cbargs); 1100 GNUNET_free (cbargs);
1079} 1101}
1080 1102
@@ -1084,8 +1106,6 @@ GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy,
1084 struct MainPublishingDialogContext *ctx) 1106 struct MainPublishingDialogContext *ctx)
1085{ 1107{
1086 struct EditPublishContext *cbargs; 1108 struct EditPublishContext *cbargs;
1087 char *short_fn;
1088 struct GNUNET_FS_FileInformation *fip;
1089 GtkListStore *anon_liststore; 1109 GtkListStore *anon_liststore;
1090 1110
1091 anon_liststore = GTK_LIST_STORE (gtk_builder_get_object (ctx->main_window_builder, 1111 anon_liststore = GTK_LIST_STORE (gtk_builder_get_object (ctx->main_window_builder,
@@ -1099,13 +1119,14 @@ GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy,
1099 return; 1119 return;
1100 } 1120 }
1101 gtk_tree_model_get (ctx->file_info_treemodel, &cbargs->iter, 1121 gtk_tree_model_get (ctx->file_info_treemodel, &cbargs->iter,
1102 2, &short_fn, 1122 5, &cbargs->fip,
1103 5, &fip,
1104 -1); 1123 -1);
1105 /* FIXME: can we just give our anon_liststore out like this? What about 1124 /* FIXME: can we just give our anon_liststore out like this? What about
1106 (unintended) sharing of state? */ 1125 (unintended) sharing of state? */
1107 GNUNET_FS_GTK_edit_publish_dialog (ctx->master_pubdialog, 1126 GNUNET_FS_GTK_edit_publish_dialog (ctx->master_pubdialog,
1108 short_fn, fip, TRUE, anon_liststore, 1127 cbargs->fip,
1128 GNUNET_YES,
1129 anon_liststore,
1109 &master_publish_edit_publish_dialog_cb, 1130 &master_publish_edit_publish_dialog_cb,
1110 cbargs); 1131 cbargs);
1111} 1132}