diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk_publish-dialog.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk_publish-dialog.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/fs/gnunet-fs-gtk_publish-dialog.c b/src/fs/gnunet-fs-gtk_publish-dialog.c index 045ff3b8..aa25440a 100644 --- a/src/fs/gnunet-fs-gtk_publish-dialog.c +++ b/src/fs/gnunet-fs-gtk_publish-dialog.c | |||
@@ -775,7 +775,7 @@ GNUNET_GTK_master_publish_dialog_updateable_checkbox_toggled_cb ( | |||
775 | * Generates an update id from a new id. | 775 | * Generates an update id from a new id. |
776 | * | 776 | * |
777 | * @param new_text new id for which to generate update id. | 777 | * @param new_text new id for which to generate update id. |
778 | * @return new update id (free with g_free ()). | 778 | * @return new update id (free with g_free()). |
779 | */ | 779 | */ |
780 | static gchar * | 780 | static gchar * |
781 | generate_update_id (const gchar *new_text) | 781 | generate_update_id (const gchar *new_text) |
@@ -806,6 +806,7 @@ generate_update_id (const gchar *new_text) | |||
806 | return new_update_id; | 806 | return new_update_id; |
807 | } | 807 | } |
808 | 808 | ||
809 | |||
809 | /** | 810 | /** |
810 | * Checks whether existing update id was generated or not. | 811 | * Checks whether existing update id was generated or not. |
811 | * Generates an update id from the previous id, then checks if | 812 | * Generates an update id from the previous id, then checks if |
@@ -819,11 +820,14 @@ generate_update_id (const gchar *new_text) | |||
819 | * FALSE otherwise | 820 | * FALSE otherwise |
820 | */ | 821 | */ |
821 | static gboolean | 822 | static gboolean |
822 | update_id_is_autofilled (const gchar *existing_update_id, gchar *previous_id) | 823 | update_id_is_autofilled (const gchar *existing_update_id, |
824 | const gchar *previous_id) | ||
823 | { | 825 | { |
824 | gboolean result; | 826 | gboolean result; |
827 | gchar *gen_update_id; | ||
828 | |||
825 | result = TRUE; | 829 | result = TRUE; |
826 | gchar *gen_update_id = generate_update_id (previous_id); | 830 | gen_update_id = generate_update_id (previous_id); |
827 | if (0 != strcmp (gen_update_id, existing_update_id)) | 831 | if (0 != strcmp (gen_update_id, existing_update_id)) |
828 | result = FALSE; | 832 | result = FALSE; |
829 | g_free (gen_update_id); | 833 | g_free (gen_update_id); |
@@ -848,13 +852,17 @@ maybe_change_update_id (struct MainPublishingDialogContext *ctx, | |||
848 | new_update_id = NULL; | 852 | new_update_id = NULL; |
849 | existing_update_id = gtk_entry_get_text (GTK_ENTRY (ctx->update_id_entry)); | 853 | existing_update_id = gtk_entry_get_text (GTK_ENTRY (ctx->update_id_entry)); |
850 | 854 | ||
851 | if (((NULL == ctx->previous_id) && ('\0' == existing_update_id[0])) | 855 | if ( ( (NULL == ctx->previous_id) && |
852 | || update_id_is_autofilled (existing_update_id, ctx->previous_id)) | 856 | ('\0' == existing_update_id[0]) ) || |
857 | ( (NULL != ctx->previous_id) && | ||
858 | update_id_is_autofilled (existing_update_id, | ||
859 | ctx->previous_id) ) ) | ||
853 | new_update_id = generate_update_id (new_text); | 860 | new_update_id = generate_update_id (new_text); |
854 | if (new_update_id) | 861 | if (NULL != new_update_id) |
862 | { | ||
855 | gtk_entry_set_text (GTK_ENTRY (ctx->update_id_entry), new_update_id); | 863 | gtk_entry_set_text (GTK_ENTRY (ctx->update_id_entry), new_update_id); |
856 | g_free (new_update_id); | 864 | g_free (new_update_id); |
857 | 865 | } | |
858 | g_free (ctx->previous_id); | 866 | g_free (ctx->previous_id); |
859 | ctx->previous_id = g_strdup (new_text); | 867 | ctx->previous_id = g_strdup (new_text); |
860 | } | 868 | } |
@@ -866,17 +874,16 @@ maybe_change_update_id (struct MainPublishingDialogContext *ctx, | |||
866 | * Updates execute/cancel buttons sensitivity. | 874 | * Updates execute/cancel buttons sensitivity. |
867 | * | 875 | * |
868 | * @param widget the entry that was changed | 876 | * @param widget the entry that was changed |
869 | * @param user_data context | 877 | * @param user_data our `struct MainPublishingDialogContext` |
870 | */ | 878 | */ |
871 | void | 879 | void |
872 | GNUNET_GTK_master_publish_dialog_identifier_entry_changed_cb ( | 880 | GNUNET_GTK_master_publish_dialog_identifier_entry_changed_cb (GtkWidget *widget, |
873 | GtkWidget *widget, gpointer user_data) | 881 | gpointer user_data) |
874 | { | 882 | { |
875 | struct MainPublishingDialogContext *ctx = user_data; | 883 | struct MainPublishingDialogContext *ctx = user_data; |
876 | const gchar *new_text; | 884 | const gchar *new_text; |
877 | 885 | ||
878 | new_text = gtk_entry_get_text (GTK_ENTRY (widget)); | 886 | new_text = gtk_entry_get_text (GTK_ENTRY (widget)); |
879 | |||
880 | if (NULL == new_text) | 887 | if (NULL == new_text) |
881 | return; | 888 | return; |
882 | maybe_change_update_id (ctx, new_text); | 889 | maybe_change_update_id (ctx, new_text); |