[Goodies-commits] r7843 - in thunar-vcs-plugin/trunk: thunar-vcs-plugin tvp-svn-helper
Peter de Ridder
peter at xfce.org
Sun Jul 26 19:49:54 CEST 2009
Author: peter
Date: 2009-07-26 17:49:54 +0000 (Sun, 26 Jul 2009)
New Revision: 7843
Added:
thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-tree-common.c
thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-tree-common.h
Modified:
thunar-vcs-plugin/trunk/thunar-vcs-plugin/tvp-svn-action.c
thunar-vcs-plugin/trunk/tvp-svn-helper/Makefile.am
thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-common.c
thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-file-selection-dialog.c
thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log-dialog.c
thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log-dialog.h
thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log-message-dialog.c
thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log.c
thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-status-dialog.c
Log:
* thunar-vcs-plugin/tvp-svn-action.c: The add context menu item is now visible on folder background menu too.
* tvp-svn-helper/tsh-{file-selection,log-message,log,status}-dialog.c: The file lists are tree views now.
* tvp-svn-helper/tsh-tree-common.[ch]: Common routines to build a tree view of files.
* tvp-svn-helper/tsh-common.c(tsh_log_func) tvp-svn-helper/tsh-log-dialog.[ch]: Support has_children for log entries.
* tvp-svn-helper/Makefile.am: tsh-tree-common.[ch] added.
Modified: thunar-vcs-plugin/trunk/thunar-vcs-plugin/tvp-svn-action.c
===================================================================
--- thunar-vcs-plugin/trunk/thunar-vcs-plugin/tvp-svn-action.c 2009-07-26 16:45:07 UTC (rev 7842)
+++ thunar-vcs-plugin/trunk/thunar-vcs-plugin/tvp-svn-action.c 2009-07-26 17:49:54 UTC (rev 7843)
@@ -292,8 +292,8 @@
menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
- /* No version control */
- if (!tvp_action->property.is_parent && tvp_action->property.parent_version_control && (tvp_action->property.directory_no_version_control || tvp_action->property.file_no_version_control))
+ /* No version control or version control (parent) */
+ if (tvp_action->property.parent_version_control && (tvp_action->property.is_parent || tvp_action->property.directory_no_version_control || tvp_action->property.file_no_version_control))
{
add_subaction (action, GTK_MENU_SHELL (menu), "tvp::add", Q_("Menu|Add"), _("Add"), GTK_STOCK_ADD, "--add");
}
Modified: thunar-vcs-plugin/trunk/tvp-svn-helper/Makefile.am
===================================================================
--- thunar-vcs-plugin/trunk/tvp-svn-helper/Makefile.am 2009-07-26 16:45:07 UTC (rev 7842)
+++ thunar-vcs-plugin/trunk/tvp-svn-helper/Makefile.am 2009-07-26 17:49:54 UTC (rev 7843)
@@ -56,6 +56,8 @@
tsh-unlock.c \
tsh-update.h \
tsh-update.c \
+ tsh-tree-common.h \
+ tsh-tree-common.c \
tsh-dialog-common.h \
tsh-dialog-common.c \
tsh-blame-dialog.h \
Modified: thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-common.c
===================================================================
--- thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-common.c 2009-07-26 16:45:07 UTC (rev 7842)
+++ thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-common.c 2009-07-26 17:49:54 UTC (rev 7843)
@@ -816,8 +816,17 @@
gchar *date = NULL;
gchar *message = NULL;
GSList *files = NULL;
+ const gchar *parent = NULL;
+ gchar *path = NULL;
TshLogDialog *dialog = TSH_LOG_DIALOG (baton);
+ if (log_entry->revision == SVN_INVALID_REVNUM)
+ {
+ tsh_log_dialog_pop (dialog);
+ return SVN_NO_ERROR;
+ }
+
+
value = apr_hash_get(revprops, SVN_PROP_REVISION_AUTHOR, APR_HASH_KEY_STRING);
if(value)
author = g_strndup (value->data, value->len);
@@ -850,10 +859,17 @@
}
}
+ parent = tsh_log_dialog_top (dialog);
+
gdk_threads_enter();
- tsh_log_dialog_add(dialog, files, log_entry->revision, author, date, message);
+ path = tsh_log_dialog_add(dialog, parent, files, log_entry->revision, author, date, message);
gdk_threads_leave();
+ if (log_entry->has_children)
+ tsh_log_dialog_push (dialog, path);
+ else
+ g_free (path);
+
g_free(author);
g_free(date);
g_free(message);
Modified: thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-file-selection-dialog.c
===================================================================
--- thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-file-selection-dialog.c 2009-07-26 16:45:07 UTC (rev 7842)
+++ thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-file-selection-dialog.c 2009-07-26 17:49:54 UTC (rev 7843)
@@ -28,6 +28,7 @@
#include <subversion-1/svn_pools.h>
#include "tsh-common.h"
+#include "tsh-tree-common.h"
#include "tsh-file-selection-dialog.h"
static void tsh_file_selection_status_func2 (void *, const char *, svn_wc_status2_t *);
@@ -35,6 +36,11 @@
static void selection_cell_toggled (GtkCellRendererToggle *, gchar *, gpointer);
static void selection_all_toggled (GtkToggleButton *, gpointer);
+static gboolean count_selected (GtkTreeModel*, GtkTreePath*, GtkTreeIter*, gpointer);
+static gboolean copy_selected (GtkTreeModel*, GtkTreePath*, GtkTreeIter*, gpointer);
+static gboolean set_selected (GtkTreeModel*, GtkTreePath*, GtkTreeIter*, gpointer);
+static void move_info (GtkTreeStore*, GtkTreeIter*, GtkTreeIter*);
+
struct _TshFileSelectionDialog
{
GtkDialog dialog;
@@ -58,11 +64,13 @@
}
enum {
- COLUMN_PATH = 0,
+ COLUMN_PATH = 0,
+ COLUMN_NAME,
COLUMN_TEXT_STAT,
COLUMN_PROP_STAT,
- COLUMN_SELECTION,
- COLUMN_COUNT
+ COLUMN_SELECTION,
+ COLUMN_ENABLED,
+ COLUMN_COUNT
};
static void
@@ -73,6 +81,7 @@
GtkWidget *all;
GtkCellRenderer *renderer;
GtkTreeModel *model;
+ gint n_columns;
scroll_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@@ -84,14 +93,16 @@
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
-1, "", renderer,
"active", COLUMN_SELECTION,
+ "activatable", COLUMN_ENABLED,
NULL);
renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
- -1, _("Path"), renderer,
- "text", COLUMN_PATH,
- NULL);
-
+ n_columns = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
+ -1, _("Path"), renderer,
+ "text", COLUMN_NAME,
+ NULL);
+ gtk_tree_view_set_expander_column (GTK_TREE_VIEW (tree_view), gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), n_columns - 1));
+
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
-1, ("State"), renderer,
@@ -104,7 +115,7 @@
"text", COLUMN_PROP_STAT,
NULL);
- model = GTK_TREE_MODEL (gtk_list_store_new (COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN));
+ model = GTK_TREE_MODEL (gtk_tree_store_new (COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN));
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), model);
@@ -202,60 +213,38 @@
svn_pool_destroy (subpool);
- return GTK_WIDGET(dialog);
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (dialog->tree_view));
+
+ return GTK_WIDGET(dialog);
}
gchar**
tsh_file_selection_dialog_get_files (TshFileSelectionDialog *dialog)
{
GtkTreeModel *model;
- GtkTreeIter iter;
gchar **files, **files_iter;
guint count = 0;
- gboolean selection;
g_return_val_if_fail (TSH_IS_FILE_SELECTION_DIALOG (dialog), NULL);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree_view));
- if (gtk_tree_model_get_iter_first (model, &iter))
- {
- do {
- gtk_tree_model_get (model, &iter,
- COLUMN_SELECTION, &selection,
- -1);
- if (selection)
- count++;
- } while (gtk_tree_model_iter_next (model, &iter));
- }
+ gtk_tree_model_foreach (model, count_selected, &count);
if (!count)
return NULL;
files_iter = files = g_new(gchar *, count+1);
- if (gtk_tree_model_get_iter_first (model, &iter))
- {
- do {
- gtk_tree_model_get (model, &iter,
- COLUMN_SELECTION, &selection,
- -1);
- if (selection)
- {
- gtk_tree_model_get (model, &iter,
- COLUMN_PATH, files_iter,
- -1);
- files_iter++;
- }
- } while (gtk_tree_model_iter_next (model, &iter));
- }
+ gtk_tree_model_foreach (model, copy_selected, &files_iter);
*files_iter = NULL;
return files;
}
-static void tsh_file_selection_status_func2(void *baton, const char *path, svn_wc_status2_t *status)
+static void
+tsh_file_selection_status_func2(void *baton, const char *path, svn_wc_status2_t *status)
{
TshFileSelectionDialog *dialog = TSH_FILE_SELECTION_DIALOG (baton);
gboolean add = FALSE;
@@ -274,23 +263,26 @@
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree_view));
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ tsh_tree_get_iter_for_path (GTK_TREE_STORE (model), path, &iter, COLUMN_NAME, move_info);
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
COLUMN_PATH, path,
COLUMN_TEXT_STAT, tsh_status_to_string(status->text_status),
COLUMN_PROP_STAT, tsh_status_to_string(status->prop_status),
COLUMN_SELECTION, TRUE,
+ COLUMN_ENABLED, TRUE,
-1);
}
}
-static svn_error_t *tsh_file_selection_status_func3(void *baton, const char *path, svn_wc_status2_t *status, apr_pool_t *pool)
+static svn_error_t*
+tsh_file_selection_status_func3(void *baton, const char *path, svn_wc_status2_t *status, apr_pool_t *pool)
{
tsh_file_selection_status_func2(baton, path, status);
return SVN_NO_ERROR;
}
-static void selection_cell_toggled (GtkCellRendererToggle *renderer, gchar *path, gpointer user_data)
+static void
+selection_cell_toggled (GtkCellRendererToggle *renderer, gchar *path, gpointer user_data)
{
TshFileSelectionDialog *dialog = TSH_FILE_SELECTION_DIALOG (user_data);
GtkTreeModel *model;
@@ -304,18 +296,18 @@
gtk_tree_model_get (model, &iter,
COLUMN_SELECTION, &selection,
-1);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
COLUMN_SELECTION, !selection,
-1);
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dialog->all), TRUE);
}
-static void selection_all_toggled (GtkToggleButton *button, gpointer user_data)
+static void
+selection_all_toggled (GtkToggleButton *button, gpointer user_data)
{
TshFileSelectionDialog *dialog = TSH_FILE_SELECTION_DIALOG (user_data);
GtkTreeModel *model;
- GtkTreeIter iter;
gboolean selection;
gtk_toggle_button_set_inconsistent (button, FALSE);
@@ -324,13 +316,76 @@
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree_view));
- if (gtk_tree_model_get_iter_first (model, &iter))
+ gtk_tree_model_foreach (model, set_selected, GINT_TO_POINTER (selection));
+}
+
+static gboolean
+count_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer count)
+{
+ gboolean selection;
+ gtk_tree_model_get (model, iter,
+ COLUMN_SELECTION, &selection,
+ -1);
+ if (selection)
+ (*(guint*)count)++;
+ return FALSE;
+}
+
+static gboolean
+copy_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer files_iter)
+{
+ gboolean selection;
+ gtk_tree_model_get (model, iter,
+ COLUMN_SELECTION, &selection,
+ -1);
+ if (selection)
{
- do {
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COLUMN_SELECTION, selection,
- -1);
- } while (gtk_tree_model_iter_next (model, &iter));
+ gtk_tree_model_get (model, iter,
+ COLUMN_PATH, *(gchar***)files_iter,
+ -1);
+ (*(gchar***)files_iter)++;
}
+ return FALSE;
}
+static gboolean
+set_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer selection)
+{
+ gboolean enabled;
+ gtk_tree_model_get (model, iter,
+ COLUMN_ENABLED, &enabled,
+ -1);
+ if (enabled)
+ gtk_tree_store_set (GTK_TREE_STORE (model), iter,
+ COLUMN_SELECTION, GPOINTER_TO_INT (selection),
+ -1);
+ return FALSE;
+}
+
+static void
+move_info (GtkTreeStore *store, GtkTreeIter *dest, GtkTreeIter *src)
+{
+ gchar *path, *text, *prop;
+ gboolean selected, enabled;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), src,
+ COLUMN_PATH, &path,
+ COLUMN_TEXT_STAT, &text,
+ COLUMN_PROP_STAT, &prop,
+ COLUMN_SELECTION, &selected,
+ COLUMN_ENABLED, &enabled,
+ -1);
+
+ gtk_tree_store_set (store, dest,
+ COLUMN_PATH, path,
+ COLUMN_TEXT_STAT, text,
+ COLUMN_PROP_STAT, prop,
+ COLUMN_SELECTION, selected,
+ COLUMN_ENABLED, enabled,
+ -1);
+
+ g_free (path);
+ g_free (text);
+ g_free (prop);
+}
+
Modified: thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log-dialog.c
===================================================================
--- thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log-dialog.c 2009-07-26 16:45:07 UTC (rev 7842)
+++ thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log-dialog.c 2009-07-26 17:49:54 UTC (rev 7843)
@@ -27,12 +27,15 @@
#include <subversion-1/svn_client.h>
#include "tsh-common.h"
+#include "tsh-tree-common.h"
#include "tsh-log-dialog.h"
static void selection_changed (GtkTreeView*, gpointer);
static void cancel_clicked (GtkButton*, gpointer);
static void refresh_clicked (GtkButton*, gpointer);
+static void move_info (GtkTreeStore*, GtkTreeIter*, GtkTreeIter*);
+
struct _TshLogDialog
{
GtkDialog dialog;
@@ -43,6 +46,8 @@
GtkWidget *close;
GtkWidget *cancel;
GtkWidget *refresh;
+
+ GSList *message_stack;
};
struct _TshLogDialogClass
@@ -105,6 +110,7 @@
GtkWidget *vpane;
GtkCellRenderer *renderer;
GtkTreeModel *model;
+ gint n_columns;
pane = gtk_vpaned_new ();
@@ -137,7 +143,7 @@
renderer, "text",
COLUMN_MESSAGE, NULL);
- model = GTK_TREE_MODEL (gtk_list_store_new (COLUMN_COUNT, G_TYPE_LONG, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER));
+ model = GTK_TREE_MODEL (gtk_tree_store_new (COLUMN_COUNT, G_TYPE_LONG, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER));
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), model);
@@ -175,13 +181,14 @@
renderer, "text",
FILE_COLUMN_ACTION, NULL);
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (file_view),
- -1, _("File"),
- renderer, "text",
- FILE_COLUMN_FILE, NULL);
+ renderer = gtk_cell_renderer_text_new ();
+ n_columns = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (file_view),
+ -1, _("File"),
+ renderer, "text",
+ FILE_COLUMN_FILE, NULL);
+ gtk_tree_view_set_expander_column (GTK_TREE_VIEW (file_view), gtk_tree_view_get_column (GTK_TREE_VIEW (file_view), n_columns - 1));
- model = GTK_TREE_MODEL (gtk_list_store_new (FILE_COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING));
+ model = GTK_TREE_MODEL (gtk_tree_store_new (FILE_COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING));
gtk_tree_view_set_model (GTK_TREE_VIEW (file_view), model);
@@ -241,16 +248,16 @@
return GTK_WIDGET(dialog);
}
-void
-tsh_log_dialog_add (TshLogDialog *dialog, GSList *files, glong revision, const char *author, const char *date, const char *message)
+gchar*
+tsh_log_dialog_add (TshLogDialog *dialog, const gchar *parent, GSList *files, glong revision, const char *author, const char *date, const char *message)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreeIter iter, parent_iter;
gchar **lines = NULL;
gchar **line_iter;
gchar *first_line = NULL;
- g_return_if_fail (TSH_IS_LOG_DIALOG (dialog));
+ g_return_val_if_fail (TSH_IS_LOG_DIALOG (dialog), NULL);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree_view));
@@ -269,26 +276,66 @@
first_line = *line_iter;
}
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COLUMN_REVISION, revision,
- COLUMN_AUTHOR, author,
- COLUMN_DATE, date,
- COLUMN_MESSAGE, first_line,
- COLUMN_FULL_MESSAGE, message,
+ if (parent && !gtk_tree_model_get_iter_from_string (model, &parent_iter, parent))
+ parent = NULL;
+
+ gtk_tree_store_append (GTK_TREE_STORE (model), &iter, parent?&parent_iter:NULL);
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
+ COLUMN_REVISION, revision,
+ COLUMN_AUTHOR, author,
+ COLUMN_DATE, date,
+ COLUMN_MESSAGE, first_line,
+ COLUMN_FULL_MESSAGE, message,
COLUMN_FILE_LIST, files,
- -1);
+ -1);
g_strfreev (lines);
+
+ return gtk_tree_model_get_string_from_iter (model, &iter);
}
void
+tsh_log_dialog_push (TshLogDialog *dialog, gchar *path)
+{
+ g_return_if_fail (TSH_IS_LOG_DIALOG (dialog));
+
+ dialog->message_stack = g_slist_prepend (dialog->message_stack, path);
+}
+
+const gchar*
+tsh_log_dialog_top (TshLogDialog *dialog)
+{
+ g_return_val_if_fail (TSH_IS_LOG_DIALOG (dialog), NULL);
+
+ if (dialog->message_stack)
+ return dialog->message_stack->data;
+ return NULL;
+}
+
+void
+tsh_log_dialog_pop (TshLogDialog *dialog)
+{
+ g_return_if_fail (TSH_IS_LOG_DIALOG (dialog));
+ g_return_if_fail (dialog->message_stack);
+
+ g_free (dialog->message_stack->data);
+ dialog->message_stack = g_slist_delete_link (dialog->message_stack, dialog->message_stack);
+}
+
+void
tsh_log_dialog_done (TshLogDialog *dialog)
{
g_return_if_fail (TSH_IS_LOG_DIALOG (dialog));
- gtk_widget_hide (dialog->cancel);
- gtk_widget_show (dialog->refresh);
+ if (dialog->message_stack)
+ {
+ g_slist_foreach (dialog->message_stack, (GFunc)g_free, NULL);
+ g_slist_free (dialog->message_stack);
+ dialog->message_stack = NULL;
+ }
+
+ gtk_widget_hide (dialog->cancel);
+ gtk_widget_show (dialog->refresh);
}
static void
@@ -311,17 +358,18 @@
g_free (message);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->file_view));
- gtk_list_store_clear (GTK_LIST_STORE (model));
+ gtk_tree_store_clear (GTK_TREE_STORE (model));
while(files)
{
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ tsh_tree_get_iter_for_path (GTK_TREE_STORE (model), TSH_LOG_FILE (files->data)->file, &iter, FILE_COLUMN_FILE, move_info);
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
FILE_COLUMN_ACTION, TSH_LOG_FILE (files->data)->action,
- FILE_COLUMN_FILE, TSH_LOG_FILE (files->data)->file,
-1);
files = files->next;
}
+
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (dialog->file_view));
}
}
@@ -348,11 +396,27 @@
g_signal_emit (dialog, signals[SIGNAL_REFRESH], 0);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree_view));
- gtk_list_store_clear (GTK_LIST_STORE (model));
+ gtk_tree_store_clear (GTK_TREE_STORE (model));
gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->text_view)), "", -1);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->file_view));
- gtk_list_store_clear (GTK_LIST_STORE (model));
+ k_tree_store_clear (GTK_TREE_STORE (model));
}
+static void
+move_info (GtkTreeStore *store, GtkTreeIter *dest, GtkTreeIter *src)
+{
+ gchar *action;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), src,
+ FILE_COLUMN_ACTION, &action,
+ -1);
+
+ gtk_tree_store_set (store, dest,
+ FILE_COLUMN_ACTION, action,
+ -1);
+
+ g_free (action);
+}
+
Modified: thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log-dialog.h
===================================================================
--- thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log-dialog.h 2009-07-26 16:45:07 UTC (rev 7842)
+++ thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log-dialog.h 2009-07-26 17:49:54 UTC (rev 7843)
@@ -42,19 +42,24 @@
#define TSH_LOG_FILE(p) ((TshLogFile*)p)
-GType tsh_log_dialog_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
+GType tsh_log_dialog_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
-GtkWidget* tsh_log_dialog_new (const gchar *title,
- GtkWindow *parent,
- GtkDialogFlags flags) G_GNUC_MALLOC G_GNUC_INTERNAL;
+GtkWidget* tsh_log_dialog_new (const gchar *title,
+ GtkWindow *parent,
+ GtkDialogFlags flags) G_GNUC_MALLOC G_GNUC_INTERNAL;
-void tsh_log_dialog_add (TshLogDialog *dialog,
- GSList *paths,
- glong revision,
- const char *author,
- const char *date,
- const char *message);
-void tsh_log_dialog_done (TshLogDialog *dialog);
+gchar* tsh_log_dialog_add (TshLogDialog *dialog,
+ const gchar *parent,
+ GSList *paths,
+ glong revision,
+ const char *author,
+ const char *date,
+ const char *message) G_GNUC_WARN_UNUSED_RESULT;
+void tsh_log_dialog_push (TshLogDialog *dialog,
+ gchar *path);
+const gchar* tsh_log_dialog_top (TshLogDialog *dialog);
+void tsh_log_dialog_pop (TshLogDialog *dialog);
+void tsh_log_dialog_done (TshLogDialog *dialog);
G_END_DECLS;
Modified: thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log-message-dialog.c
===================================================================
--- thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log-message-dialog.c 2009-07-26 16:45:07 UTC (rev 7842)
+++ thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log-message-dialog.c 2009-07-26 17:49:54 UTC (rev 7843)
@@ -24,8 +24,11 @@
#include <thunar-vfs/thunar-vfs.h>
#include <gtk/gtk.h>
+#include "tsh-tree-common.h"
#include "tsh-log-message-dialog.h"
+static void move_info (GtkTreeStore*, GtkTreeIter*, GtkTreeIter*);
+
struct _TshLogMessageDialog
{
GtkDialog dialog;
@@ -62,6 +65,7 @@
GtkWidget *vpane;
GtkCellRenderer *renderer;
GtkTreeModel *model;
+ gint n_columns;
dialog->vpane = vpane = gtk_vpaned_new ();
@@ -79,6 +83,9 @@
scroll_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ scroll_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
dialog->tree_view = tree_view = gtk_tree_view_new ();
renderer = gtk_cell_renderer_text_new ();
@@ -87,13 +94,14 @@
renderer, "text",
COLUMN_STATE, NULL);
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
- -1, _("Path"),
- renderer, "text",
- COLUMN_PATH, NULL);
+ renderer = gtk_cell_renderer_text_new ();
+ n_columns = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
+ -1, _("Path"),
+ renderer, "text",
+ COLUMN_PATH, NULL);
+ gtk_tree_view_set_expander_column (GTK_TREE_VIEW (tree_view), gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), n_columns - 1));
- model = GTK_TREE_MODEL (gtk_list_store_new (COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING));
+ model = GTK_TREE_MODEL (gtk_tree_store_new (COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING));
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), model);
@@ -152,11 +160,12 @@
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree_view));
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COLUMN_STATE, state,
- COLUMN_PATH, file,
- -1);
+ tsh_tree_get_iter_for_path (GTK_TREE_STORE (model), file, &iter, COLUMN_PATH, move_info);
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
+ COLUMN_STATE, state,
+ -1);
+
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (dialog->tree_view));
}
gchar *
@@ -172,3 +181,19 @@
return gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
}
+static void
+move_info (GtkTreeStore *store, GtkTreeIter *dest, GtkTreeIter *src)
+{
+ gchar *state;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), src,
+ COLUMN_STATE, &state,
+ -1);
+
+ gtk_tree_store_set (store, dest,
+ COLUMN_STATE, state,
+ -1);
+
+ g_free (state);
+}
+
Modified: thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log.c
===================================================================
--- thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log.c 2009-07-26 16:45:07 UTC (rev 7842)
+++ thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-log.c 2009-07-26 17:49:54 UTC (rev 7843)
@@ -29,6 +29,7 @@
#include <subversion-1/svn_client.h>
#include <subversion-1/svn_pools.h>
+#include <subversion-1/svn_props.h>
#include "tsh-common.h"
#include "tsh-dialog-common.h"
@@ -56,6 +57,7 @@
gchar **files = args->files;
apr_array_header_t *paths = args->paths;
apr_array_header_t *ranges;
+ apr_array_header_t *revprops;
gint size, i;
GtkWidget *error;
gchar *error_str;
@@ -85,16 +87,21 @@
subpool = svn_pool_create (pool);
+ revprops = apr_array_make (subpool, 3, sizeof (const char*));
+ APR_ARRAY_PUSH (revprops, const char*) = SVN_PROP_REVISION_AUTHOR;
+ APR_ARRAY_PUSH (revprops, const char*) = SVN_PROP_REVISION_DATE;
+ APR_ARRAY_PUSH (revprops, const char*) = SVN_PROP_REVISION_LOG;
+
revision.kind = svn_opt_revision_unspecified;
range.start.kind = svn_opt_revision_head;
range.end.kind = svn_opt_revision_number;
range.end.value.number = 0;
- ranges = apr_array_make (pool, 1, sizeof (svn_opt_revision_range_t *));
+ ranges = apr_array_make (subpool, 1, sizeof (svn_opt_revision_range_t *));
APR_ARRAY_PUSH (ranges, svn_opt_revision_range_t *) = ⦥
#if CHECK_SVN_VERSION(1,5)
- if ((err = svn_client_log4(paths, &revision, &range.start, &range.end, 0, TRUE, FALSE, FALSE, NULL, tsh_log_func, dialog, ctx, subpool)))
+ if ((err = svn_client_log4(paths, &revision, &range.start, &range.end, 0, TRUE, FALSE, TRUE, revprops, tsh_log_func, dialog, ctx, subpool)))
#else /* CHECK_SVN_VERSION(1,6) */
- if ((err = svn_client_log5(paths, &revision, ranges, 0, TRUE, FALSE, FALSE, NULL, tsh_log_func, dialog, ctx, subpool)))
+ if ((err = svn_client_log5(paths, &revision, ranges, 0, TRUE, FALSE, TRUE, revprops, tsh_log_func, dialog, ctx, subpool)))
#endif
{
svn_pool_destroy (subpool);
Modified: thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-status-dialog.c
===================================================================
--- thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-status-dialog.c 2009-07-26 16:45:07 UTC (rev 7842)
+++ thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-status-dialog.c 2009-07-26 17:49:54 UTC (rev 7843)
@@ -27,10 +27,12 @@
#include <subversion-1/svn_client.h>
#include "tsh-common.h"
+#include "tsh-tree-common.h"
#include "tsh-status-dialog.h"
static void cancel_clicked (GtkButton*, gpointer);
static void refresh_clicked (GtkButton*, gpointer);
+static void move_info (GtkTreeStore*, GtkTreeIter*, GtkTreeIter*);
struct _TshStatusDialog
{
@@ -141,7 +143,7 @@
renderer, "text",
COLUMN_REPO_PROP_STAT, NULL);
- model = GTK_TREE_MODEL (gtk_list_store_new (COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING));
+ model = GTK_TREE_MODEL (gtk_tree_store_new (COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING));
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), model);
@@ -297,14 +299,14 @@
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree_view));
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COLUMN_PATH, file,
- COLUMN_TEXT_STAT, text,
- COLUMN_PROP_STAT, prop,
- COLUMN_REPO_TEXT_STAT, repo_text,
- COLUMN_REPO_PROP_STAT, repo_prop,
- -1);
+ tsh_tree_get_iter_for_path (GTK_TREE_STORE (model), file, &iter, COLUMN_PATH, move_info);
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
+ //COLUMN_PATH, file,
+ COLUMN_TEXT_STAT, text,
+ COLUMN_PROP_STAT, prop,
+ COLUMN_REPO_TEXT_STAT, repo_text,
+ COLUMN_REPO_PROP_STAT, repo_prop,
+ -1);
}
void
@@ -312,8 +314,10 @@
{
g_return_if_fail (TSH_IS_STATUS_DIALOG (dialog));
- gtk_widget_hide (dialog->cancel);
- gtk_widget_show (dialog->refresh);
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (dialog->tree_view));
+
+ gtk_widget_hide (dialog->cancel);
+ gtk_widget_show (dialog->refresh);
}
svn_depth_t
@@ -329,7 +333,7 @@
g_return_val_if_fail (TSH_IS_STATUS_DIALOG (dialog), svn_depth_unknown);
if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->depth), &iter))
- return svn_depth_unknown;
+ return svn_depth_unknown;
model = gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->depth));
gtk_tree_model_get_value (model, &iter, 1, &value);
@@ -403,7 +407,32 @@
g_signal_emit (dialog, signals[SIGNAL_REFRESH], 0);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree_view));
- gtk_list_store_clear (GTK_LIST_STORE (model));
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree_view));
+ gtk_tree_store_clear (GTK_TREE_STORE (model));
}
+static void
+move_info (GtkTreeStore *store, GtkTreeIter *dest, GtkTreeIter *src)
+{
+ gchar *text, *prop, *repo_text, *repo_prop;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), src,
+ COLUMN_TEXT_STAT, &text,
+ COLUMN_PROP_STAT, &prop,
+ COLUMN_REPO_TEXT_STAT, &repo_text,
+ COLUMN_REPO_PROP_STAT, &repo_prop,
+ -1);
+
+ gtk_tree_store_set (store, dest,
+ COLUMN_TEXT_STAT, text,
+ COLUMN_PROP_STAT, prop,
+ COLUMN_REPO_TEXT_STAT, repo_text,
+ COLUMN_REPO_PROP_STAT, repo_prop,
+ -1);
+
+ g_free (text);
+ g_free (prop);
+ g_free (repo_text);
+ g_free (repo_prop);
+}
+
Added: thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-tree-common.c
===================================================================
--- thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-tree-common.c (rev 0)
+++ thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-tree-common.c 2009-07-26 17:49:54 UTC (rev 7843)
@@ -0,0 +1,247 @@
+/*-
+ * 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 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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "tsh-tree-common.h"
+
+static gint
+path_compare (const gchar *path1, const gchar *path2)
+{
+ const gchar *i1, *i2;
+ gchar c1, c2;
+ gint depth = 0;
+ i1 = path1;
+ i2 = path2;
+ while ((c1 = *i1++))
+ {
+ c2 = *i2++;
+
+ if (c1 != c2)
+ {
+ if (c1 == '/'&& !c2)
+ depth++;
+ else if (!depth)
+ depth = -1;
+
+ return depth;
+ }
+
+ if (c1 == '/')
+ depth++;
+ }
+
+ switch (*i2)
+ {
+ case '/':
+ depth++;
+ break;
+ case '\0':
+ return 0;
+ }
+
+ if (!depth)
+ depth = -1;
+
+ return depth;
+}
+
+static gint
+path_depth (const gchar *path)
+{
+ const gchar *i;
+ gchar c, last_c = '\0';
+ gint depth = 0;
+ i = path;
+ while ((c = *i++))
+ {
+ if (c == '/')
+ depth++;
+ last_c = c;
+ }
+ if (last_c != '/')
+ depth++;
+ return depth;
+}
+
+static gchar*
+path_get_prefix (const gchar *path, gint depth)
+{
+ const gchar *i;
+ gchar c;
+ gint lng = 0;
+ i = path;
+ while ((c = *i++))
+ {
+ if (c == '/')
+ if (!--depth)
+ break;
+ lng++;
+ }
+ if (lng == 0)
+ return g_strdup("/");
+ return g_strndup (path, lng);
+}
+
+static const gchar*
+path_remove_prefix (const gchar *path, gint depth)
+{
+ const gchar *i;
+ gchar c;
+ i = path;
+ while ((c = *i++))
+ {
+ if (c == '/')
+ if (!--depth)
+ return i;
+ }
+ return NULL;
+}
+
+static void
+move_children (GtkTreeStore *model, GtkTreeIter *dest, GtkTreeIter *src, gint path_column, TshTreeMoveInfoFunc move_info)
+{
+ gchar *path;
+ GtkTreeIter iter_src;
+ GtkTreeIter iter_dst;
+
+ if (gtk_tree_model_iter_children (GTK_TREE_MODEL (model), &iter_src, src))
+ {
+ do
+ {
+ gtk_tree_store_append (model, &iter_dst, dest);
+ gtk_tree_model_get (GTK_TREE_MODEL (model), &iter_src, path_column, &path, -1);
+ move_info (model, &iter_dst, &iter_src);
+ gtk_tree_store_set (model, &iter_dst, path_column, path, -1);
+ g_free (path);
+
+ move_children (model, &iter_dst, &iter_src, path_column, move_info);
+ }
+ while (gtk_tree_store_remove (model, &iter_src));
+ }
+}
+
+void
+tsh_tree_get_iter_for_path (GtkTreeStore *model, const gchar *file, GtkTreeIter *iter, gint path_column, TshTreeMoveInfoFunc move_info)
+{
+ const gchar *relative_file = file;
+ GtkTreeIter real_parent, *parent = NULL;
+
+ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), iter))
+ {
+ gint file_depth = path_depth (relative_file);
+ for (;;)
+ {
+ gchar *path;
+ gint depth;
+ gtk_tree_model_get (GTK_TREE_MODEL (model), iter, path_column, &path, -1);
+
+ depth = path_compare (path, relative_file);
+ if(!depth)
+ {
+ g_free (path);
+ return;
+ }
+ if (depth > 0)
+ {
+ gint depth_p = path_depth (path);
+
+ if (depth_p == depth)
+ {
+ /* path is the parent */
+ real_parent = *iter;
+ parent = &real_parent;
+
+ relative_file = path_remove_prefix (relative_file, depth);
+
+ if (!gtk_tree_model_iter_children (GTK_TREE_MODEL (model), iter, parent))
+ {
+ g_free (path);
+ break;
+ }
+
+ g_free(path);
+ continue;
+ }
+ else if (depth == file_depth)
+ {
+ /* file is the parent */
+ GtkTreeIter new;
+ /* Add a new parent to the model, on iter removal iter will become this new iter */
+ gtk_tree_store_insert_after (model, &real_parent, parent, iter);
+ /* Add a child to copy the old iter's data to */
+ gtk_tree_store_append (model, &new, &real_parent);
+ /* Copy the data */
+ move_info (model, &new, iter);
+ /* Set the path names */
+ gtk_tree_store_set (model, &real_parent, path_column, relative_file, -1);
+ gtk_tree_store_set (model, &new, path_column, path_remove_prefix(path, depth), -1);
+ /* Move the children */
+ move_children (model, &new, iter, path_column, move_info);
+ /* Iter becomes the next child, which is our new iter */
+ gtk_tree_store_remove (model, iter);
+
+ g_free (path);
+ return;
+ }
+ else
+ {
+ /* common prefix */
+ GtkTreeIter new;
+ gchar *prefix = path_get_prefix (relative_file, depth);
+
+ /* Add a new parent to the model */
+ gtk_tree_store_insert_after (model, &real_parent, parent, iter);
+ parent = &real_parent;
+ /* Add a child to copy the old iter's data to */
+ gtk_tree_store_append(model, &new, parent);
+ /* Copy the data */
+ move_info (model, &new, iter);
+ /* Set the path names */
+ gtk_tree_store_set (model, parent, path_column, prefix, -1);
+ gtk_tree_store_set (model, &new, path_column, path_remove_prefix(path, depth), -1);
+ /* Move the children */
+ move_children (model, &new, iter, path_column, move_info);
+ /* Remove the old iter */
+ gtk_tree_store_remove (model, iter);
+
+ relative_file = path_remove_prefix (relative_file, depth);
+
+ g_free (prefix);
+ g_free (path);
+ break;
+ }
+ }
+
+ g_free (path);
+ if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (model), iter))
+ break;
+ }
+ }
+
+ gtk_tree_store_append (model, iter, parent);
+ gtk_tree_store_set (model, iter, path_column, relative_file, -1);
+}
+
Added: thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-tree-common.h
===================================================================
--- thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-tree-common.h (rev 0)
+++ thunar-vcs-plugin/trunk/tvp-svn-helper/tsh-tree-common.h 2009-07-26 17:49:54 UTC (rev 7843)
@@ -0,0 +1,29 @@
+/*-
+ * 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 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 __TSH_TREE_COMMON_H__
+#define __TSH_TREE_COMMON_H__
+
+G_BEGIN_DECLS
+
+typedef void (*TshTreeMoveInfoFunc) (GtkTreeStore*, GtkTreeIter*, GtkTreeIter*);
+
+void tsh_tree_get_iter_for_path (GtkTreeStore*, const gchar*, GtkTreeIter*, gint, TshTreeMoveInfoFunc);
+
+G_END_DECLS
+
+#endif /*__TSH_TREE_COMMON_H__*/
+
More information about the Goodies-commits
mailing list