From b160144c9e0a24f8a53edce72a33adcd6df5652f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 2 Feb 2012 23:52:15 +0000 Subject: -misc --- src/fs/gnunet-fs-gtk_advertise-pseudonym.c | 2 +- src/fs/gnunet-fs-gtk_common.h | 2 +- src/fs/gnunet-fs-gtk_publish-dialog.c | 2 +- src/fs/gnunet-fs-gtk_publish-edit-dialog.c | 48 +++++++++++++++++++----------- src/fs/gnunet-fs-gtk_publish-edit-dialog.h | 8 ++--- src/fs/metatypes.c | 6 ++-- 6 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/fs/gnunet-fs-gtk_advertise-pseudonym.c b/src/fs/gnunet-fs-gtk_advertise-pseudonym.c index 17f98825..2af42833 100644 --- a/src/fs/gnunet-fs-gtk_advertise-pseudonym.c +++ b/src/fs/gnunet-fs-gtk_advertise-pseudonym.c @@ -187,7 +187,7 @@ GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog * dialog, GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_FS_GTK_edit_publish_dialog (transient, nds->fip, - GNUNET_NO, + GNUNET_YES, &adv_pseudonym_edit_publish_dialog_cb, nds); } diff --git a/src/fs/gnunet-fs-gtk_common.h b/src/fs/gnunet-fs-gtk_common.h index 3e88c364..98d4c5e2 100644 --- a/src/fs/gnunet-fs-gtk_common.h +++ b/src/fs/gnunet-fs-gtk_common.h @@ -46,7 +46,7 @@ GNUNET_FS_GTK_get_thumbnail_from_meta_data (const struct * Initialize the 'expiration_year_adjustment' of the given * builder to have a lower range of current-year+1 and a * default of current-year+2. - * FIXME: odd API... + * FIXME-STYLE: odd API... * * @param builder builder object for which we should manipulate * the adjustment diff --git a/src/fs/gnunet-fs-gtk_publish-dialog.c b/src/fs/gnunet-fs-gtk_publish-dialog.c index cb7e2c1e..c57ab9d8 100644 --- a/src/fs/gnunet-fs-gtk_publish-dialog.c +++ b/src/fs/gnunet-fs-gtk_publish-dialog.c @@ -1529,7 +1529,7 @@ GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, -1); GNUNET_FS_GTK_edit_publish_dialog (ctx->master_pubdialog, epc->fip, - GNUNET_YES, + GNUNET_NO, &master_publish_edit_publish_dialog_cb, epc); } 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 @@ -537,6 +537,27 @@ GNUNET_GTK_edit_publication_keyword_entry_changed_cb (GtkEditable * editable, } +/** + * Update the sensitivity of the 'confirm' button based on + * the availability of keywords and whether they are required or + * not. + * + * @param ctx the 'struct EditPublicationDialogContext' + */ +static void +update_confirm_sensitivity (struct EditPublicationDialogContext *ctx) +{ + GtkTreeIter iter; + + if ( (! ctx->allow_no_keywords) && + (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->keywords_liststore), + &iter)) ) + gtk_widget_set_sensitive (ctx->confirm_button, FALSE); + else + gtk_widget_set_sensitive (ctx->confirm_button, TRUE); +} + + /** * The user has pushed the 'del' button for the keyword. * If there is a keyword selected, remove it from the list store. @@ -563,10 +584,7 @@ GNUNET_GTK_edit_publication_keyword_list_del_button_clicked_cb (GtkButton * gtk_tree_selection_select_iter (keywords_selection, &iter); /* disable confirm button if keywords are required and we have no more keywords */ - if ( (! ctx->allow_no_keywords) && - (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->keywords_liststore), - &iter)) ) - gtk_widget_set_sensitive (ctx->confirm_button, FALSE); + update_confirm_sensitivity (ctx); } @@ -594,8 +612,8 @@ GNUNET_GTK_edit_publication_keyword_list_add_button_clicked_cb (GtkButton * 0, keyword, 1, TRUE, -1); - gtk_widget_set_sensitive (ctx->confirm_button, TRUE); gtk_entry_set_text (ctx->keyword_entry, ""); + update_confirm_sensitivity (ctx); } @@ -1005,16 +1023,16 @@ file_information_import (void *cls, * * @param parent parent window of the dialog * @param fip information about the file information that is to be edited - * @param allow_no_keywords is it OK to close the dialog without any keywords? - * also used to indicate that this is a namespace operation - * (FIXME-UNCLEAN: overloaded/badly-named argument) + * @param is_namespace_edit GNUNET_YES if we are editing a namespace advertisement; + * this means that keywords are required and that a "root" can be + * entered * @param cb function to call when the dialog is closed * @param cb_cls closure for 'cb' */ void GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, struct GNUNET_FS_FileInformation *fip, - int allow_no_keywords, + int is_namespace_edit, GNUNET_FS_GTK_EditPublishDialogCallback cb, gpointer cb_cls) { @@ -1030,7 +1048,7 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, ctx = GNUNET_malloc (sizeof (struct EditPublicationDialogContext)); ctx->fip = fip; ctx->preview_changed = GNUNET_NO; - ctx->allow_no_keywords = allow_no_keywords; + ctx->allow_no_keywords = is_namespace_edit ? GNUNET_NO : GNUNET_YES; ctx->is_directory = GNUNET_FS_file_information_is_directory (fip); ctx->cb = cb; ctx->cb_cls = cb_cls; @@ -1128,16 +1146,11 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, /* show root label only if we must have keywords, which is also only the case for namespaces (FIXME-UNCLEAN: overloaded use of the argument) */ gtk_widget_set_visible (GTK_WIDGET (ctx->root_entry), - !allow_no_keywords); + is_namespace_edit ? TRUE : FALSE); root_label = GTK_LABEL (gtk_builder_get_object (ctx->builder, "GNUNET_GTK_edit_publication_root_label")); gtk_widget_set_visible (GTK_WIDGET (root_label), - !allow_no_keywords); - - /* FIXME-UNCLEAN: what if we already have keywords? Again, does not really - apply to namespace-case, but this seems a bit ugly */ - gtk_widget_set_sensitive (ctx->confirm_button, allow_no_keywords ? TRUE : FALSE); - + is_namespace_edit ? TRUE : FALSE); /* FIXME-UNCLEAN: these signal handlers can be set by (modern) versions of Glade */ keywords_selection = gtk_tree_view_get_selection (ctx->keywords_treeview); @@ -1152,6 +1165,7 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, /* Finally, display window */ + update_confirm_sensitivity (ctx); gtk_window_set_transient_for (ctx->edit_publication_window, parent); gtk_window_present (ctx->edit_publication_window); } diff --git a/src/fs/gnunet-fs-gtk_publish-edit-dialog.h b/src/fs/gnunet-fs-gtk_publish-edit-dialog.h index 8ee7d52c..0635d058 100644 --- a/src/fs/gnunet-fs-gtk_publish-edit-dialog.h +++ b/src/fs/gnunet-fs-gtk_publish-edit-dialog.h @@ -47,16 +47,16 @@ typedef void (*GNUNET_FS_GTK_EditPublishDialogCallback) (gpointer cls, * * @param parent parent window of the dialog * @param fip information about the file information that is to be edited - * @param allow_no_keywords is it OK to close the dialog without any keywords? - * also used to indicate that this is a namespace operation - * (FIXME: overloaded/badly-named argument) + * @param is_namespace_edit GNUNET_YES if we are editing a namespace advertisement; + * this means that keywords are required and that a "root" can be + * entered * @param cb function to call when the dialog is closed * @param cb_cls closure for 'cb' */ void GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, struct GNUNET_FS_FileInformation *fip, - int allow_no_keywords, + int is_namespace_edit, GNUNET_FS_GTK_EditPublishDialogCallback cb, gpointer cls); diff --git a/src/fs/metatypes.c b/src/fs/metatypes.c index 5bc0af67..2b9185f4 100644 --- a/src/fs/metatypes.c +++ b/src/fs/metatypes.c @@ -219,9 +219,9 @@ gint types_software[] = /** - * Must match data in 'gnunet_fs_gt_main_window.glade'. FIXME: should - * probably move that name list in here and only have one place for - * both... + * Must match data in 'gnunet_fs_gt_main_window.glade'. + * FIXME-FEATURE-UNCLEAN-MAYBE: should probably move that name list in + * here and only have one place for both... */ gint *types[] = { types_generic, -- cgit v1.2.3