aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk_publish-edit-dialog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk_publish-edit-dialog.c')
-rw-r--r--src/fs/gnunet-fs-gtk_publish-edit-dialog.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/src/fs/gnunet-fs-gtk_publish-edit-dialog.c b/src/fs/gnunet-fs-gtk_publish-edit-dialog.c
index d49396a1..0951b316 100644
--- a/src/fs/gnunet-fs-gtk_publish-edit-dialog.c
+++ b/src/fs/gnunet-fs-gtk_publish-edit-dialog.c
@@ -538,6 +538,27 @@ GNUNET_GTK_edit_publication_keyword_entry_changed_cb (GtkEditable * editable,
538 538
539 539
540/** 540/**
541 * Update the sensitivity of the 'confirm' button based on
542 * the availability of keywords and whether they are required or
543 * not.
544 *
545 * @param ctx the 'struct EditPublicationDialogContext'
546 */
547static void
548update_confirm_sensitivity (struct EditPublicationDialogContext *ctx)
549{
550 GtkTreeIter iter;
551
552 if ( (! ctx->allow_no_keywords) &&
553 (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->keywords_liststore),
554 &iter)) )
555 gtk_widget_set_sensitive (ctx->confirm_button, FALSE);
556 else
557 gtk_widget_set_sensitive (ctx->confirm_button, TRUE);
558}
559
560
561/**
541 * The user has pushed the 'del' button for the keyword. 562 * The user has pushed the 'del' button for the keyword.
542 * If there is a keyword selected, remove it from the list store. 563 * If there is a keyword selected, remove it from the list store.
543 * 564 *
@@ -563,10 +584,7 @@ GNUNET_GTK_edit_publication_keyword_list_del_button_clicked_cb (GtkButton *
563 gtk_tree_selection_select_iter (keywords_selection, &iter); 584 gtk_tree_selection_select_iter (keywords_selection, &iter);
564 585
565 /* disable confirm button if keywords are required and we have no more keywords */ 586 /* disable confirm button if keywords are required and we have no more keywords */
566 if ( (! ctx->allow_no_keywords) && 587 update_confirm_sensitivity (ctx);
567 (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->keywords_liststore),
568 &iter)) )
569 gtk_widget_set_sensitive (ctx->confirm_button, FALSE);
570} 588}
571 589
572 590
@@ -594,8 +612,8 @@ GNUNET_GTK_edit_publication_keyword_list_add_button_clicked_cb (GtkButton *
594 0, keyword, 612 0, keyword,
595 1, TRUE, 613 1, TRUE,
596 -1); 614 -1);
597 gtk_widget_set_sensitive (ctx->confirm_button, TRUE);
598 gtk_entry_set_text (ctx->keyword_entry, ""); 615 gtk_entry_set_text (ctx->keyword_entry, "");
616 update_confirm_sensitivity (ctx);
599} 617}
600 618
601 619
@@ -1005,16 +1023,16 @@ file_information_import (void *cls,
1005 * 1023 *
1006 * @param parent parent window of the dialog 1024 * @param parent parent window of the dialog
1007 * @param fip information about the file information that is to be edited 1025 * @param fip information about the file information that is to be edited
1008 * @param allow_no_keywords is it OK to close the dialog without any keywords? 1026 * @param is_namespace_edit GNUNET_YES if we are editing a namespace advertisement;
1009 * also used to indicate that this is a namespace operation 1027 * this means that keywords are required and that a "root" can be
1010 * (FIXME-UNCLEAN: overloaded/badly-named argument) 1028 * entered
1011 * @param cb function to call when the dialog is closed 1029 * @param cb function to call when the dialog is closed
1012 * @param cb_cls closure for 'cb' 1030 * @param cb_cls closure for 'cb'
1013 */ 1031 */
1014void 1032void
1015GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, 1033GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent,
1016 struct GNUNET_FS_FileInformation *fip, 1034 struct GNUNET_FS_FileInformation *fip,
1017 int allow_no_keywords, 1035 int is_namespace_edit,
1018 GNUNET_FS_GTK_EditPublishDialogCallback cb, 1036 GNUNET_FS_GTK_EditPublishDialogCallback cb,
1019 gpointer cb_cls) 1037 gpointer cb_cls)
1020{ 1038{
@@ -1030,7 +1048,7 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent,
1030 ctx = GNUNET_malloc (sizeof (struct EditPublicationDialogContext)); 1048 ctx = GNUNET_malloc (sizeof (struct EditPublicationDialogContext));
1031 ctx->fip = fip; 1049 ctx->fip = fip;
1032 ctx->preview_changed = GNUNET_NO; 1050 ctx->preview_changed = GNUNET_NO;
1033 ctx->allow_no_keywords = allow_no_keywords; 1051 ctx->allow_no_keywords = is_namespace_edit ? GNUNET_NO : GNUNET_YES;
1034 ctx->is_directory = GNUNET_FS_file_information_is_directory (fip); 1052 ctx->is_directory = GNUNET_FS_file_information_is_directory (fip);
1035 ctx->cb = cb; 1053 ctx->cb = cb;
1036 ctx->cb_cls = cb_cls; 1054 ctx->cb_cls = cb_cls;
@@ -1128,16 +1146,11 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent,
1128 /* show root label only if we must have keywords, which is also only the 1146 /* show root label only if we must have keywords, which is also only the
1129 case for namespaces (FIXME-UNCLEAN: overloaded use of the argument) */ 1147 case for namespaces (FIXME-UNCLEAN: overloaded use of the argument) */
1130 gtk_widget_set_visible (GTK_WIDGET (ctx->root_entry), 1148 gtk_widget_set_visible (GTK_WIDGET (ctx->root_entry),
1131 !allow_no_keywords); 1149 is_namespace_edit ? TRUE : FALSE);
1132 root_label = GTK_LABEL (gtk_builder_get_object 1150 root_label = GTK_LABEL (gtk_builder_get_object
1133 (ctx->builder, "GNUNET_GTK_edit_publication_root_label")); 1151 (ctx->builder, "GNUNET_GTK_edit_publication_root_label"));
1134 gtk_widget_set_visible (GTK_WIDGET (root_label), 1152 gtk_widget_set_visible (GTK_WIDGET (root_label),
1135 !allow_no_keywords); 1153 is_namespace_edit ? TRUE : FALSE);
1136
1137 /* FIXME-UNCLEAN: what if we already have keywords? Again, does not really
1138 apply to namespace-case, but this seems a bit ugly */
1139 gtk_widget_set_sensitive (ctx->confirm_button, allow_no_keywords ? TRUE : FALSE);
1140
1141 1154
1142 /* FIXME-UNCLEAN: these signal handlers can be set by (modern) versions of Glade */ 1155 /* FIXME-UNCLEAN: these signal handlers can be set by (modern) versions of Glade */
1143 keywords_selection = gtk_tree_view_get_selection (ctx->keywords_treeview); 1156 keywords_selection = gtk_tree_view_get_selection (ctx->keywords_treeview);
@@ -1152,6 +1165,7 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent,
1152 1165
1153 1166
1154 /* Finally, display window */ 1167 /* Finally, display window */
1168 update_confirm_sensitivity (ctx);
1155 gtk_window_set_transient_for (ctx->edit_publication_window, parent); 1169 gtk_window_set_transient_for (ctx->edit_publication_window, parent);
1156 gtk_window_present (ctx->edit_publication_window); 1170 gtk_window_present (ctx->edit_publication_window);
1157} 1171}