[Xfce4-commits] [apps/xfce4-screenshooter] 01/01: Refactor the tons of copypasted code between screenshooter-imgur.c and screenshooter-zimagez.c

noreply at xfce.org noreply at xfce.org
Wed Dec 17 00:04:01 CET 2014


This is an automated email from the git hooks/post-receive script.

landry pushed a commit to branch master
in repository apps/xfce4-screenshooter.

commit 26f89ff582cd604bb99a4f1d914d4e59dbec00ae
Author: Landry Breuil <landry at xfce.org>
Date:   Wed Dec 17 00:00:17 2014 +0100

    Refactor the tons of copypasted code between screenshooter-imgur.c and screenshooter-zimagez.c
    
    - move common callbacks to screenshooter-job-callbacks.c
    - only pass screenshot name and title to screenshooter_upload_to_imgur
    - set a jobtype property on the job gobject to figure out if we need to show imgur or zimagez urls
    - add a create_throbber_dialog function to build the dialog displayed during upload
    
    Finally, screenshooter-imgur.c and screenshooter-zimagez.c only have the upload-related code.
---
 Makefile.am                                        |    1 +
 lib/screenshooter-actions.c                        |   11 +-
 lib/screenshooter-imgur.c                          |  358 +----------
 lib/screenshooter-imgur.h                          |    5 +-
 ...ooter-imgur.c => screenshooter-job-callbacks.c} |  641 +++++++++++---------
 lib/screenshooter-job-callbacks.h                  |   63 ++
 lib/screenshooter-zimagez.c                        |  567 +----------------
 7 files changed, 440 insertions(+), 1206 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index d6d78d5..a22fc20 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,6 +31,7 @@ lib_libscreenshooter_la_SOURCES =	\
   lib/screenshooter-dialogs.c lib/screenshooter-dialogs.h \
 	lib/screenshooter-global.h \
 	lib/screenshooter-job.c lib/screenshooter-job.h \
+	lib/screenshooter-job-callbacks.c lib/screenshooter-job-callbacks.h \
 	lib/screenshooter-simple-job.c lib/screenshooter-simple-job.h \
 	lib/screenshooter-utils.c lib/screenshooter-utils.h \
 	lib/screenshooter-imgur.c lib/screenshooter-imgur.h \
diff --git a/lib/screenshooter-actions.c b/lib/screenshooter-actions.c
index 76fcc69..43ee4e2 100644
--- a/lib/screenshooter-actions.c
+++ b/lib/screenshooter-actions.c
@@ -125,17 +125,8 @@ gboolean screenshooter_action_idle (ScreenshotData *sd)
           if (sd->action == OPEN)
             screenshooter_open_screenshot (screenshot_path, sd->app);
           else if (sd->action == UPLOAD_IMGUR) {
-              gchar *new_last_user = NULL;
-
               screenshooter_upload_to_imgur   (screenshot_path,
-                                               sd->last_user,
-                                               sd->title,
-                                               &new_last_user);
-              if (new_last_user)
-                {
-                  g_free (sd->last_user);
-                  sd->last_user = new_last_user;
-                }
+                                               sd->title);
             }
           else
             {
diff --git a/lib/screenshooter-imgur.c b/lib/screenshooter-imgur.c
index f8cecb2..c249eb9 100644
--- a/lib/screenshooter-imgur.c
+++ b/lib/screenshooter-imgur.c
@@ -19,33 +19,20 @@
 
 
 #include "screenshooter-imgur.h"
+#include "screenshooter-job-callbacks.h"
 #include <string.h>
 #include <stdlib.h>
 #include <libsoup/soup.h>
 #include <libxml/parser.h>
 
-static ScreenshooterJob *imgur_upload_to_imgur     (const gchar       *file_name,
-                                                    const gchar       *last_user,
-                                                    const gchar       *title);
 static gboolean          imgur_upload_job          (ScreenshooterJob  *job,
                                                     GValueArray       *param_values,
                                                     GError           **error);
-static void              cb_image_uploaded         (ScreenshooterJob  *job,
-                                                    gchar             *upload_name,
-                                                    gchar            **last_user);
-static void              cb_error                  (ExoJob            *job,
-                                                    GError            *error,
-                                                    gpointer           unused);
-static void              cb_finished               (ExoJob            *job,
-                                                    GtkWidget         *dialog);
-static void              cb_update_info            (ExoJob            *job,
-                                                    gchar             *message,
-                                                    GtkWidget         *label);
 
 static gboolean
 imgur_upload_job (ScreenshooterJob *job, GValueArray *param_values, GError **error)
 {
-  const gchar *image_path;
+  const gchar *image_path, *title;
   gchar *online_file_name = NULL;
   gchar* proxy_uri;
   SoupURI *soup_proxy_uri;
@@ -67,15 +54,18 @@ imgur_upload_job (ScreenshooterJob *job, GValueArray *param_values, GError **err
 
   g_return_val_if_fail (SCREENSHOOTER_IS_JOB (job), FALSE);
   g_return_val_if_fail (param_values != NULL, FALSE);
-  g_return_val_if_fail (param_values->n_values == 1, FALSE);
+  g_return_val_if_fail (param_values->n_values == 2, FALSE);
   g_return_val_if_fail (G_VALUE_HOLDS_STRING (&param_values->values[0]), FALSE);
+  g_return_val_if_fail (G_VALUE_HOLDS_STRING (&param_values->values[1]), FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
+  g_object_set_data (G_OBJECT (job), "jobtype", "imgur");
   if (exo_job_set_error_if_cancelled (EXO_JOB (job), error))
     return FALSE;
 
 
   image_path = g_value_get_string (g_value_array_get_nth (param_values, 0));
+  title = g_value_get_string (g_value_array_get_nth (param_values, 1));
 
   session = soup_session_sync_new ();
 #if DEBUG > 0
@@ -106,8 +96,8 @@ imgur_upload_job (ScreenshooterJob *job, GValueArray *param_values, GError **err
                                     mapping, (GDestroyNotify)g_mapped_file_unref);
 
   soup_multipart_append_form_file (mp, "image", NULL, NULL, buf);
-  soup_multipart_append_form_string (mp, "name", "Screenshot");
-  soup_multipart_append_form_string (mp, "title", "Screenshot");
+  soup_multipart_append_form_string (mp, "name", title);
+  soup_multipart_append_form_string (mp, "title", title);
   msg = soup_form_request_new_from_multipart (upload_url, mp);
 
   // for v3 API - key registered *only* for xfce4-screenshooter!
@@ -151,258 +141,6 @@ imgur_upload_job (ScreenshooterJob *job, GValueArray *param_values, GError **err
 }
 
 
-
-static ScreenshooterJob
-*imgur_upload_to_imgur (const gchar *file_path,
-                            const gchar *last_user,
-                            const gchar *title)
-{
-  g_return_val_if_fail (file_path != NULL, NULL);
-
-  return screenshooter_simple_job_launch (imgur_upload_job, 1,
-                                          G_TYPE_STRING, file_path);
-}
-
-
-
-static void cb_image_uploaded (ScreenshooterJob  *job,
-                               gchar             *upload_name,
-                               gchar            **last_user)
-{
-  GtkWidget *dialog;
-  GtkWidget *main_alignment, *vbox;
-  GtkWidget *link_label;
-  GtkWidget *image_link, *thumbnail_link, *small_thumbnail_link;
-  GtkWidget *example_label, *html_label, *bb_label;
-  GtkWidget *html_code_view, *bb_code_view;
-  GtkWidget *html_frame, *bb_frame;
-  GtkWidget *links_alignment, *code_alignment;
-  GtkWidget *links_box, *code_box;
-
-  GtkTextBuffer *html_buffer, *bb_buffer;
-
-  const gchar *image_url, *thumbnail_url, *small_thumbnail_url;
-  const gchar *image_markup, *thumbnail_markup, *small_thumbnail_markup;
-  const gchar *html_code, *bb_code;
-
-  gchar *last_user_temp;
-
-  g_return_if_fail (upload_name != NULL);
-  g_return_if_fail (last_user == NULL || *last_user == NULL);
-
-  image_url = g_strdup_printf ("http://i.imgur.com/%s.png", upload_name);
-  thumbnail_url =
-    g_strdup_printf ("http://imgur.com/%sl.png", upload_name);
-  small_thumbnail_url =
-    g_strdup_printf ("http://imgur.com/%ss.png", upload_name);
-  image_markup =
-    g_markup_printf_escaped (_("<a href=\"%s\">Full size image</a>"), image_url);
-  thumbnail_markup =
-    g_markup_printf_escaped (_("<a href=\"%s\">Large thumbnail</a>"), thumbnail_url);
-  small_thumbnail_markup =
-    g_markup_printf_escaped (_("<a href=\"%s\">Small thumbnail</a>"), small_thumbnail_url);
-  html_code =
-    g_markup_printf_escaped ("<a href=\"%s\">\n  <img src=\"%s\" />\n</a>",
-                     image_url, thumbnail_url);
-  bb_code =
-    g_strdup_printf ("[url=%s]\n  [img]%s[/img]\n[/url]", image_url, thumbnail_url);
-
-  last_user_temp = g_object_get_data (G_OBJECT (job), "user");
-
-  if (last_user_temp == NULL)
-    last_user_temp = g_strdup ("");
-
-  *last_user = g_strdup (last_user_temp);
-
-  /* Dialog */
-  dialog =
-    xfce_titled_dialog_new_with_buttons (_("My screenshot on Imgur"),
-                                         NULL,
-                                         GTK_DIALOG_NO_SEPARATOR,
-                                         GTK_STOCK_CLOSE,
-                                         GTK_RESPONSE_CLOSE,
-                                         NULL);
-
-  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
-  gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 0);
-  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 12);
-  gtk_window_set_icon_name (GTK_WINDOW (dialog), "applications-internet");
-  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
-  /* Create the main alignment for the dialog */
-  main_alignment = gtk_alignment_new (0, 0, 1, 1);
-  gtk_alignment_set_padding (GTK_ALIGNMENT (main_alignment), 6, 0, 10, 10);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_alignment, TRUE, TRUE, 0);
-
-  /* Create the main box for the dialog */
-  vbox = gtk_vbox_new (FALSE, 10);
-  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
-  gtk_container_add (GTK_CONTAINER (main_alignment), vbox);
-
-  /* Links bold label */
-  link_label = gtk_label_new ("");
-  gtk_label_set_markup (GTK_LABEL (link_label),
-                        _("<span weight=\"bold\" stretch=\"semiexpanded\">"
-                          "Links</span>"));
-  gtk_misc_set_alignment (GTK_MISC (link_label), 0, 0);
-  gtk_container_add (GTK_CONTAINER (vbox), link_label);
-
-  /* Links alignment */
-  links_alignment = gtk_alignment_new (0, 0, 1, 1);
-  gtk_alignment_set_padding (GTK_ALIGNMENT (links_alignment), 0, 0, 12, 0);
-  gtk_container_add (GTK_CONTAINER (vbox), links_alignment);
-
-  /* Links box */
-  links_box = gtk_vbox_new (FALSE, 10);
-  gtk_container_set_border_width (GTK_CONTAINER (links_box), 0);
-  gtk_container_add (GTK_CONTAINER (links_alignment), links_box);
-
-  /* Create the image link */
-  image_link = gtk_label_new (NULL);
-  gtk_label_set_markup (GTK_LABEL (image_link), image_markup);
-  gtk_misc_set_alignment (GTK_MISC (image_link), 0, 0);
-  gtk_widget_set_tooltip_text (image_link, image_url);
-  gtk_container_add (GTK_CONTAINER (links_box), image_link);
-
-  /* Create the thumbnail link */
-  thumbnail_link = gtk_label_new (NULL);
-  gtk_label_set_markup (GTK_LABEL (thumbnail_link), thumbnail_markup);
-  gtk_misc_set_alignment (GTK_MISC (thumbnail_link), 0, 0);
-  gtk_widget_set_tooltip_text (thumbnail_link, thumbnail_url);
-  gtk_container_add (GTK_CONTAINER (links_box), thumbnail_link);
-
-  /* Create the small thumbnail link */
-  small_thumbnail_link = gtk_label_new (NULL);
-  gtk_label_set_markup (GTK_LABEL (small_thumbnail_link), small_thumbnail_markup);
-  gtk_misc_set_alignment (GTK_MISC (small_thumbnail_link), 0, 0);
-  gtk_widget_set_tooltip_text (small_thumbnail_link, small_thumbnail_url);
-  gtk_container_add (GTK_CONTAINER (links_box), small_thumbnail_link);
-
-  /* Examples bold label */
-  example_label = gtk_label_new ("");
-  gtk_label_set_markup (GTK_LABEL (example_label),
-                        _("<span weight=\"bold\" stretch=\"semiexpanded\">"
-                          "Code for a thumbnail pointing to the full size image</span>"));
-  gtk_misc_set_alignment (GTK_MISC (example_label), 0, 0);
-  gtk_container_add (GTK_CONTAINER (vbox), example_label);
-
-  /* Code alignment */
-  code_alignment = gtk_alignment_new (0, 0, 1, 1);
-  gtk_alignment_set_padding (GTK_ALIGNMENT (code_alignment), 0, 0, 12, 0);
-  gtk_container_add (GTK_CONTAINER (vbox), code_alignment);
-
-  /* Links box */
-  code_box = gtk_vbox_new (FALSE, 10);
-  gtk_container_set_border_width (GTK_CONTAINER (code_box), 0);
-  gtk_container_add (GTK_CONTAINER (code_alignment), code_box);
-
-  /* HTML title */
-  html_label = gtk_label_new (_("HTML"));
-  gtk_misc_set_alignment (GTK_MISC (html_label), 0, 0);
-  gtk_container_add (GTK_CONTAINER (code_box), html_label);
-
-  /* HTML frame */
-  html_frame = gtk_frame_new (NULL);
-  gtk_frame_set_shadow_type (GTK_FRAME (html_frame), GTK_SHADOW_IN);
-  gtk_container_add (GTK_CONTAINER (code_box), html_frame);
-
-  /* HTML code text view */
-  html_buffer = gtk_text_buffer_new (NULL);
-  gtk_text_buffer_set_text (html_buffer, html_code, -1);
-
-  html_code_view = gtk_text_view_new_with_buffer (html_buffer);
-  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (html_code_view),
-                                 10);
-  gtk_text_view_set_editable (GTK_TEXT_VIEW (html_code_view),
-                              FALSE);
-  gtk_container_add (GTK_CONTAINER (html_frame), html_code_view);
-
-  /* BB title */
-  bb_label = gtk_label_new (_("BBCode for forums"));
-  gtk_misc_set_alignment (GTK_MISC (bb_label), 0, 0);
-  gtk_container_add (GTK_CONTAINER (code_box), bb_label);
-
-  /* BB frame */
-  bb_frame = gtk_frame_new (NULL);
-  gtk_frame_set_shadow_type (GTK_FRAME (bb_frame), GTK_SHADOW_IN);
-  gtk_container_add (GTK_CONTAINER (code_box), bb_frame);
-
-  /* BBcode text view */
-  bb_buffer = gtk_text_buffer_new (NULL);
-  gtk_text_buffer_set_text (bb_buffer, bb_code, -1);
-
-  bb_code_view = gtk_text_view_new_with_buffer (bb_buffer);
-  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (bb_code_view),
-                                 10);
-  gtk_text_view_set_editable (GTK_TEXT_VIEW (bb_code_view),
-                              FALSE);
-  gtk_container_add (GTK_CONTAINER (bb_frame), bb_code_view);
-
-  /* Show the dialog and run it */
-  gtk_widget_show_all (GTK_DIALOG(dialog)->vbox);
-  gtk_dialog_run (GTK_DIALOG (dialog));
-  gtk_widget_destroy (dialog);
-
-  g_object_unref (html_buffer);
-  g_object_unref (bb_buffer);
-}
-
-
-
-static void cb_error (ExoJob *job, GError *error, gpointer unused)
-{
-  g_return_if_fail (error != NULL);
-
-  screenshooter_error ("%s", error->message);
-}
-
-
-
-static void cb_finished (ExoJob *job, GtkWidget *dialog)
-{
-  g_return_if_fail (EXO_IS_JOB (job));
-  g_return_if_fail (GTK_IS_DIALOG (dialog));
-
-  g_signal_handlers_disconnect_matched (job,
-                                        G_SIGNAL_MATCH_FUNC,
-                                        0, 0, NULL,
-                                        cb_image_uploaded,
-                                        NULL);
-
-  g_signal_handlers_disconnect_matched (job,
-                                        G_SIGNAL_MATCH_FUNC,
-                                        0, 0, NULL,
-                                        cb_error,
-                                        NULL);
-
-  g_signal_handlers_disconnect_matched (job,
-                                        G_SIGNAL_MATCH_FUNC,
-                                        0, 0, NULL,
-                                        cb_update_info,
-                                        NULL);
-
-  g_signal_handlers_disconnect_matched (job,
-                                        G_SIGNAL_MATCH_FUNC,
-                                        0, 0, NULL,
-                                        cb_finished,
-                                        NULL);
-
-  g_object_unref (G_OBJECT (job));
-  gtk_widget_destroy (dialog);
-}
-
-
-
-static void cb_update_info (ExoJob *job, gchar *message, GtkWidget *label)
-{
-  g_return_if_fail (EXO_IS_JOB (job));
-  g_return_if_fail (GTK_IS_LABEL (label));
-
-  gtk_label_set_text (GTK_LABEL (label), message);
-}
-
-
-
 /* Public */
 
 
@@ -411,83 +149,27 @@ static void cb_update_info (ExoJob *job, gchar *message, GtkWidget *label)
  * screenshooter_upload_to_imgur:
  * @image_path: the local path of the image that should be uploaded to
  * imgur.com.
- * @last_user: the last user name used, to pre-fill the user field.
- * @title: a default title, to pre-fill the title field.
- * @new_last_user: address of the string used to store the new user
- * if the upload is succesful.
  *
- * Uploads the image whose path is @image_path: a dialog asks for the user
- * login, password, a title for the image and a comment; then the image is
- * uploaded. The dialog is shown again with a warning is the password did
- * not match the user name. The user can also cancel the upload procedure.
- *
- * If the upload was succesful, @new_last_user points to the user name for
- * which the upload was done.
+ * Uploads the image whose path is @image_path
  *
  **/
 
 void screenshooter_upload_to_imgur   (const gchar  *image_path,
-                                      const gchar  *last_user,
-                                      const gchar  *title,
-                                      gchar       **new_last_user)
+                                      const gchar  *title)
 {
   ScreenshooterJob *job;
-  GtkWidget *dialog;
-  GtkWidget *label, *status_label;
-  GtkWidget *hbox, *throbber;
-  GtkWidget *main_box, *main_alignment;
+  GtkWidget *dialog, *label;
 
   g_return_if_fail (image_path != NULL);
-  g_return_if_fail (new_last_user == NULL || *new_last_user == NULL);
-
-  dialog =
-    gtk_dialog_new_with_buttons (_("Imgur"),
-                                 NULL,
-                                 GTK_DIALOG_NO_SEPARATOR,
-                                 NULL);
-
-  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
-  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 0);
-  gtk_window_set_deletable (GTK_WINDOW (dialog), FALSE);
-  gtk_window_set_icon_name (GTK_WINDOW (dialog), "gtk-info");
-
-  /* Create the main alignment for the dialog */
-  main_alignment = gtk_alignment_new (0, 0, 1, 1);
-  gtk_alignment_set_padding (GTK_ALIGNMENT (main_alignment), 0, 0, 6, 6);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_alignment, TRUE, TRUE, 0);
-
-  /* Create the main box for the dialog */
-  main_box = gtk_vbox_new (FALSE, 10);
-  gtk_container_set_border_width (GTK_CONTAINER (main_box), 12);
-  gtk_container_add (GTK_CONTAINER (main_alignment), main_box);
-
-  /* Top horizontal box for the throbber */
-  hbox= gtk_hbox_new (FALSE, 0);
-  gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
-  gtk_container_add (GTK_CONTAINER (main_box), hbox);
-
-  /* Add the throbber */
-  throbber = katze_throbber_new ();
-  katze_throbber_set_animated (KATZE_THROBBER (throbber), TRUE);
-  gtk_box_pack_end (GTK_BOX (hbox), throbber, FALSE, FALSE, 0);
-
-  /* Status label*/
-  status_label = gtk_label_new ("");
-  gtk_label_set_markup (GTK_LABEL (status_label),
-                        _("<span weight=\"bold\" stretch=\"semiexpanded\">"
-                          "Status</span>"));
-  gtk_misc_set_alignment (GTK_MISC (status_label), 0, 0);
-  gtk_box_pack_start (GTK_BOX (hbox), status_label, FALSE, FALSE, 0);
-
-  /* Information label */
-  label = gtk_label_new ("");
-  gtk_container_add (GTK_CONTAINER (main_box), label);
-
-  gtk_widget_show_all (GTK_DIALOG(dialog)->vbox);
-
-  job = imgur_upload_to_imgur (image_path, last_user, title);
-
-  g_signal_connect (job, "image-uploaded", G_CALLBACK (cb_image_uploaded), new_last_user);
+
+  dialog = create_throbber_dialog(_("Imgur"), &label);
+
+  job = screenshooter_simple_job_launch (imgur_upload_job, 2,
+                                          G_TYPE_STRING, image_path,
+                                          G_TYPE_STRING, title);
+
+  g_signal_connect (job, "ask", G_CALLBACK (cb_ask_for_information), NULL);
+  g_signal_connect (job, "image-uploaded", G_CALLBACK (cb_image_uploaded), NULL);
   g_signal_connect (job, "error", G_CALLBACK (cb_error), NULL);
   g_signal_connect (job, "finished", G_CALLBACK (cb_finished), dialog);
   g_signal_connect (job, "info-message", G_CALLBACK (cb_update_info), label);
diff --git a/lib/screenshooter-imgur.h b/lib/screenshooter-imgur.h
index 47e233e..b1bb88c 100644
--- a/lib/screenshooter-imgur.h
+++ b/lib/screenshooter-imgur.h
@@ -32,9 +32,6 @@
 #include "katze-throbber.h"
 
 void screenshooter_upload_to_imgur (const gchar  *image_path,
-                                    const gchar  *last_user,
-                                    const gchar  *title,
-                                    gchar       **new_last_user);
-
+                                    const gchar  *title);
 
 #endif
diff --git a/lib/screenshooter-imgur.c b/lib/screenshooter-job-callbacks.c
similarity index 51%
copy from lib/screenshooter-imgur.c
copy to lib/screenshooter-job-callbacks.c
index f8cecb2..b24232d 100644
--- a/lib/screenshooter-imgur.c
+++ b/lib/screenshooter-job-callbacks.c
@@ -1,6 +1,6 @@
 /*  $Id$
  *
- *  Copyright © 2009-2010 Sebastian Waisbrot <seppo0010 at gmail.com>
+ *  Copyright © 2008-2010 Jérôme Guelfucci <jeromeg at xfce.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -15,159 +15,344 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * */
-
-
-#include "screenshooter-imgur.h"
-#include <string.h>
-#include <stdlib.h>
-#include <libsoup/soup.h>
-#include <libxml/parser.h>
-
-static ScreenshooterJob *imgur_upload_to_imgur     (const gchar       *file_name,
-                                                    const gchar       *last_user,
-                                                    const gchar       *title);
-static gboolean          imgur_upload_job          (ScreenshooterJob  *job,
-                                                    GValueArray       *param_values,
-                                                    GError           **error);
-static void              cb_image_uploaded         (ScreenshooterJob  *job,
-                                                    gchar             *upload_name,
-                                                    gchar            **last_user);
-static void              cb_error                  (ExoJob            *job,
-                                                    GError            *error,
-                                                    gpointer           unused);
-static void              cb_finished               (ExoJob            *job,
-                                                    GtkWidget         *dialog);
-static void              cb_update_info            (ExoJob            *job,
-                                                    gchar             *message,
-                                                    GtkWidget         *label);
-
-static gboolean
-imgur_upload_job (ScreenshooterJob *job, GValueArray *param_values, GError **error)
+ */
+
+#include "screenshooter-job-callbacks.h"
+
+/* Create and return a dialog with a throbber and a translated title
+ * will be used during upload jobs
+ */
+
+GtkWidget *
+create_throbber_dialog             (const gchar        *title,
+                                    GtkWidget         **label)
 {
-  const gchar *image_path;
-  gchar *online_file_name = NULL;
-  gchar* proxy_uri;
-  SoupURI *soup_proxy_uri;
-#if DEBUG > 0
-  SoupLogger *log;
-#endif
-  guint status;
-  SoupSession *session;
-  SoupMessage *msg;
-  SoupBuffer *buf;
-  GMappedFile *mapping;
-  SoupMultipart *mp;
-  xmlDoc *doc;
-  xmlNode *root_node, *child_node;
-
-  const gchar *upload_url = "https://api.imgur.com/3/upload.xml";
-
-  GError *tmp_error = NULL;
-
-  g_return_val_if_fail (SCREENSHOOTER_IS_JOB (job), FALSE);
-  g_return_val_if_fail (param_values != NULL, FALSE);
-  g_return_val_if_fail (param_values->n_values == 1, FALSE);
-  g_return_val_if_fail (G_VALUE_HOLDS_STRING (&param_values->values[0]), FALSE);
-  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
-  if (exo_job_set_error_if_cancelled (EXO_JOB (job), error))
-    return FALSE;
-
-
-  image_path = g_value_get_string (g_value_array_get_nth (param_values, 0));
-
-  session = soup_session_sync_new ();
-#if DEBUG > 0
-  log = soup_logger_new (SOUP_LOGGER_LOG_HEADERS, -1);
-  soup_session_add_feature (session, (SoupSessionFeature *)log);
-#endif
-
-  /* Set the proxy URI if any */
-  proxy_uri = g_getenv ("http_proxy");
-
-  if (proxy_uri != NULL)
-    {
-      soup_proxy_uri = soup_uri_new (proxy_uri);
-      g_object_set (session, "proxy-uri", soup_proxy_uri, NULL);
-      soup_uri_free (soup_proxy_uri);
-    }
+  GtkWidget *dialog;
+  GtkWidget *status_label;
+  GtkWidget *hbox, *throbber;
+  GtkWidget *main_box, *main_alignment;
 
-  mapping = g_mapped_file_new(image_path, FALSE, NULL);
-  if (!mapping) {
-    g_object_unref (session);
+  dialog = gtk_dialog_new_with_buttons (title,
+                                 NULL,
+                                 GTK_DIALOG_NO_SEPARATOR,
+                                 NULL);
 
-    return FALSE;
-  }
+  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
+  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 0);
+  gtk_window_set_deletable (GTK_WINDOW (dialog), FALSE);
+  gtk_window_set_icon_name (GTK_WINDOW (dialog), "gtk-info");
 
-  mp = soup_multipart_new(SOUP_FORM_MIME_TYPE_MULTIPART);
-  buf = soup_buffer_new_with_owner (g_mapped_file_get_contents (mapping),
-                                    g_mapped_file_get_length (mapping),
-                                    mapping, (GDestroyNotify)g_mapped_file_unref);
+  /* Create the main alignment for the dialog */
+  main_alignment = gtk_alignment_new (0, 0, 1, 1);
+  gtk_alignment_set_padding (GTK_ALIGNMENT (main_alignment), 0, 0, 6, 6);
+  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_alignment, TRUE, TRUE, 0);
 
-  soup_multipart_append_form_file (mp, "image", NULL, NULL, buf);
-  soup_multipart_append_form_string (mp, "name", "Screenshot");
-  soup_multipart_append_form_string (mp, "title", "Screenshot");
-  msg = soup_form_request_new_from_multipart (upload_url, mp);
+  /* Create the main box for the dialog */
+  main_box = gtk_vbox_new (FALSE, 10);
+  gtk_container_set_border_width (GTK_CONTAINER (main_box), 12);
+  gtk_container_add (GTK_CONTAINER (main_alignment), main_box);
 
-  // for v3 API - key registered *only* for xfce4-screenshooter!
-  soup_message_headers_append (msg->request_headers, "Authorization", "Client-ID 66ab680b597e293");
-  status = soup_session_send_message (session, msg);
+  /* Top horizontal box for the throbber */
+  hbox= gtk_hbox_new (FALSE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
+  gtk_container_add (GTK_CONTAINER (main_box), hbox);
 
-  if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code))
-    {
-      TRACE ("Error during the POST exchange: %d %s\n",
-             msg->status_code, msg->reason_phrase);
-
-      tmp_error = g_error_new (SOUP_HTTP_ERROR,
-                         msg->status_code,
-                         _("An error occurred when transferring the data"
-                           " to imgur."));
-      g_propagate_error (error, tmp_error);
-      g_object_unref (session);
-      g_object_unref (msg);
-
-      return FALSE;
-    }
+  /* Add the throbber */
+  throbber = katze_throbber_new ();
+  katze_throbber_set_animated (KATZE_THROBBER (throbber), TRUE);
+  gtk_box_pack_end (GTK_BOX (hbox), throbber, FALSE, FALSE, 0);
+
+  /* Status label*/
+  status_label = gtk_label_new ("");
+  gtk_label_set_markup (GTK_LABEL (status_label),
+                        _("<span weight=\"bold\" stretch=\"semiexpanded\">"
+                          "Status</span>"));
+  gtk_misc_set_alignment (GTK_MISC (status_label), 0, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), status_label, FALSE, FALSE, 0);
 
-  TRACE("response was %s\n", msg->response_body->data);
-  /* returned XML is like <data type="array" success="1" status="200"><id>xxxxxx</id> */
-  doc = xmlParseMemory(msg->response_body->data,
-                                  strlen(msg->response_body->data));
+  /* Information label */
+  *label = gtk_label_new ("");
+  gtk_container_add (GTK_CONTAINER (main_box), *label);
 
-  root_node = xmlDocGetRootElement(doc);
-  for (child_node = root_node->children; child_node; child_node = child_node->next)
-    if (xmlStrEqual(child_node->name, (const xmlChar *) "id"))
-       online_file_name = xmlNodeGetContent(child_node);
-  TRACE("found picture id %s\n", online_file_name);
-  xmlFreeDoc(doc);
-  soup_buffer_free (buf);
-  g_object_unref (session);
-  g_object_unref (msg);
+  gtk_widget_show_all (GTK_DIALOG(dialog)->vbox);
+  return dialog;
+}
 
-  screenshooter_job_image_uploaded (job, online_file_name);
+void cb_error (ExoJob *job, GError *error, gpointer unused)
+{
+  g_return_if_fail (error != NULL);
 
-  return TRUE;
+  screenshooter_error ("%s", error->message);
 }
 
 
 
-static ScreenshooterJob
-*imgur_upload_to_imgur (const gchar *file_path,
-                            const gchar *last_user,
-                            const gchar *title)
+void cb_finished (ExoJob *job, GtkWidget *dialog)
 {
-  g_return_val_if_fail (file_path != NULL, NULL);
+  g_return_if_fail (EXO_IS_JOB (job));
+  g_return_if_fail (GTK_IS_DIALOG (dialog));
+
+  g_signal_handlers_disconnect_matched (job,
+                                        G_SIGNAL_MATCH_FUNC,
+                                        0, 0, NULL,
+                                        cb_image_uploaded,
+                                        NULL);
+
+  g_signal_handlers_disconnect_matched (job,
+                                        G_SIGNAL_MATCH_FUNC,
+                                        0, 0, NULL,
+                                        cb_error,
+                                        NULL);
 
-  return screenshooter_simple_job_launch (imgur_upload_job, 1,
-                                          G_TYPE_STRING, file_path);
+  g_signal_handlers_disconnect_matched (job,
+                                        G_SIGNAL_MATCH_FUNC,
+                                        0, 0, NULL,
+                                        cb_ask_for_information,
+                                        NULL);
+
+  g_signal_handlers_disconnect_matched (job,
+                                        G_SIGNAL_MATCH_FUNC,
+                                        0, 0, NULL,
+                                        cb_update_info,
+                                        NULL);
+
+  g_signal_handlers_disconnect_matched (job,
+                                        G_SIGNAL_MATCH_FUNC,
+                                        0, 0, NULL,
+                                        cb_finished,
+                                        NULL);
+
+  g_object_unref (G_OBJECT (job));
+  gtk_widget_destroy (dialog);
 }
 
 
 
-static void cb_image_uploaded (ScreenshooterJob  *job,
-                               gchar             *upload_name,
-                               gchar            **last_user)
+void cb_update_info (ExoJob *job, gchar *message, GtkWidget *label)
+{
+  g_return_if_fail (EXO_IS_JOB (job));
+  g_return_if_fail (GTK_IS_LABEL (label));
+
+  gtk_label_set_text (GTK_LABEL (label), message);
+}
+
+void
+cb_ask_for_information (ScreenshooterJob *job,
+                        GtkListStore     *liststore,
+                        const gchar      *message,
+                        gpointer          unused)
+{
+  GtkWidget *dialog;
+  GtkWidget *information_label;
+  GtkWidget *vbox, *main_alignment;
+  GtkWidget *table;
+  GtkWidget *user_entry, *password_entry, *title_entry, *comment_entry;
+  GtkWidget *user_label, *password_label, *title_label, *comment_label;
+
+  GtkTreeIter iter;
+  gint response;
+
+  g_return_if_fail (SCREENSHOOTER_IS_JOB (job));
+  g_return_if_fail (GTK_IS_LIST_STORE (liststore));
+  g_return_if_fail (message != NULL);
+
+  TRACE ("Create the dialog to ask for user information.");
+
+  /* Create the information dialog */
+  dialog =
+    xfce_titled_dialog_new_with_buttons (_("Details about the screenshot for ZimageZ"),
+                                         NULL,
+                                         GTK_DIALOG_NO_SEPARATOR,
+                                         GTK_STOCK_CANCEL,
+                                         GTK_RESPONSE_CANCEL,
+                                         GTK_STOCK_OK,
+                                         GTK_RESPONSE_OK,
+                                         NULL);
+
+  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
+  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG(dialog)->vbox), 12);
+
+  gtk_window_set_icon_name (GTK_WINDOW (dialog), "gtk-info");
+  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+
+  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+  /* Create the main alignment for the dialog */
+  main_alignment = gtk_alignment_new (0, 0, 1, 1);
+  gtk_alignment_set_padding (GTK_ALIGNMENT (main_alignment), 6, 0, 12, 12);
+  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_alignment, TRUE, TRUE, 0);
+
+  /* Create the main box for the dialog */
+  vbox = gtk_vbox_new (FALSE, 10);
+  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+  gtk_container_add (GTK_CONTAINER (main_alignment), vbox);
+
+  /* Create the information label */
+  information_label = gtk_label_new ("");
+  gtk_label_set_markup (GTK_LABEL (information_label), message);
+  gtk_misc_set_alignment (GTK_MISC (information_label), 0, 0);
+  gtk_container_add (GTK_CONTAINER (vbox), information_label);
+
+  /* Create the layout table */
+  table = gtk_table_new (4, 2, FALSE);
+  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
+  gtk_table_set_row_spacings (GTK_TABLE (table), 12);
+  gtk_container_add (GTK_CONTAINER (vbox), table);
+
+  /* Create the user label */
+  user_label = gtk_label_new (_("User:"));
+  gtk_misc_set_alignment (GTK_MISC (user_label), 0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), user_label,
+                    0, 1,
+                    0, 1,
+                    GTK_FILL, GTK_FILL,
+                    0, 0);
+
+  /* Create the user entry */
+  user_entry = gtk_entry_new ();
+  gtk_widget_set_tooltip_text (user_entry,
+                               _("Your Zimagez user name, if you do not have one yet"
+                                 " please create one on the Web page linked above"));
+  gtk_entry_set_activates_default (GTK_ENTRY (user_entry), TRUE);
+  gtk_table_attach_defaults (GTK_TABLE (table), user_entry, 1, 2, 0, 1);
+
+  /* Create the password label */
+  password_label = gtk_label_new (_("Password:"));
+  gtk_misc_set_alignment (GTK_MISC (password_label), 0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), password_label,
+                    0, 1,
+                    1, 2,
+                    GTK_FILL, GTK_FILL,
+                    0, 0);
+
+  /* Create the password entry */
+  password_entry = gtk_entry_new ();
+  gtk_widget_set_tooltip_text (password_entry, _("The password for the user above"));
+  gtk_entry_set_visibility (GTK_ENTRY (password_entry), FALSE);
+  gtk_entry_set_activates_default (GTK_ENTRY (password_entry), TRUE);
+  gtk_table_attach_defaults (GTK_TABLE (table), password_entry, 1, 2, 1, 2);
+
+  /* Create the title label */
+  title_label = gtk_label_new (_("Title:"));
+  gtk_misc_set_alignment (GTK_MISC (title_label), 0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), title_label,
+                    0, 1,
+                    2, 3,
+                    GTK_FILL, GTK_FILL,
+                    0, 0);
+  /* Create the title entry */
+  title_entry = gtk_entry_new ();
+  gtk_widget_set_tooltip_text (title_entry,
+                               _("The title of the screenshot, it will be used when"
+                                 " displaying the screenshot on ZimageZ"));
+  gtk_entry_set_activates_default (GTK_ENTRY (title_entry), TRUE);
+  gtk_table_attach_defaults (GTK_TABLE (table), title_entry, 1, 2, 2, 3);
+
+  /* Create the comment label */
+  comment_label = gtk_label_new (_("Comment:"));
+  gtk_misc_set_alignment (GTK_MISC (comment_label), 0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), comment_label,
+                    0, 1,
+                    3, 4,
+                    GTK_FILL, GTK_FILL,
+                    0, 0);
+
+  /* Create the comment entry */
+  comment_entry = gtk_entry_new ();
+  gtk_widget_set_tooltip_text (comment_entry,
+                               _("A comment on the screenshot, it will be used when"
+                                 " displaying the screenshot on ZimageZ"));
+  gtk_entry_set_activates_default (GTK_ENTRY (comment_entry), TRUE);
+  gtk_table_attach_defaults (GTK_TABLE (table), comment_entry, 1, 2, 3, 4);
+
+  /* Set the values */
+  gtk_tree_model_get_iter_first (GTK_TREE_MODEL (liststore), &iter);
+
+  do
+    {
+      gint field_index;
+      gchar *field_value = NULL;
+
+      gtk_tree_model_get (GTK_TREE_MODEL (liststore), &iter,
+                          0, &field_index,
+                          1, &field_value,
+                          -1);
+      switch (field_index)
+        {
+          case USER:
+            gtk_entry_set_text (GTK_ENTRY (user_entry), field_value);
+            break;
+          case PASSWORD:
+            gtk_entry_set_text (GTK_ENTRY (password_entry), field_value);
+            break;
+          case TITLE:
+            gtk_entry_set_text (GTK_ENTRY (title_entry), field_value);
+            break;
+          case COMMENT:
+            gtk_entry_set_text (GTK_ENTRY (comment_entry), field_value);
+            break;
+          default:
+            break;
+        }
+
+      g_free (field_value);
+    }
+  while (gtk_tree_model_iter_next (GTK_TREE_MODEL (liststore), &iter));
+
+  gtk_widget_show_all (GTK_DIALOG(dialog)->vbox);
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+  gtk_widget_hide (dialog);
+
+  if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT)
+    {
+      exo_job_cancel (EXO_JOB (job));
+    }
+  else if (response == GTK_RESPONSE_OK)
+    {
+      gtk_tree_model_get_iter_first (GTK_TREE_MODEL (liststore), &iter);
+
+      do
+        {
+          gint field_index;
+
+          gtk_tree_model_get (GTK_TREE_MODEL (liststore), &iter,
+                              0, &field_index, -1);
+
+          switch (field_index)
+            {
+              case USER:
+                gtk_list_store_set (liststore, &iter,
+                                    1, gtk_entry_get_text (GTK_ENTRY (user_entry)),
+                                    -1);
+                break;
+              case PASSWORD:
+                gtk_list_store_set (liststore, &iter,
+                                    1, gtk_entry_get_text (GTK_ENTRY (password_entry)),
+                                    -1);
+                break;
+              case TITLE:
+                gtk_list_store_set (liststore, &iter,
+                                    1, gtk_entry_get_text (GTK_ENTRY (title_entry)),
+                                    -1);
+                break;
+              case COMMENT:
+                gtk_list_store_set (liststore, &iter,
+                                    1, gtk_entry_get_text (GTK_ENTRY (comment_entry)),
+                                    -1);
+                break;
+              default:
+                break;
+            }
+        }
+      while (gtk_tree_model_iter_next (GTK_TREE_MODEL (liststore), &iter));
+    }
+
+  gtk_widget_destroy (dialog);
+}
+
+void cb_image_uploaded (ScreenshooterJob  *job,
+                        gchar             *upload_name,
+                        gchar            **last_user)
 {
   GtkWidget *dialog;
   GtkWidget *main_alignment, *vbox;
@@ -184,17 +369,33 @@ static void cb_image_uploaded (ScreenshooterJob  *job,
   const gchar *image_url, *thumbnail_url, *small_thumbnail_url;
   const gchar *image_markup, *thumbnail_markup, *small_thumbnail_markup;
   const gchar *html_code, *bb_code;
-
+  gchar *job_type, *title;
   gchar *last_user_temp;
 
   g_return_if_fail (upload_name != NULL);
-  g_return_if_fail (last_user == NULL || *last_user == NULL);
-
-  image_url = g_strdup_printf ("http://i.imgur.com/%s.png", upload_name);
-  thumbnail_url =
-    g_strdup_printf ("http://imgur.com/%sl.png", upload_name);
-  small_thumbnail_url =
-    g_strdup_printf ("http://imgur.com/%ss.png", upload_name);
+  job_type = g_object_get_data(G_OBJECT (job), "jobtype");
+  if (!strcmp(job_type, "imgur")) {
+    title = _("My screenshot on Imgur");
+    image_url = g_strdup_printf ("http://i.imgur.com/%s.png", upload_name);
+    thumbnail_url =
+      g_strdup_printf ("http://imgur.com/%sl.png", upload_name);
+    small_thumbnail_url =
+      g_strdup_printf ("http://imgur.com/%ss.png", upload_name);
+  } else {
+    g_return_if_fail (last_user == NULL || *last_user == NULL);
+    title = _("My screenshot on ZimageZ");
+    image_url = g_strdup_printf ("http://www.zimagez.com/zimage/%s.php", upload_name);
+    thumbnail_url =
+      g_strdup_printf ("http://www.zimagez.com/miniature/%s.php", upload_name);
+    small_thumbnail_url =
+      g_strdup_printf ("http://www.zimagez.com/avatar/%s.php", upload_name);
+    last_user_temp = g_object_get_data (G_OBJECT (job), "user");
+
+    if (last_user_temp == NULL)
+      last_user_temp = g_strdup ("");
+
+    *last_user = g_strdup (last_user_temp);
+  }
   image_markup =
     g_markup_printf_escaped (_("<a href=\"%s\">Full size image</a>"), image_url);
   thumbnail_markup =
@@ -207,16 +408,9 @@ static void cb_image_uploaded (ScreenshooterJob  *job,
   bb_code =
     g_strdup_printf ("[url=%s]\n  [img]%s[/img]\n[/url]", image_url, thumbnail_url);
 
-  last_user_temp = g_object_get_data (G_OBJECT (job), "user");
-
-  if (last_user_temp == NULL)
-    last_user_temp = g_strdup ("");
-
-  *last_user = g_strdup (last_user_temp);
-
   /* Dialog */
   dialog =
-    xfce_titled_dialog_new_with_buttons (_("My screenshot on Imgur"),
+    xfce_titled_dialog_new_with_buttons (title,
                                          NULL,
                                          GTK_DIALOG_NO_SEPARATOR,
                                          GTK_STOCK_CLOSE,
@@ -336,6 +530,8 @@ static void cb_image_uploaded (ScreenshooterJob  *job,
                                  10);
   gtk_text_view_set_editable (GTK_TEXT_VIEW (bb_code_view),
                               FALSE);
+  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (bb_code_view),
+                               GTK_WRAP_CHAR);
   gtk_container_add (GTK_CONTAINER (bb_frame), bb_code_view);
 
   /* Show the dialog and run it */
@@ -347,150 +543,3 @@ static void cb_image_uploaded (ScreenshooterJob  *job,
   g_object_unref (bb_buffer);
 }
 
-
-
-static void cb_error (ExoJob *job, GError *error, gpointer unused)
-{
-  g_return_if_fail (error != NULL);
-
-  screenshooter_error ("%s", error->message);
-}
-
-
-
-static void cb_finished (ExoJob *job, GtkWidget *dialog)
-{
-  g_return_if_fail (EXO_IS_JOB (job));
-  g_return_if_fail (GTK_IS_DIALOG (dialog));
-
-  g_signal_handlers_disconnect_matched (job,
-                                        G_SIGNAL_MATCH_FUNC,
-                                        0, 0, NULL,
-                                        cb_image_uploaded,
-                                        NULL);
-
-  g_signal_handlers_disconnect_matched (job,
-                                        G_SIGNAL_MATCH_FUNC,
-                                        0, 0, NULL,
-                                        cb_error,
-                                        NULL);
-
-  g_signal_handlers_disconnect_matched (job,
-                                        G_SIGNAL_MATCH_FUNC,
-                                        0, 0, NULL,
-                                        cb_update_info,
-                                        NULL);
-
-  g_signal_handlers_disconnect_matched (job,
-                                        G_SIGNAL_MATCH_FUNC,
-                                        0, 0, NULL,
-                                        cb_finished,
-                                        NULL);
-
-  g_object_unref (G_OBJECT (job));
-  gtk_widget_destroy (dialog);
-}
-
-
-
-static void cb_update_info (ExoJob *job, gchar *message, GtkWidget *label)
-{
-  g_return_if_fail (EXO_IS_JOB (job));
-  g_return_if_fail (GTK_IS_LABEL (label));
-
-  gtk_label_set_text (GTK_LABEL (label), message);
-}
-
-
-
-/* Public */
-
-
-
-/**
- * screenshooter_upload_to_imgur:
- * @image_path: the local path of the image that should be uploaded to
- * imgur.com.
- * @last_user: the last user name used, to pre-fill the user field.
- * @title: a default title, to pre-fill the title field.
- * @new_last_user: address of the string used to store the new user
- * if the upload is succesful.
- *
- * Uploads the image whose path is @image_path: a dialog asks for the user
- * login, password, a title for the image and a comment; then the image is
- * uploaded. The dialog is shown again with a warning is the password did
- * not match the user name. The user can also cancel the upload procedure.
- *
- * If the upload was succesful, @new_last_user points to the user name for
- * which the upload was done.
- *
- **/
-
-void screenshooter_upload_to_imgur   (const gchar  *image_path,
-                                      const gchar  *last_user,
-                                      const gchar  *title,
-                                      gchar       **new_last_user)
-{
-  ScreenshooterJob *job;
-  GtkWidget *dialog;
-  GtkWidget *label, *status_label;
-  GtkWidget *hbox, *throbber;
-  GtkWidget *main_box, *main_alignment;
-
-  g_return_if_fail (image_path != NULL);
-  g_return_if_fail (new_last_user == NULL || *new_last_user == NULL);
-
-  dialog =
-    gtk_dialog_new_with_buttons (_("Imgur"),
-                                 NULL,
-                                 GTK_DIALOG_NO_SEPARATOR,
-                                 NULL);
-
-  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
-  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 0);
-  gtk_window_set_deletable (GTK_WINDOW (dialog), FALSE);
-  gtk_window_set_icon_name (GTK_WINDOW (dialog), "gtk-info");
-
-  /* Create the main alignment for the dialog */
-  main_alignment = gtk_alignment_new (0, 0, 1, 1);
-  gtk_alignment_set_padding (GTK_ALIGNMENT (main_alignment), 0, 0, 6, 6);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_alignment, TRUE, TRUE, 0);
-
-  /* Create the main box for the dialog */
-  main_box = gtk_vbox_new (FALSE, 10);
-  gtk_container_set_border_width (GTK_CONTAINER (main_box), 12);
-  gtk_container_add (GTK_CONTAINER (main_alignment), main_box);
-
-  /* Top horizontal box for the throbber */
-  hbox= gtk_hbox_new (FALSE, 0);
-  gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
-  gtk_container_add (GTK_CONTAINER (main_box), hbox);
-
-  /* Add the throbber */
-  throbber = katze_throbber_new ();
-  katze_throbber_set_animated (KATZE_THROBBER (throbber), TRUE);
-  gtk_box_pack_end (GTK_BOX (hbox), throbber, FALSE, FALSE, 0);
-
-  /* Status label*/
-  status_label = gtk_label_new ("");
-  gtk_label_set_markup (GTK_LABEL (status_label),
-                        _("<span weight=\"bold\" stretch=\"semiexpanded\">"
-                          "Status</span>"));
-  gtk_misc_set_alignment (GTK_MISC (status_label), 0, 0);
-  gtk_box_pack_start (GTK_BOX (hbox), status_label, FALSE, FALSE, 0);
-
-  /* Information label */
-  label = gtk_label_new ("");
-  gtk_container_add (GTK_CONTAINER (main_box), label);
-
-  gtk_widget_show_all (GTK_DIALOG(dialog)->vbox);
-
-  job = imgur_upload_to_imgur (image_path, last_user, title);
-
-  g_signal_connect (job, "image-uploaded", G_CALLBACK (cb_image_uploaded), new_last_user);
-  g_signal_connect (job, "error", G_CALLBACK (cb_error), NULL);
-  g_signal_connect (job, "finished", G_CALLBACK (cb_finished), dialog);
-  g_signal_connect (job, "info-message", G_CALLBACK (cb_update_info), label);
-
-  gtk_dialog_run (GTK_DIALOG (dialog));
-}
diff --git a/lib/screenshooter-job-callbacks.h b/lib/screenshooter-job-callbacks.h
new file mode 100644
index 0000000..8c1f600
--- /dev/null
+++ b/lib/screenshooter-job-callbacks.h
@@ -0,0 +1,63 @@
+/*  $Id$
+ *
+ *  Copyright 2008-2009 Jérôme Guelfucci <jeromeg at xfce.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __HAVE_JOB_CB_H__
+#define __HAVE_JOB_CB_H__
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "screenshooter-utils.h"
+#include "screenshooter-simple-job.h"
+#include "katze-throbber.h"
+
+typedef enum
+{
+  USER,
+  PASSWORD,
+  TITLE,
+  COMMENT,
+} AskInformation;
+
+
+GtkWidget *
+create_throbber_dialog             (const gchar        *title,
+                                    GtkWidget          **label);
+
+void
+cb_error                           (ExoJob            *job,
+                                    GError            *error,
+                                    gpointer           unused);
+void
+cb_finished                        (ExoJob            *job,
+                                    GtkWidget         *dialog);
+void
+cb_update_info                     (ExoJob            *job,
+                                    gchar             *message,
+                                    GtkWidget         *label);
+void
+cb_image_uploaded                  (ScreenshooterJob  *job,
+                                    gchar             *upload_name,
+                                    gchar            **last_user);
+void
+cb_ask_for_information             (ScreenshooterJob  *job,
+                                    GtkListStore      *liststore,
+                                    const gchar       *message,
+                                    gpointer           unused);
+
+#endif
diff --git a/lib/screenshooter-zimagez.c b/lib/screenshooter-zimagez.c
index d6a01ca..1be2b79 100644
--- a/lib/screenshooter-zimagez.c
+++ b/lib/screenshooter-zimagez.c
@@ -42,14 +42,7 @@
 */
 
 #include "screenshooter-zimagez.h"
-
-typedef enum
-{
-  USER,
-  PASSWORD,
-  TITLE,
-  COMMENT,
-} ZimagezInformation;
+#include "screenshooter-job-callbacks.h"
 
 static gboolean          do_xmlrpc                 (SoupSession       *session,
                                                     const gchar       *uri,
@@ -58,28 +51,9 @@ static gboolean          do_xmlrpc                 (SoupSession       *session,
                                                     GValue            *retval,
                                                     ...);
 static gboolean          has_empty_field           (GtkListStore      *liststore);
-static ScreenshooterJob *zimagez_upload_to_zimagez (const gchar       *file_name,
-                                                    const gchar       *last_user,
-                                                    const gchar       *title);
 static gboolean          zimagez_upload_job        (ScreenshooterJob  *job,
                                                     GValueArray       *param_values,
                                                     GError           **error);
-static void              cb_ask_for_information    (ScreenshooterJob  *job,
-                                                    GtkListStore      *liststore,
-                                                    const gchar       *message,
-                                                    gpointer           unused);
-static void              cb_image_uploaded         (ScreenshooterJob  *job,
-                                                    gchar             *upload_name,
-                                                    gchar            **last_user);
-static void              cb_error                  (ExoJob            *job,
-                                                    GError            *error,
-                                                    gpointer           unused);
-static void              cb_finished               (ExoJob            *job,
-                                                    GtkWidget         *dialog);
-static void              cb_update_info            (ExoJob            *job,
-                                                    gchar             *message,
-                                                    GtkWidget         *label);
-
 
 
 /* Private */
@@ -240,6 +214,7 @@ zimagez_upload_job (ScreenshooterJob *job, GValueArray *param_values, GError **e
   g_return_val_if_fail (G_VALUE_HOLDS_STRING (&param_values->values[2]), FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
+  g_object_set_data (G_OBJECT (job), "jobtype", "zimagez");
   if (exo_job_set_error_if_cancelled (EXO_JOB (job), error))
     {
       g_free (comment);
@@ -635,489 +610,8 @@ zimagez_upload_job (ScreenshooterJob *job, GValueArray *param_values, GError **e
   return TRUE;
 }
 
-
-
-static ScreenshooterJob
-*zimagez_upload_to_zimagez (const gchar *file_path,
-                            const gchar *last_user,
-                            const gchar *title)
-{
-  g_return_val_if_fail (file_path != NULL, NULL);
-
-  return screenshooter_simple_job_launch (zimagez_upload_job, 3,
-                                          G_TYPE_STRING, file_path,
-                                          G_TYPE_STRING, last_user,
-                                          G_TYPE_STRING, title);
-}
-
-
-
-static void
-cb_ask_for_information (ScreenshooterJob *job,
-                        GtkListStore     *liststore,
-                        const gchar      *message,
-                        gpointer          unused)
-{
-  GtkWidget *dialog;
-  GtkWidget *information_label;
-  GtkWidget *vbox, *main_alignment;
-  GtkWidget *table;
-  GtkWidget *user_entry, *password_entry, *title_entry, *comment_entry;
-  GtkWidget *user_label, *password_label, *title_label, *comment_label;
-
-  GtkTreeIter iter;
-  gint response;
-
-  g_return_if_fail (SCREENSHOOTER_IS_JOB (job));
-  g_return_if_fail (GTK_IS_LIST_STORE (liststore));
-  g_return_if_fail (message != NULL);
-
-  TRACE ("Create the dialog to ask for user information.");
-
-  /* Create the information dialog */
-  dialog =
-    xfce_titled_dialog_new_with_buttons (_("Details about the screenshot for ZimageZ"),
-                                         NULL,
-                                         GTK_DIALOG_NO_SEPARATOR,
-                                         GTK_STOCK_CANCEL,
-                                         GTK_RESPONSE_CANCEL,
-                                         GTK_STOCK_OK,
-                                         GTK_RESPONSE_OK,
-                                         NULL);
-
-  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
-  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG(dialog)->vbox), 12);
-
-  gtk_window_set_icon_name (GTK_WINDOW (dialog), "gtk-info");
-  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-
-  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
-  /* Create the main alignment for the dialog */
-  main_alignment = gtk_alignment_new (0, 0, 1, 1);
-  gtk_alignment_set_padding (GTK_ALIGNMENT (main_alignment), 6, 0, 12, 12);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_alignment, TRUE, TRUE, 0);
-
-  /* Create the main box for the dialog */
-  vbox = gtk_vbox_new (FALSE, 10);
-  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
-  gtk_container_add (GTK_CONTAINER (main_alignment), vbox);
-
-  /* Create the information label */
-  information_label = gtk_label_new ("");
-  gtk_label_set_markup (GTK_LABEL (information_label), message);
-  gtk_misc_set_alignment (GTK_MISC (information_label), 0, 0);
-  gtk_container_add (GTK_CONTAINER (vbox), information_label);
-
-  /* Create the layout table */
-  table = gtk_table_new (4, 2, FALSE);
-  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
-  gtk_table_set_row_spacings (GTK_TABLE (table), 12);
-  gtk_container_add (GTK_CONTAINER (vbox), table);
-
-  /* Create the user label */
-  user_label = gtk_label_new (_("User:"));
-  gtk_misc_set_alignment (GTK_MISC (user_label), 0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), user_label,
-                    0, 1,
-                    0, 1,
-                    GTK_FILL, GTK_FILL,
-                    0, 0);
-
-  /* Create the user entry */
-  user_entry = gtk_entry_new ();
-  gtk_widget_set_tooltip_text (user_entry,
-                               _("Your Zimagez user name, if you do not have one yet"
-                                 " please create one on the Web page linked above"));
-  gtk_entry_set_activates_default (GTK_ENTRY (user_entry), TRUE);
-  gtk_table_attach_defaults (GTK_TABLE (table), user_entry, 1, 2, 0, 1);
-
-  /* Create the password label */
-  password_label = gtk_label_new (_("Password:"));
-  gtk_misc_set_alignment (GTK_MISC (password_label), 0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), password_label,
-                    0, 1,
-                    1, 2,
-                    GTK_FILL, GTK_FILL,
-                    0, 0);
-
-  /* Create the password entry */
-  password_entry = gtk_entry_new ();
-  gtk_widget_set_tooltip_text (password_entry, _("The password for the user above"));
-  gtk_entry_set_visibility (GTK_ENTRY (password_entry), FALSE);
-  gtk_entry_set_activates_default (GTK_ENTRY (password_entry), TRUE);
-  gtk_table_attach_defaults (GTK_TABLE (table), password_entry, 1, 2, 1, 2);
-
-  /* Create the title label */
-  title_label = gtk_label_new (_("Title:"));
-  gtk_misc_set_alignment (GTK_MISC (title_label), 0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), title_label,
-                    0, 1,
-                    2, 3,
-                    GTK_FILL, GTK_FILL,
-                    0, 0);
-  /* Create the title entry */
-  title_entry = gtk_entry_new ();
-  gtk_widget_set_tooltip_text (title_entry,
-                               _("The title of the screenshot, it will be used when"
-                                 " displaying the screenshot on ZimageZ"));
-  gtk_entry_set_activates_default (GTK_ENTRY (title_entry), TRUE);
-  gtk_table_attach_defaults (GTK_TABLE (table), title_entry, 1, 2, 2, 3);
-
-  /* Create the comment label */
-  comment_label = gtk_label_new (_("Comment:"));
-  gtk_misc_set_alignment (GTK_MISC (comment_label), 0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), comment_label,
-                    0, 1,
-                    3, 4,
-                    GTK_FILL, GTK_FILL,
-                    0, 0);
-
-  /* Create the comment entry */
-  comment_entry = gtk_entry_new ();
-  gtk_widget_set_tooltip_text (comment_entry,
-                               _("A comment on the screenshot, it will be used when"
-                                 " displaying the screenshot on ZimageZ"));
-  gtk_entry_set_activates_default (GTK_ENTRY (comment_entry), TRUE);
-  gtk_table_attach_defaults (GTK_TABLE (table), comment_entry, 1, 2, 3, 4);
-
-  /* Set the values */
-  gtk_tree_model_get_iter_first (GTK_TREE_MODEL (liststore), &iter);
-
-  do
-    {
-      gint field_index;
-      gchar *field_value = NULL;
-
-      gtk_tree_model_get (GTK_TREE_MODEL (liststore), &iter,
-                          0, &field_index,
-                          1, &field_value,
-                          -1);
-      switch (field_index)
-        {
-          case USER:
-            gtk_entry_set_text (GTK_ENTRY (user_entry), field_value);
-            break;
-          case PASSWORD:
-            gtk_entry_set_text (GTK_ENTRY (password_entry), field_value);
-            break;
-          case TITLE:
-            gtk_entry_set_text (GTK_ENTRY (title_entry), field_value);
-            break;
-          case COMMENT:
-            gtk_entry_set_text (GTK_ENTRY (comment_entry), field_value);
-            break;
-          default:
-            break;
-        }
-
-      g_free (field_value);
-    }
-  while (gtk_tree_model_iter_next (GTK_TREE_MODEL (liststore), &iter));
-
-  gtk_widget_show_all (GTK_DIALOG(dialog)->vbox);
-  response = gtk_dialog_run (GTK_DIALOG (dialog));
-  gtk_widget_hide (dialog);
-
-  if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT)
-    {
-      exo_job_cancel (EXO_JOB (job));
-    }
-  else if (response == GTK_RESPONSE_OK)
-    {
-      gtk_tree_model_get_iter_first (GTK_TREE_MODEL (liststore), &iter);
-
-      do
-        {
-          gint field_index;
-
-          gtk_tree_model_get (GTK_TREE_MODEL (liststore), &iter,
-                              0, &field_index, -1);
-
-          switch (field_index)
-            {
-              case USER:
-                gtk_list_store_set (liststore, &iter,
-                                    1, gtk_entry_get_text (GTK_ENTRY (user_entry)),
-                                    -1);
-                break;
-              case PASSWORD:
-                gtk_list_store_set (liststore, &iter,
-                                    1, gtk_entry_get_text (GTK_ENTRY (password_entry)),
-                                    -1);
-                break;
-              case TITLE:
-                gtk_list_store_set (liststore, &iter,
-                                    1, gtk_entry_get_text (GTK_ENTRY (title_entry)),
-                                    -1);
-                break;
-              case COMMENT:
-                gtk_list_store_set (liststore, &iter,
-                                    1, gtk_entry_get_text (GTK_ENTRY (comment_entry)),
-                                    -1);
-                break;
-              default:
-                break;
-            }
-        }
-      while (gtk_tree_model_iter_next (GTK_TREE_MODEL (liststore), &iter));
-    }
-
-  gtk_widget_destroy (dialog);
-}
-
-
-
-static void cb_image_uploaded (ScreenshooterJob  *job,
-                               gchar             *upload_name,
-                               gchar            **last_user)
-{
-  GtkWidget *dialog;
-  GtkWidget *main_alignment, *vbox;
-  GtkWidget *link_label;
-  GtkWidget *image_link, *thumbnail_link, *small_thumbnail_link;
-  GtkWidget *example_label, *html_label, *bb_label;
-  GtkWidget *html_code_view, *bb_code_view;
-  GtkWidget *html_frame, *bb_frame;
-  GtkWidget *links_alignment, *code_alignment;
-  GtkWidget *links_box, *code_box;
-
-  GtkTextBuffer *html_buffer, *bb_buffer;
-
-  const gchar *image_url, *thumbnail_url, *small_thumbnail_url;
-  const gchar *image_markup, *thumbnail_markup, *small_thumbnail_markup;
-  const gchar *html_code, *bb_code;
-
-  gchar *last_user_temp;
-
-  g_return_if_fail (upload_name != NULL);
-  g_return_if_fail (last_user == NULL || *last_user == NULL);
-
-  image_url = g_strdup_printf ("http://www.zimagez.com/zimage/%s.php", upload_name);
-  thumbnail_url =
-    g_strdup_printf ("http://www.zimagez.com/miniature/%s.php", upload_name);
-  small_thumbnail_url =
-    g_strdup_printf ("http://www.zimagez.com/avatar/%s.php", upload_name);
-  image_markup =
-    g_strdup_printf (_("<a href=\"%s\">Full size image</a>"), image_url);
-  thumbnail_markup =
-    g_strdup_printf (_("<a href=\"%s\">Large thumbnail</a>"), thumbnail_url);
-  small_thumbnail_markup =
-    g_strdup_printf (_("<a href=\"%s\">Small thumbnail</a>"), small_thumbnail_url);
-  html_code =
-    g_strdup_printf ("<a href=\"%s\">\n  <img src=\"%s\" />\n</a>",
-                     image_url, thumbnail_url);
-  bb_code =
-    g_strdup_printf ("[url=%s][img]%s[/img][/url]", image_url, thumbnail_url);
-
-  last_user_temp = g_object_get_data (G_OBJECT (job), "user");
-
-  if (last_user_temp == NULL)
-    last_user_temp = g_strdup ("");
-
-  *last_user = g_strdup (last_user_temp);
-
-  /* Dialog */
-  dialog =
-    xfce_titled_dialog_new_with_buttons (_("My screenshot on ZimageZ"),
-                                         NULL,
-                                         GTK_DIALOG_NO_SEPARATOR,
-                                         GTK_STOCK_CLOSE,
-                                         GTK_RESPONSE_CLOSE,
-                                         NULL);
-
-  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
-  gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 0);
-  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 12);
-  gtk_window_set_icon_name (GTK_WINDOW (dialog), "applications-internet");
-  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
-  /* Create the main alignment for the dialog */
-  main_alignment = gtk_alignment_new (0, 0, 1, 1);
-  gtk_alignment_set_padding (GTK_ALIGNMENT (main_alignment), 6, 0, 10, 10);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_alignment, TRUE, TRUE, 0);
-
-  /* Create the main box for the dialog */
-  vbox = gtk_vbox_new (FALSE, 10);
-  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
-  gtk_container_add (GTK_CONTAINER (main_alignment), vbox);
-
-  /* Links bold label */
-  link_label = gtk_label_new ("");
-  gtk_label_set_markup (GTK_LABEL (link_label),
-                        _("<span weight=\"bold\" stretch=\"semiexpanded\">"
-                          "Links</span>"));
-  gtk_misc_set_alignment (GTK_MISC (link_label), 0, 0);
-  gtk_container_add (GTK_CONTAINER (vbox), link_label);
-
-  /* Links alignment */
-  links_alignment = gtk_alignment_new (0, 0, 1, 1);
-  gtk_alignment_set_padding (GTK_ALIGNMENT (links_alignment), 0, 0, 12, 0);
-  gtk_container_add (GTK_CONTAINER (vbox), links_alignment);
-
-  /* Links box */
-  links_box = gtk_vbox_new (FALSE, 10);
-  gtk_container_set_border_width (GTK_CONTAINER (links_box), 0);
-  gtk_container_add (GTK_CONTAINER (links_alignment), links_box);
-
-  /* Create the image link */
-  image_link = gtk_label_new ("");
-  gtk_label_set_markup (GTK_LABEL (image_link), image_markup);
-  gtk_misc_set_alignment (GTK_MISC (image_link), 0, 0);
-  gtk_widget_set_tooltip_text (image_link, image_url);
-  gtk_container_add (GTK_CONTAINER (links_box), image_link);
-
-  /* Create the thumbnail link */
-  thumbnail_link = gtk_label_new ("");
-  gtk_label_set_markup (GTK_LABEL (thumbnail_link), thumbnail_markup);
-  gtk_misc_set_alignment (GTK_MISC (thumbnail_link), 0, 0);
-  gtk_widget_set_tooltip_text (thumbnail_link, thumbnail_url);
-  gtk_container_add (GTK_CONTAINER (links_box), thumbnail_link);
-
-  /* Create the small thumbnail link */
-  small_thumbnail_link = gtk_label_new ("");
-  gtk_label_set_markup (GTK_LABEL (small_thumbnail_link), small_thumbnail_markup);
-  gtk_misc_set_alignment (GTK_MISC (small_thumbnail_link), 0, 0);
-  gtk_widget_set_tooltip_text (small_thumbnail_link, small_thumbnail_url);
-  gtk_container_add (GTK_CONTAINER (links_box), small_thumbnail_link);
-
-  /* Examples bold label */
-  example_label = gtk_label_new ("");
-  gtk_label_set_markup (GTK_LABEL (example_label),
-                        _("<span weight=\"bold\" stretch=\"semiexpanded\">"
-                          "Code for a thumbnail pointing to the full size image</span>"));
-  gtk_misc_set_alignment (GTK_MISC (example_label), 0, 0);
-  gtk_container_add (GTK_CONTAINER (vbox), example_label);
-
-  /* Code alignment */
-  code_alignment = gtk_alignment_new (0, 0, 1, 1);
-  gtk_alignment_set_padding (GTK_ALIGNMENT (code_alignment), 0, 0, 12, 0);
-  gtk_container_add (GTK_CONTAINER (vbox), code_alignment);
-
-  /* Links box */
-  code_box = gtk_vbox_new (FALSE, 10);
-  gtk_container_set_border_width (GTK_CONTAINER (code_box), 0);
-  gtk_container_add (GTK_CONTAINER (code_alignment), code_box);
-
-  /* HTML title */
-  html_label = gtk_label_new (_("HTML"));
-  gtk_misc_set_alignment (GTK_MISC (html_label), 0, 0);
-  gtk_container_add (GTK_CONTAINER (code_box), html_label);
-
-  /* HTML frame */
-  html_frame = gtk_frame_new (NULL);
-  gtk_frame_set_shadow_type (GTK_FRAME (html_frame), GTK_SHADOW_IN);
-  gtk_container_add (GTK_CONTAINER (code_box), html_frame);
-
-  /* HTML code text view */
-  html_buffer = gtk_text_buffer_new (NULL);
-  gtk_text_buffer_set_text (html_buffer, html_code, -1);
-
-  html_code_view = gtk_text_view_new_with_buffer (html_buffer);
-  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (html_code_view),
-                                 10);
-  gtk_text_view_set_editable (GTK_TEXT_VIEW (html_code_view),
-                              FALSE);
-  gtk_container_add (GTK_CONTAINER (html_frame), html_code_view);
-
-  /* BB title */
-  bb_label = gtk_label_new (_("BBCode for forums"));
-  gtk_misc_set_alignment (GTK_MISC (bb_label), 0, 0);
-  gtk_container_add (GTK_CONTAINER (code_box), bb_label);
-
-  /* BB frame */
-  bb_frame = gtk_frame_new (NULL);
-  gtk_frame_set_shadow_type (GTK_FRAME (bb_frame), GTK_SHADOW_IN);
-  gtk_container_add (GTK_CONTAINER (code_box), bb_frame);
-
-  /* BBcode text view */
-  bb_buffer = gtk_text_buffer_new (NULL);
-  gtk_text_buffer_set_text (bb_buffer, bb_code, -1);
-
-  bb_code_view = gtk_text_view_new_with_buffer (bb_buffer);
-  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (bb_code_view),
-                                 10);
-  gtk_text_view_set_editable (GTK_TEXT_VIEW (bb_code_view),
-                              FALSE);
-  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (bb_code_view),
-                               GTK_WRAP_CHAR);
-  gtk_container_add (GTK_CONTAINER (bb_frame), bb_code_view);
-
-  /* Show the dialog and run it */
-  gtk_widget_show_all (GTK_DIALOG(dialog)->vbox);
-  gtk_dialog_run (GTK_DIALOG (dialog));
-  gtk_widget_destroy (dialog);
-
-  g_object_unref (html_buffer);
-  g_object_unref (bb_buffer);
-}
-
-
-
-static void cb_error (ExoJob *job, GError *error, gpointer unused)
-{
-  g_return_if_fail (error != NULL);
-
-  screenshooter_error ("%s", error->message);
-}
-
-
-
-static void cb_finished (ExoJob *job, GtkWidget *dialog)
-{
-  g_return_if_fail (EXO_IS_JOB (job));
-  g_return_if_fail (GTK_IS_DIALOG (dialog));
-
-  g_signal_handlers_disconnect_matched (job,
-                                        G_SIGNAL_MATCH_FUNC,
-                                        0, 0, NULL,
-                                        cb_image_uploaded,
-                                        NULL);
-
-  g_signal_handlers_disconnect_matched (job,
-                                        G_SIGNAL_MATCH_FUNC,
-                                        0, 0, NULL,
-                                        cb_error,
-                                        NULL);
-
-  g_signal_handlers_disconnect_matched (job,
-                                        G_SIGNAL_MATCH_FUNC,
-                                        0, 0, NULL,
-                                        cb_ask_for_information,
-                                        NULL);
-
-  g_signal_handlers_disconnect_matched (job,
-                                        G_SIGNAL_MATCH_FUNC,
-                                        0, 0, NULL,
-                                        cb_update_info,
-                                        NULL);
-
-  g_signal_handlers_disconnect_matched (job,
-                                        G_SIGNAL_MATCH_FUNC,
-                                        0, 0, NULL,
-                                        cb_finished,
-                                        NULL);
-
-  g_object_unref (G_OBJECT (job));
-  gtk_widget_destroy (dialog);
-}
-
-
-
-static void cb_update_info (ExoJob *job, gchar *message, GtkWidget *label)
-{
-  g_return_if_fail (EXO_IS_JOB (job));
-  g_return_if_fail (GTK_IS_LABEL (label));
-
-  gtk_label_set_text (GTK_LABEL (label), message);
-}
-
-
-
 /* Public */
 
-
-
 /**
  * screenshooter_upload_to_zimagez:
  * @image_path: the local path of the image that should be uploaded to
@@ -1143,60 +637,17 @@ void screenshooter_upload_to_zimagez (const gchar  *image_path,
                                       gchar       **new_last_user)
 {
   ScreenshooterJob *job;
-  GtkWidget *dialog;
-  GtkWidget *label, *status_label;
-  GtkWidget *hbox, *throbber;
-  GtkWidget *main_box, *main_alignment;
+  GtkWidget *dialog, *label;
 
   g_return_if_fail (image_path != NULL);
   g_return_if_fail (new_last_user == NULL || *new_last_user == NULL);
 
-  dialog =
-    gtk_dialog_new_with_buttons (_("ZimageZ"),
-                                 NULL,
-                                 GTK_DIALOG_NO_SEPARATOR,
-                                 NULL);
-
-  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
-  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 0);
-  gtk_window_set_deletable (GTK_WINDOW (dialog), FALSE);
-  gtk_window_set_icon_name (GTK_WINDOW (dialog), "gtk-info");
-
-  /* Create the main alignment for the dialog */
-  main_alignment = gtk_alignment_new (0, 0, 1, 1);
-  gtk_alignment_set_padding (GTK_ALIGNMENT (main_alignment), 0, 0, 6, 6);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_alignment, TRUE, TRUE, 0);
-
-  /* Create the main box for the dialog */
-  main_box = gtk_vbox_new (FALSE, 10);
-  gtk_container_set_border_width (GTK_CONTAINER (main_box), 12);
-  gtk_container_add (GTK_CONTAINER (main_alignment), main_box);
-
-  /* Top horizontal box for the throbber */
-  hbox= gtk_hbox_new (FALSE, 0);
-  gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
-  gtk_container_add (GTK_CONTAINER (main_box), hbox);
-
-  /* Add the throbber */
-  throbber = katze_throbber_new ();
-  katze_throbber_set_animated (KATZE_THROBBER (throbber), TRUE);
-  gtk_box_pack_end (GTK_BOX (hbox), throbber, FALSE, FALSE, 0);
-
-  /* Status label*/
-  status_label = gtk_label_new ("");
-  gtk_label_set_markup (GTK_LABEL (status_label),
-                        _("<span weight=\"bold\" stretch=\"semiexpanded\">"
-                          "Status</span>"));
-  gtk_misc_set_alignment (GTK_MISC (status_label), 0, 0);
-  gtk_box_pack_start (GTK_BOX (hbox), status_label, FALSE, FALSE, 0);
-
-  /* Information label */
-  label = gtk_label_new ("");
-  gtk_container_add (GTK_CONTAINER (main_box), label);
-
-  gtk_widget_show_all (GTK_DIALOG(dialog)->vbox);
-
-  job = zimagez_upload_to_zimagez (image_path, last_user, title);
+  dialog = create_throbber_dialog(_("ZimageZ"), &label);
+
+  job = screenshooter_simple_job_launch (zimagez_upload_job, 3,
+                                          G_TYPE_STRING, image_path,
+                                          G_TYPE_STRING, last_user,
+                                          G_TYPE_STRING, title);
 
   g_signal_connect (job, "ask", G_CALLBACK (cb_ask_for_information), NULL);
   g_signal_connect (job, "image-uploaded", G_CALLBACK (cb_image_uploaded), new_last_user);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list