[gitg] Code cleanup in gitg-commit-view
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Code cleanup in gitg-commit-view
- Date: Fri, 5 Aug 2011 13:08:59 +0000 (UTC)
commit 0de129eb92ebbc9b224f85fd27789aea929aaa93
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Fri Aug 5 15:07:49 2011 +0200
Code cleanup in gitg-commit-view
gitg/gitg-commit-view.c | 1533 +++++++++++++++++++++++++++++++----------------
gitg/gitg-commit-view.h | 11 +-
2 files changed, 1031 insertions(+), 513 deletions(-)
---
diff --git a/gitg/gitg-commit-view.c b/gitg/gitg-commit-view.c
index b7640d0..09e3d15 100644
--- a/gitg/gitg-commit-view.c
+++ b/gitg/gitg-commit-view.c
@@ -33,7 +33,8 @@
#include "gitg-diff-view.h"
#include "gitg-utils.h"
-#define GITG_COMMIT_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_COMMIT_VIEW, GitgCommitViewPrivate))
+#define GITG_COMMIT_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GITG_TYPE_COMMIT_VIEW, GitgCommitViewPrivate))
+
#define CATEGORY_UNSTAGE_HUNK "CategoryUnstageHunk"
#define CATEGORY_STAGE_HUNK "CategoryStageHunk"
@@ -98,67 +99,95 @@ struct _GitgCommitViewPrivate
GSettings *diff_settings;
};
-static void gitg_commit_view_buildable_iface_init(GtkBuildableIface *iface);
+static void gitg_commit_view_buildable_iface_init (GtkBuildableIface *iface);
-G_DEFINE_TYPE_EXTENDED(GitgCommitView, gitg_commit_view, GTK_TYPE_VPANED, 0,
- G_IMPLEMENT_INTERFACE(GTK_TYPE_BUILDABLE, gitg_commit_view_buildable_iface_init));
+G_DEFINE_TYPE_EXTENDED (GitgCommitView, gitg_commit_view, GTK_TYPE_VPANED, 0,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gitg_commit_view_buildable_iface_init));
static GtkBuildableIface parent_iface;
-static void on_commit_file_inserted(GitgCommit *commit, GitgChangedFile *file, GitgCommitView *view);
-static void on_commit_file_removed(GitgCommit *commit, GitgChangedFile *file, GitgCommitView *view);
-
-static void on_staged_button_press(GtkWidget *widget, GdkEventButton *event, GitgCommitView *view);
-static void on_unstaged_button_press(GtkWidget *widget, GdkEventButton *event, GitgCommitView *view);
-static gboolean on_staged_unstaged_button_press_before (GtkWidget *widget, GdkEventButton *event, GitgCommitView *view);
-static void on_unstaged_tree_view_row_activated (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- GitgCommitView *view);
-static void on_staged_tree_view_row_activated (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- GitgCommitView *view);
-
-static gboolean popup_unstaged_menu(GitgCommitView *view, GdkEventButton *event);
-static gboolean popup_staged_menu(GitgCommitView *view, GdkEventButton *event);
-
-static gboolean on_staged_popup_menu(GtkWidget *widget, GitgCommitView *view);
-static gboolean on_unstaged_popup_menu(GtkWidget *widget, GitgCommitView *view);
-
-static gboolean on_staged_motion(GtkWidget *widget, GdkEventMotion *event, GitgCommitView *view);
-static gboolean on_unstaged_motion(GtkWidget *widget, GdkEventMotion *event, GitgCommitView *view);
-
-static void on_commit_clicked(GtkButton *button, GitgCommitView *view);
-static void on_context_value_changed(GtkHScale *scale, GitgCommitView *view);
-
-static void on_changes_view_popup_menu(GtkTextView *textview, GtkMenu *menu, GitgCommitView *view);
-
-static void on_stage_changes(GtkAction *action, GitgCommitView *view);
-static void on_revert_changes(GtkAction *action, GitgCommitView *view);
-static void on_ignore_file(GtkAction *action, GitgCommitView *view);
-static void on_unstage_changes(GtkAction *action, GitgCommitView *view);
-static void on_edit_file(GtkAction *action, GitgCommitView *view);
-static void on_delete_file (GtkAction *action,
- GitgCommitView *view);
-
-static void on_check_button_amend_toggled (GtkToggleButton *button, GitgCommitView *view);
-
-static void pixbuf_renderer_query_data_cb (GtkSourceGutterRenderer *renderer,
- GtkTextIter *start,
- GtkTextIter *end,
- GtkSourceGutterRendererState state,
- GitgCommitView *view);
-static gboolean pixbuf_renderer_query_activatable_cb (GtkSourceGutterRenderer *renderer,
- GtkTextIter *iter,
- GdkRectangle *area,
- GdkEvent *event,
- GitgCommitView *view);
-static void pixbuf_renderer_activate_cb (GtkSourceGutterRenderer *renderer,
- GtkTextIter *iter,
- GdkRectangle *area,
- GdkEvent *event,
- GitgCommitView *view);
+static void on_commit_file_inserted (GitgCommit *commit,
+ GitgChangedFile *file,
+ GitgCommitView *view);
+static void on_commit_file_removed (GitgCommit *commit,
+ GitgChangedFile *file,
+ GitgCommitView *view);
+
+static void on_staged_button_press (GtkWidget *widget,
+ GdkEventButton *event,
+ GitgCommitView *view);
+static void on_unstaged_button_press (GtkWidget *widget,
+ GdkEventButton *event,
+ GitgCommitView *view);
+static gboolean on_staged_unstaged_button_press_before (GtkWidget *widget,
+ GdkEventButton *event,
+ GitgCommitView *view);
+static void on_unstaged_tree_view_row_activated (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ GitgCommitView *view);
+static void on_staged_tree_view_row_activated (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ GitgCommitView *view);
+
+static gboolean popup_unstaged_menu (GitgCommitView *view,
+ GdkEventButton *event);
+static gboolean popup_staged_menu (GitgCommitView *view,
+ GdkEventButton *event);
+
+static gboolean on_staged_popup_menu (GtkWidget *widget,
+ GitgCommitView *view);
+static gboolean on_unstaged_popup_menu (GtkWidget *widget,
+ GitgCommitView *view);
+
+static gboolean on_staged_motion (GtkWidget *widget,
+ GdkEventMotion *event,
+ GitgCommitView *view);
+static gboolean on_unstaged_motion (GtkWidget *widget,
+ GdkEventMotion *event,
+ GitgCommitView *view);
+
+static void on_commit_clicked (GtkButton *button,
+ GitgCommitView *view);
+static void on_context_value_changed (GtkHScale *scale,
+ GitgCommitView *view);
+
+static void on_changes_view_popup_menu (GtkTextView *textview,
+ GtkMenu *menu,
+ GitgCommitView *view);
+
+static void on_stage_changes (GtkAction *action,
+ GitgCommitView *view);
+static void on_revert_changes (GtkAction *action,
+ GitgCommitView *view);
+static void on_ignore_file (GtkAction *action,
+ GitgCommitView *view);
+static void on_unstage_changes (GtkAction *action,
+ GitgCommitView *view);
+static void on_edit_file (GtkAction *action,
+ GitgCommitView *view);
+static void on_delete_file (GtkAction *action,
+ GitgCommitView *view);
+
+static void on_check_button_amend_toggled (GtkToggleButton *button,
+ GitgCommitView *view);
+
+static void pixbuf_renderer_query_data_cb (GtkSourceGutterRenderer *renderer,
+ GtkTextIter *start,
+ GtkTextIter *end,
+ GtkSourceGutterRendererState state,
+ GitgCommitView *view);
+static gboolean pixbuf_renderer_query_activatable_cb (GtkSourceGutterRenderer *renderer,
+ GtkTextIter *iter,
+ GdkRectangle *area,
+ GdkEvent *event,
+ GitgCommitView *view);
+static void pixbuf_renderer_activate_cb (GtkSourceGutterRenderer *renderer,
+ GtkTextIter *iter,
+ GdkRectangle *area,
+ GdkEvent *event,
+ GitgCommitView *view);
static void
gitg_commit_view_finalize (GObject *object)
@@ -180,43 +209,63 @@ gitg_commit_view_finalize (GObject *object)
}
static void
-icon_data_func(GtkTreeViewColumn *column, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, GitgCommitView *view)
+icon_data_func (GtkTreeViewColumn *column,
+ GtkCellRenderer *renderer,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ GitgCommitView *view)
{
GitgChangedFile *file;
- gtk_tree_model_get(model, iter, COLUMN_FILE, &file, -1);
- GitgChangedFileStatus status = gitg_changed_file_get_status(file);
+ gtk_tree_model_get (model, iter, COLUMN_FILE, &file, -1);
+ GitgChangedFileStatus status = gitg_changed_file_get_status (file);
- gboolean staged = (model == GTK_TREE_MODEL(view->priv->store_staged));
+ gboolean staged = (model == GTK_TREE_MODEL (view->priv->store_staged));
switch (status)
{
case GITG_CHANGED_FILE_STATUS_NEW:
- g_object_set(renderer, "stock-id", staged ? GTK_STOCK_ADD : GTK_STOCK_NEW, NULL);
+ g_object_set (renderer,
+ "stock-id",
+ staged ? GTK_STOCK_ADD : GTK_STOCK_NEW,
+ NULL);
break;
case GITG_CHANGED_FILE_STATUS_MODIFIED:
- g_object_set(renderer, "stock-id", staged ? GTK_STOCK_APPLY : GTK_STOCK_EDIT, NULL);
+ g_object_set (renderer,
+ "stock-id",
+ staged ? GTK_STOCK_APPLY : GTK_STOCK_EDIT,
+ NULL);
break;
case GITG_CHANGED_FILE_STATUS_DELETED:
- g_object_set(renderer, "stock-id", staged ? GTK_STOCK_REMOVE : GTK_STOCK_DELETE, NULL);
+ g_object_set (renderer,
+ "stock-id",
+ staged ? GTK_STOCK_REMOVE : GTK_STOCK_DELETE,
+ NULL);
break;
default:
break;
}
- g_object_unref(file);
+ g_object_unref (file);
}
static void
-set_icon_data_func(GitgCommitView *view, GtkTreeView *treeview, GtkCellRenderer *renderer)
+set_icon_data_func (GitgCommitView *view,
+ GtkTreeView *treeview,
+ GtkCellRenderer *renderer)
{
- GtkTreeViewColumn *column = gtk_tree_view_get_column(treeview, 0);
+ GtkTreeViewColumn *column = gtk_tree_view_get_column (treeview, 0);
- gtk_tree_view_column_set_cell_data_func(column, renderer, (GtkTreeCellDataFunc)icon_data_func, view, NULL);
+ gtk_tree_view_column_set_cell_data_func (column,
+ renderer,
+ (GtkTreeCellDataFunc)icon_data_func,
+ view,
+ NULL);
}
static void
-set_language(GitgCommitView *view, GtkSourceLanguage *language)
+set_language (GitgCommitView *view,
+ GtkSourceLanguage *language)
{
GtkTextView *text_view;
GtkSourceBuffer *buffer;
@@ -236,8 +285,8 @@ set_diff_language (GitgCommitView *view)
GtkSourceLanguage *language = gtk_source_language_manager_get_language (manager, "gitgdiff");
set_language (view, language);
- gitg_diff_view_set_diff_enabled (GITG_DIFF_VIEW(view->priv->changes_view), TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET(view->priv->hscale_context), TRUE);
+ gitg_diff_view_set_diff_enabled (GITG_DIFF_VIEW (view->priv->changes_view), TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (view->priv->hscale_context), TRUE);
}
static void
@@ -253,10 +302,12 @@ show_binary_information (GitgCommitView *view)
}
static void
-on_changes_update (GitgShell *shell, gchar **buffer, GitgCommitView *view)
+on_changes_update (GitgShell *shell,
+ gchar **buffer,
+ GitgCommitView *view)
{
gchar *line;
- GtkTextBuffer *buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW(view->priv->changes_view));
+ GtkTextBuffer *buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view->priv->changes_view));
GtkTextIter iter;
gtk_text_buffer_get_end_iter (buf, &iter);
@@ -267,14 +318,14 @@ on_changes_update (GitgShell *shell, gchar **buffer, GitgCommitView *view)
{
if (view->priv->current_changes & GITG_CHANGED_FILE_CHANGES_UNSTAGED)
{
- gtk_source_buffer_create_source_mark (GTK_SOURCE_BUFFER(buf),
+ gtk_source_buffer_create_source_mark (GTK_SOURCE_BUFFER (buf),
NULL,
CATEGORY_STAGE_HUNK,
&iter);
}
else
{
- gtk_source_buffer_create_source_mark (GTK_SOURCE_BUFFER(buf),
+ gtk_source_buffer_create_source_mark (GTK_SOURCE_BUFFER (buf),
NULL,
CATEGORY_UNSTAGE_HUNK,
&iter);
@@ -284,9 +335,9 @@ on_changes_update (GitgShell *shell, gchar **buffer, GitgCommitView *view)
gtk_text_buffer_insert (buf, &iter, line, -1);
}
- if (gtk_source_buffer_get_language (GTK_SOURCE_BUFFER(buf)) == NULL)
+ if (gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (buf)) == NULL)
{
- gchar *content_type = gitg_utils_guess_content_type (GTK_TEXT_BUFFER(buf));
+ gchar *content_type = gitg_utils_guess_content_type (GTK_TEXT_BUFFER (buf));
if (content_type && !gitg_utils_can_display_content_type (content_type))
{
@@ -319,9 +370,9 @@ connect_update (GitgCommitView *view)
}
static void
-set_current_file (GitgCommitView *view,
- GitgChangedFile *file,
- GitgChangedFileChanges changes)
+set_current_file (GitgCommitView *view,
+ GitgChangedFile *file,
+ GitgChangedFileChanges changes)
{
if (view->priv->current_file != NULL)
{
@@ -333,62 +384,82 @@ set_current_file (GitgCommitView *view,
}
static gboolean
-get_selected_files(GtkTreeView *tree_view,
- GList **files,
- GList **paths,
- GitgChangedFileChanges *changes,
- GitgChangedFileStatus *status)
+get_selected_files (GtkTreeView *tree_view,
+ GList **files,
+ GList **paths,
+ GitgChangedFileChanges *changes,
+ GitgChangedFileStatus *status)
{
- GtkTreeSelection *selection = gtk_tree_view_get_selection(tree_view);
+ GtkTreeSelection *selection = gtk_tree_view_get_selection (tree_view);
if (files == NULL && changes == NULL && status == NULL && paths == NULL)
- return gtk_tree_selection_count_selected_rows(selection) != 0;
+ {
+ return gtk_tree_selection_count_selected_rows (selection) != 0;
+ }
GtkTreeModel *model;
- GList *items = gtk_tree_selection_get_selected_rows(selection, &model);
+ GList *items = gtk_tree_selection_get_selected_rows (selection, &model);
if (files)
+ {
*files = NULL;
+ }
if (paths)
+ {
*paths = NULL;
+ }
if (!items)
+ {
return FALSE;
+ }
if (changes)
+ {
*changes = ~0;
+ }
if (status)
+ {
*status = -1;
+ }
GList *item;
GitgChangedFile *file;
- for (item = items; item; item = g_list_next(item))
+ for (item = items; item; item = g_list_next (item))
{
GtkTreeIter iter;
- gtk_tree_model_get_iter(model, &iter, (GtkTreePath *)item->data);
- gtk_tree_model_get(model, &iter, COLUMN_FILE, &file, -1);
+ gtk_tree_model_get_iter (model, &iter, (GtkTreePath *)item->data);
+ gtk_tree_model_get (model, &iter, COLUMN_FILE, &file, -1);
if (changes)
- *changes &= gitg_changed_file_get_status(file);
+ {
+ *changes &= gitg_changed_file_get_status (file);
+ }
- GitgChangedFileStatus s = gitg_changed_file_get_status(file);
+ GitgChangedFileStatus s = gitg_changed_file_get_status (file);
if (status)
{
if (*status != -1 && *status != s)
+ {
*status = GITG_CHANGED_FILE_STATUS_NONE;
+ }
else
*status = s;
}
if (files)
- *files = g_list_prepend(*files, file);
+ {
+ *files = g_list_prepend (*files, file);
+ }
else
- g_object_unref(file);
+ {
+ g_object_unref (file);
+ }
}
if (paths)
@@ -401,50 +472,65 @@ get_selected_files(GtkTreeView *tree_view,
}
if (files)
- *files = g_list_reverse(*files);
+ {
+ *files = g_list_reverse (*files);
+ }
return TRUE;
}
static gboolean
-check_selection(GtkTreeView *tree_view,
+check_selection (GtkTreeView *tree_view,
GtkTreeIter *iter,
GitgCommitView *view)
{
if (view->priv->update_id)
{
- g_signal_handler_disconnect(view->priv->shell, view->priv->update_id);
+ g_signal_handler_disconnect (view->priv->shell, view->priv->update_id);
}
- gitg_io_cancel(GITG_IO (view->priv->shell));
+ gitg_io_cancel (GITG_IO (view->priv->shell));
view->priv->update_id = 0;
- GtkTextView *tv = GTK_TEXT_VIEW(view->priv->changes_view);
- GtkTextBuffer *buffer = gtk_text_view_get_buffer(tv);
+ GtkTextView *tv = GTK_TEXT_VIEW (view->priv->changes_view);
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer (tv);
GtkTextIter start;
GtkTextIter end;
- gtk_text_buffer_get_bounds(buffer, &start, &end);
- gtk_source_buffer_remove_source_marks(GTK_SOURCE_BUFFER(buffer), &start, &end, CATEGORY_UNSTAGE_HUNK);
- gtk_source_buffer_remove_source_marks(GTK_SOURCE_BUFFER(buffer), &start, &end, CATEGORY_STAGE_HUNK);
- gtk_text_buffer_set_text(gtk_text_view_get_buffer(tv), "", -1);
+ gtk_text_buffer_get_bounds (buffer, &start, &end);
+
+ gtk_source_buffer_remove_source_marks (GTK_SOURCE_BUFFER (buffer),
+ &start,
+ &end,
+ CATEGORY_UNSTAGE_HUNK);
+
+ gtk_source_buffer_remove_source_marks (GTK_SOURCE_BUFFER (buffer),
+ &start,
+ &end,
+ CATEGORY_STAGE_HUNK);
+
+ gtk_text_buffer_set_text (gtk_text_view_get_buffer (tv), "", -1);
GList *paths;
gboolean ret;
- get_selected_files(tree_view, NULL, &paths, NULL, NULL);
+ get_selected_files (tree_view, NULL, &paths, NULL, NULL);
- if (g_list_length(paths) != 1)
+ if (g_list_length (paths) != 1)
{
- set_current_file(view, NULL, GITG_CHANGED_FILE_CHANGES_NONE);
- gtk_widget_set_sensitive(GTK_WIDGET(view->priv->hscale_context), FALSE);
+ set_current_file (view, NULL, GITG_CHANGED_FILE_CHANGES_NONE);
+ gtk_widget_set_sensitive (GTK_WIDGET (view->priv->hscale_context),
+ FALSE);
ret = FALSE;
}
else
{
if (iter)
- gtk_tree_model_get_iter(gtk_tree_view_get_model(tree_view),
+ {
+ gtk_tree_model_get_iter (gtk_tree_view_get_model (tree_view),
iter,
(GtkTreePath *)paths->data);
+ }
+
ret = TRUE;
}
@@ -453,9 +539,9 @@ check_selection(GtkTreeView *tree_view,
}
static void
-unselect_tree_view(GtkTreeView *view)
+unselect_tree_view (GtkTreeView *view)
{
- gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(view));
+ gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (view));
}
static void
@@ -498,16 +584,23 @@ unstaged_selection_changed (GtkTreeSelection *selection,
else
{
gchar *basename = g_file_get_basename (f);
- GtkSourceLanguage *language = gitg_utils_get_language (basename, content_type);
+ GtkSourceLanguage *language;
+
+ language = gitg_utils_get_language (basename,
+ content_type);
g_free (basename);
set_language (view, language);
- gtk_widget_set_sensitive (GTK_WIDGET (view->priv->hscale_context), FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (view->priv->hscale_context),
+ FALSE);
view->priv->is_diff = FALSE;
connect_update (view);
- gitg_shell_run_stream (view->priv->shell, stream, NULL);
+ gitg_shell_run_stream (view->priv->shell,
+ stream,
+ NULL);
+
g_object_unref (stream);
}
}
@@ -525,7 +618,7 @@ unstaged_selection_changed (GtkTreeSelection *selection,
gchar *path = gitg_repository_relative (view->priv->repository, f);
gchar ct[10];
- g_snprintf (ct, sizeof(ct), "-U%d", view->priv->context_size);
+ g_snprintf (ct, sizeof (ct), "-U%d", view->priv->context_size);
allow_external = g_settings_get_boolean (view->priv->diff_settings,
"external");
@@ -551,7 +644,8 @@ unstaged_selection_changed (GtkTreeSelection *selection,
}
static void
-staged_selection_changed (GtkTreeSelection *selection, GitgCommitView *view)
+staged_selection_changed (GtkTreeSelection *selection,
+ GitgCommitView *view)
{
GtkTreeModel *model;
GtkTreeIter iter;
@@ -614,7 +708,7 @@ staged_selection_changed (GtkTreeSelection *selection, GitgCommitView *view)
gchar *head = gitg_repository_parse_head (view->priv->repository);
gchar ct[10];
- g_snprintf (ct, sizeof(ct), "-U%d", view->priv->context_size);
+ g_snprintf (ct, sizeof (ct), "-U%d", view->priv->context_size);
allow_external = g_settings_get_boolean (view->priv->diff_settings,
"external");
@@ -632,59 +726,83 @@ staged_selection_changed (GtkTreeSelection *selection, GitgCommitView *view)
NULL),
NULL);
- g_free(head);
+ g_free (head);
}
- g_object_unref(f);
- g_free(path);
+ g_object_unref (f);
+ g_free (path);
- set_current_file(view, file, GITG_CHANGED_FILE_CHANGES_CACHED);
- g_object_unref(file);
+ set_current_file (view, file, GITG_CHANGED_FILE_CHANGES_CACHED);
+ g_object_unref (file);
}
static gint
-compare_by_name(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata)
+compare_by_name (GtkTreeModel *model,
+ GtkTreeIter *a,
+ GtkTreeIter *b,
+ gpointer userdata)
{
gchar *s1;
gchar *s2;
- gtk_tree_model_get(model, a, COLUMN_NAME, &s1, -1);
- gtk_tree_model_get(model, b, COLUMN_NAME, &s2, -1);
+ gtk_tree_model_get (model, a, COLUMN_NAME, &s1, -1);
+ gtk_tree_model_get (model, b, COLUMN_NAME, &s2, -1);
- gint ret = gitg_utils_sort_names(s1, s2);
+ gint ret = gitg_utils_sort_names (s1, s2);
- g_free(s1);
- g_free(s2);
+ g_free (s1);
+ g_free (s2);
return ret;
}
static void
-set_sort_func(GtkListStore *store)
+set_sort_func (GtkListStore *store)
{
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), 0, GTK_SORT_ASCENDING);
- gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), 0, compare_by_name, NULL, NULL);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ 0,
+ GTK_SORT_ASCENDING);
+
+ gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store),
+ 0,
+ compare_by_name,
+ NULL,
+ NULL);
}
static gboolean
-has_hunk_mark(GtkSourceBuffer *buffer, GtkTextIter *iter)
+has_hunk_mark (GtkSourceBuffer *buffer,
+ GtkTextIter *iter)
{
- GSList *m1 = gtk_source_buffer_get_source_marks_at_iter(buffer, iter, CATEGORY_UNSTAGE_HUNK);
- gboolean has_mark = (m1 != NULL);
- g_slist_free(m1);
+ GSList *m1;
+ gboolean has_mark;
+
+ m1 = gtk_source_buffer_get_source_marks_at_iter (buffer,
+ iter,
+ CATEGORY_UNSTAGE_HUNK);
+
+ has_mark = (m1 != NULL);
+ g_slist_free (m1);
if (has_mark)
+ {
return TRUE;
+ }
+
+ m1 = gtk_source_buffer_get_source_marks_at_iter (buffer,
+ iter,
+ CATEGORY_STAGE_HUNK);
- m1 = gtk_source_buffer_get_source_marks_at_iter(buffer, iter, CATEGORY_STAGE_HUNK);
has_mark = (m1 != NULL);
- g_slist_free(m1);
+ g_slist_free (m1);
return has_mark;
}
static gchar *
-get_patch_header(GitgCommitView *view, GtkTextBuffer *buffer, GtkTextIter const *iter)
+get_patch_header (GitgCommitView *view,
+ GtkTextBuffer *buffer,
+ GtkTextIter const *iter)
{
GtkTextIter begin;
GtkTextIter end;
@@ -699,11 +817,13 @@ get_patch_header(GitgCommitView *view, GtkTextBuffer *buffer, GtkTextIter const
gitg_diff_iter_get_bounds (&diff_iter, &begin, &end);
- return gtk_text_buffer_get_text(buffer, &begin, &end, TRUE);
+ return gtk_text_buffer_get_text (buffer, &begin, &end, TRUE);
}
static gchar *
-get_patch_contents(GitgCommitView *view, GtkTextBuffer *buffer, GtkTextIter const *iter)
+get_patch_contents (GitgCommitView *view,
+ GtkTextBuffer *buffer,
+ GtkTextIter const *iter)
{
GtkTextIter begin;
GtkTextIter end;
@@ -718,36 +838,39 @@ get_patch_contents(GitgCommitView *view, GtkTextBuffer *buffer, GtkTextIter cons
gitg_diff_iter_get_bounds (&diff_iter, &begin, &end);
- return gtk_text_buffer_get_text(buffer, &begin, &end, FALSE);
+ return gtk_text_buffer_get_text (buffer, &begin, &end, FALSE);
}
static gchar *
-get_hunk_patch(GitgCommitView *view, GtkTextIter *iter)
+get_hunk_patch (GitgCommitView *view,
+ GtkTextIter *iter)
{
/* Get patch header */
- GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view->priv->changes_view));
- gchar *header = get_patch_header(view, buffer, iter);
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view->priv->changes_view));
+ gchar *header = get_patch_header (view, buffer, iter);
if (!header)
+ {
return NULL;
+ }
/* Get patch contents */
- gchar *contents = get_patch_contents(view, buffer, iter);
+ gchar *contents = get_patch_contents (view, buffer, iter);
if (!contents)
{
- g_free(header);
+ g_free (header);
return NULL;
}
- return g_strconcat(header, contents, NULL);
+ return g_strconcat (header, contents, NULL);
}
static gchar *
-line_patch_contents (GitgCommitView *view,
+line_patch_contents (GitgCommitView *view,
GtkTextIter const *iter,
- GitgDiffLineType old_type,
- GitgDiffLineType new_type)
+ GitgDiffLineType old_type,
+ GitgDiffLineType new_type)
{
GtkTextIter start;
GtkTextIter end;
@@ -847,25 +970,34 @@ line_patch_contents (GitgCommitView *view,
}
static gboolean
-stage_unstage_hunk (GitgCommitView *view, gchar const *hunk, GError **error)
+stage_unstage_hunk (GitgCommitView *view,
+ gchar const *hunk,
+ GError **error)
{
gboolean ret;
gboolean unstage = view->priv->current_changes & GITG_CHANGED_FILE_CHANGES_UNSTAGED;
if (unstage)
{
- ret = gitg_commit_stage (view->priv->commit, view->priv->current_file, hunk, error);
+ ret = gitg_commit_stage (view->priv->commit,
+ view->priv->current_file,
+ hunk,
+ error);
}
else
{
- ret = gitg_commit_unstage (view->priv->commit, view->priv->current_file, hunk, error);
+ ret = gitg_commit_unstage (view->priv->commit,
+ view->priv->current_file,
+ hunk,
+ error);
}
return ret;
}
static gboolean
-handle_stage_unstage_line (GitgCommitView *view, GtkTextIter const *iter)
+handle_stage_unstage_line (GitgCommitView *view,
+ GtkTextIter const *iter)
{
GitgDiffView *diff_view = GITG_DIFF_VIEW (view->priv->changes_view);
GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view->priv->changes_view));
@@ -935,7 +1067,8 @@ handle_stage_unstage_line (GitgCommitView *view, GtkTextIter const *iter)
}
static gboolean
-handle_stage_unstage(GitgCommitView *view, GtkTextIter *iter)
+handle_stage_unstage (GitgCommitView *view,
+ GtkTextIter *iter)
{
gchar *hunk = get_hunk_patch (view, iter);
@@ -968,11 +1101,11 @@ handle_stage_unstage(GitgCommitView *view, GtkTextIter *iter)
}
static gboolean
-get_info_at_pointer (GitgCommitView *view,
- GtkTextIter *iter,
- gboolean *is_hunk,
- gchar **hunk,
- GitgDiffLineType *line_type)
+get_info_at_pointer (GitgCommitView *view,
+ GtkTextIter *iter,
+ gboolean *is_hunk,
+ gchar **hunk,
+ GitgDiffLineType *line_type)
{
GtkTextView *textview = GTK_TEXT_VIEW (view->priv->changes_view);
gint x;
@@ -1046,7 +1179,8 @@ unset_highlight (GitgCommitView *view)
}
static void
-set_highlight (GitgCommitView *view, GtkTextIter *iter)
+set_highlight (GitgCommitView *view,
+ GtkTextIter *iter)
{
if (!view->priv->highlight_tag)
{
@@ -1088,7 +1222,9 @@ set_highlight (GitgCommitView *view, GtkTextIter *iter)
}
static gboolean
-gutter_event (GtkWidget *widget, GdkEventAny *event, GitgCommitView *view)
+gutter_event (GtkWidget *widget,
+ GdkEventAny *event,
+ GitgCommitView *view)
{
GtkTextView *textview = GTK_TEXT_VIEW (view->priv->changes_view);
gint x;
@@ -1147,7 +1283,9 @@ gutter_event (GtkWidget *widget, GdkEventAny *event, GitgCommitView *view)
}
static gboolean
-view_event (GtkWidget *widget, GdkEventAny *event, GitgCommitView *view)
+view_event (GtkWidget *widget,
+ GdkEventAny *event,
+ GitgCommitView *view)
{
GtkTextWindowType type;
GtkTextBuffer *buffer;
@@ -1204,13 +1342,13 @@ view_event (GtkWidget *widget, GdkEventAny *event, GitgCommitView *view)
}
static GtkTextBuffer *
-initialize_buffer(GitgCommitView *view)
+initialize_buffer (GitgCommitView *view)
{
- GtkTextBuffer *buffer = GTK_TEXT_BUFFER(gtk_source_buffer_new(NULL));
+ GtkTextBuffer *buffer = GTK_TEXT_BUFFER (gtk_source_buffer_new (NULL));
- GtkSourceStyleSchemeManager *manager = gtk_source_style_scheme_manager_get_default();
- GtkSourceStyleScheme *scheme = gtk_source_style_scheme_manager_get_scheme(manager, "gitg");
- gtk_source_buffer_set_style_scheme(GTK_SOURCE_BUFFER(buffer), scheme);
+ GtkSourceStyleSchemeManager *manager = gtk_source_style_scheme_manager_get_default ();
+ GtkSourceStyleScheme *scheme = gtk_source_style_scheme_manager_get_scheme (manager, "gitg");
+ gtk_source_buffer_set_style_scheme (GTK_SOURCE_BUFFER (buffer), scheme);
return buffer;
}
@@ -1232,28 +1370,28 @@ on_tree_view_drag_data_get (GtkWidget *widget,
gchar **uris;
guint i = 0;
- get_selected_files(GTK_TREE_VIEW(widget), &selected, NULL, NULL, NULL);
- uris = g_new(gchar *, g_list_length(selected) + 1);
+ get_selected_files (GTK_TREE_VIEW (widget), &selected, NULL, NULL, NULL);
+ uris = g_new (gchar *, g_list_length (selected) + 1);
- for (item = selected; item; item = g_list_next(item))
+ for (item = selected; item; item = g_list_next (item))
{
GitgChangedFile *file = GITG_CHANGED_FILE (item->data);
- GFile *gf = gitg_changed_file_get_file(file);
+ GFile *gf = gitg_changed_file_get_file (file);
- uris[i++] = g_file_get_uri(gf);
- g_object_unref(gf);
+ uris[i++] = g_file_get_uri (gf);
+ g_object_unref (gf);
}
uris[i] = NULL;
- gtk_selection_data_set_uris(selection, uris);
+ gtk_selection_data_set_uris (selection, uris);
- g_strfreev(uris);
+ g_strfreev (uris);
g_list_free_full (selected, g_object_unref);
}
static void
-on_tree_view_staged_drag_data_received(GtkWidget *widget,
+on_tree_view_staged_drag_data_received (GtkWidget *widget,
GdkDragContext *drag_context,
gint x,
gint y,
@@ -1263,28 +1401,28 @@ on_tree_view_staged_drag_data_received(GtkWidget *widget,
GitgCommitView *view)
{
/* Stage all the files dropped on this */
- gchar **uris = gtk_selection_data_get_uris(data);
+ gchar **uris = gtk_selection_data_get_uris (data);
gchar **uri;
for (uri = uris; *uri; ++uri)
{
- GFile *file = g_file_new_for_uri(*uri);
+ GFile *file = g_file_new_for_uri (*uri);
GitgChangedFile *f;
- f = gitg_commit_find_changed_file(view->priv->commit, file);
+ f = gitg_commit_find_changed_file (view->priv->commit, file);
- if (f && (gitg_changed_file_get_changes(f) & GITG_CHANGED_FILE_CHANGES_UNSTAGED))
+ if (f && (gitg_changed_file_get_changes (f) & GITG_CHANGED_FILE_CHANGES_UNSTAGED))
{
- gitg_commit_stage(view->priv->commit, f, NULL, NULL);
+ gitg_commit_stage (view->priv->commit, f, NULL, NULL);
}
- g_object_unref(f);
- g_object_unref(file);
+ g_object_unref (f);
+ g_object_unref (file);
}
}
static void
-on_tree_view_unstaged_drag_data_received(GtkWidget *widget,
+on_tree_view_unstaged_drag_data_received (GtkWidget *widget,
GdkDragContext *drag_context,
gint x,
gint y,
@@ -1294,66 +1432,73 @@ on_tree_view_unstaged_drag_data_received(GtkWidget *widget,
GitgCommitView *view)
{
/* Unstage all the files dropped on this */
- gchar **uris = gtk_selection_data_get_uris(data);
+ gchar **uris = gtk_selection_data_get_uris (data);
gchar **uri;
for (uri = uris; *uri; ++uri)
{
- GFile *file = g_file_new_for_uri(*uri);
+ GFile *file = g_file_new_for_uri (*uri);
GitgChangedFile *f;
- f = gitg_commit_find_changed_file(view->priv->commit, file);
+ f = gitg_commit_find_changed_file (view->priv->commit, file);
- if (f && (gitg_changed_file_get_changes(f) & GITG_CHANGED_FILE_CHANGES_CACHED))
+ if (f && (gitg_changed_file_get_changes (f) & GITG_CHANGED_FILE_CHANGES_CACHED))
{
- gitg_commit_unstage(view->priv->commit, f, NULL, NULL);
+ gitg_commit_unstage (view->priv->commit, f, NULL, NULL);
}
- g_object_unref(f);
- g_object_unref(file);
+ g_object_unref (f);
+ g_object_unref (file);
}
}
static void
-initialize_dnd(GitgCommitView *view,
- GtkTreeView *tree_view,
- GCallback drag_data_received)
+initialize_dnd (GitgCommitView *view,
+ GtkTreeView *tree_view,
+ GCallback drag_data_received)
{
- gtk_tree_view_enable_model_drag_dest(tree_view,
+ gtk_tree_view_enable_model_drag_dest (tree_view,
dnd_entries,
- G_N_ELEMENTS(dnd_entries),
+ G_N_ELEMENTS (dnd_entries),
GDK_ACTION_COPY);
- gtk_tree_view_enable_model_drag_source(tree_view,
+ gtk_tree_view_enable_model_drag_source (tree_view,
GDK_BUTTON1_MASK,
dnd_entries,
- G_N_ELEMENTS(dnd_entries),
+ G_N_ELEMENTS (dnd_entries),
GDK_ACTION_COPY);
- g_signal_connect(tree_view, "drag-data-get", G_CALLBACK(on_tree_view_drag_data_get), view);
- g_signal_connect(tree_view, "drag-data-received", G_CALLBACK(drag_data_received), view);
+ g_signal_connect (tree_view,
+ "drag-data-get",
+ G_CALLBACK (on_tree_view_drag_data_get),
+ view);
+
+ g_signal_connect (tree_view,
+ "drag-data-received",
+ G_CALLBACK (drag_data_received),
+ view);
}
static void
-initialize_dnd_staged(GitgCommitView *view)
+initialize_dnd_staged (GitgCommitView *view)
{
- initialize_dnd(view,
+ initialize_dnd (view,
view->priv->tree_view_staged,
- G_CALLBACK(on_tree_view_staged_drag_data_received));
+ G_CALLBACK (on_tree_view_staged_drag_data_received));
}
static void
-initialize_dnd_unstaged(GitgCommitView *view)
+initialize_dnd_unstaged (GitgCommitView *view)
{
- initialize_dnd(view,
+ initialize_dnd (view,
view->priv->tree_view_unstaged,
- G_CALLBACK(on_tree_view_unstaged_drag_data_received));
+ G_CALLBACK (on_tree_view_unstaged_drag_data_received));
}
static void
on_tag_added (GtkTextTagTable *table,
- GtkTextTag *tag,
- GitgCommitView *view)
+ GtkTextTag *tag,
+ GitgCommitView *view)
{
gtk_text_tag_set_priority (view->priv->highlight_tag,
gtk_text_tag_table_get_size (table) - 1);
@@ -1378,51 +1523,74 @@ measure_line_height (GtkSourceView *view)
}
static void
-gitg_commit_view_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
+gitg_commit_view_parser_finished (GtkBuildable *buildable,
+ GtkBuilder *builder)
{
GtkSourceMarkAttributes *attrs;
GtkSourceGutter *gutter;
if (parent_iface.parser_finished)
- parent_iface.parser_finished(buildable, builder);
+ {
+ parent_iface.parser_finished (buildable, builder);
+ }
/* Store widgets */
- GitgCommitView *self = GITG_COMMIT_VIEW(buildable);
+ GitgCommitView *self = GITG_COMMIT_VIEW (buildable);
- GtkBuilder *b = gitg_utils_new_builder("gitg-commit-menu.ui");
- self->priv->ui_manager = g_object_ref(gtk_builder_get_object(b, "uiman"));
+ GtkBuilder *b = gitg_utils_new_builder ("gitg-commit-menu.ui");
+ self->priv->ui_manager = g_object_ref (gtk_builder_get_object (b, "uiman"));
+
+ g_signal_connect (gtk_builder_get_object (b, "StageChangesAction"),
+ "activate",
+ G_CALLBACK (on_stage_changes),
+ self);
+
+ g_signal_connect (gtk_builder_get_object (b, "RevertChangesAction"),
+ "activate",
+ G_CALLBACK (on_revert_changes),
+ self);
+
+ g_signal_connect (gtk_builder_get_object (b, "IgnoreFileAction"),
+ "activate",
+ G_CALLBACK (on_ignore_file),
+ self);
+
+ g_signal_connect (gtk_builder_get_object (b, "UnstageChangesAction"),
+ "activate",
+ G_CALLBACK (on_unstage_changes),
+ self);
+
+ g_signal_connect (gtk_builder_get_object (b, "EditFileAction"),
+ "activate",
+ G_CALLBACK (on_edit_file),
+ self);
- g_signal_connect(gtk_builder_get_object(b, "StageChangesAction"), "activate", G_CALLBACK(on_stage_changes), self);
- g_signal_connect(gtk_builder_get_object(b, "RevertChangesAction"), "activate", G_CALLBACK(on_revert_changes), self);
- g_signal_connect(gtk_builder_get_object(b, "IgnoreFileAction"), "activate", G_CALLBACK(on_ignore_file), self);
- g_signal_connect(gtk_builder_get_object(b, "UnstageChangesAction"), "activate", G_CALLBACK(on_unstage_changes), self);
- g_signal_connect(gtk_builder_get_object(b, "EditFileAction"), "activate", G_CALLBACK(on_edit_file), self);
g_signal_connect (gtk_builder_get_object (b, "DeleteFileAction"),
"activate",
G_CALLBACK (on_delete_file),
self);
- self->priv->group_context = GTK_ACTION_GROUP(gtk_builder_get_object(b, "action_group_commit_context"));
+ self->priv->group_context = GTK_ACTION_GROUP (gtk_builder_get_object (b, "action_group_commit_context"));
- g_object_unref(b);
+ g_object_unref (b);
- self->priv->tree_view_unstaged = GTK_TREE_VIEW(gtk_builder_get_object(builder, "tree_view_unstaged"));
- self->priv->tree_view_staged = GTK_TREE_VIEW(gtk_builder_get_object(builder, "tree_view_staged"));
+ self->priv->tree_view_unstaged = GTK_TREE_VIEW (gtk_builder_get_object (builder, "tree_view_unstaged"));
+ self->priv->tree_view_staged = GTK_TREE_VIEW (gtk_builder_get_object (builder, "tree_view_staged"));
- self->priv->store_unstaged = gtk_list_store_new(N_COLUMNS, G_TYPE_STRING, GITG_TYPE_CHANGED_FILE);
- self->priv->store_staged = gtk_list_store_new(N_COLUMNS, G_TYPE_STRING, GITG_TYPE_CHANGED_FILE);
+ self->priv->store_unstaged = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, GITG_TYPE_CHANGED_FILE);
+ self->priv->store_staged = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, GITG_TYPE_CHANGED_FILE);
- set_sort_func(self->priv->store_unstaged);
- set_sort_func(self->priv->store_staged);
+ set_sort_func (self->priv->store_unstaged);
+ set_sort_func (self->priv->store_staged);
- self->priv->changes_view = GTK_SOURCE_VIEW(gtk_builder_get_object(builder, "source_view_changes"));
+ self->priv->changes_view = GTK_SOURCE_VIEW (gtk_builder_get_object (builder, "source_view_changes"));
gtk_widget_add_events (GTK_WIDGET (self->priv->changes_view),
GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK);
- self->priv->comment_view = GTK_TEXT_VIEW(gtk_builder_get_object(builder, "text_view_comment"));
- self->priv->check_button_signed_off_by = GTK_CHECK_BUTTON(gtk_builder_get_object(builder, "check_button_signed_off_by"));
- self->priv->check_button_amend = GTK_CHECK_BUTTON(gtk_builder_get_object(builder, "check_button_amend"));
+ self->priv->comment_view = GTK_TEXT_VIEW (gtk_builder_get_object (builder, "text_view_comment"));
+ self->priv->check_button_signed_off_by = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "check_button_signed_off_by"));
+ self->priv->check_button_amend = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "check_button_amend"));
g_settings_bind (self->priv->message_settings,
"show-right-margin",
@@ -1436,14 +1604,14 @@ gitg_commit_view_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
"right-margin-position",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- self->priv->hscale_context = GTK_HSCALE(gtk_builder_get_object(builder, "hscale_context"));
+ self->priv->hscale_context = GTK_HSCALE (gtk_builder_get_object (builder, "hscale_context"));
gtk_range_set_value (GTK_RANGE (self->priv->hscale_context), 3);
- initialize_dnd_staged(self);
- initialize_dnd_unstaged(self);
+ initialize_dnd_staged (self);
+ initialize_dnd_unstaged (self);
- GtkIconTheme *theme = gtk_icon_theme_get_default();
- GdkPixbuf *pixbuf = gtk_icon_theme_load_icon(theme, GTK_STOCK_ADD, 12, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
+ GtkIconTheme *theme = gtk_icon_theme_get_default ();
+ GdkPixbuf *pixbuf = gtk_icon_theme_load_icon (theme, GTK_STOCK_ADD, 12, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
if (pixbuf)
{
@@ -1458,7 +1626,7 @@ gitg_commit_view_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
g_object_unref (attrs);
}
- pixbuf = gtk_icon_theme_load_icon(theme, GTK_STOCK_REMOVE, 12, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
+ pixbuf = gtk_icon_theme_load_icon (theme, GTK_STOCK_REMOVE, 12, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
if (pixbuf)
{
@@ -1473,17 +1641,17 @@ gitg_commit_view_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
g_object_unref (attrs);
}
- gitg_utils_set_monospace_font(GTK_WIDGET(self->priv->changes_view));
+ gitg_utils_set_monospace_font (GTK_WIDGET (self->priv->changes_view));
- GtkTextBuffer *buffer = initialize_buffer(self);
- gtk_text_view_set_buffer(GTK_TEXT_VIEW(self->priv->changes_view), buffer);
- g_signal_connect(self->priv->changes_view, "event", G_CALLBACK(view_event), self);
+ GtkTextBuffer *buffer = initialize_buffer (self);
+ gtk_text_view_set_buffer (GTK_TEXT_VIEW (self->priv->changes_view), buffer);
+ g_signal_connect (self->priv->changes_view, "event", G_CALLBACK (view_event), self);
- gtk_tree_view_set_model(self->priv->tree_view_unstaged, GTK_TREE_MODEL(self->priv->store_unstaged));
- gtk_tree_view_set_model(self->priv->tree_view_staged, GTK_TREE_MODEL(self->priv->store_staged));
+ gtk_tree_view_set_model (self->priv->tree_view_unstaged, GTK_TREE_MODEL (self->priv->store_unstaged));
+ gtk_tree_view_set_model (self->priv->tree_view_staged, GTK_TREE_MODEL (self->priv->store_staged));
- set_icon_data_func(self, self->priv->tree_view_unstaged, GTK_CELL_RENDERER(gtk_builder_get_object(builder, "unstaged_cell_renderer_icon")));
- set_icon_data_func(self, self->priv->tree_view_staged, GTK_CELL_RENDERER(gtk_builder_get_object(builder, "staged_cell_renderer_icon")));
+ set_icon_data_func (self, self->priv->tree_view_unstaged, GTK_CELL_RENDERER (gtk_builder_get_object (builder, "unstaged_cell_renderer_icon")));
+ set_icon_data_func (self, self->priv->tree_view_staged, GTK_CELL_RENDERER (gtk_builder_get_object (builder, "staged_cell_renderer_icon")));
GtkSourceStyleScheme *scheme;
GtkSourceStyle *style;
@@ -1544,17 +1712,24 @@ gitg_commit_view_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
GtkTreeSelection *selection;
- selection = gtk_tree_view_get_selection(self->priv->tree_view_unstaged);
+ selection = gtk_tree_view_get_selection (self->priv->tree_view_unstaged);
- gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
- g_signal_connect(selection, "changed", G_CALLBACK(unstaged_selection_changed), self);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+ g_signal_connect (selection, "changed", G_CALLBACK (unstaged_selection_changed), self);
- selection = gtk_tree_view_get_selection(self->priv->tree_view_staged);
- gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
- g_signal_connect(selection, "changed", G_CALLBACK(staged_selection_changed), self);
+ selection = gtk_tree_view_get_selection (self->priv->tree_view_staged);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+ g_signal_connect (selection, "changed", G_CALLBACK (staged_selection_changed), self);
- g_signal_connect(self->priv->tree_view_unstaged, "event-after", G_CALLBACK(on_unstaged_button_press), self);
- g_signal_connect(self->priv->tree_view_staged, "event-after", G_CALLBACK(on_staged_button_press), self);
+ g_signal_connect (self->priv->tree_view_unstaged,
+ "event-after",
+ G_CALLBACK (on_unstaged_button_press),
+ self);
+
+ g_signal_connect (self->priv->tree_view_staged,
+ "event-after",
+ G_CALLBACK (on_staged_button_press),
+ self);
g_signal_connect (self->priv->tree_view_unstaged,
"button-press-event",
@@ -1575,16 +1750,40 @@ gitg_commit_view_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
G_CALLBACK (on_staged_tree_view_row_activated),
self);
- g_signal_connect(self->priv->tree_view_unstaged, "popup-menu", G_CALLBACK(on_unstaged_popup_menu), self);
- g_signal_connect(self->priv->tree_view_staged, "popup-menu", G_CALLBACK(on_staged_popup_menu), self);
- g_signal_connect(self->priv->changes_view, "populate-popup", G_CALLBACK(on_changes_view_popup_menu), self);
+ g_signal_connect (self->priv->tree_view_unstaged,
+ "popup-menu",
+ G_CALLBACK (on_unstaged_popup_menu),
+ self);
+
+ g_signal_connect (self->priv->tree_view_staged,
+ "popup-menu",
+ G_CALLBACK (on_staged_popup_menu),
+ self);
- g_signal_connect(self->priv->tree_view_unstaged, "motion-notify-event", G_CALLBACK(on_unstaged_motion), self);
- g_signal_connect(self->priv->tree_view_staged, "motion-notify-event", G_CALLBACK(on_staged_motion), self);
+ g_signal_connect (self->priv->changes_view,
+ "populate-popup",
+ G_CALLBACK (on_changes_view_popup_menu),
+ self);
+
+ g_signal_connect (self->priv->tree_view_unstaged,
+ "motion-notify-event",
+ G_CALLBACK (on_unstaged_motion),
+ self);
+
+ g_signal_connect (self->priv->tree_view_staged,
+ "motion-notify-event",
+ G_CALLBACK (on_staged_motion),
+ self);
- g_signal_connect(gtk_builder_get_object(builder, "button_commit"), "clicked", G_CALLBACK(on_commit_clicked), self);
+ g_signal_connect (gtk_builder_get_object (builder, "button_commit"),
+ "clicked",
+ G_CALLBACK (on_commit_clicked),
+ self);
- g_signal_connect(self->priv->hscale_context, "value-changed", G_CALLBACK(on_context_value_changed), self);
+ g_signal_connect (self->priv->hscale_context,
+ "value-changed",
+ G_CALLBACK (on_context_value_changed),
+ self);
g_signal_connect (self->priv->check_button_amend,
"toggled",
@@ -1616,7 +1815,7 @@ gitg_commit_view_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
}
static void
-gitg_commit_view_buildable_iface_init(GtkBuildableIface *iface)
+gitg_commit_view_buildable_iface_init (GtkBuildableIface *iface)
{
parent_iface = *iface;
@@ -1624,9 +1823,9 @@ gitg_commit_view_buildable_iface_init(GtkBuildableIface *iface)
}
static void
-gitg_commit_view_dispose(GObject *object)
+gitg_commit_view_dispose (GObject *object)
{
- GitgCommitView *self = GITG_COMMIT_VIEW(object);
+ GitgCommitView *self = GITG_COMMIT_VIEW (object);
if (self->priv->message_settings)
{
@@ -1642,16 +1841,21 @@ gitg_commit_view_dispose(GObject *object)
if (self->priv->repository)
{
- g_object_unref(self->priv->repository);
+ g_object_unref (self->priv->repository);
self->priv->repository = NULL;
}
if (self->priv->commit)
{
- g_signal_handlers_disconnect_by_func(self->priv->commit, on_commit_file_inserted, self);
- g_signal_handlers_disconnect_by_func(self->priv->commit, on_commit_file_removed, self);
+ g_signal_handlers_disconnect_by_func (self->priv->commit,
+ on_commit_file_inserted,
+ self);
+
+ g_signal_handlers_disconnect_by_func (self->priv->commit,
+ on_commit_file_removed,
+ self);
- g_object_unref(self->priv->commit);
+ g_object_unref (self->priv->commit);
self->priv->commit = NULL;
}
@@ -1663,75 +1867,92 @@ gitg_commit_view_dispose(GObject *object)
}
static void
-gitg_commit_view_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gitg_commit_view_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GitgCommitView *self = GITG_COMMIT_VIEW(object);
+ GitgCommitView *self = GITG_COMMIT_VIEW (object);
switch (prop_id)
{
case PROP_REPOSITORY:
- g_value_set_object(value, self->priv->repository);
+ g_value_set_object (value, self->priv->repository);
break;
case PROP_CONTEXT_SIZE:
- g_value_set_int(value, self->priv->context_size);
+ g_value_set_int (value, self->priv->context_size);
break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
-gitg_commit_view_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gitg_commit_view_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GitgCommitView *self = GITG_COMMIT_VIEW(object);
+ GitgCommitView *self = GITG_COMMIT_VIEW (object);
switch (prop_id)
{
case PROP_REPOSITORY:
- self->priv->repository = g_value_dup_object(value);
+ self->priv->repository = g_value_dup_object (value);
break;
case PROP_CONTEXT_SIZE:
- self->priv->context_size = g_value_get_int(value);
+ self->priv->context_size = g_value_get_int (value);
break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
-initialize_commit(GitgCommitView *self)
+initialize_commit (GitgCommitView *self)
{
if (self->priv->commit)
+ {
return;
+ }
- self->priv->commit = gitg_commit_new(self->priv->repository);
+ self->priv->commit = gitg_commit_new (self->priv->repository);
- g_signal_connect(self->priv->commit, "inserted", G_CALLBACK(on_commit_file_inserted), self);
- g_signal_connect(self->priv->commit, "removed", G_CALLBACK(on_commit_file_removed), self);
+ g_signal_connect (self->priv->commit,
+ "inserted",
+ G_CALLBACK (on_commit_file_inserted),
+ self);
- gitg_commit_refresh(self->priv->commit);
+ g_signal_connect (self->priv->commit,
+ "removed",
+ G_CALLBACK (on_commit_file_removed),
+ self);
+
+ gitg_commit_refresh (self->priv->commit);
}
static void
-gitg_commit_view_map(GtkWidget *widget)
+gitg_commit_view_map (GtkWidget *widget)
{
- GitgCommitView *self = GITG_COMMIT_VIEW(widget);
+ GitgCommitView *self = GITG_COMMIT_VIEW (widget);
- GTK_WIDGET_CLASS(gitg_commit_view_parent_class)->map(widget);
+ GTK_WIDGET_CLASS (gitg_commit_view_parent_class)->map (widget);
if (!self->priv->repository)
+ {
return;
+ }
- initialize_commit(self);
+ initialize_commit (self);
}
static void
-gitg_commit_view_class_init(GitgCommitViewClass *klass)
+gitg_commit_view_class_init (GitgCommitViewClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS(klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = gitg_commit_view_finalize;
object_class->dispose = gitg_commit_view_dispose;
@@ -1741,23 +1962,26 @@ gitg_commit_view_class_init(GitgCommitViewClass *klass)
object_class->set_property = gitg_commit_view_set_property;
object_class->get_property = gitg_commit_view_get_property;
- g_object_class_install_property(object_class, PROP_REPOSITORY,
- g_param_spec_object("repository",
- "REPOSITORY",
- "Repository",
- GITG_TYPE_REPOSITORY,
- G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_REPOSITORY,
+ g_param_spec_object ("repository",
+ "REPOSITORY",
+ "Repository",
+ GITG_TYPE_REPOSITORY,
+ G_PARAM_READWRITE));
- g_object_class_install_property(object_class, PROP_CONTEXT_SIZE,
- g_param_spec_int("context-size",
- "CONTEXT_SIZE",
- "Diff context size",
- 1,
- G_MAXINT,
- 3,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_CONTEXT_SIZE,
+ g_param_spec_int ("context-size",
+ "CONTEXT_SIZE",
+ "Diff context size",
+ 1,
+ G_MAXINT,
+ 3,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
- g_type_class_add_private(object_class, sizeof(GitgCommitViewPrivate));
+ g_type_class_add_private (object_class, sizeof (GitgCommitViewPrivate));
}
static void
@@ -1765,8 +1989,12 @@ gitg_commit_view_init (GitgCommitView *self)
{
self->priv = GITG_COMMIT_VIEW_GET_PRIVATE (self);
- self->priv->message_settings = g_settings_new ("org.gnome.gitg.preferences.commit.message");
- self->priv->diff_settings = g_settings_new ("org.gnome.gitg.preferences.diff");
+ self->priv->message_settings =
+ g_settings_new ("org.gnome.gitg.preferences.commit.message");
+
+ self->priv->diff_settings =
+ g_settings_new ("org.gnome.gitg.preferences.diff");
+
self->priv->shell = gitg_shell_new (10000);
gitg_shell_set_preserve_line_endings (self->priv->shell, TRUE);
@@ -1774,41 +2002,44 @@ gitg_commit_view_init (GitgCommitView *self)
}
void
-gitg_commit_view_set_repository(GitgCommitView *view, GitgRepository *repository)
+gitg_commit_view_set_repository (GitgCommitView *view,
+ GitgRepository *repository)
{
- g_return_if_fail(GITG_IS_COMMIT_VIEW(view));
- g_return_if_fail(repository == NULL || GITG_IS_REPOSITORY(repository));
+ g_return_if_fail (GITG_IS_COMMIT_VIEW (view));
+ g_return_if_fail (repository == NULL || GITG_IS_REPOSITORY (repository));
if (view->priv->repository)
{
- g_object_unref(view->priv->repository);
+ g_object_unref (view->priv->repository);
view->priv->repository = NULL;
}
if (view->priv->commit)
{
- g_object_unref(view->priv->commit);
+ g_object_unref (view->priv->commit);
view->priv->commit = NULL;
}
- gtk_list_store_clear(view->priv->store_unstaged);
- gtk_list_store_clear(view->priv->store_staged);
+ gtk_list_store_clear (view->priv->store_unstaged);
+ gtk_list_store_clear (view->priv->store_staged);
if (repository)
{
- view->priv->repository = g_object_ref(repository);
+ view->priv->repository = g_object_ref (repository);
}
if (gtk_widget_get_mapped (GTK_WIDGET (view)))
{
- initialize_commit(view);
+ initialize_commit (view);
}
- g_object_notify(G_OBJECT(view), "repository");
+ g_object_notify (G_OBJECT (view), "repository");
}
static void
-append_file(GtkListStore *store, GitgChangedFile *file, GitgCommitView *view)
+append_file (GtkListStore *store,
+ GitgChangedFile *file,
+ GitgCommitView *view)
{
GFile *f = gitg_changed_file_get_file (file);
gchar *rel = gitg_repository_relative (view->priv->repository, f);
@@ -1816,7 +2047,13 @@ append_file(GtkListStore *store, GitgChangedFile *file, GitgCommitView *view)
GtkTreeIter iter;
gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, COLUMN_NAME, rel, COLUMN_FILE, file, -1);
+ gtk_list_store_set (store,
+ &iter,
+ COLUMN_NAME,
+ rel,
+ COLUMN_FILE,
+ file,
+ -1);
g_free (rel);
g_object_unref (f);
@@ -1824,136 +2061,205 @@ append_file(GtkListStore *store, GitgChangedFile *file, GitgCommitView *view)
/* Callbacks */
static gboolean
-find_file_in_store(GtkListStore *store, GitgChangedFile *file, GtkTreeIter *iter)
+find_file_in_store (GtkListStore *store,
+ GitgChangedFile *file,
+ GtkTreeIter *iter)
{
- GtkTreeModel *model = GTK_TREE_MODEL(store);
+ GtkTreeModel *model = GTK_TREE_MODEL (store);
- if (!gtk_tree_model_get_iter_first(model, iter))
+ if (!gtk_tree_model_get_iter_first (model, iter))
+ {
return FALSE;
+ }
do
{
GitgChangedFile *other;
- gtk_tree_model_get(model, iter, COLUMN_FILE, &other, -1);
+ gtk_tree_model_get (model, iter, COLUMN_FILE, &other, -1);
gboolean ret = (other == file);
- g_object_unref(other);
+ g_object_unref (other);
if (ret)
+ {
return TRUE;
- } while (gtk_tree_model_iter_next(model, iter));
+ }
+ } while (gtk_tree_model_iter_next (model, iter));
return FALSE;
}
static void
-model_row_changed(GtkListStore *store, GtkTreeIter *iter)
+model_row_changed (GtkListStore *store,
+ GtkTreeIter *iter)
{
- GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), iter);
+ GtkTreePath *path;
+
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), iter);
if (!path)
+ {
return;
+ }
- gtk_tree_model_row_changed(GTK_TREE_MODEL(store), path, iter);
- gtk_tree_path_free(path);
+ gtk_tree_model_row_changed (GTK_TREE_MODEL (store), path, iter);
+ gtk_tree_path_free (path);
}
static void
-on_commit_file_changed(GitgChangedFile *file, GParamSpec *spec, GitgCommitView *view)
+on_commit_file_changed (GitgChangedFile *file,
+ GParamSpec *spec,
+ GitgCommitView *view)
{
GtkTreeIter staged;
GtkTreeIter unstaged;
+ gboolean isstaged;
+ gboolean isunstaged;
+
+ isstaged = find_file_in_store (view->priv->store_staged,
+ file,
+ &staged);
- gboolean isstaged = find_file_in_store(view->priv->store_staged, file, &staged);
- gboolean isunstaged = find_file_in_store(view->priv->store_unstaged, file, &unstaged);
+ isunstaged = find_file_in_store (view->priv->store_unstaged,
+ file,
+ &unstaged);
if (isstaged)
- model_row_changed(view->priv->store_staged, &staged);
+ {
+ model_row_changed (view->priv->store_staged, &staged);
+ }
if (isunstaged)
- model_row_changed(view->priv->store_unstaged, &unstaged);
+ {
+ model_row_changed (view->priv->store_unstaged, &unstaged);
+ }
- GitgChangedFileChanges changes = gitg_changed_file_get_changes(file);
+ GitgChangedFileChanges changes = gitg_changed_file_get_changes (file);
if (changes & GITG_CHANGED_FILE_CHANGES_CACHED)
{
if (!isstaged)
- append_file(view->priv->store_staged, file, view);
+ {
+ append_file (view->priv->store_staged, file, view);
+ }
}
else
{
if (isstaged)
- gtk_list_store_remove(view->priv->store_staged, &staged);
+ {
+ gtk_list_store_remove (view->priv->store_staged, &staged);
+ }
}
if (changes & GITG_CHANGED_FILE_CHANGES_UNSTAGED)
{
if (!isunstaged)
- append_file(view->priv->store_unstaged, file, view);
+ {
+ append_file (view->priv->store_unstaged, file, view);
+ }
}
else
{
if (isunstaged)
- gtk_list_store_remove(view->priv->store_unstaged, &unstaged);
+ {
+ gtk_list_store_remove (view->priv->store_unstaged,
+ &unstaged);
+ }
}
}
static void
-on_commit_file_inserted(GitgCommit *commit, GitgChangedFile *file, GitgCommitView *view)
+on_commit_file_inserted (GitgCommit *commit,
+ GitgChangedFile *file,
+ GitgCommitView *view)
{
- GitgChangedFileChanges changes = gitg_changed_file_get_changes(file);
+ GitgChangedFileChanges changes;
+
+ changes = gitg_changed_file_get_changes (file);
if (changes & GITG_CHANGED_FILE_CHANGES_UNSTAGED)
- append_file(view->priv->store_unstaged, file, view);
+ {
+ append_file (view->priv->store_unstaged, file, view);
+ }
if (changes & GITG_CHANGED_FILE_CHANGES_CACHED)
- append_file(view->priv->store_staged, file, view);
+ {
+ append_file (view->priv->store_staged, file, view);
+ }
- g_signal_connect(file, "notify::changes", G_CALLBACK(on_commit_file_changed), view);
- g_signal_connect(file, "notify::status", G_CALLBACK(on_commit_file_changed), view);
+ g_signal_connect (file,
+ "notify::changes",
+ G_CALLBACK (on_commit_file_changed),
+ view);
+
+ g_signal_connect (file,
+ "notify::status",
+ G_CALLBACK (on_commit_file_changed),
+ view);
}
static void
-on_commit_file_removed(GitgCommit *commit, GitgChangedFile *file, GitgCommitView *view)
+on_commit_file_removed (GitgCommit *commit,
+ GitgChangedFile *file,
+ GitgCommitView *view)
{
GtkTreeIter iter;
- if (find_file_in_store(view->priv->store_staged, file, &iter))
- gtk_list_store_remove(view->priv->store_staged, &iter);
+ if (find_file_in_store (view->priv->store_staged, file, &iter))
+ {
+ gtk_list_store_remove (view->priv->store_staged, &iter);
+ }
- if (find_file_in_store(view->priv->store_unstaged, file, &iter))
- gtk_list_store_remove(view->priv->store_unstaged, &iter);
+ if (find_file_in_store (view->priv->store_unstaged, file, &iter))
+ {
+ gtk_list_store_remove (view->priv->store_unstaged, &iter);
+ }
}
static gboolean
-column_icon_test(GtkTreeView *view, gdouble ex, gdouble ey, GitgChangedFile **file)
+column_icon_test (GtkTreeView *view,
+ gdouble ex,
+ gdouble ey,
+ GitgChangedFile **file)
{
GtkTreeViewColumn *column;
gint x;
gint y;
-
- gtk_tree_view_convert_widget_to_bin_window_coords(view, (gint)ex, (gint)ey, &x, &y);
GtkTreePath *path;
- if (!gtk_tree_view_get_path_at_pos(view, x, y, &path, &column, NULL, NULL))
+ gtk_tree_view_convert_widget_to_bin_window_coords (view,
+ (gint)ex,
+ (gint)ey,
+ &x,
+ &y);
+
+ if (!gtk_tree_view_get_path_at_pos (view,
+ x,
+ y,
+ &path,
+ &column,
+ NULL,
+ NULL))
+ {
return FALSE;
+ }
- if (column != gtk_tree_view_get_column(view, 0))
+ if (column != gtk_tree_view_get_column (view, 0))
{
- gtk_tree_path_free(path);
+ gtk_tree_path_free (path);
return FALSE;
}
if (file)
{
- GtkTreeModel *model = gtk_tree_view_get_model(view);
+ GtkTreeModel *model = gtk_tree_view_get_model (view);
GtkTreeIter iter;
- gtk_tree_model_get_iter(model, &iter, path);
- gtk_tree_model_get(model, &iter, COLUMN_FILE, file, -1);
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, COLUMN_FILE, file, -1);
}
- gtk_tree_path_free(path);
+ gtk_tree_path_free (path);
return TRUE;
}
@@ -1980,7 +2286,9 @@ on_staged_unstaged_button_press_before (GtkWidget *widget,
NULL,
NULL))
{
- GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview);
+ GtkTreeSelection *selection =
+ gtk_tree_view_get_selection (treeview);
+
if (gtk_tree_selection_path_is_selected (selection, path))
{
/* Block normal treeview behavior to unselect potential
@@ -2000,10 +2308,14 @@ on_unstaged_tree_view_row_activated (GtkTreeView *tree_view,
{
GList *files = NULL;
- get_selected_files (view->priv->tree_view_unstaged, &files, NULL, NULL, NULL);
+ get_selected_files (view->priv->tree_view_unstaged,
+ &files,
+ NULL,
+ NULL,
+ NULL);
- gitg_commit_stage(view->priv->commit, files->data, NULL, NULL);
- g_list_free (files);
+ gitg_commit_stage (view->priv->commit, files->data, NULL, NULL);
+ g_list_free_full (files, (GDestroyNotify)g_object_unref);
}
static void
@@ -2014,56 +2326,81 @@ on_staged_tree_view_row_activated (GtkTreeView *tree_view,
{
GList *files = NULL;
- get_selected_files (view->priv->tree_view_staged, &files, NULL, NULL, NULL);
+ get_selected_files (view->priv->tree_view_staged,
+ &files,
+ NULL,
+ NULL,
+ NULL);
- gitg_commit_unstage(view->priv->commit, files->data, NULL, NULL);
- g_list_free (files);
+ gitg_commit_unstage (view->priv->commit, files->data, NULL, NULL);
+ g_list_free_full (files, (GDestroyNotify)g_object_unref);
}
static void
-on_unstaged_button_press(GtkWidget *widget, GdkEventButton *event, GitgCommitView *view)
+on_unstaged_button_press (GtkWidget *widget,
+ GdkEventButton *event,
+ GitgCommitView *view)
{
GitgChangedFile *file;
if (event->type != GDK_BUTTON_PRESS)
+ {
return;
+ }
- if (event->button == 1 && column_icon_test(view->priv->tree_view_unstaged, event->x, event->y, &file))
+ if (event->button == 1 &&
+ column_icon_test (view->priv->tree_view_unstaged,
+ event->x,
+ event->y,
+ &file))
{
- gitg_commit_stage(view->priv->commit, file, NULL, NULL);
- g_object_unref(file);
+ gitg_commit_stage (view->priv->commit, file, NULL, NULL);
+ g_object_unref (file);
}
else if (event->button == 3)
{
view->priv->context_type = CONTEXT_TYPE_FILE;
- popup_unstaged_menu(view, event);
+ popup_unstaged_menu (view, event);
}
}
static void
-on_staged_button_press(GtkWidget *widget, GdkEventButton *event, GitgCommitView *view)
+on_staged_button_press (GtkWidget *widget,
+ GdkEventButton *event,
+ GitgCommitView *view)
{
GitgChangedFile *file;
if (event->type != GDK_BUTTON_PRESS)
+ {
return;
+ }
- if (event->button == 1 && column_icon_test(view->priv->tree_view_staged, event->x, event->y, &file))
+ if (event->button == 1 &&
+ column_icon_test (view->priv->tree_view_staged,
+ event->x,
+ event->y,
+ &file))
{
- gitg_commit_unstage(view->priv->commit, file, NULL, NULL);
- g_object_unref(file);
+ gitg_commit_unstage (view->priv->commit, file, NULL, NULL);
+ g_object_unref (file);
}
else if (event->button == 3)
{
view->priv->context_type = CONTEXT_TYPE_FILE;
- popup_staged_menu(view, event);
+ popup_staged_menu (view, event);
}
}
static gboolean
-on_unstaged_motion (GtkWidget *widget, GdkEventMotion *event, GitgCommitView *view)
+on_unstaged_motion (GtkWidget *widget,
+ GdkEventMotion *event,
+ GitgCommitView *view)
{
- if (column_icon_test(view->priv->tree_view_unstaged, event->x, event->y, NULL))
+ if (column_icon_test (view->priv->tree_view_unstaged,
+ event->x,
+ event->y,
+ NULL))
{
gdk_window_set_cursor (gtk_widget_get_window (widget),
view->priv->hand);
@@ -2077,9 +2414,14 @@ on_unstaged_motion (GtkWidget *widget, GdkEventMotion *event, GitgCommitView *vi
}
static gboolean
-on_staged_motion(GtkWidget *widget, GdkEventMotion *event, GitgCommitView *view)
+on_staged_motion (GtkWidget *widget,
+ GdkEventMotion *event,
+ GitgCommitView *view)
{
- if (column_icon_test(view->priv->tree_view_staged, event->x, event->y, NULL))
+ if (column_icon_test (view->priv->tree_view_staged,
+ event->x,
+ event->y,
+ NULL))
{
gdk_window_set_cursor (gtk_widget_get_window (widget),
view->priv->hand);
@@ -2093,104 +2435,168 @@ on_staged_motion(GtkWidget *widget, GdkEventMotion *event, GitgCommitView *view)
}
static gchar *
-get_comment(GitgCommitView *view)
+get_comment (GitgCommitView *view)
{
- GtkTextBuffer *buffer = gtk_text_view_get_buffer(view->priv->comment_view);
+ GtkTextBuffer *buffer;
GtkTextIter start;
GtkTextIter end;
- gtk_text_buffer_get_bounds(buffer, &start, &end);
- gchar *text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
+ buffer = gtk_text_view_get_buffer (view->priv->comment_view);
+
+ gtk_text_buffer_get_bounds (buffer, &start, &end);
+ gchar *text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
gchar *ptr;
- for (ptr = text; *ptr; ptr = g_utf8_next_char(ptr))
- if (!g_unichar_isspace(g_utf8_get_char(ptr)))
+ for (ptr = text; *ptr; ptr = g_utf8_next_char (ptr))
+ if (!g_unichar_isspace (g_utf8_get_char (ptr)))
+ {
return text;
+ }
- g_free(text);
+ g_free (text);
return NULL;
}
static void
-show_error(GitgCommitView *view, gchar const *error)
+show_error (GitgCommitView *view,
+ gchar const *error)
{
- GtkWidget *dlg = gtk_message_dialog_new(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view))), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", error);
+ GtkWidget *dlg;
+
+ dlg = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s",
+ error);
- gtk_dialog_run(GTK_DIALOG(dlg));
- gtk_widget_destroy(dlg);
+ gtk_dialog_run (GTK_DIALOG (dlg));
+ gtk_widget_destroy (dlg);
}
static void
-on_commit_clicked(GtkButton *button, GitgCommitView *view)
+on_commit_clicked (GtkButton *button,
+ GitgCommitView *view)
{
- if (!gitg_commit_has_changes(view->priv->commit))
+ gchar *comment;
+ gboolean signoff;
+ gboolean amend;
+
+ if (!gitg_commit_has_changes (view->priv->commit))
{
- show_error(view, _("You must first stage some changes before committing"));
+ show_error (view, _("You must first stage some changes before committing"));
return;
}
- gchar *comment = get_comment(view);
+ comment = get_comment (view);
if (!comment)
{
- show_error(view, _("Please enter a commit message before committing"));
+ show_error (view, _("Please enter a commit message before committing"));
return;
}
- gboolean signoff = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(view->priv->check_button_signed_off_by));
- gboolean amend = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (view->priv->check_button_amend));
+ signoff = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (view->priv->check_button_signed_off_by));
+
+ amend = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (view->priv->check_button_amend));
GError *error = NULL;
- if (!gitg_commit_commit(view->priv->commit, comment, signoff, amend, &error))
+ if (!gitg_commit_commit (view->priv->commit,
+ comment,
+ signoff,
+ amend,
+ &error))
{
- if (error && error->domain == GITG_COMMIT_ERROR && error->code == GITG_COMMIT_ERROR_SIGNOFF)
- show_error(view, _("Your user name or email could not be retrieved for use in the sign off message"));
+ if (error &&
+ error->domain == GITG_COMMIT_ERROR &&
+ error->code == GITG_COMMIT_ERROR_SIGNOFF)
+ {
+ show_error (view, _("Your user name or email could not be retrieved for use in the sign off message"));
+ }
else
- show_error(view, _("Something went wrong while trying to commit"));
+ show_error (view, _("Something went wrong while trying to commit"));
if (error)
- g_error_free(error);
+ {
+ g_error_free (error);
+ }
}
else
{
- gtk_text_buffer_set_text(gtk_text_view_get_buffer(view->priv->comment_view), "", -1);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (view->priv->check_button_amend), FALSE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (view->priv->check_button_signed_off_by), FALSE);
+ gtk_text_buffer_set_text (
+ gtk_text_view_get_buffer (view->priv->comment_view),
+ "",
+ -1);
+
+ gtk_toggle_button_set_active (
+ GTK_TOGGLE_BUTTON (view->priv->check_button_amend),
+ FALSE);
+
+ gtk_toggle_button_set_active (
+ GTK_TOGGLE_BUTTON (view->priv->check_button_signed_off_by),
+ FALSE);
}
- g_free(comment);
+ g_free (comment);
}
static void
-on_context_value_changed(GtkHScale *scale, GitgCommitView *view)
+on_context_value_changed (GtkHScale *scale,
+ GitgCommitView *view)
{
- view->priv->context_size = (gint)gtk_range_get_value(GTK_RANGE(scale));
+ view->priv->context_size = (gint)gtk_range_get_value (GTK_RANGE (scale));
if (view->priv->current_changes & GITG_CHANGED_FILE_CHANGES_UNSTAGED)
- unstaged_selection_changed(gtk_tree_view_get_selection(view->priv->tree_view_unstaged), view);
+ {
+ unstaged_selection_changed (
+ gtk_tree_view_get_selection (view->priv->tree_view_unstaged),
+ view);
+ }
else if (view->priv->current_changes & GITG_CHANGED_FILE_CHANGES_CACHED)
- staged_selection_changed(gtk_tree_view_get_selection(view->priv->tree_view_staged), view);
+ {
+ staged_selection_changed (
+ gtk_tree_view_get_selection (view->priv->tree_view_staged),
+ view);
+ }
}
static gboolean
-set_unstaged_popup_status(GitgCommitView *view)
+set_unstaged_popup_status (GitgCommitView *view)
{
GitgChangedFileChanges changes;
GitgChangedFileStatus status;
+ GtkAction *revert;
+ GtkAction *ignore;
+ GtkAction *edit;
+ GtkAction *delete;
- if (!get_selected_files(view->priv->tree_view_unstaged, NULL, NULL, &changes, &status))
+ if (!get_selected_files (view->priv->tree_view_unstaged,
+ NULL,
+ NULL,
+ &changes,
+ &status))
+ {
return FALSE;
+ }
+
+ revert = gtk_ui_manager_get_action (view->priv->ui_manager,
+ "/ui/popup_commit_stage/RevertChangesAction");
- GtkAction *revert = gtk_ui_manager_get_action(view->priv->ui_manager, "/ui/popup_commit_stage/RevertChangesAction");
- GtkAction *ignore = gtk_ui_manager_get_action(view->priv->ui_manager, "/ui/popup_commit_stage/IgnoreFileAction");
- GtkAction *edit = gtk_ui_manager_get_action(view->priv->ui_manager, "/ui/popup_commit_stage/EditFileAction");
- GtkAction *delete = gtk_ui_manager_get_action (view->priv->ui_manager,
- "/ui/popup_commit_stage/DeleteFileAction");
+ ignore = gtk_ui_manager_get_action (view->priv->ui_manager,
+ "/ui/popup_commit_stage/IgnoreFileAction");
- gtk_action_set_visible(revert, status == GITG_CHANGED_FILE_STATUS_MODIFIED ||
+ edit = gtk_ui_manager_get_action (view->priv->ui_manager,
+ "/ui/popup_commit_stage/EditFileAction");
+
+ delete = gtk_ui_manager_get_action (view->priv->ui_manager,
+ "/ui/popup_commit_stage/DeleteFileAction");
+
+ gtk_action_set_visible (revert, status == GITG_CHANGED_FILE_STATUS_MODIFIED ||
status == GITG_CHANGED_FILE_STATUS_DELETED);
- gtk_action_set_visible(ignore, status == GITG_CHANGED_FILE_STATUS_NEW);
+ gtk_action_set_visible (ignore, status == GITG_CHANGED_FILE_STATUS_NEW);
gtk_action_set_visible (edit, status != GITG_CHANGED_FILE_STATUS_DELETED);
gtk_action_set_visible (delete, status == GITG_CHANGED_FILE_STATUS_NEW);
@@ -2199,64 +2605,103 @@ set_unstaged_popup_status(GitgCommitView *view)
}
static gboolean
-set_staged_popup_status(GitgCommitView *view)
+set_staged_popup_status (GitgCommitView *view)
{
GitgChangedFileStatus status;
+ GtkAction *edit;
- if (!get_selected_files(view->priv->tree_view_staged, NULL, NULL, NULL, &status))
+ if (!get_selected_files (view->priv->tree_view_staged,
+ NULL,
+ NULL,
+ NULL,
+ &status))
+ {
return FALSE;
+ }
+
+ edit = gtk_ui_manager_get_action (view->priv->ui_manager,
+ "/ui/popup_commit_stage/EditFileAction");
- GtkAction *edit = gtk_ui_manager_get_action(view->priv->ui_manager, "/ui/popup_commit_stage/EditFileAction");
gtk_action_set_visible (edit, status != GITG_CHANGED_FILE_STATUS_DELETED);
return TRUE;
}
static gboolean
-popup_unstaged_menu(GitgCommitView *view, GdkEventButton *event)
+popup_unstaged_menu (GitgCommitView *view,
+ GdkEventButton *event)
{
- if (!set_unstaged_popup_status(view))
+ GtkWidget *wd;
+
+ if (!set_unstaged_popup_status (view))
+ {
return FALSE;
+ }
- GtkWidget *wd = gtk_ui_manager_get_widget(view->priv->ui_manager, "/ui/popup_commit_stage");
+ wd = gtk_ui_manager_get_widget (view->priv->ui_manager,
+ "/ui/popup_commit_stage");
view->priv->context_type = CONTEXT_TYPE_FILE;
if (event)
{
- gtk_menu_popup(GTK_MENU(wd), NULL, NULL, NULL, NULL, event->button, event->time);
+ gtk_menu_popup (GTK_MENU (wd),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ event->button,
+ event->time);
}
else
{
- gtk_menu_popup(GTK_MENU(wd), NULL, NULL,
- gitg_utils_menu_position_under_tree_view,
- view->priv->tree_view_staged, 0,
- gtk_get_current_event_time());
+ gtk_menu_popup (GTK_MENU (wd),
+ NULL,
+ NULL,
+ gitg_utils_menu_position_under_tree_view,
+ view->priv->tree_view_staged,
+ 0,
+ gtk_get_current_event_time ());
}
return TRUE;
}
static gboolean
-popup_staged_menu(GitgCommitView *view, GdkEventButton *event)
+popup_staged_menu (GitgCommitView *view,
+ GdkEventButton *event)
{
- if (!set_staged_popup_status(view))
+ GtkWidget *wd;
+
+ if (!set_staged_popup_status (view))
+ {
return FALSE;
+ }
- GtkWidget *wd = gtk_ui_manager_get_widget(view->priv->ui_manager, "/ui/popup_commit_unstage");
+ wd = gtk_ui_manager_get_widget (view->priv->ui_manager,
+ "/ui/popup_commit_unstage");
view->priv->context_type = CONTEXT_TYPE_FILE;
if (event)
{
- gtk_menu_popup(GTK_MENU(wd), NULL, NULL, NULL, NULL, event->button, event->time);
+ gtk_menu_popup (GTK_MENU (wd),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ event->button,
+ event->time);
}
else
{
- gtk_menu_popup(GTK_MENU(wd), NULL, NULL,
- gitg_utils_menu_position_under_tree_view,
- view->priv->tree_view_unstaged, 0,
- gtk_get_current_event_time());
+ gtk_menu_popup (GTK_MENU (wd),
+ NULL,
+ NULL,
+ gitg_utils_menu_position_under_tree_view,
+ view->priv->tree_view_unstaged,
+ 0,
+ gtk_get_current_event_time ());
}
return TRUE;
@@ -2264,43 +2709,52 @@ popup_staged_menu(GitgCommitView *view, GdkEventButton *event)
static gboolean
-on_unstaged_popup_menu(GtkWidget *widget, GitgCommitView *view)
+on_unstaged_popup_menu (GtkWidget *widget,
+ GitgCommitView *view)
{
- return popup_unstaged_menu(view, NULL);
+ return popup_unstaged_menu (view, NULL);
}
static gboolean
-on_staged_popup_menu(GtkWidget *widget, GitgCommitView *view)
+on_staged_popup_menu (GtkWidget *widget,
+ GitgCommitView *view)
{
- return popup_staged_menu(view, NULL);
+ return popup_staged_menu (view, NULL);
}
static void
-on_stage_changes(GtkAction *action, GitgCommitView *view)
+on_stage_changes (GtkAction *action,
+ GitgCommitView *view)
{
if (view->priv->context_type == CONTEXT_TYPE_FILE)
{
GList *files = NULL;
GList *item;
- get_selected_files (view->priv->tree_view_unstaged, &files, NULL, NULL, NULL);
+ get_selected_files (view->priv->tree_view_unstaged,
+ &files,
+ NULL,
+ NULL,
+ NULL);
for (item = files; item; item = g_list_next (item))
{
- gitg_commit_stage(view->priv->commit, GITG_CHANGED_FILE (item->data), NULL, NULL);
- g_object_unref (item->data);
+ gitg_commit_stage (view->priv->commit,
+ GITG_CHANGED_FILE (item->data),
+ NULL,
+ NULL);
}
- g_list_free (files);
+ g_list_free_full (files, (GDestroyNotify)g_object_unref);
}
else
{
- handle_stage_unstage(view, &view->priv->context_iter);
+ handle_stage_unstage (view, &view->priv->context_iter);
}
}
static void
-do_revert_changes(GitgCommitView *view)
+do_revert_changes (GitgCommitView *view)
{
gboolean ret = TRUE;
@@ -2309,79 +2763,101 @@ do_revert_changes(GitgCommitView *view)
GList *files = NULL;
GList *item;
- get_selected_files (view->priv->tree_view_unstaged, &files, NULL, NULL, NULL);
+ get_selected_files (view->priv->tree_view_unstaged,
+ &files,
+ NULL,
+ NULL,
+ NULL);
for (item = files; item; item = g_list_next (item))
{
- ret &= gitg_commit_undo (view->priv->commit,
- GITG_CHANGED_FILE (item->data),
- NULL,
- NULL);
- g_object_unref (item->data);
+ ret &= gitg_commit_undo (view->priv->commit,
+ GITG_CHANGED_FILE (item->data),
+ NULL,
+ NULL);
}
- g_list_free (files);
+ g_list_free_full (files, (GDestroyNotify)g_object_unref);
}
else
{
- GitgChangedFile *file = g_object_ref(view->priv->current_file);
+ GitgChangedFile *file;
+ gchar *hunk;
+
+ file = g_object_ref (view->priv->current_file);
+
+ hunk = get_hunk_patch (view, &view->priv->context_iter);
- gchar *hunk = get_hunk_patch(view, &view->priv->context_iter);
ret = gitg_commit_undo (view->priv->commit,
view->priv->current_file,
hunk,
NULL);
- g_free(hunk);
+
+ g_free (hunk);
if (ret && view->priv->current_file == file)
{
- gitg_diff_view_remove_hunk (GITG_DIFF_VIEW(view->priv->changes_view),
+ gitg_diff_view_remove_hunk (GITG_DIFF_VIEW (view->priv->changes_view),
&view->priv->context_iter);
}
- g_object_unref(file);
+ g_object_unref (file);
}
if (!ret)
- show_error(view, _("Revert fail"));
+ {
+ show_error (view, _("Revert fail"));
+ }
}
static void
-on_revert_changes(GtkAction *action, GitgCommitView *view)
+on_revert_changes (GtkAction *action,
+ GitgCommitView *view)
{
- GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view))),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_YES_NO,
- "%s",
- _("Are you sure you want to revert these changes?"));
+ GtkWidget *dialog;
+ gint response;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ "%s",
+ _("Are you sure you want to revert these changes?"));
- gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s",
- _("Reverting changes is permanent and cannot be undone"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s",
+ _("Reverting changes is permanent and cannot be undone"));
- gint response = gtk_dialog_run(GTK_DIALOG(dialog));
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
if (response == GTK_RESPONSE_YES)
- do_revert_changes(view);
+ {
+ do_revert_changes (view);
+ }
- gtk_widget_destroy(dialog);
+ gtk_widget_destroy (dialog);
}
static void
-on_edit_file (GtkAction *action, GitgCommitView *view)
+on_edit_file (GtkAction *action,
+ GitgCommitView *view)
{
GList *files = NULL;
GList *item;
- get_selected_files (view->priv->tree_view_unstaged, &files, NULL, NULL, NULL);
+ get_selected_files (view->priv->tree_view_unstaged,
+ &files,
+ NULL,
+ NULL,
+ NULL);
for (item = files; item; item = g_list_next (item))
{
GitgChangedFile *file = item->data;
- if (gitg_changed_file_get_status (file) == GITG_CHANGED_FILE_STATUS_DELETED)
+ if (gitg_changed_file_get_status (file) ==
+ GITG_CHANGED_FILE_STATUS_DELETED)
{
- g_object_unref (file);
continue;
}
@@ -2395,10 +2871,9 @@ on_edit_file (GtkAction *action, GitgCommitView *view)
g_free (uri);
g_object_unref (location);
- g_object_unref (file);
}
- g_list_free (files);
+ g_list_free_full (files, (GDestroyNotify)g_object_unref);
}
static void
@@ -2408,7 +2883,11 @@ do_delete_file (GitgCommitView *view)
GList *item;
gboolean success = TRUE;
- get_selected_files (view->priv->tree_view_unstaged, &files, NULL, NULL, NULL);
+ get_selected_files (view->priv->tree_view_unstaged,
+ &files,
+ NULL,
+ NULL,
+ NULL);
for (item = files; item; item = g_list_next (item))
{
@@ -2418,10 +2897,9 @@ do_delete_file (GitgCommitView *view)
success &= g_file_delete (location, NULL, NULL);
g_object_unref (location);
- g_object_unref (file);
}
- g_list_free (files);
+ g_list_free_full (files, (GDestroyNotify)g_object_unref);
gitg_commit_refresh (view->priv->commit);
@@ -2439,6 +2917,7 @@ on_delete_file (GtkAction *action,
GtkWidget *dialog;
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
+
dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION,
@@ -2459,59 +2938,82 @@ on_delete_file (GtkAction *action,
}
static void
-on_ignore_file (GtkAction *action, GitgCommitView *view)
+on_ignore_file (GtkAction *action,
+ GitgCommitView *view)
{
GList *files = NULL;
GList *item;
- get_selected_files (view->priv->tree_view_unstaged, &files, NULL, NULL, NULL);
+ get_selected_files (view->priv->tree_view_unstaged,
+ &files,
+ NULL,
+ NULL,
+ NULL);
for (item = files; item; item = g_list_next (item))
{
- gitg_commit_add_ignore (view->priv->commit, GITG_CHANGED_FILE (item->data), NULL);
- g_object_unref (item->data);
+ gitg_commit_add_ignore (view->priv->commit,
+ GITG_CHANGED_FILE (item->data),
+ NULL);
}
- g_list_free (files);
+ g_list_free_full (files, (GDestroyNotify)g_object_unref);
}
static void
-on_unstage_changes(GtkAction *action, GitgCommitView *view)
+on_unstage_changes (GtkAction *action,
+ GitgCommitView *view)
{
if (view->priv->context_type == CONTEXT_TYPE_FILE)
{
GList *files = NULL;
GList *item;
- get_selected_files (view->priv->tree_view_staged, &files, NULL, NULL, NULL);
+ get_selected_files (view->priv->tree_view_staged,
+ &files,
+ NULL,
+ NULL,
+ NULL);
for (item = files; item; item = g_list_next (item))
{
- gitg_commit_unstage(view->priv->commit, GITG_CHANGED_FILE (item->data), NULL, NULL);
- g_object_unref (item->data);
+ gitg_commit_unstage (view->priv->commit,
+ GITG_CHANGED_FILE (item->data),
+ NULL,
+ NULL);
}
- g_list_free (files);
+ g_list_free_full (files, (GDestroyNotify)g_object_unref);
}
else
{
- handle_stage_unstage(view, &view->priv->context_iter);
+ handle_stage_unstage (view, &view->priv->context_iter);
}
}
static GtkWidget *
-create_context_menu_item (GitgCommitView *view, gchar const *action)
+create_context_menu_item (GitgCommitView *view,
+ gchar const *action)
{
- GtkAction *ac = gtk_action_group_get_action (view->priv->group_context, action);
+ GtkAction *ac;
+
+ ac = gtk_action_group_get_action (view->priv->group_context, action);
+
return gtk_action_create_menu_item (ac);
}
static void
-on_changes_view_popup_menu (GtkTextView *textview, GtkMenu *menu, GitgCommitView *view)
+on_changes_view_popup_menu (GtkTextView *textview,
+ GtkMenu *menu,
+ GitgCommitView *view)
{
gboolean is_hunk;
- get_info_at_pointer (view, &view->priv->context_iter, &is_hunk, NULL, NULL);
+ get_info_at_pointer (view,
+ &view->priv->context_iter,
+ &is_hunk,
+ NULL,
+ NULL);
if (!is_hunk)
{
@@ -2527,13 +3029,18 @@ on_changes_view_popup_menu (GtkTextView *textview, GtkMenu *menu, GitgCommitView
if (view->priv->current_changes & GITG_CHANGED_FILE_CHANGES_CACHED)
{
- GtkWidget *unstage = create_context_menu_item (view, "UnstageChangesAction");
+ GtkWidget *unstage;
+
+ unstage = create_context_menu_item (view, "UnstageChangesAction");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), unstage);
}
else
{
- GtkWidget *stage = create_context_menu_item (view, "StageChangesAction");
- GtkWidget *revert = create_context_menu_item (view, "RevertChangesAction");
+ GtkWidget *stage;
+ GtkWidget *revert;
+
+ stage = create_context_menu_item (view, "StageChangesAction");
+ revert = create_context_menu_item (view, "RevertChangesAction");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), stage);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), revert);
@@ -2541,19 +3048,25 @@ on_changes_view_popup_menu (GtkTextView *textview, GtkMenu *menu, GitgCommitView
}
static void
-on_check_button_amend_toggled (GtkToggleButton *button, GitgCommitView *view)
+on_check_button_amend_toggled (GtkToggleButton *button,
+ GitgCommitView *view)
{
- gboolean active = gtk_toggle_button_get_active (button);
- GtkTextBuffer *buffer = gtk_text_view_get_buffer (view->priv->comment_view);
+ gboolean active;
+ GtkTextBuffer *buffer;
GtkTextIter start;
GtkTextIter end;
+ active = gtk_toggle_button_get_active (button);
+ buffer = gtk_text_view_get_buffer (view->priv->comment_view);
+
gtk_text_buffer_get_bounds (buffer, &start, &end);
if (active && gtk_text_iter_compare (&start, &end) == 0)
{
// Get last commit message
- gchar *message = gitg_commit_amend_message (view->priv->commit);
+ gchar *message;
+
+ message = gitg_commit_amend_message (view->priv->commit);
if (message)
{
@@ -2571,9 +3084,11 @@ pixbuf_renderer_query_data_cb (GtkSourceGutterRenderer *renderer,
GtkSourceGutterRendererState state,
GitgCommitView *view)
{
- GitgDiffView *diff_view = GITG_DIFF_VIEW (view->priv->changes_view);
+ GitgDiffView *diff_view;
const gchar *stock_id;
+ diff_view = GITG_DIFF_VIEW (view->priv->changes_view);
+
switch (gitg_diff_view_get_line_type (diff_view, start))
{
case GITG_DIFF_LINE_TYPE_NONE:
diff --git a/gitg/gitg-commit-view.h b/gitg/gitg-commit-view.h
index b38521a..a4cde9d 100644
--- a/gitg/gitg-commit-view.h
+++ b/gitg/gitg-commit-view.h
@@ -40,18 +40,21 @@ typedef struct _GitgCommitView GitgCommitView;
typedef struct _GitgCommitViewClass GitgCommitViewClass;
typedef struct _GitgCommitViewPrivate GitgCommitViewPrivate;
-struct _GitgCommitView {
+struct _GitgCommitView
+{
GtkVPaned parent;
GitgCommitViewPrivate *priv;
};
-struct _GitgCommitViewClass {
+struct _GitgCommitViewClass
+{
GtkVPanedClass parent_class;
};
-GType gitg_commit_view_get_type (void) G_GNUC_CONST;
-void gitg_commit_view_set_repository(GitgCommitView *view, GitgRepository *repository);
+GType gitg_commit_view_get_type (void) G_GNUC_CONST;
+void gitg_commit_view_set_repository (GitgCommitView *view,
+ GitgRepository *repository);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]