[Xfce4-commits] <thunar-vcs-plugin:thunarx-2> * thunar-vcs-plugin/tvp-git-action.c tvp-git-helper/main.c tvp-git-helper/tgh-move.[ch]: Added move action. * tvp-git-helper/tgh-common.c: Correctly exit the helper if no parent was given for an error dialog.
Peter de Ridder
noreply at xfce.org
Sun Nov 29 19:06:04 CET 2009
Updating branch refs/heads/thunarx-2
to 7ad4d3df2c23f6acc2679f6f7da6c3dda390a880 (commit)
from 6caa3f0f37898d4b01ee892c9b437e872ea810bc (commit)
commit 7ad4d3df2c23f6acc2679f6f7da6c3dda390a880
Author: Peter de Ridder <peter at xfce.org>
Date: Sat Nov 7 18:18:13 2009 +0100
* thunar-vcs-plugin/tvp-git-action.c tvp-git-helper/main.c
tvp-git-helper/tgh-move.[ch]: Added move action.
* tvp-git-helper/tgh-common.c: Correctly exit the helper if no parent
was given for an error dialog.
thunar-vcs-plugin/tvp-git-action.c | 3 +-
tvp-git-helper/Makefile.am | 2 +
tvp-git-helper/main.c | 17 ++++++
tvp-git-helper/tgh-common.c | 2 +-
tvp-git-helper/{tgh-reset.c => tgh-move.c} | 83 +++++++++++++++------------
tvp-git-helper/{tgh-log.h => tgh-move.h} | 8 +-
6 files changed, 72 insertions(+), 43 deletions(-)
diff --git a/thunar-vcs-plugin/tvp-git-action.c b/thunar-vcs-plugin/tvp-git-action.c
index 59d58a4..ab38395 100644
--- a/thunar-vcs-plugin/tvp-git-action.c
+++ b/thunar-vcs-plugin/tvp-git-action.c
@@ -278,7 +278,8 @@ tvp_git_action_create_menu_item (GtkAction *action)
add_subaction_u(GTK_MENU_SHELL(menu), "tvp::init", Q_("Menu|Init"), _("Init"), NULL, _("Init"));
add_subaction (action, GTK_MENU_SHELL(menu), "tvp::log", Q_("Menu|Log"), _("Log"), GTK_STOCK_INDEX, "--log");
add_subaction_u(GTK_MENU_SHELL(menu), "tvp::merge", Q_("Menu|Merge"), _("Merge"), NULL, _("Merge"));
- add_subaction_u(GTK_MENU_SHELL(menu), "tvp::move", Q_("Menu|Move"), _("Move"), GTK_STOCK_DND_MULTIPLE, _("Move"));
+ if(!tvp_action->property.is_parent)
+ add_subaction (action, GTK_MENU_SHELL(menu), "tvp::move", Q_("Menu|Move"), _("Move"), GTK_STOCK_DND_MULTIPLE, "--move");
add_subaction_u(GTK_MENU_SHELL(menu), "tvp::pull", Q_("Menu|Pull"), _("Pull"), NULL, _("Pull"));
add_subaction_u(GTK_MENU_SHELL(menu), "tvp::push", Q_("Menu|Push"), _("Push"), NULL, _("Push"));
add_subaction_u(GTK_MENU_SHELL(menu), "tvp::rebase", Q_("Menu|Rebase"), _("Rebase"), NULL, _("Rebase"));
diff --git a/tvp-git-helper/Makefile.am b/tvp-git-helper/Makefile.am
index 1957d9c..475f01f 100644
--- a/tvp-git-helper/Makefile.am
+++ b/tvp-git-helper/Makefile.am
@@ -28,6 +28,8 @@ tvp_git_helper_SOURCES = \
tgh-common.c \
tgh-log.h \
tgh-log.c \
+ tgh-move.h \
+ tgh-move.c \
tgh-reset.h \
tgh-reset.c \
tgh-stash.h \
diff --git a/tvp-git-helper/main.c b/tvp-git-helper/main.c
index 0690662..3a8ed52 100644
--- a/tvp-git-helper/main.c
+++ b/tvp-git-helper/main.c
@@ -36,6 +36,7 @@
#include "tgh-clone.h"
#include "tgh-clean.h"
#include "tgh-log.h"
+#include "tgh-move.h"
#include "tgh-reset.h"
#include "tgh-stash.h"
#include "tgh-status.h"
@@ -62,6 +63,7 @@ int main (int argc, char *argv[])
gboolean clean = FALSE;
gboolean clone = FALSE;
gboolean log = FALSE;
+ gboolean move = FALSE;
gboolean reset = FALSE;
gboolean stash = FALSE;
gboolean status = FALSE;
@@ -114,6 +116,12 @@ int main (int argc, char *argv[])
{ NULL, '\0', 0, 0, NULL, NULL, NULL }
};
+ GOptionEntry move_options_table[] =
+ {
+ { "move", '\0', 0, G_OPTION_ARG_NONE, &move, N_("Execute move action"), NULL },
+ { NULL, '\0', 0, 0, NULL, NULL, NULL }
+ };
+
GOptionEntry reset_options_table[] =
{
{ "reset", '\0', 0, G_OPTION_ARG_NONE, &reset, N_("Execute reset action"), NULL },
@@ -164,6 +172,10 @@ int main (int argc, char *argv[])
g_option_group_add_entries(option_group, log_options_table);
g_option_context_add_group(option_context, option_group);
+ option_group = g_option_group_new("move", N_("Move Related Options:"), N_("Move"), NULL, NULL);
+ g_option_group_add_entries(option_group, move_options_table);
+ g_option_context_add_group(option_context, option_group);
+
option_group = g_option_group_new("reset", N_("Reset Related Options:"), N_("Reset"), NULL, NULL);
g_option_group_add_entries(option_group, reset_options_table);
g_option_context_add_group(option_context, option_group);
@@ -218,6 +230,11 @@ int main (int argc, char *argv[])
has_child = tgh_log(files, &pid);
}
+ if(move)
+ {
+ has_child = tgh_move(files, &pid);
+ }
+
if(reset)
{
has_child = tgh_reset(files, &pid);
diff --git a/tvp-git-helper/tgh-common.c b/tvp-git-helper/tgh-common.c
index 8daddac..62fd1d0 100644
--- a/tvp-git-helper/tgh-common.c
+++ b/tvp-git-helper/tgh-common.c
@@ -79,7 +79,7 @@ create_error_dialog (GtkWindow *parent, gchar *message)
GtkWidget *error;
error = gtk_message_dialog_new (parent?GTK_WINDOW (parent):NULL, parent?GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL:0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Failed"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (error), "%s", g_strstrip (message));
- tgh_dialog_start (GTK_DIALOG (error), FALSE);
+ tgh_dialog_start (GTK_DIALOG (error), !parent);
}
}
diff --git a/tvp-git-helper/tgh-reset.c b/tvp-git-helper/tgh-move.c
similarity index 51%
copy from tvp-git-helper/tgh-reset.c
copy to tvp-git-helper/tgh-move.c
index 7a4414d..0e89843 100644
--- a/tvp-git-helper/tgh-reset.c
+++ b/tvp-git-helper/tgh-move.c
@@ -24,14 +24,15 @@
#include <glib.h>
#include <gtk/gtk.h>
+#include <dirent.h>
#include <thunar-vfs/thunar-vfs.h>
#include "tgh-common.h"
#include "tgh-dialog-common.h"
-#include "tgh-file-selection-dialog.h"
+#include "tgh-notify-dialog.h"
-#include "tgh-reset.h"
+#include "tgh-move.h"
struct exit_args
{
@@ -39,24 +40,24 @@ struct exit_args
GtkWidget *dialog;
};
-static void child_exit(GPid pid, gint status, gpointer user_data)
+static void child_exit (GPid pid, gint status, gpointer user_data)
{
struct exit_args *args = user_data;
- gtk_widget_destroy(args->dialog);
+ gtk_widget_destroy (args->dialog);
- if(WEXITSTATUS(status) <= 1)
+ if (WEXITSTATUS (status) <= 1)
{
- GtkWidget *dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_OTHER, GTK_BUTTONS_CLOSE, _("Reset finished"));
- tgh_dialog_start(GTK_DIALOG(dialog), TRUE);
+ GtkWidget *dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_OTHER, GTK_BUTTONS_CLOSE, _("Move finished"));
+ tgh_dialog_start (GTK_DIALOG (dialog), TRUE);
}
- tgh_child_exit(pid, status, args->parser);
+ tgh_child_exit (pid, status, args->parser);
- g_free(args);
+ g_free (args);
}
-static gboolean reset_spawn (GtkWidget *dialog, gchar **files, GPid *pid)
+static gboolean move_spawn (GtkWidget *dialog, gchar **files, gchar *dest, GPid *pid)
{
GError *error = NULL;
gint fd_err;
@@ -67,51 +68,56 @@ static gboolean reset_spawn (GtkWidget *dialog, gchar **files, GPid *pid)
gchar **argv;
struct exit_args *args;
- length = 5;
- length += g_strv_length(files);
+ length = 4;
+ length += g_strv_length (files);
- argv = g_new(gchar*, length);
+ argv = g_new (gchar*, length);
argv[0] = "git";
- argv[1] = "reset";
- argv[2] = "-q";
- argv[3] = "--";
+ argv[1] = "mv";
argv[length-1] = NULL;
- i = 4;
- while(*files)
+ i = 2;
+ while (*files)
argv[i++] = *files++;
- if(!g_spawn_async_with_pipes(NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, NULL, NULL, pid, NULL, NULL, &fd_err, &error))
+ argv[i] = dest;
+
+ if (!g_spawn_async_with_pipes (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, NULL, NULL, pid, NULL, NULL, &fd_err, &error))
{
g_free (argv);
return FALSE;
}
g_free (argv);
- parser = tgh_error_parser_new(GTK_WIDGET(dialog));
+ parser = tgh_error_parser_new (NULL);
- args = g_new(struct exit_args, 1);
+ args = g_new (struct exit_args, 1);
args->parser = parser;
args->dialog = dialog;
- g_child_watch_add(*pid, (GChildWatchFunc)child_exit, args);
+ g_child_watch_add (*pid, (GChildWatchFunc)child_exit, args);
- chan_err = g_io_channel_unix_new(fd_err);
- g_io_add_watch(chan_err, G_IO_IN|G_IO_HUP, (GIOFunc)tgh_parse_output_func, parser);
+ chan_err = g_io_channel_unix_new (fd_err);
+ g_io_add_watch (chan_err, G_IO_IN|G_IO_HUP, (GIOFunc)tgh_parse_output_func, parser);
return TRUE;
}
-gboolean tgh_reset (gchar **files, GPid *pid)
+gboolean tgh_move (gchar **files, GPid *pid)
{
GtkWidget *dialog;
+ gchar *to;
+ gboolean multiple = FALSE;
+
+ if (files && files[0] && files[1])
+ multiple = TRUE;
if (files)
- if (chdir(files[0]))
+ if (chdir (files[0]))
{
- gchar *dirname = g_dirname (files[0]);
- if (chdir(dirname))
+ gchar *dirname = g_path_get_dirname (files[0]);
+ if (chdir (dirname))
{
g_free (dirname);
return FALSE;
@@ -119,23 +125,26 @@ gboolean tgh_reset (gchar **files, GPid *pid)
g_free (dirname);
}
- dialog = tgh_file_selection_dialog_new (_("Reset"), NULL, 0, TGH_FILE_SELECTION_FLAG_ADDED);
+ dialog = gtk_file_chooser_dialog_new (_("Move To"), NULL,
+ multiple?GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+ NULL);
+
if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
{
gtk_widget_destroy (dialog);
return FALSE;
}
- g_strfreev (files);
- files = tgh_file_selection_dialog_get_files (TGH_FILE_SELECTION_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- if (!files)
- return FALSE;
+ to = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+
+ gtk_widget_destroy (dialog);
- dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_OTHER, GTK_BUTTONS_CANCEL, _("Reset ..."));
+ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_OTHER, GTK_BUTTONS_CANCEL, _("Move ..."));
g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (tgh_cancel), NULL);
- tgh_dialog_start (GTK_DIALOG(dialog), TRUE);
+ tgh_dialog_start (GTK_DIALOG (dialog), TRUE);
- return reset_spawn (dialog, files, pid);
+ return move_spawn (dialog, files, to, pid);
}
diff --git a/tvp-git-helper/tgh-log.h b/tvp-git-helper/tgh-move.h
similarity index 87%
copy from tvp-git-helper/tgh-log.h
copy to tvp-git-helper/tgh-move.h
index 4dc7265..9947c00 100644
--- a/tvp-git-helper/tgh-log.h
+++ b/tvp-git-helper/tgh-move.h
@@ -14,14 +14,14 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef __TGH_LOG_H__
-#define __TGH_LOG_H__
+#ifndef __TGH_MOVE_H__
+#define __TGH_MOVE_H__
G_BEGIN_DECLS
-gboolean tgh_log (gchar**, GPid*);
+gboolean tgh_move (gchar **, GPid *);
G_END_DECLS
-#endif /*__TGH_LOG_H__*/
+#endif /*__TGH_MOVE_H__*/
More information about the Xfce4-commits
mailing list