Commit 544dad41 authored by Cyrille Pontvieux's avatar Cyrille Pontvieux Committed by Alexander Schwinn
Browse files

Add THUNAR_JOB_RESPONSE_REPLACE and

THUNAR_JOB_RESPONSE_SKIP to keep the code human readable, and as
preperation for Bug #16686
parent 1859bb98
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -458,6 +458,22 @@ thunar_dialogs_show_job_ask (GtkWindow *parent,
          mnemonic = _("Yes to _all");
          break;

        case THUNAR_JOB_RESPONSE_REPLACE:
          mnemonic = _("_Replace");
          break;

        case THUNAR_JOB_RESPONSE_REPLACE_ALL:
          mnemonic = _("Replace _All");
          break;

        case THUNAR_JOB_RESPONSE_SKIP:
          mnemonic = _("_Skip");
          break;

        case THUNAR_JOB_RESPONSE_SKIP_ALL:
          mnemonic = _("S_kip All");
          break;

        case THUNAR_JOB_RESPONSE_NO:
          mnemonic = _("_No");
          break;
@@ -588,7 +604,7 @@ thunar_dialogs_show_job_ask_replace (GtkWindow *parent,
  gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
  gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
  gtk_dialog_set_default_response (GTK_DIALOG (dialog), THUNAR_JOB_RESPONSE_YES);
  gtk_dialog_set_default_response (GTK_DIALOG (dialog), THUNAR_JOB_RESPONSE_REPLACE);
  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));

  /* determine the icon factory to use */
@@ -618,10 +634,10 @@ thunar_dialogs_show_job_ask_replace (GtkWindow *parent,
  g_signal_connect (replace_button,     "clicked", G_CALLBACK (thunar_dialogs_show_job_ask_replace_callback), dialog);

  g_object_set_data (G_OBJECT (cancel_button),     "response-id", GINT_TO_POINTER (GTK_RESPONSE_CANCEL));
  g_object_set_data (G_OBJECT (skipall_button),    "response-id", GINT_TO_POINTER (THUNAR_JOB_RESPONSE_NO_ALL));
  g_object_set_data (G_OBJECT (skip_button),       "response-id", GINT_TO_POINTER (THUNAR_JOB_RESPONSE_NO));
  g_object_set_data (G_OBJECT (replaceall_button), "response-id", GINT_TO_POINTER (THUNAR_JOB_RESPONSE_YES_ALL));
  g_object_set_data (G_OBJECT (replace_button),    "response-id", GINT_TO_POINTER (THUNAR_JOB_RESPONSE_YES));
  g_object_set_data (G_OBJECT (skipall_button),    "response-id", GINT_TO_POINTER (THUNAR_JOB_RESPONSE_SKIP_ALL));
  g_object_set_data (G_OBJECT (skip_button),       "response-id", GINT_TO_POINTER (THUNAR_JOB_RESPONSE_SKIP));
  g_object_set_data (G_OBJECT (replaceall_button), "response-id", GINT_TO_POINTER (THUNAR_JOB_RESPONSE_REPLACE_ALL));
  g_object_set_data (G_OBJECT (replace_button),    "response-id", GINT_TO_POINTER (THUNAR_JOB_RESPONSE_REPLACE));

  gtk_container_add (GTK_CONTAINER (button_box), cancel_button);
  gtk_container_add (GTK_CONTAINER (button_box), skipall_button);
+12 −8
Original line number Diff line number Diff line
@@ -368,6 +368,10 @@ thunar_job_response_get_type (void)
	      { THUNAR_JOB_RESPONSE_NO_ALL,      "THUNAR_JOB_RESPONSE_NO_ALL",      "no-all"      },
	      { THUNAR_JOB_RESPONSE_RETRY,       "THUNAR_JOB_RESPONSE_RETRY",       "retry"       },
	      { THUNAR_JOB_RESPONSE_FORCE,       "THUNAR_JOB_RESPONSE_FORCE",       "force"       },
	      { THUNAR_JOB_RESPONSE_REPLACE,     "THUNAR_JOB_RESPONSE_REPLACE",     "replace"     },
	      { THUNAR_JOB_RESPONSE_REPLACE_ALL, "THUNAR_JOB_RESPONSE_REPLACE_ALL", "replace-all" },
	      { THUNAR_JOB_RESPONSE_SKIP,        "THUNAR_JOB_RESPONSE_SKIP",        "skip"        },
	      { THUNAR_JOB_RESPONSE_SKIP_ALL,    "THUNAR_JOB_RESPONSE_SKIP_ALL",    "skip-all"    },
	      { 0,                               NULL,                              NULL          }
	    };

+23 −15
Original line number Diff line number Diff line
@@ -236,6 +236,10 @@ ThunarThumbnailSize thunar_zoom_level_to_thumbnail_size (ThunarZoomLevel zoom_
 * @THUNAR_JOB_RESPONSE_CANCEL      :
 * @THUNAR_JOB_RESPONSE_RETRY       :
 * @THUNAR_JOB_RESPONSE_FORCE       :
 * @THUNAR_JOB_RESPONSE_REPLACE     :
 * @THUNAR_JOB_RESPONSE_REPLACE_ALL :
 * @THUNAR_JOB_RESPONSE_SKIP        :
 * @THUNAR_JOB_RESPONSE_SKIP_ALL    :
 *
 * Possible responses for the ThunarJob::ask signal.
 **/
@@ -248,8 +252,12 @@ typedef enum /*< flags >*/
  THUNAR_JOB_RESPONSE_NO_ALL      = 1 << 4,
  THUNAR_JOB_RESPONSE_RETRY       = 1 << 5,
  THUNAR_JOB_RESPONSE_FORCE       = 1 << 6,
  THUNAR_JOB_RESPONSE_REPLACE     = 1 << 7,
  THUNAR_JOB_RESPONSE_REPLACE_ALL = 1 << 8,
  THUNAR_JOB_RESPONSE_SKIP        = 1 << 9,
  THUNAR_JOB_RESPONSE_SKIP_ALL    = 1 << 10,
} ThunarJobResponse;
#define THUNAR_JOB_RESPONSE_MAX_INT 6
#define THUNAR_JOB_RESPONSE_MAX_INT 10

GType thunar_job_response_get_type (void) G_GNUC_CONST;

+4 −4
Original line number Diff line number Diff line
@@ -215,7 +215,7 @@ again:
                                                   display_name);

              /* check if we should overwrite */
              if (response == THUNAR_JOB_RESPONSE_YES)
              if (response == THUNAR_JOB_RESPONSE_REPLACE)
                {
                  /* try to remove the file. fail if not possible */
                  if (_tij_delete_file (lp->data, exo_job_get_cancellable (EXO_JOB (job)), &err))
@@ -370,7 +370,7 @@ again:
                                                   display_name);

              /* check if we should overwrite it */
              if (response == THUNAR_JOB_RESPONSE_YES)
              if (response == THUNAR_JOB_RESPONSE_REPLACE)
                {
                  /* try to remove the file, fail if not possible */
                  if (_tij_delete_file (lp->data, exo_job_get_cancellable (EXO_JOB (job)), &err))
@@ -709,7 +709,7 @@ _thunar_io_jobs_link_file (ThunarJob *job,
            break;

          /* try to delete the file */
          if (response == THUNAR_JOB_RESPONSE_YES)
          if (response == THUNAR_JOB_RESPONSE_REPLACE)
            {
              /* try to remove the target file. if not possible, err will be set and
               * the while loop will be aborted */
@@ -718,7 +718,7 @@ _thunar_io_jobs_link_file (ThunarJob *job,

          /* tell the caller that we skipped this file if the user doesn't want to
           * overwrite it */
          if (response == THUNAR_JOB_RESPONSE_NO)
          if (response == THUNAR_JOB_RESPONSE_SKIP)
            return g_object_ref (source_file);
        }
    }
+33 −33
Original line number Diff line number Diff line
@@ -257,10 +257,10 @@ thunar_job_real_ask_replace (ThunarJob *job,
                             thunar_file_get_display_name (source_file));

  g_signal_emit (job, job_signals[ASK], 0, message,
                 THUNAR_JOB_RESPONSE_YES
                 | THUNAR_JOB_RESPONSE_YES_ALL
                 | THUNAR_JOB_RESPONSE_NO
                 | THUNAR_JOB_RESPONSE_NO_ALL
                 THUNAR_JOB_RESPONSE_REPLACE
                 | THUNAR_JOB_RESPONSE_REPLACE_ALL
                 | THUNAR_JOB_RESPONSE_SKIP
                 | THUNAR_JOB_RESPONSE_SKIP_ALL
                 | THUNAR_JOB_RESPONSE_CANCEL,
                 &response);

@@ -322,21 +322,21 @@ thunar_job_ask_overwrite (ThunarJob *job,
    return THUNAR_JOB_RESPONSE_CANCEL;

  /* check if the user said "Overwrite All" earlier */
  if (G_UNLIKELY (job->priv->earlier_ask_overwrite_response == THUNAR_JOB_RESPONSE_YES_ALL))
    return THUNAR_JOB_RESPONSE_YES;
  if (G_UNLIKELY (job->priv->earlier_ask_overwrite_response == THUNAR_JOB_RESPONSE_REPLACE_ALL))
    return THUNAR_JOB_RESPONSE_REPLACE;

  /* check if the user said "Overwrite None" earlier */
  if (G_UNLIKELY (job->priv->earlier_ask_overwrite_response == THUNAR_JOB_RESPONSE_NO_ALL))
    return THUNAR_JOB_RESPONSE_NO;
  if (G_UNLIKELY (job->priv->earlier_ask_overwrite_response == THUNAR_JOB_RESPONSE_SKIP_ALL))
    return THUNAR_JOB_RESPONSE_SKIP;

  /* ask the user what he wants to do */
  va_start (var_args, format);
  response = _thunar_job_ask_valist (job, format, var_args,
                                     _("Do you want to overwrite it?"),
                                     THUNAR_JOB_RESPONSE_YES
                                     | THUNAR_JOB_RESPONSE_YES_ALL
                                     | THUNAR_JOB_RESPONSE_NO
                                     | THUNAR_JOB_RESPONSE_NO_ALL
                                     THUNAR_JOB_RESPONSE_REPLACE
                                     | THUNAR_JOB_RESPONSE_REPLACE_ALL
                                     | THUNAR_JOB_RESPONSE_SKIP
                                     | THUNAR_JOB_RESPONSE_SKIP_ALL
                                     | THUNAR_JOB_RESPONSE_CANCEL);
  va_end (var_args);

@@ -346,12 +346,12 @@ thunar_job_ask_overwrite (ThunarJob *job,
  /* translate response */
  switch (response)
    {
    case THUNAR_JOB_RESPONSE_YES_ALL:
      response = THUNAR_JOB_RESPONSE_YES;
    case THUNAR_JOB_RESPONSE_REPLACE_ALL:
      response = THUNAR_JOB_RESPONSE_REPLACE;
      break;

    case THUNAR_JOB_RESPONSE_NO_ALL:
      response = THUNAR_JOB_RESPONSE_NO;
    case THUNAR_JOB_RESPONSE_SKIP_ALL:
      response = THUNAR_JOB_RESPONSE_SKIP;
      break;

    default:
@@ -481,24 +481,24 @@ thunar_job_ask_replace (ThunarJob *job,
    return THUNAR_JOB_RESPONSE_CANCEL;

  /* check if the user said "Overwrite All" earlier */
  if (G_UNLIKELY (job->priv->earlier_ask_overwrite_response == THUNAR_JOB_RESPONSE_YES_ALL))
    return THUNAR_JOB_RESPONSE_YES;
  if (G_UNLIKELY (job->priv->earlier_ask_overwrite_response == THUNAR_JOB_RESPONSE_REPLACE_ALL))
    return THUNAR_JOB_RESPONSE_REPLACE;

  /* check if the user said "Overwrite None" earlier */
  if (G_UNLIKELY (job->priv->earlier_ask_overwrite_response == THUNAR_JOB_RESPONSE_NO_ALL))
    return THUNAR_JOB_RESPONSE_NO;
  if (G_UNLIKELY (job->priv->earlier_ask_overwrite_response == THUNAR_JOB_RESPONSE_SKIP_ALL))
    return THUNAR_JOB_RESPONSE_SKIP;

  source_file = thunar_file_get (source_path, error);

  if (G_UNLIKELY (source_file == NULL))
    return THUNAR_JOB_RESPONSE_NO;
    return THUNAR_JOB_RESPONSE_SKIP;

  target_file = thunar_file_get (target_path, error);

  if (G_UNLIKELY (target_file == NULL))
    {
      g_object_unref (source_file);
      return THUNAR_JOB_RESPONSE_NO;
      return THUNAR_JOB_RESPONSE_SKIP;
    }

  exo_job_emit (EXO_JOB (job), job_signals[ASK_REPLACE], 0,
@@ -511,10 +511,10 @@ thunar_job_ask_replace (ThunarJob *job,
  job->priv->earlier_ask_overwrite_response = response;

  /* translate the response */
  if (response == THUNAR_JOB_RESPONSE_YES_ALL)
    response = THUNAR_JOB_RESPONSE_YES;
  else if (response == THUNAR_JOB_RESPONSE_NO_ALL)
    response = THUNAR_JOB_RESPONSE_NO;
  if (response == THUNAR_JOB_RESPONSE_REPLACE_ALL)
    response = THUNAR_JOB_RESPONSE_REPLACE;
  else if (response == THUNAR_JOB_RESPONSE_SKIP_ALL)
    response = THUNAR_JOB_RESPONSE_SKIP;
  else if (response == THUNAR_JOB_RESPONSE_CANCEL)
    exo_job_cancel (EXO_JOB (job));

@@ -539,15 +539,15 @@ thunar_job_ask_skip (ThunarJob *job,
    return THUNAR_JOB_RESPONSE_CANCEL;

  /* check if the user said "Skip All" earlier */
  if (G_UNLIKELY (job->priv->earlier_ask_skip_response == THUNAR_JOB_RESPONSE_YES_ALL))
    return THUNAR_JOB_RESPONSE_YES;
  if (G_UNLIKELY (job->priv->earlier_ask_skip_response == THUNAR_JOB_RESPONSE_SKIP_ALL))
    return THUNAR_JOB_RESPONSE_SKIP;

  /* ask the user what he wants to do */
  va_start (var_args, format);
  response = _thunar_job_ask_valist (job, format, var_args,
                                     _("Do you want to skip it?"),
                                     THUNAR_JOB_RESPONSE_YES
                                     | THUNAR_JOB_RESPONSE_YES_ALL
                                     THUNAR_JOB_RESPONSE_SKIP
                                     | THUNAR_JOB_RESPONSE_SKIP_ALL
                                     | THUNAR_JOB_RESPONSE_CANCEL
                                     | THUNAR_JOB_RESPONSE_RETRY);
  va_end (var_args);
@@ -558,11 +558,11 @@ thunar_job_ask_skip (ThunarJob *job,
  /* translate the response */
  switch (response)
    {
    case THUNAR_JOB_RESPONSE_YES_ALL:
      response = THUNAR_JOB_RESPONSE_YES;
    case THUNAR_JOB_RESPONSE_SKIP_ALL:
      response = THUNAR_JOB_RESPONSE_SKIP;
      break;

    case THUNAR_JOB_RESPONSE_YES:
    case THUNAR_JOB_RESPONSE_SKIP:
    case THUNAR_JOB_RESPONSE_CANCEL:
    case THUNAR_JOB_RESPONSE_RETRY:
      break;
Loading