[shotwell] publishing: Remove reuse of string util functions



commit 9d2b698023366e95baddbb677118a50e27bd6e8e
Author: Jens Georg <mail jensge org>
Date:   Fri Jun 10 00:32:19 2016 +0200

    publishing: Remove reuse of string util functions
    
    Signed-off-by: Jens Georg <mail jensge org>

 plugins/shotwell-publishing-extras/Makefile        |    1 -
 .../RajcePublishing.vala                           |    5 +--
 .../TumblrPublishing.vala                          |   13 ++--------
 plugins/shotwell-publishing/Makefile               |    1 -
 plugins/shotwell-publishing/PiwigoPublishing.vala  |   25 +++++++------------
 5 files changed, 14 insertions(+), 31 deletions(-)
---
diff --git a/plugins/shotwell-publishing-extras/Makefile b/plugins/shotwell-publishing-extras/Makefile
index 91452cf..58ff6e3 100644
--- a/plugins/shotwell-publishing-extras/Makefile
+++ b/plugins/shotwell-publishing-extras/Makefile
@@ -16,7 +16,6 @@ SRC_FILES := \
        YandexPublishing.vala \
        TumblrPublishing.vala \
        RajcePublishing.vala \
-       ../../src/util/string.vala \
        ../common/RESTSupport.vala
 
 # RC_FILES must also be added to ../plugins.mk to ensure they're installed properly
diff --git a/plugins/shotwell-publishing-extras/RajcePublishing.vala 
b/plugins/shotwell-publishing-extras/RajcePublishing.vala
index 8ae05c6..1351251 100644
--- a/plugins/shotwell-publishing-extras/RajcePublishing.vala
+++ b/plugins/shotwell-publishing-extras/RajcePublishing.vala
@@ -932,9 +932,8 @@ internal class AuthenticationPane : Spit.Publishing.DialogPane, Object
     
     private void update_login_button_sensitivity()
        {
-        login_button.set_sensitive(
-            !is_string_empty(username_entry.get_text()) &&
-            !is_string_empty(password_entry.get_text())
+        login_button.set_sensitive(username_entry.text_length > 0 &&
+                                   password_entry.text_length > 0);
         );
     }
     
diff --git a/plugins/shotwell-publishing-extras/TumblrPublishing.vala 
b/plugins/shotwell-publishing-extras/TumblrPublishing.vala
index 0d6fbfb..9e17b4e 100644
--- a/plugins/shotwell-publishing-extras/TumblrPublishing.vala
+++ b/plugins/shotwell-publishing-extras/TumblrPublishing.vala
@@ -655,10 +655,8 @@ internal class AuthenticationPane : Spit.Publishing.DialogPane, Object {
     }
     
     private void update_login_button_sensitivity() {
-        login_button.set_sensitive(
-            !is_string_empty(username_entry.get_text()) &&
-            !is_string_empty(password_entry.get_text())
-        );
+        login_button.set_sensitive(username_entry.text_length > 0 &&
+                                   password_entry.text_length > 0);
     }
     
     public Gtk.Widget get_widget() {
@@ -953,12 +951,7 @@ internal class UploadTransaction : Publishing.RESTSupport.UploadTransaction {
                        string[] keywords = base.publishable.get_publishing_keywords();
                        string tags = "";
                        if (keywords != null) {
-                               foreach (string tag in keywords) {
-                               if (!is_string_empty(tags)) {
-                                       tags += ",";
-                               }
-                               tags += tag;
-                               }
+                tags = string.joinv (",", keywords);
                        }
                        add_argument("tags", Soup.URI.encode(tags, ENCODE_RFC_3986_EXTRA));
 
diff --git a/plugins/shotwell-publishing/Makefile b/plugins/shotwell-publishing/Makefile
index 6b3945b..830b7ca 100644
--- a/plugins/shotwell-publishing/Makefile
+++ b/plugins/shotwell-publishing/Makefile
@@ -18,7 +18,6 @@ SRC_FILES := \
        FlickrPublishing.vala \
        YouTubePublishing.vala \
        PiwigoPublishing.vala \
-       ../../src/util/string.vala \
        ../common/RESTSupport.vala
 
 RC_FILES := \
diff --git a/plugins/shotwell-publishing/PiwigoPublishing.vala 
b/plugins/shotwell-publishing/PiwigoPublishing.vala
index ff8ad1f..7dd9090 100644
--- a/plugins/shotwell-publishing/PiwigoPublishing.vala
+++ b/plugins/shotwell-publishing/PiwigoPublishing.vala
@@ -1082,11 +1082,9 @@ internal class AuthenticationPane : Spit.Publishing.DialogPane, Object {
     }
     
     private void update_login_button_sensitivity() {
-        login_button.set_sensitive(
-            !is_string_empty(url_entry.get_text()) &&
-            !is_string_empty(username_entry.get_text()) &&
-            !is_string_empty(password_entry.get_text())
-        );
+        login_button.set_sensitive(url_entry.text_length != 0 &&
+                                   username_entry.text_length != 0 &&
+                                   password_entry.text_length != 0);
     }
     
     public Gtk.Widget get_widget() {
@@ -1314,7 +1312,7 @@ internal class PublishingOptionsPane : Spit.Publishing.DialogPane, Object {
             !(
                 create_new_radio.get_active() &&
                 (
-                    is_string_empty(category_name) ||
+                    category_name != "" ||
                     category_already_exists(search_name)
                 )
             )
@@ -1658,12 +1656,7 @@ private class ImagesAddTransaction : Publishing.RESTSupport.UploadTransaction {
         string[] keywords = publishable.get_publishing_keywords();
         string tags = "";
         if (keywords != null) {
-            foreach (string tag in keywords) {
-                if (!is_string_empty(tags)) {
-                    tags += ",";
-                }
-                tags += tag;
-            }
+            tags = string.joinv (",", keywords);
         }
         
         debug("PiwigoConnector: Uploading photo %s to category id %d with perm level %d",
@@ -1672,16 +1665,16 @@ private class ImagesAddTransaction : Publishing.RESTSupport.UploadTransaction {
         string name = publishable.get_publishing_name();
         string comment = publishable.get_param_string(
             Spit.Publishing.Publishable.PARAM_STRING_COMMENT);
-        if (is_string_empty(name)) {
+        if (name != "") {
             name = publishable.get_param_string(
                 Spit.Publishing.Publishable.PARAM_STRING_BASENAME);
             add_argument("name", name);
-            if (!is_string_empty(comment)) {
+            if (comment != null && comment != "") {
                 add_argument("comment", comment);
             }
         } else {
             // name is set
-            if (!is_string_empty(comment)) {
+            if (comment != null && comment != "") {
                 add_argument("name", name);
                 add_argument("comment", comment);
             } else {
@@ -1699,7 +1692,7 @@ private class ImagesAddTransaction : Publishing.RESTSupport.UploadTransaction {
         add_argument("category", parameters.category.id.to_string());
         add_argument("level", parameters.perm_level.id.to_string());
         if (!parameters.no_upload_tags)
-            if (!is_string_empty(tags))
+            if (tags != "")
                 add_argument("tags", tags);
         // TODO: update the Publishable interface so that it gives access to
         // the image's meta-data where the author (artist) is kept


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]