[gitg] Code cleanup, lib fixes
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Code cleanup, lib fixes
- Date: Sun, 30 May 2010 21:37:48 +0000 (UTC)
commit 1cec32b01a40743efa12e4a2bad54d5ee892dd1f
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Sun May 30 23:37:21 2010 +0200
Code cleanup, lib fixes
Makefile.am | 15 +-
configure.ac | 1 +
data/Makefile.am | 7 -
gitg/Makefile.am | 9 +-
gitg/gitg-branch-actions.c | 306 ++++++------
gitg/gitg-diff-view.c | 232 +++++-----
gitg/gitg-revision-view.c | 846 ++++++++++++++++++++++------------
gitg/gitg-window.c | 1109 +++++++++++++++++++++++++++-----------------
libgitg-1.0.pc.in | 11 +
libgitg/Makefile.am | 8 +-
libgitg/gitg-color.h | 22 +-
libgitg/gitg-commit.c | 4 +-
libgitg/gitg-commit.h | 4 +-
libgitg/gitg-config.h | 2 +-
libgitg/gitg-convert.h | 6 +-
libgitg/gitg-hash.c | 54 ++-
libgitg/gitg-hash.h | 9 +
libgitg/gitg-lane.h | 11 +-
libgitg/gitg-lanes.c | 444 +++++++++++--------
libgitg/gitg-ref.c | 95 +++--
libgitg/gitg-ref.h | 49 +-
libgitg/gitg-repository.c | 713 ++++++++++++++--------------
libgitg/gitg-repository.h | 6 +-
libgitg/gitg-revision.c | 183 +++++---
libgitg/gitg-revision.h | 11 +-
libgitg/gitg-types.h | 34 --
26 files changed, 2411 insertions(+), 1780 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 962d582..c05690a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,9 @@
SUBDIRS = libgitg gitg data po
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libgitg-1.0.pc
+
DISTCLEANFILES = \
intltool-extract \
intltool-merge \
@@ -12,7 +15,8 @@ EXTRA_DIST = \
MAINTAINERS \
intltool-extract.in \
intltool-merge.in \
- intltool-update.in
+ intltool-update.in \
+ libgitg-1.0.pc.in
MAINTAINERCLEANFILES = \
aclocal.m4 \
@@ -34,13 +38,6 @@ MAINTAINERCLEANFILES = \
m4/lt~obsolete.m4 \
`find "$(srcdir)" -type f -name Makefile.in -print`
-bundle:
- rm -rf "$(bundledir)"; mkdir "$(bundledir)"; \
-rm -rf gitg-$(PACKAGE_VERSION).zip; \
-top_bundledir=`cd "$(bundledir)" && pwd`; \
-for i in $(SUBDIRS); do (cd $$i && $(MAKE) top_bundledir="$$top_bundledir" $(AM_MAKEFLAGS) bundle); done; \
-zip -r gitg-$(PACKAGE_VERSION).zip $(bundledir) >/dev/null;
-
dist-hook: generate-changelog
generate-changelog:
@@ -51,6 +48,6 @@ generate-changelog:
mv $(distdir)/c-l $(distdir)/ChangeLog; \
fi
-.PHONY: bundle generate-changelog
+.PHONY: generate-changelog
-include $(top_srcdir)/git.mk
diff --git a/configure.ac b/configure.ac
index 5eaa528..db0f0ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -102,6 +102,7 @@ AM_GCONF_SOURCE_2
AC_CONFIG_FILES([
Makefile
+libgitg-1.0.pc
libgitg/Makefile
gitg/Makefile
data/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index ddbdf1b..4faf5fb 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -29,13 +29,6 @@ else
install-data-local:
endif
-bundle: $(gitglangs_DATA) $(gitgstyles_DATA)
- for i in $(SUBDIRS); do (cd $$i && $(MAKE) top_bundledir="$(top_bundledir)" $(AM_MAKEFLAGS) bundle); done; \
-for i in $(gitglangs_DATA); do $(INSTALL) -D $$i $(top_bundledir)/resources/language-specs/$$i; done; \
-for i in $(gitgstyles_DATA); do $(INSTALL) -D $$i $(top_bundledir)/resources/styles/$$i; done;
-
-.PHONY: bundle
-
EXTRA_DIST = \
$(desktop_in_files) \
$(schemas_in_files) \
diff --git a/gitg/Makefile.am b/gitg/Makefile.am
index 83c1bdc..a9db2fe 100644
--- a/gitg/Makefile.am
+++ b/gitg/Makefile.am
@@ -75,13 +75,6 @@ ui_DATA = \
EXTRA_DIST = \
$(ui_DATA)
-bundle: $(bin_PROGRAMS) $(ui_DATA)
- for i in $(SUBDIRS); do (cd $$i && $(MAKE) top_bundledir="$(top_bundledir)" $(AM_MAKEFLAGS) bundle); done; \
-for i in $(bin_PROGRAMS); do $(INSTALL) -D $$i $(top_bundledir)/bin/$$i; done; \
-for i in $(ui_DATA); do $(INSTALL) -D $$i $(top_bundledir)/resources/ui/$$i; done;
-
-.PHONY: bundle
+-include $(top_srcdir)/git.mk
# vi:ts=8
-
--include $(top_srcdir)/git.mk
diff --git a/gitg/gitg-branch-actions.c b/gitg/gitg-branch-actions.c
index ef76cc0..2db8714 100644
--- a/gitg/gitg-branch-actions.c
+++ b/gitg/gitg-branch-actions.c
@@ -33,7 +33,7 @@ typedef enum
GITG_PROGRESS_CANCELLED
} GitgProgress;
-typedef void (*ProgressCallback)(GitgWindow *window, GitgProgress progress, gpointer data);
+typedef void (*ProgressCallback) (GitgWindow *window, GitgProgress progress, gpointer data);
typedef struct
{
@@ -64,15 +64,15 @@ free_progress_info (ProgressInfo *info)
}
static gchar const **
-parse_valist(va_list ap)
+parse_valist (va_list ap)
{
gchar const *a;
gchar const **ret = NULL;
guint num = 0;
- while ((a = va_arg(ap, gchar const *)) != NULL)
+ while ( (a = va_arg (ap, gchar const *)) != NULL)
{
- ret = g_realloc(ret, sizeof(gchar const *) * (++num + 1));
+ ret = g_realloc (ret, sizeof (gchar const *) * (++num + 1));
ret[num - 1] = a;
}
@@ -165,7 +165,7 @@ run_progress (GitgWindow *window,
"%s",
message);
- gtk_window_set_title (GTK_WINDOW (dlg), _("gitg"));
+ gtk_window_set_title (GTK_WINDOW (dlg), _ ("gitg"));
// Add progress bar
GtkWidget *area = gtk_dialog_get_content_area (GTK_DIALOG (dlg));
@@ -218,7 +218,7 @@ message_dialog (GitgWindow *window,
g_free (prim);
- gtk_window_set_title (GTK_WINDOW (dlg), _("gitg"));
+ gtk_window_set_title (GTK_WINDOW (dlg), _ ("gitg"));
if (secondary)
{
@@ -232,8 +232,8 @@ message_dialog (GitgWindow *window,
button = gtk_button_new_from_stock (accept ? GTK_STOCK_CANCEL : GTK_STOCK_OK);
gtk_widget_show (button);
- gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
- button,
+ gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
+ button,
accept ? GTK_RESPONSE_CANCEL : GTK_RESPONSE_ACCEPT);
if (accept)
@@ -241,13 +241,13 @@ message_dialog (GitgWindow *window,
button = gtk_button_new_with_label (accept);
gtk_widget_show (button);
- GtkWidget *image = gtk_image_new_from_stock (GTK_STOCK_OK,
+ GtkWidget *image = gtk_image_new_from_stock (GTK_STOCK_OK,
GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image);
gtk_button_set_image (GTK_BUTTON (button), image);
- gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
- button,
+ gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
+ button,
GTK_RESPONSE_ACCEPT);
}
@@ -268,18 +268,18 @@ remove_local_branch (GitgWindow *window,
{
gint ret = message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Branch <%s> could not be removed"),
- _("This usually means that the branch is not fully merged in HEAD. Do you want to forcefully remove the branch?"),
- _("Force remove"),
+ _ ("Branch <%s> could not be removed"),
+ _ ("This usually means that the branch is not fully merged in HEAD. Do you want to forcefully remove the branch?"),
+ _ ("Force remove"),
name);
if (ret == GTK_RESPONSE_ACCEPT)
{
if (!gitg_repository_commandv (repository, NULL, "branch", "-D", name, NULL))
{
- message_dialog (window,
+ message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Branch <%s> could not be forcefully removed"),
+ _ ("Branch <%s> could not be forcefully removed"),
NULL,
NULL,
name);
@@ -310,9 +310,9 @@ on_remove_remote_result (GitgWindow *window, GitgProgress progress, gpointer dat
if (progress == GITG_PROGRESS_ERROR)
{
- message_dialog (window,
+ message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to remove remote branch <%s>."),
+ _ ("Failed to remove remote branch <%s>."),
NULL,
NULL,
gitg_ref_get_shortname (ref));
@@ -333,9 +333,9 @@ remove_remote_branch (GitgWindow *window,
gint r = message_dialog (window,
GTK_MESSAGE_QUESTION,
- _("Are you sure you want to remove the remote branch <%s>?"),
- _("This permanently removes the remote branch."),
- _("Remove remote branch"),
+ _ ("Are you sure you want to remove the remote branch <%s>?"),
+ _ ("This permanently removes the remote branch."),
+ _ ("Remove remote branch"),
name);
if (r != GTK_RESPONSE_ACCEPT)
@@ -349,9 +349,9 @@ remove_remote_branch (GitgWindow *window,
GitgRunner *ret;
gchar *message = g_strdup_printf ("Removing remote branch `%s'", name);
- ret = run_progress (window,
- _("Remove branch"),
- message,
+ ret = run_progress (window,
+ _ ("Remove branch"),
+ message,
on_remove_remote_result,
gitg_ref_copy (ref),
"push",
@@ -368,7 +368,7 @@ get_stash_refspec (GitgRepository *repository, GitgRef *stash)
{
gchar **out;
- out = gitg_repository_command_with_outputv (repository,
+ out = gitg_repository_command_with_outputv (repository,
NULL,
"log",
"--no-color",
@@ -385,7 +385,7 @@ get_stash_refspec (GitgRepository *repository, GitgRef *stash)
{
if (g_str_has_prefix (*ptr, sha1))
{
- gchar *start = *ptr + HASH_SHA_SIZE + 1;
+ gchar *start = *ptr + GITG_HASH_SHA_SIZE + 1;
gchar *end = strchr (start, ':');
if (end)
@@ -408,9 +408,9 @@ remove_stash (GitgWindow *window, GitgRef *ref)
{
gint r = message_dialog (window,
GTK_MESSAGE_QUESTION,
- _("Are you sure you want to remove this stash item?"),
- _("This permanently removes the stash item"),
- _("Remove stash"));
+ _ ("Are you sure you want to remove this stash item?"),
+ _ ("This permanently removes the stash item"),
+ _ ("Remove stash"));
if (r != GTK_RESPONSE_ACCEPT)
{
@@ -436,8 +436,8 @@ remove_stash (GitgWindow *window, GitgRef *ref)
{
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to remove stash"),
- _("The stash item could not be successfully removed"),
+ _ ("Failed to remove stash"),
+ _ ("The stash item could not be successfully removed"),
NULL);
}
else
@@ -468,13 +468,13 @@ static GitgRunner *
remove_tag (GitgWindow *window, GitgRef *ref)
{
gchar const *name = gitg_ref_get_shortname (ref);
- gchar *message = g_strdup_printf (_("Are you sure you want to remove the tag <%s>?"),
+ gchar *message = g_strdup_printf (_ ("Are you sure you want to remove the tag <%s>?"),
name);
gint r = message_dialog (window,
GTK_MESSAGE_QUESTION,
- _("Remove tag"),
+ _ ("Remove tag"),
message,
- _("Remove tag"));
+ _ ("Remove tag"));
g_free (message);
if (r != GTK_RESPONSE_ACCEPT)
@@ -491,11 +491,11 @@ remove_tag (GitgWindow *window, GitgRef *ref)
name,
NULL))
{
- message = g_strdup_printf (_("The tag <%s> could not be successfully removed"),
+ message = g_strdup_printf (_ ("The tag <%s> could not be successfully removed"),
name);
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to remove tag"),
+ _ ("Failed to remove tag"),
message,
NULL);
g_free (message);
@@ -508,7 +508,7 @@ remove_tag (GitgWindow *window, GitgRef *ref)
}
}
-GitgRunner *
+GitgRunner *
gitg_branch_actions_remove (GitgWindow *window,
GitgRef *ref)
{
@@ -552,18 +552,18 @@ rename_branch (GitgWindow *window,
{
gint ret = message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Branch <%s> could not be renamed to <%s>"),
- _("This usually means that a branch with that name already exists. Do you want to overwrite the branch?"),
- _("Force rename"),
+ _ ("Branch <%s> could not be renamed to <%s>"),
+ _ ("This usually means that a branch with that name already exists. Do you want to overwrite the branch?"),
+ _ ("Force rename"),
oldname, newname);
if (ret == GTK_RESPONSE_ACCEPT)
{
if (!gitg_repository_commandv (repository, NULL, "branch", "-M", oldname, newname, NULL))
{
- message_dialog (window,
+ message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Branch <%s> could not be forcefully renamed"),
+ _ ("Branch <%s> could not be forcefully renamed"),
NULL,
NULL,
oldname);
@@ -603,7 +603,7 @@ rename_dialog (GitgWindow *window, const gchar *oldname)
gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK);
GtkWidget *box = gtk_hbox_new (FALSE, 6);
- GtkWidget *label = gtk_label_new (_("Name:"));
+ GtkWidget *label = gtk_label_new (_ ("Name:"));
GtkWidget *entry = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (entry), oldname);
gtk_entry_set_width_chars (GTK_ENTRY (entry), 25);
@@ -630,7 +630,7 @@ rename_dialog (GitgWindow *window, const gchar *oldname)
return newname;
}
-GitgRunner *
+GitgRunner *
gitg_branch_actions_rename (GitgWindow *window,
GitgRef *ref)
{
@@ -681,11 +681,11 @@ update_buffer (GitgRunner *runner, gchar **lines, GString *buffer)
static gboolean
no_changes (GitgRepository *repository)
{
- return gitg_repository_commandv (repository, NULL,
+ return gitg_repository_commandv (repository, NULL,
"update-index", "--refresh", NULL) &&
- gitg_repository_commandv (repository, NULL,
+ gitg_repository_commandv (repository, NULL,
"diff-files", "--quiet", NULL) &&
- gitg_repository_commandv (repository, NULL,
+ gitg_repository_commandv (repository, NULL,
"diff-index", "--cached", "--quiet", "HEAD", "--", NULL);
}
@@ -710,18 +710,18 @@ stash_changes_real (GitgWindow *window, gchar **ref, gboolean storeref)
if (storeref)
{
- secondary = _("Do you want to temporarily stash these changes?");
+ secondary = _ ("Do you want to temporarily stash these changes?");
}
else
{
- secondary = _("Do you want to stash and reapply these changes?");
+ secondary = _ ("Do you want to stash and reapply these changes?");
}
gint r = message_dialog (window,
GTK_MESSAGE_QUESTION,
- _("You have uncommited changes in your current working tree"),
+ _ ("You have uncommited changes in your current working tree"),
secondary,
- _("Stash changes"));
+ _ ("Stash changes"));
if (r != GTK_RESPONSE_ACCEPT)
{
@@ -730,7 +730,7 @@ stash_changes_real (GitgWindow *window, gchar **ref, gboolean storeref)
}
gitg_repository_run_commandv (repository, runner, NULL,
- "log", "--no-color", "--abbrev-commit",
+ "log", "--no-color", "--abbrev-commit",
"--pretty=oneline", "-n", "1", "HEAD", NULL);
GitgRef *working = gitg_repository_get_current_working_ref (repository);
@@ -741,7 +741,7 @@ stash_changes_real (GitgWindow *window, gchar **ref, gboolean storeref)
}
else
{
- msg = g_strconcat ("(no branch): ", buffer->str, NULL);
+ msg = g_strconcat (" (no branch): ", buffer->str, NULL);
}
// Create tree object of the current index
@@ -760,7 +760,7 @@ stash_changes_real (GitgWindow *window, gchar **ref, gboolean storeref)
head = gitg_repository_parse_head (repository);
gchar *idxmsg = g_strconcat ("index on ", msg, NULL);
- gitg_repository_run_command_with_inputv (repository, runner, idxmsg, NULL,
+ gitg_repository_run_command_with_inputv (repository, runner, idxmsg, NULL,
"commit-tree", tree, "-p", head, NULL);
g_free (idxmsg);
@@ -814,11 +814,11 @@ stash_changes_real (GitgWindow *window, gchar **ref, gboolean storeref)
gboolean writestash;
- writestash = gitg_repository_run_commandv (repository, runner, NULL,
+ writestash = gitg_repository_run_commandv (repository, runner, NULL,
"read-tree", "-m", tree, NULL) &&
- gitg_repository_run_commandv (repository, runner, NULL,
+ gitg_repository_run_commandv (repository, runner, NULL,
"add", "-u", NULL) &&
- gitg_repository_run_commandv (repository, runner, NULL,
+ gitg_repository_run_commandv (repository, runner, NULL,
"write-tree", NULL);
g_file_delete (customindex, NULL, NULL);
@@ -883,7 +883,7 @@ stash_changes_real (GitgWindow *window, gchar **ref, gboolean storeref)
g_free (path);
gitg_repository_run_commandv (repository, runner, NULL,
- "update-ref", "-m", reason,
+ "update-ref", "-m", reason,
"refs/stash", rref, NULL);
g_free (rref);
@@ -902,9 +902,9 @@ cleanup:
if (showerror)
{
- message_dialog (window,
+ message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to save current index state"),
+ _ ("Failed to save current index state"),
NULL,
NULL);
}
@@ -958,7 +958,7 @@ checkout_local_branch (GitgWindow *window,
{
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to checkout local branch <%s>"),
+ _ ("Failed to checkout local branch <%s>"),
NULL,
NULL,
name);
@@ -985,10 +985,10 @@ checkout_remote_branch (GitgWindow *window,
gchar const *local = gitg_ref_get_local_name (ref);
gboolean ret;
- if (!gitg_repository_commandv (repository,
- NULL,
- "checkout",
- "--track",
+ if (!gitg_repository_commandv (repository,
+ NULL,
+ "checkout",
+ "--track",
"-b",
local,
name,
@@ -996,7 +996,7 @@ checkout_remote_branch (GitgWindow *window,
{
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to checkout remote branch <%s> to local branch <%s>"),
+ _ ("Failed to checkout remote branch <%s> to local branch <%s>"),
NULL,
NULL,
name,
@@ -1025,9 +1025,9 @@ checkout_tag (GitgWindow *window,
gchar const *name = gitg_ref_get_shortname (ref);
gboolean ret;
- if (!gitg_repository_commandv (repository,
- NULL,
- "checkout",
+ if (!gitg_repository_commandv (repository,
+ NULL,
+ "checkout",
"-b",
name,
name,
@@ -1035,7 +1035,7 @@ checkout_tag (GitgWindow *window,
{
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to checkout tag <%s> to local branch <%s>"),
+ _ ("Failed to checkout tag <%s> to local branch <%s>"),
NULL,
NULL,
name,
@@ -1126,11 +1126,11 @@ on_merge_rebase_result (GitgWindow *window,
if (info->rebase)
{
- message = _("Failed to rebase %s branch <%s> onto %s branch <%s>");
+ message = _ ("Failed to rebase %s branch <%s> onto %s branch <%s>");
}
else
{
- message = _("Failed to merge %s branch <%s> with %s branch <%s>");
+ message = _ ("Failed to merge %s branch <%s> with %s branch <%s>");
}
message_dialog (window,
@@ -1138,9 +1138,9 @@ on_merge_rebase_result (GitgWindow *window,
message,
NULL,
NULL,
- gitg_ref_get_ref_type (info->source) == GITG_REF_TYPE_BRANCH ? _("local") : _("remote"),
+ gitg_ref_get_ref_type (info->source) == GITG_REF_TYPE_BRANCH ? _ ("local") : _ ("remote"),
gitg_ref_get_shortname (info->source),
- gitg_ref_get_ref_type (info->dest) == GITG_REF_TYPE_BRANCH ? _("local") : _("remote"),
+ gitg_ref_get_ref_type (info->dest) == GITG_REF_TYPE_BRANCH ? _ ("local") : _ ("remote"),
gitg_ref_get_shortname (info->dest));
}
else if (progress == GITG_PROGRESS_SUCCESS)
@@ -1154,15 +1154,15 @@ on_merge_rebase_result (GitgWindow *window,
if (info->stashcommit)
{
- gitg_repository_commandv (repository, NULL,
- "update-ref", "-m", "gitg autosave stash",
+ gitg_repository_commandv (repository, NULL,
+ "update-ref", "-m", "gitg autosave stash",
"refs/stash", info->stashcommit, NULL);
- message = _("The stashed changes have been stored to be reapplied manually");
+ message = _ ("The stashed changes have been stored to be reapplied manually");
}
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to checkout previously checked out branch"),
+ _ ("Failed to checkout previously checked out branch"),
message,
NULL);
}
@@ -1177,14 +1177,14 @@ on_merge_rebase_result (GitgWindow *window,
info->stashcommit,
NULL))
{
- gitg_repository_commandv (repository, NULL,
- "update-ref", "-m", "gitg autosave stash",
+ gitg_repository_commandv (repository, NULL,
+ "update-ref", "-m", "gitg autosave stash",
"refs/stash", info->stashcommit, NULL);
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to reapply stash correctly"),
- _("There might be unresolved conflicts in the working tree or index which you need to resolve manually"),
+ _ ("Failed to reapply stash correctly"),
+ _ ("There might be unresolved conflicts in the working tree or index which you need to resolve manually"),
NULL);
}
}
@@ -1205,17 +1205,17 @@ gitg_branch_actions_merge (GitgWindow *window,
g_return_val_if_fail (source != NULL, NULL);
g_return_val_if_fail (gitg_ref_get_ref_type (dest) != GITG_REF_TYPE_REMOTE, NULL);
- gchar *message = g_strdup_printf (_("Are you sure you want to merge %s branch <%s> onto %s branch <%s>?"),
- gitg_ref_get_ref_type (source) == GITG_REF_TYPE_BRANCH ? _("local") : _("remote"),
+ gchar *message = g_strdup_printf (_ ("Are you sure you want to merge %s branch <%s> onto %s branch <%s>?"),
+ gitg_ref_get_ref_type (source) == GITG_REF_TYPE_BRANCH ? _ ("local") : _ ("remote"),
gitg_ref_get_shortname (source),
- gitg_ref_get_ref_type (dest) == GITG_REF_TYPE_BRANCH ? _("local") : _("remote"),
+ gitg_ref_get_ref_type (dest) == GITG_REF_TYPE_BRANCH ? _ ("local") : _ ("remote"),
gitg_ref_get_shortname (dest));
if (message_dialog (window,
GTK_MESSAGE_QUESTION,
- _("Merge"),
+ _ ("Merge"),
message,
- _("Merge")) != GTK_RESPONSE_ACCEPT)
+ _ ("Merge")) != GTK_RESPONSE_ACCEPT)
{
g_free (message);
return NULL;
@@ -1239,17 +1239,17 @@ gitg_branch_actions_merge (GitgWindow *window,
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to checkout local branch <%s>"),
- _("The branch on which to merge could not be checked out"),
+ _ ("Failed to checkout local branch <%s>"),
+ _ ("The branch on which to merge could not be checked out"),
NULL,
gitg_ref_get_shortname (dest));
return NULL;
}
- message = g_strdup_printf (_("Merging %s branch <%s> onto %s branch <%s>"),
- gitg_ref_get_ref_type (source) == GITG_REF_TYPE_BRANCH ? _("local") : _("remote"),
+ message = g_strdup_printf (_ ("Merging %s branch <%s> onto %s branch <%s>"),
+ gitg_ref_get_ref_type (source) == GITG_REF_TYPE_BRANCH ? _ ("local") : _ ("remote"),
gitg_ref_get_shortname (source),
- gitg_ref_get_ref_type (dest) == GITG_REF_TYPE_BRANCH ? _("local") : _("remote"),
+ gitg_ref_get_ref_type (dest) == GITG_REF_TYPE_BRANCH ? _ ("local") : _ ("remote"),
gitg_ref_get_shortname (dest));
GitgRunner *ret;
@@ -1258,9 +1258,9 @@ gitg_branch_actions_merge (GitgWindow *window,
info->head = gitg_ref_copy (head);
info->rebase = FALSE;
- ret = run_progress (window,
- _("Merge"),
- message,
+ ret = run_progress (window,
+ _ ("Merge"),
+ message,
on_merge_rebase_result,
info,
"merge",
@@ -1282,17 +1282,17 @@ gitg_branch_actions_rebase (GitgWindow *window,
g_return_val_if_fail (source != NULL, NULL);
g_return_val_if_fail (gitg_ref_get_ref_type (source) != GITG_REF_TYPE_REMOTE, NULL);
- gchar *message = g_strdup_printf (_("Are you sure you want to rebase %s branch <%s> onto %s branch <%s>?"),
- gitg_ref_get_ref_type (source) == GITG_REF_TYPE_BRANCH ? _("local") : _("remote"),
+ gchar *message = g_strdup_printf (_ ("Are you sure you want to rebase %s branch <%s> onto %s branch <%s>?"),
+ gitg_ref_get_ref_type (source) == GITG_REF_TYPE_BRANCH ? _ ("local") : _ ("remote"),
gitg_ref_get_shortname (source),
- gitg_ref_get_ref_type (dest) == GITG_REF_TYPE_BRANCH ? _("local") : _("remote"),
+ gitg_ref_get_ref_type (dest) == GITG_REF_TYPE_BRANCH ? _ ("local") : _ ("remote"),
gitg_ref_get_shortname (dest));
if (message_dialog (window,
GTK_MESSAGE_QUESTION,
- _("Rebase"),
+ _ ("Rebase"),
message,
- _("Rebase")) != GTK_RESPONSE_ACCEPT)
+ _ ("Rebase")) != GTK_RESPONSE_ACCEPT)
{
g_free (message);
return NULL;
@@ -1306,7 +1306,7 @@ gitg_branch_actions_rebase (GitgWindow *window,
{
// Check if destination is current HEAD
gchar *head = gitg_repository_parse_head (repository);
- Hash hash;
+ GitgHash hash;
gitg_hash_sha1_to_hash (head, hash);
g_free (head);
@@ -1315,8 +1315,8 @@ gitg_branch_actions_rebase (GitgWindow *window,
{
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Unable to rebase"),
- _("There are still uncommitted changes in your working tree and you are trying to rebase a branch onto the currently checked out branch. Either remove, stash or commit your changes first and try again"),
+ _ ("Unable to rebase"),
+ _ ("There are still uncommitted changes in your working tree and you are trying to rebase a branch onto the currently checked out branch. Either remove, stash or commit your changes first and try again"),
NULL);
return NULL;
}
@@ -1329,10 +1329,10 @@ gitg_branch_actions_rebase (GitgWindow *window,
gchar *merge_head = gitg_hash_hash_to_sha1_new (gitg_ref_get_hash (dest));
- message = g_strdup_printf (_("Rebasing %s branch <%s> onto %s branch <%s>"),
- gitg_ref_get_ref_type (source) == GITG_REF_TYPE_BRANCH ? _("local") : _("remote"),
+ message = g_strdup_printf (_ ("Rebasing %s branch <%s> onto %s branch <%s>"),
+ gitg_ref_get_ref_type (source) == GITG_REF_TYPE_BRANCH ? _ ("local") : _ ("remote"),
gitg_ref_get_shortname (source),
- gitg_ref_get_ref_type (dest) == GITG_REF_TYPE_BRANCH ? _("local") : _("remote"),
+ gitg_ref_get_ref_type (dest) == GITG_REF_TYPE_BRANCH ? _ ("local") : _ ("remote"),
gitg_ref_get_shortname (dest));
GitgRunner *ret;
@@ -1341,9 +1341,9 @@ gitg_branch_actions_rebase (GitgWindow *window,
info->head = gitg_ref_copy (gitg_repository_get_current_working_ref (repository));
info->rebase = TRUE;
- ret = run_progress (window,
- _("Rebase"),
- message,
+ ret = run_progress (window,
+ _ ("Rebase"),
+ message,
on_merge_rebase_result,
info,
"rebase",
@@ -1368,8 +1368,8 @@ on_push_result (GitgWindow *window,
{
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to push local branch <%s> to remote <%s>"),
- _("This usually means that the remote branch could not be fast-forwarded. Try fetching the latest changes."),
+ _ ("Failed to push local branch <%s> to remote <%s>"),
+ _ ("This usually means that the remote branch could not be fast-forwarded. Try fetching the latest changes."),
NULL,
gitg_ref_get_shortname (info->source),
gitg_ref_get_shortname (info->dest));
@@ -1393,15 +1393,15 @@ gitg_branch_actions_push (GitgWindow *window,
g_return_val_if_fail (gitg_ref_get_ref_type (source) == GITG_REF_TYPE_BRANCH, NULL);
g_return_val_if_fail (gitg_ref_get_ref_type (dest) == GITG_REF_TYPE_REMOTE, NULL);
- gchar *message = g_strdup_printf (_("Are you sure you want to push <%s> to <%s>?"),
+ gchar *message = g_strdup_printf (_ ("Are you sure you want to push <%s> to <%s>?"),
gitg_ref_get_shortname (source),
gitg_ref_get_shortname (dest));
if (message_dialog (window,
GTK_MESSAGE_QUESTION,
- _("Push"),
+ _ ("Push"),
message,
- _("Push")) != GTK_RESPONSE_ACCEPT)
+ _ ("Push")) != GTK_RESPONSE_ACCEPT)
{
g_free (message);
return NULL;
@@ -1414,16 +1414,16 @@ gitg_branch_actions_push (GitgWindow *window,
gchar const *name = gitg_ref_get_shortname (source);
gchar *spec = g_strconcat (name, ":", local, NULL);
- message = g_strdup_printf (_("Pushing local branch <%s> to remote branch <%s>"),
+ message = g_strdup_printf (_ ("Pushing local branch <%s> to remote branch <%s>"),
gitg_ref_get_shortname (source),
gitg_ref_get_shortname (dest));
GitgRunner *ret;
RefInfo *info = ref_info_new (source, dest);
- ret = run_progress (window,
- _("Push"),
- message,
+ ret = run_progress (window,
+ _ ("Push"),
+ message,
on_push_result,
info,
"push",
@@ -1448,15 +1448,15 @@ gitg_branch_actions_push_remote (GitgWindow *window,
g_return_val_if_fail (source != NULL, NULL);
g_return_val_if_fail (gitg_ref_get_ref_type (source) == GITG_REF_TYPE_BRANCH, NULL);
- gchar *message = g_strdup_printf (_("Are you sure you want to push <%s> to remote <%s/%s>?"),
+ gchar *message = g_strdup_printf (_ ("Are you sure you want to push <%s> to remote <%s/%s>?"),
gitg_ref_get_shortname (source),
remote, branch);
if (message_dialog (window,
GTK_MESSAGE_QUESTION,
- _("Push"),
+ _ ("Push"),
message,
- _("Push")) != GTK_RESPONSE_ACCEPT)
+ _ ("Push")) != GTK_RESPONSE_ACCEPT)
{
g_free (message);
return NULL;
@@ -1466,7 +1466,7 @@ gitg_branch_actions_push_remote (GitgWindow *window,
gchar const *name = gitg_ref_get_shortname (source);
gchar *spec = g_strconcat (name, ":", branch, NULL);
- message = g_strdup_printf (_("Pushing local branch <%s> to remote branch <%s/%s>"),
+ message = g_strdup_printf (_ ("Pushing local branch <%s> to remote branch <%s/%s>"),
gitg_ref_get_shortname (source),
remote, branch);
@@ -1478,9 +1478,9 @@ gitg_branch_actions_push_remote (GitgWindow *window,
RefInfo *info = ref_info_new (source, rmref);
gitg_ref_free (rmref);
- ret = run_progress (window,
- _("Push"),
- message,
+ ret = run_progress (window,
+ _ ("Push"),
+ message,
on_push_result,
info,
"push",
@@ -1503,14 +1503,14 @@ gitg_branch_actions_apply_stash (GitgWindow *window,
g_return_val_if_fail (gitg_ref_get_ref_type (stash) == GITG_REF_TYPE_STASH, FALSE);
g_return_val_if_fail (gitg_ref_get_ref_type (branch) == GITG_REF_TYPE_BRANCH, FALSE);
- gchar *message = g_strdup_printf (_("Are you sure you want to apply the stash item to local branch <%s>?"),
+ gchar *message = g_strdup_printf (_ ("Are you sure you want to apply the stash item to local branch <%s>?"),
gitg_ref_get_shortname (branch));
if (message_dialog (window,
GTK_MESSAGE_QUESTION,
- _("Apply stash"),
+ _ ("Apply stash"),
message,
- _("Apply stash")) != GTK_RESPONSE_ACCEPT)
+ _ ("Apply stash")) != GTK_RESPONSE_ACCEPT)
{
g_free (message);
return FALSE;
@@ -1530,7 +1530,7 @@ gitg_branch_actions_apply_stash (GitgWindow *window,
{
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to checkout local branch <%s>"),
+ _ ("Failed to checkout local branch <%s>"),
NULL,
NULL,
gitg_ref_get_shortname (branch));
@@ -1549,11 +1549,11 @@ gitg_branch_actions_apply_stash (GitgWindow *window,
sha1,
NULL))
{
- message = g_strdup_printf (_("The stash could not be applied to local branch <%s>"),
+ message = g_strdup_printf (_ ("The stash could not be applied to local branch <%s>"),
gitg_ref_get_shortname (branch));
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to apply stash"),
+ _ ("Failed to apply stash"),
message,
NULL);
g_free (message);
@@ -1573,7 +1573,7 @@ gitg_branch_actions_apply_stash (GitgWindow *window,
return ret;
}
-gboolean
+gboolean
gitg_branch_actions_tag (GitgWindow *window, gchar const *sha1, gchar const *name, gchar const *message, gboolean sign)
{
g_return_val_if_fail (GITG_IS_WINDOW (window), FALSE);
@@ -1613,16 +1613,16 @@ gitg_branch_actions_tag (GitgWindow *window, gchar const *sha1, gchar const *nam
if (sign)
{
- secondary = _("The tag object could not be successfully created. Please make sure you have a GPG key and the key is unlocked");
+ secondary = _ ("The tag object could not be successfully created. Please make sure you have a GPG key and the key is unlocked");
}
else
{
- secondary = _("The tag object could not be successfully created");
+ secondary = _ ("The tag object could not be successfully created");
}
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to create tag"),
+ _ ("Failed to create tag"),
secondary,
NULL);
return FALSE;
@@ -1677,7 +1677,7 @@ on_cherry_pick_result (GitgWindow *window,
{
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to cherry-pick on <%s>"),
+ _ ("Failed to cherry-pick on <%s>"),
NULL,
NULL,
gitg_ref_get_shortname (info->dest));
@@ -1693,16 +1693,16 @@ on_cherry_pick_result (GitgWindow *window,
if (info->stashcommit)
{
- gitg_repository_commandv (repository, NULL,
+ gitg_repository_commandv (repository, NULL,
"update-ref", "-m", "gitg autosave stash",
"refs/stash", info->stashcommit, NULL);
-
- message = _("The stashed changes have been stored to be reapplied manually");
+
+ message = _ ("The stashed changes have been stored to be reapplied manually");
}
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to checkout previously checked out branch"),
+ _ ("Failed to checkout previously checked out branch"),
message,
NULL);
}
@@ -1717,14 +1717,14 @@ on_cherry_pick_result (GitgWindow *window,
info->stashcommit,
NULL))
{
- gitg_repository_commandv (repository, NULL,
+ gitg_repository_commandv (repository, NULL,
"update-ref", "-m", "gitg autosave stash",
"refs/stash", info->stashcommit, NULL);
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to reapply stash correctly"),
- _("There might be unresolved conflicts in the working tree or index which you need to resolve manually"),
+ _ ("Failed to reapply stash correctly"),
+ _ ("There might be unresolved conflicts in the working tree or index which you need to resolve manually"),
NULL);
}
}
@@ -1744,14 +1744,14 @@ gitg_branch_actions_cherry_pick (GitgWindow *window,
g_return_val_if_fail (revision != NULL, NULL);
g_return_val_if_fail (dest != NULL, NULL);
- gchar *message = g_strdup_printf (_("Are you sure you want to cherry-pick that revision on <%s>?"),
+ gchar *message = g_strdup_printf (_ ("Are you sure you want to cherry-pick that revision on <%s>?"),
gitg_ref_get_shortname (dest));
if (message_dialog (window,
GTK_MESSAGE_QUESTION,
- _("Cherry-pick"),
+ _ ("Cherry-pick"),
message,
- _("Cherry-pick")) != GTK_RESPONSE_ACCEPT)
+ _ ("Cherry-pick")) != GTK_RESPONSE_ACCEPT)
{
g_free (message);
return NULL;
@@ -1778,15 +1778,15 @@ gitg_branch_actions_cherry_pick (GitgWindow *window,
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to checkout local branch <%s>"),
- _("The branch on which to cherry-pick could not be checked out"),
+ _ ("Failed to checkout local branch <%s>"),
+ _ ("The branch on which to cherry-pick could not be checked out"),
NULL,
gitg_ref_get_shortname (dest));
return NULL;
}
- message = g_strdup_printf (_("Cherry-picking on <%s>"),
+ message = g_strdup_printf (_ ("Cherry-picking on <%s>"),
gitg_ref_get_shortname (dest));
GitgRunner *ret;
@@ -1799,7 +1799,7 @@ gitg_branch_actions_cherry_pick (GitgWindow *window,
gchar *sha1 = gitg_revision_get_sha1 (revision);
ret = run_progress (window,
- _("Cherry-pick"),
+ _ ("Cherry-pick"),
message,
on_cherry_pick_result,
info,
@@ -1854,7 +1854,7 @@ on_format_patch_result (GitgWindow *window,
{
message_dialog (window,
GTK_MESSAGE_ERROR,
- _("Failed to generate format-patch"),
+ _ ("Failed to generate format-patch"),
NULL,
NULL,
NULL);
@@ -1902,7 +1902,7 @@ gitg_branch_actions_format_patch (GitgWindow *window,
gchar *sha1 = gitg_revision_get_sha1 (revision);
gchar *message;
- message = g_strdup_printf (_("Generating format-patch for <%s>"),
+ message = g_strdup_printf (_ ("Generating format-patch for <%s>"),
gitg_revision_get_subject (revision));
FormatPatchInfo *info = format_patch_info_new (revision,
@@ -1910,7 +1910,7 @@ gitg_branch_actions_format_patch (GitgWindow *window,
G_OUTPUT_STREAM (stream));
ret = run_progress (window,
- _("Format patch"),
+ _ ("Format patch"),
message,
on_format_patch_result,
info,
diff --git a/gitg/gitg-diff-view.c b/gitg/gitg-diff-view.c
index b2ed007..5f11b57 100644
--- a/gitg/gitg-diff-view.c
+++ b/gitg/gitg-diff-view.c
@@ -20,8 +20,6 @@
* Boston, MA 02111-1307, USA.
*/
-#include <libgitg/gitg-types.h>
-
#include "gitg-diff-view.h"
#include "gitg-diff-line-renderer.h"
#include "gitg-utils.h"
@@ -29,7 +27,7 @@
#include <string.h>
#include <stdlib.h>
-#define GITG_DIFF_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_DIFF_VIEW, GitgDiffViewPrivate))
+#define GITG_DIFF_VIEW_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_DIFF_VIEW, GitgDiffViewPrivate))
#ifndef MAX
#define MAX(a, b) (a > b ? a : b)
@@ -41,8 +39,8 @@
#define IDLE_SCAN_COUNT 30
-#define GITG_DIFF_ITER_GET_VIEW(iter) ((GitgDiffView *)((iter)->userdata))
-#define GITG_DIFF_ITER_GET_REGION(iter) ((Region *)((iter)->userdata2))
+#define GITG_DIFF_ITER_GET_VIEW(iter) ((GitgDiffView *) ((iter)->userdata))
+#define GITG_DIFF_ITER_GET_REGION(iter) ((Region *) ((iter)->userdata2))
#define GITG_DIFF_ITER_SET_REGION(iter, region) ((iter)->userdata2 = region)
#define GITG_DIFF_ITER_SET_VIEW(iter, view) ((iter)->userdata = view)
@@ -106,11 +104,11 @@ typedef struct
{
Region region;
- gchar index_from[HASH_SHA_SIZE + 1];
- gchar index_to[HASH_SHA_SIZE + 1];
+ gchar index_from[GITG_HASH_SHA_SIZE + 1];
+ gchar index_to[GITG_HASH_SHA_SIZE + 1];
} Header;
-typedef struct
+typedef struct
{
Region region;
guint old;
@@ -145,9 +143,9 @@ struct _GitgDiffViewPrivate
GDestroyNotify label_func_destroy_notify;
};
-G_DEFINE_TYPE(GitgDiffView, gitg_diff_view, GTK_TYPE_SOURCE_VIEW)
+G_DEFINE_TYPE (GitgDiffView, gitg_diff_view, GTK_TYPE_SOURCE_VIEW)
-static gboolean gitg_diff_view_expose(GtkWidget *widget, GdkEventExpose *event);
+static gboolean gitg_diff_view_expose (GtkWidget *widget, GdkEventExpose *event);
static guint diff_view_signals[NUM_SIGNALS] = {0,};
static void
@@ -251,7 +249,7 @@ set_diff_enabled (GitgDiffView *view,
disable_diff_view (view);
}
- gtk_widget_queue_draw (GTK_WIDGET(view));
+ gtk_widget_queue_draw (GTK_WIDGET (view));
}
static void
@@ -260,12 +258,12 @@ gitg_diff_view_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GitgDiffView *self = GITG_DIFF_VIEW(object);
+ GitgDiffView *self = GITG_DIFF_VIEW (object);
switch (prop_id)
{
case PROP_DIFF_ENABLED:
- set_diff_enabled(self, g_value_get_boolean (value));
+ set_diff_enabled (self, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -299,10 +297,10 @@ gitg_diff_view_constructed (GObject *object)
}
static void
-gitg_diff_view_class_init(GitgDiffViewClass *klass)
+gitg_diff_view_class_init (GitgDiffViewClass *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_diff_view_finalize;
object_class->dispose = gitg_diff_view_dispose;
@@ -335,14 +333,14 @@ gitg_diff_view_class_init(GitgDiffViewClass *klass)
1,
G_TYPE_POINTER);
- g_object_class_install_property(object_class, PROP_DIFF_ENABLED,
- g_param_spec_boolean("diff-enabled",
+ g_object_class_install_property (object_class, PROP_DIFF_ENABLED,
+ g_param_spec_boolean ("diff-enabled",
"DIFF_ENABLED",
"Enables diff view",
FALSE,
G_PARAM_READWRITE));
- g_type_class_add_private (object_class, sizeof(GitgDiffViewPrivate));
+ g_type_class_add_private (object_class, sizeof (GitgDiffViewPrivate));
}
static void
@@ -420,7 +418,7 @@ enable_diff_view (GitgDiffView *view)
G_CALLBACK (on_buffer_delete_range),
view);
- view->priv->scan_id = g_idle_add ((GSourceFunc)on_idle_scan, view);
+ view->priv->scan_id = g_idle_add ( (GSourceFunc)on_idle_scan, view);
view->priv->invisible_tag = gtk_text_buffer_create_tag (view->priv->current_buffer,
"GitgHunkInvisible",
@@ -491,10 +489,10 @@ gitg_diff_view_new ()
}
static gint
-index_compare(gconstpointer a, gconstpointer b, gpointer userdata)
+index_compare (gconstpointer a, gconstpointer b, gpointer userdata)
{
- guint la = ((Region *)a)->line;
- guint lb = ((Region *)b)->line;
+ guint la = ( (Region *)a)->line;
+ guint lb = ( (Region *)b)->line;
return la < lb ? -1 : (la > lb ? 1 : 0);
}
@@ -574,102 +572,102 @@ add_region (GitgDiffView *view, Region *region)
hide_header_details (view, region->prev);
}
- g_sequence_insert_sorted(view->priv->regions_index, region, index_compare, NULL);
+ g_sequence_insert_sorted (view->priv->regions_index, region, index_compare, NULL);
GitgDiffIter iter;
region_to_iter (view, region, &iter);
if (region->type == GITG_DIFF_ITER_TYPE_HEADER)
{
- g_signal_emit(view, diff_view_signals[HEADER_ADDED], 0, &iter);
+ g_signal_emit (view, diff_view_signals[HEADER_ADDED], 0, &iter);
}
else if (region->type == GITG_DIFF_ITER_TYPE_HUNK)
{
- g_signal_emit(view, diff_view_signals[HUNK_ADDED], 0, &iter);
+ g_signal_emit (view, diff_view_signals[HUNK_ADDED], 0, &iter);
}
}
static void
-parse_hunk_info(Hunk *hunk, GtkTextIter *iter)
+parse_hunk_info (Hunk *hunk, GtkTextIter *iter)
{
GtkTextIter end = *iter;
- gtk_text_iter_forward_to_line_end(&end);
- gchar *text = gtk_text_iter_get_text(iter, &end);
+ gtk_text_iter_forward_to_line_end (&end);
+ gchar *text = gtk_text_iter_get_text (iter, &end);
hunk->old = 0;
hunk->new = 0;
- gchar *old = g_utf8_strchr(text, -1, '-');
- gchar *new = g_utf8_strchr(text, -1, '+');
+ gchar *old = g_utf8_strchr (text, -1, '-');
+ gchar *new = g_utf8_strchr (text, -1, '+');
if (!old || !new)
{
return;
}
- hunk->old = atoi(old + 1);
- hunk->new = atoi(new + 1);
+ hunk->old = atoi (old + 1);
+ hunk->new = atoi (new + 1);
- g_free(text);
+ g_free (text);
}
static void
-ensure_scan(GitgDiffView *view, guint last_line)
+ensure_scan (GitgDiffView *view, guint last_line)
{
/* Scan from last_scan_line, making regions */
GtkTextIter iter;
GtkTextBuffer *buffer = view->priv->current_buffer;
- gtk_text_buffer_get_iter_at_line(buffer, &iter, view->priv->last_scan_line);
+ gtk_text_buffer_get_iter_at_line (buffer, &iter, view->priv->last_scan_line);
while (view->priv->last_scan_line <= last_line)
{
GtkTextIter start = iter;
GtkTextIter end = iter;
- if (!gtk_text_iter_forward_line(&iter))
+ if (!gtk_text_iter_forward_line (&iter))
{
break;
}
++view->priv->last_scan_line;
- if (!gtk_text_iter_forward_chars(&end, 3))
+ if (!gtk_text_iter_forward_chars (&end, 3))
{
continue;
}
- gchar *text = gtk_text_iter_get_text(&start, &end);
+ gchar *text = gtk_text_iter_get_text (&start, &end);
- if (g_str_has_prefix(text, "@@ ") || g_str_has_prefix (text, "@@@"))
+ if (g_str_has_prefix (text, "@@ ") || g_str_has_prefix (text, "@@@"))
{
/* start new hunk region */
- Hunk *hunk = g_slice_new(Hunk);
+ Hunk *hunk = g_slice_new (Hunk);
hunk->region.type = GITG_DIFF_ITER_TYPE_HUNK;
hunk->region.line = view->priv->last_scan_line - 1;
hunk->region.visible = TRUE;
- parse_hunk_info(hunk, &start);
+ parse_hunk_info (hunk, &start);
- add_region(view, (Region *)hunk);
+ add_region (view, (Region *)hunk);
- g_free(text);
+ g_free (text);
continue;
}
- g_free(text);
+ g_free (text);
- if (!gtk_text_iter_forward_chars(&end, 7))
+ if (!gtk_text_iter_forward_chars (&end, 7))
{
continue;
}
- text = gtk_text_iter_get_text(&start, &end);
+ text = gtk_text_iter_get_text (&start, &end);
- if (g_str_has_prefix(text, "diff --git") || g_str_has_prefix(text, "diff --cc"))
+ if (g_str_has_prefix (text, "diff --git") || g_str_has_prefix (text, "diff --cc"))
{
/* start new header region */
- Header *header = g_slice_new(Header);
+ Header *header = g_slice_new (Header);
header->region.type = GITG_DIFF_ITER_TYPE_HEADER;
header->region.line = view->priv->last_scan_line - 1;
header->region.visible = TRUE;
@@ -677,34 +675,34 @@ ensure_scan(GitgDiffView *view, guint last_line)
header->index_to[0] = '\0';
header->index_from[0] = '\0';
- add_region(view, (Region *)header);
+ add_region (view, (Region *)header);
}
- g_free(text);
+ g_free (text);
}
if (view->priv->last_region && view->priv->last_region->type == GITG_DIFF_ITER_TYPE_HUNK)
{
- ensure_max_line(view, (Hunk *)view->priv->last_region);
+ ensure_max_line (view, (Hunk *)view->priv->last_region);
}
}
static Region *
-find_current_region(GitgDiffView *view, guint line)
+find_current_region (GitgDiffView *view, guint line)
{
GSequenceIter *iter;
Region tmp = {0, NULL, NULL, line};
- iter = g_sequence_search(view->priv->regions_index, &tmp, index_compare, NULL);
+ iter = g_sequence_search (view->priv->regions_index, &tmp, index_compare, NULL);
- if (!iter || g_sequence_iter_is_begin(iter))
+ if (!iter || g_sequence_iter_is_begin (iter))
{
return NULL;
}
- if (!g_sequence_iter_is_end(iter))
+ if (!g_sequence_iter_is_end (iter))
{
- Region *ret = (Region *)g_sequence_get(iter);
+ Region *ret = (Region *)g_sequence_get (iter);
if (ret->line == line)
{
@@ -712,45 +710,45 @@ find_current_region(GitgDiffView *view, guint line)
}
}
- Region *ret = (Region *)g_sequence_get(g_sequence_iter_prev(iter));
+ Region *ret = (Region *)g_sequence_get (g_sequence_iter_prev (iter));
return ret->visible ? ret : NULL;
}
static gboolean
-line_has_prefix(GitgDiffView *view, guint line, gchar const *prefix)
+line_has_prefix (GitgDiffView *view, guint line, gchar const *prefix)
{
GtkTextIter iter;
- gtk_text_buffer_get_iter_at_line(view->priv->current_buffer, &iter, line);
+ gtk_text_buffer_get_iter_at_line (view->priv->current_buffer, &iter, line);
GtkTextIter end = iter;
- if (!gtk_text_iter_forward_chars(&end, g_utf8_strlen(prefix, -1)))
+ if (!gtk_text_iter_forward_chars (&end, g_utf8_strlen (prefix, -1)))
{
return FALSE;
}
- gchar *text = gtk_text_iter_get_text(&iter, &end);
- gboolean ret = g_str_has_prefix(text, prefix);
- g_free(text);
+ gchar *text = gtk_text_iter_get_text (&iter, &end);
+ gboolean ret = g_str_has_prefix (text, prefix);
+ g_free (text);
return ret;
}
static gboolean
-draw_old(GitgDiffView *view, guint line)
+draw_old (GitgDiffView *view, guint line)
{
- return !line_has_prefix(view, line, "+");
+ return !line_has_prefix (view, line, "+");
}
static gboolean
-draw_new(GitgDiffView *view, guint line)
+draw_new (GitgDiffView *view, guint line)
{
- return !line_has_prefix(view, line, "-");
+ return !line_has_prefix (view, line, "-");
}
static void
-get_initial_counters(GitgDiffView *view, Region *region, guint line, guint counters[2])
+get_initial_counters (GitgDiffView *view, Region *region, guint line, guint counters[2])
{
guint i;
@@ -758,10 +756,10 @@ get_initial_counters(GitgDiffView *view, Region *region, guint line, guint count
for (i = region->line + 1; i < line; ++i)
{
- if (draw_old(view, i))
+ if (draw_old (view, i))
++counters[0];
- if (draw_new(view, i))
+ if (draw_new (view, i))
++counters[1];
}
}
@@ -874,13 +872,13 @@ gitg_diff_view_expose (GtkWidget *widget,
}
void
-gitg_diff_view_set_diff_enabled(GitgDiffView *view, gboolean enabled)
+gitg_diff_view_set_diff_enabled (GitgDiffView *view, gboolean enabled)
{
- g_return_if_fail(GITG_IS_DIFF_VIEW(view));
+ g_return_if_fail (GITG_IS_DIFF_VIEW (view));
- set_diff_enabled(view, enabled);
+ set_diff_enabled (view, enabled);
- g_object_notify(G_OBJECT(view), "diff-enabled");
+ g_object_notify (G_OBJECT (view), "diff-enabled");
}
static void
@@ -1056,10 +1054,10 @@ gitg_diff_view_remove_hunk (GitgDiffView *view, GtkTextIter *iter)
}
gboolean
-gitg_diff_view_get_start_iter(GitgDiffView *view, GitgDiffIter *iter)
+gitg_diff_view_get_start_iter (GitgDiffView *view, GitgDiffIter *iter)
{
- g_return_val_if_fail(GITG_IS_DIFF_VIEW(view), FALSE);
- g_return_val_if_fail(iter != NULL, FALSE);
+ g_return_val_if_fail (GITG_IS_DIFF_VIEW (view), FALSE);
+ g_return_val_if_fail (iter != NULL, FALSE);
if (!view->priv->diff_enabled)
{
@@ -1071,9 +1069,9 @@ gitg_diff_view_get_start_iter(GitgDiffView *view, GitgDiffIter *iter)
}
gboolean
-gitg_diff_iter_forward(GitgDiffIter *iter)
+gitg_diff_iter_forward (GitgDiffIter *iter)
{
- g_return_val_if_fail(iter != NULL, FALSE);
+ g_return_val_if_fail (iter != NULL, FALSE);
if (!GITG_DIFF_ITER_GET_REGION (iter))
{
@@ -1086,10 +1084,10 @@ gitg_diff_iter_forward(GitgDiffIter *iter)
}
gboolean
-gitg_diff_view_get_end_iter(GitgDiffView *view, GitgDiffIter *iter)
+gitg_diff_view_get_end_iter (GitgDiffView *view, GitgDiffIter *iter)
{
- g_return_val_if_fail(GITG_IS_DIFF_VIEW(view), FALSE);
- g_return_val_if_fail(iter != NULL, FALSE);
+ g_return_val_if_fail (GITG_IS_DIFF_VIEW (view), FALSE);
+ g_return_val_if_fail (iter != NULL, FALSE);
region_to_iter (view, view->priv->last_region, iter);
@@ -1097,9 +1095,9 @@ gitg_diff_view_get_end_iter(GitgDiffView *view, GitgDiffIter *iter)
}
gboolean
-gitg_diff_iter_backward(GitgDiffIter *iter)
+gitg_diff_iter_backward (GitgDiffIter *iter)
{
- g_return_val_if_fail(iter != NULL, FALSE);
+ g_return_val_if_fail (iter != NULL, FALSE);
if (!GITG_DIFF_ITER_GET_REGION (iter))
{
@@ -1112,8 +1110,8 @@ gitg_diff_iter_backward(GitgDiffIter *iter)
}
-GitgDiffIterType
-gitg_diff_iter_get_type(GitgDiffIter *iter)
+GitgDiffIterType
+gitg_diff_iter_get_type (GitgDiffIter *iter)
{
g_return_val_if_fail (iter != NULL, 0);
g_return_val_if_fail (GITG_IS_DIFF_VIEW (GITG_DIFF_ITER_GET_VIEW (iter)), 0);
@@ -1123,9 +1121,9 @@ gitg_diff_iter_get_type(GitgDiffIter *iter)
}
static void
-region_iter_range(GitgDiffView *view, Region *region, GtkTextIter *start, GtkTextIter *end)
+region_iter_range (GitgDiffView *view, Region *region, GtkTextIter *start, GtkTextIter *end)
{
- gtk_text_buffer_get_iter_at_line(view->priv->current_buffer, start, region->line);
+ gtk_text_buffer_get_iter_at_line (view->priv->current_buffer, start, region->line);
Region *next = region->next;
@@ -1133,13 +1131,13 @@ region_iter_range(GitgDiffView *view, Region *region, GtkTextIter *start, GtkTex
next = next->next;
if (next)
- gtk_text_buffer_get_iter_at_line(view->priv->current_buffer, end, next->line);
+ gtk_text_buffer_get_iter_at_line (view->priv->current_buffer, end, next->line);
else
- gtk_text_buffer_get_end_iter(view->priv->current_buffer, end);
+ gtk_text_buffer_get_end_iter (view->priv->current_buffer, end);
}
void
-gitg_diff_iter_set_visible(GitgDiffIter *iter, gboolean visible)
+gitg_diff_iter_set_visible (GitgDiffIter *iter, gboolean visible)
{
g_return_if_fail (iter != NULL);
g_return_if_fail (GITG_IS_DIFF_VIEW (GITG_DIFF_ITER_GET_VIEW (iter)));
@@ -1154,7 +1152,7 @@ gitg_diff_iter_set_visible(GitgDiffIter *iter, gboolean visible)
GtkTextIter start;
GtkTextIter end;
- region_iter_range(view, region, &start, &end);
+ region_iter_range (view, region, &start, &end);
region->visible = visible;
/* Propagate visibility to hunks */
@@ -1171,7 +1169,7 @@ gitg_diff_iter_set_visible(GitgDiffIter *iter, gboolean visible)
if (visible)
{
- gtk_text_buffer_remove_tag(view->priv->current_buffer, view->priv->invisible_tag, &start, &end);
+ gtk_text_buffer_remove_tag (view->priv->current_buffer, view->priv->invisible_tag, &start, &end);
if (region->type == GITG_DIFF_ITER_TYPE_HEADER)
{
@@ -1185,12 +1183,12 @@ gitg_diff_iter_set_visible(GitgDiffIter *iter, gboolean visible)
gtk_text_buffer_remove_tag (view->priv->current_buffer, view->priv->subheader_tag, &start, &end);
}
- gtk_text_buffer_apply_tag(view->priv->current_buffer, view->priv->invisible_tag, &start, &end);
+ gtk_text_buffer_apply_tag (view->priv->current_buffer, view->priv->invisible_tag, &start, &end);
}
}
static gboolean
-header_parse_index(GitgDiffView *view, Header *header)
+header_parse_index (GitgDiffView *view, Header *header)
{
GtkTextIter iter;
GtkTextBuffer *buffer = view->priv->current_buffer;
@@ -1200,40 +1198,40 @@ header_parse_index(GitgDiffView *view, Header *header)
if (header->region.next)
num = header->region.next->line - header->region.line;
else
- num = gtk_text_buffer_get_line_count(buffer) - header->region.line;
+ num = gtk_text_buffer_get_line_count (buffer) - header->region.line;
- gtk_text_buffer_get_iter_at_line(buffer, &iter, header->region.line);
+ gtk_text_buffer_get_iter_at_line (buffer, &iter, header->region.line);
for (i = 0; i < num; ++i)
{
- if (!gtk_text_iter_forward_line(&iter))
+ if (!gtk_text_iter_forward_line (&iter))
return FALSE;
GtkTextIter end = iter;
- gtk_text_iter_forward_to_line_end(&end);
+ gtk_text_iter_forward_to_line_end (&end);
/* get line contents */
- gchar *line = gtk_text_iter_get_text(&iter, &end);
+ gchar *line = gtk_text_iter_get_text (&iter, &end);
gchar match[] = "index ";
- if (g_str_has_prefix(line, match))
+ if (g_str_has_prefix (line, match))
{
- gchar *start = line + strlen(match);
- gchar *sep = strstr(start, "..");
+ gchar *start = line + strlen (match);
+ gchar *sep = strstr (start, "..");
gboolean ret;
if (sep)
{
- gchar *last = strstr(sep, " ");
- gchar *bet = strstr(start, ",");
+ gchar *last = strstr (sep, " ");
+ gchar *bet = strstr (start, ",");
if (!last)
- last = line + strlen(line);
+ last = line + strlen (line);
- strncpy(header->index_from, start, (bet ? bet : sep) - start);
- strncpy(header->index_to, sep + 2, last - (sep + 2));
+ strncpy (header->index_from, start, (bet ? bet : sep) - start);
+ strncpy (header->index_to, sep + 2, last - (sep + 2));
- header->index_from[(bet ? bet : sep) - start] = '\0';
+ header->index_from[ (bet ? bet : sep) - start] = '\0';
header->index_to[last - (sep + 2)] = '\0';
ret = TRUE;
@@ -1243,11 +1241,11 @@ header_parse_index(GitgDiffView *view, Header *header)
ret = FALSE;
}
- g_free(line);
+ g_free (line);
return ret;
}
- g_free(line);
+ g_free (line);
}
return FALSE;
@@ -1273,7 +1271,7 @@ gitg_diff_iter_get_index (GitgDiffIter *iter,
Header *header = (Header *)region;
gboolean ret = TRUE;
- if (!*(header->index_to))
+ if (!* (header->index_to))
{
ret = header_parse_index (GITG_DIFF_ITER_GET_VIEW (iter), header);
}
@@ -1302,7 +1300,7 @@ iter_in_view (GitgDiffView *view,
gtk_text_view_get_iter_at_location (textview, &start, rect.x, rect.y);
gtk_text_view_get_iter_at_location (textview, &end, rect.x + rect.width, rect.y + rect.height);
- return gtk_text_iter_in_range(iter, &start, &end) || gtk_text_iter_equal(iter, &end);
+ return gtk_text_iter_in_range (iter, &start, &end) || gtk_text_iter_equal (iter, &end);
}
static gboolean
@@ -1358,7 +1356,7 @@ on_buffer_delete_range (GtkTextBuffer *buffer,
if (!view->priv->scan_id)
{
- view->priv->scan_id = g_idle_add ((GSourceFunc)on_idle_scan,
+ view->priv->scan_id = g_idle_add ( (GSourceFunc)on_idle_scan,
view);
}
}
@@ -1383,14 +1381,14 @@ on_buffer_insert_text (GtkTextBuffer *buffer,
if (!view->priv->scan_id)
{
- view->priv->scan_id = g_idle_add ((GSourceFunc)on_idle_scan, view);
+ view->priv->scan_id = g_idle_add ( (GSourceFunc)on_idle_scan, view);
}
}
static gboolean
on_idle_scan (GitgDiffView *view)
{
- if (try_scan(view))
+ if (try_scan (view))
{
return TRUE;
}
diff --git a/gitg/gitg-revision-view.c b/gitg/gitg-revision-view.c
index 545fcf3..18cc63b 100644
--- a/gitg/gitg-revision-view.c
+++ b/gitg/gitg-revision-view.c
@@ -74,9 +74,9 @@ struct _GitgRevisionViewPrivate
GSList *cached_headers;
};
-static void gitg_revision_view_buildable_iface_init(GtkBuildableIface *iface);
-static void on_header_added(GitgDiffView *view, GitgDiffIter *iter, GitgRevisionView *self);
-static void on_diff_files_selection_changed(GtkTreeSelection *selection, GitgRevisionView *self);
+static void gitg_revision_view_buildable_iface_init (GtkBuildableIface *iface);
+static void on_header_added (GitgDiffView *view, GitgDiffIter *iter, GitgRevisionView *self);
+static void on_diff_files_selection_changed (GtkTreeSelection *selection, GitgRevisionView *self);
G_DEFINE_TYPE_EXTENDED(GitgRevisionView, gitg_revision_view, GTK_TYPE_VBOX, 0,
G_IMPLEMENT_INTERFACE(GTK_TYPE_BUILDABLE, gitg_revision_view_buildable_iface_init));
@@ -95,8 +95,8 @@ typedef struct
{
gint refcount;
- gchar index_from[HASH_SHA_SIZE + 1];
- gchar index_to[HASH_SHA_SIZE + 1];
+ gchar index_from[GITG_HASH_SHA_SIZE + 1];
+ gchar index_to[GITG_HASH_SHA_SIZE + 1];
DiffFileStatus status;
gchar *filename;
@@ -105,15 +105,18 @@ typedef struct
} DiffFile;
static DiffFile *
-diff_file_new(gchar const *from, gchar *to, gchar const *status, gchar const *filename)
+diff_file_new (gchar const *from,
+ gchar *to,
+ gchar const *status,
+ gchar const *filename)
{
- DiffFile *f = g_slice_new(DiffFile);
+ DiffFile *f = g_slice_new (DiffFile);
- strncpy(f->index_from, from, HASH_SHA_SIZE);
- strncpy(f->index_to, to, HASH_SHA_SIZE);
+ strncpy (f->index_from, from, GITG_HASH_SHA_SIZE);
+ strncpy (f->index_to, to, GITG_HASH_SHA_SIZE);
- f->index_from[HASH_SHA_SIZE] = '\0';
- f->index_to[HASH_SHA_SIZE] = '\0';
+ f->index_from[GITG_HASH_SHA_SIZE] = '\0';
+ f->index_to[GITG_HASH_SHA_SIZE] = '\0';
f->visible = FALSE;
DiffFileStatus st;
@@ -132,57 +135,68 @@ diff_file_new(gchar const *from, gchar *to, gchar const *status, gchar const *fi
}
f->status = st;
- f->filename = g_strdup(filename);
+ f->filename = g_strdup (filename);
f->refcount = 1;
return f;
}
static DiffFile *
-diff_file_copy(DiffFile *f)
+diff_file_copy (DiffFile *f)
{
- g_atomic_int_inc(&f->refcount);
+ g_atomic_int_inc (&f->refcount);
return f;
}
static void
-diff_file_unref(DiffFile *f)
+diff_file_unref (DiffFile *f)
{
- if (!g_atomic_int_dec_and_test(&f->refcount))
+ if (!g_atomic_int_dec_and_test (&f->refcount))
return;
- g_free(f->filename);
- g_slice_free(DiffFile, f);
+ g_free (f->filename);
+ g_slice_free (DiffFile, f);
}
static GType
-diff_file_get_type()
+diff_file_get_type ()
{
static GType gtype = 0;
if (!G_UNLIKELY(gtype))
- gtype = g_boxed_type_register_static("DiffFile", (GBoxedCopyFunc)diff_file_copy, (GBoxedFreeFunc)diff_file_unref);
+ {
+ gtype = g_boxed_type_register_static ("DiffFile",
+ (GBoxedCopyFunc)diff_file_copy,
+ (GBoxedFreeFunc)diff_file_unref);
+ }
return gtype;
}
static void
-update_markup(GObject *object)
+update_markup (GObject *object)
{
GtkLabel *label = GTK_LABEL(object);
- gchar const *text = gtk_label_get_text(label);
+ gchar const *text = gtk_label_get_text (label);
- gchar *newtext = g_strconcat("<span weight='bold' foreground='#777'>", text, "</span>", NULL);
+ gchar *newtext = g_strconcat ("<span weight='bold' foreground='#777'>",
+ text,
+ "</span>",
+ NULL);
- gtk_label_set_markup(label, newtext);
- g_free(newtext);
+ gtk_label_set_markup (label, newtext);
+ g_free (newtext);
}
static void
-revision_files_icon(GtkTreeViewColumn *column, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, GitgRevisionView *self)
+revision_files_icon (GtkTreeViewColumn *column,
+ GtkCellRenderer *renderer,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ GitgRevisionView *self)
{
DiffFile *f;
- gtk_tree_model_get(model, iter, 0, &f, -1);
+ gtk_tree_model_get (model, iter, 0, &f, -1);
gchar const *id = NULL;
@@ -201,115 +215,167 @@ revision_files_icon(GtkTreeViewColumn *column, GtkCellRenderer *renderer, GtkTre
break;
}
- g_object_set(G_OBJECT(renderer), "stock-id", id, NULL);
- diff_file_unref(f);
+ g_object_set (G_OBJECT(renderer), "stock-id", id, NULL);
+ diff_file_unref (f);
}
static void
-revision_files_name(GtkTreeViewColumn *column, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, GitgRevisionView *self)
+revision_files_name (GtkTreeViewColumn *column,
+ GtkCellRenderer *renderer,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ GitgRevisionView *self)
{
DiffFile *f;
- gtk_tree_model_get(model, iter, 0, &f, -1);
+ gtk_tree_model_get (model, iter, 0, &f, -1);
- g_object_set(G_OBJECT(renderer), "text", f->filename, NULL);
+ g_object_set (G_OBJECT(renderer), "text", f->filename, NULL);
- diff_file_unref(f);
+ diff_file_unref (f);
}
static gboolean
-diff_file_visible(GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
+diff_file_visible (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer data)
{
DiffFile *f;
- gtk_tree_model_get(model, iter, 0, &f, -1);
+ gtk_tree_model_get (model, iter, 0, &f, -1);
if (!f)
+ {
return FALSE;
+ }
gboolean ret = f->visible;
- diff_file_unref(f);
+ diff_file_unref (f);
return ret;
}
static gboolean
-on_diff_files_button_press(GtkTreeView *treeview, GdkEventButton *event, GitgRevisionView *view)
+on_diff_files_button_press (GtkTreeView *treeview,
+ GdkEventButton *event,
+ GitgRevisionView *view)
{
if (event->button != 1)
+ {
return FALSE;
+ }
- if (event->window != gtk_tree_view_get_bin_window(treeview))
+ if (event->window != gtk_tree_view_get_bin_window (treeview))
+ {
return FALSE;
+ }
GtkTreePath *path;
- if (!gtk_tree_view_get_path_at_pos(treeview, event->x, event->y, &path, NULL, NULL, NULL))
+
+ if (!gtk_tree_view_get_path_at_pos (treeview,
+ event->x,
+ event->y,
+ &path,
+ NULL,
+ NULL,
+ NULL))
+ {
return FALSE;
+ }
- GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
+ GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview);
gboolean ret = FALSE;
- if (gtk_tree_selection_path_is_selected(selection, path) && gtk_tree_selection_count_selected_rows(selection) == 1)
+ if (gtk_tree_selection_path_is_selected (selection, path) &&
+ gtk_tree_selection_count_selected_rows (selection) == 1)
{
/* deselect */
- gtk_tree_selection_unselect_path(selection, path);
+ gtk_tree_selection_unselect_path (selection, path);
ret = TRUE;
}
- gtk_tree_path_free(path);
+ gtk_tree_path_free (path);
return ret;
}
static void
-gitg_revision_view_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
+gitg_revision_view_parser_finished (GtkBuildable *buildable, GtkBuilder *builder)
{
if (parent_iface.parser_finished)
- parent_iface.parser_finished(buildable, builder);
+ {
+ parent_iface.parser_finished (buildable, builder);
+ }
GitgRevisionView *rvv = GITG_REVISION_VIEW(buildable);
- rvv->priv->sha = GTK_LABEL(gtk_builder_get_object(builder, "label_sha"));
- rvv->priv->author = GTK_LABEL(gtk_builder_get_object(builder, "label_author"));
- rvv->priv->date = GTK_LABEL(gtk_builder_get_object(builder, "label_date"));
- rvv->priv->subject = GTK_LABEL(gtk_builder_get_object(builder, "label_subject"));
- rvv->priv->parents = GTK_TABLE(gtk_builder_get_object(builder, "table_parents"));
- rvv->priv->diff = GTK_SOURCE_VIEW(gtk_builder_get_object(builder, "revision_diff"));
- rvv->priv->diff_files = GTK_TREE_VIEW(gtk_builder_get_object(builder, "tree_view_revision_files"));
-
- GtkTreeSelection *selection = gtk_tree_view_get_selection(rvv->priv->diff_files);
- gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
- g_signal_connect(selection, "changed", G_CALLBACK(on_diff_files_selection_changed), rvv);
-
- g_signal_connect(rvv->priv->diff_files, "button-press-event", G_CALLBACK(on_diff_files_button_press), rvv);
-
- rvv->priv->list_store_diff_files = gtk_list_store_new(1, diff_file_get_type());
-
- GtkTreeModel *filter = gtk_tree_model_filter_new(GTK_TREE_MODEL(rvv->priv->list_store_diff_files), NULL);
- gtk_tree_view_set_model(rvv->priv->diff_files, filter);
-
- gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(filter), diff_file_visible, NULL, NULL);
-
- gtk_tree_view_column_set_cell_data_func(GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder, "revision_files_column_icon")),
- GTK_CELL_RENDERER(gtk_builder_get_object(builder, "revision_files_cell_renderer_icon")),
- (GtkTreeCellDataFunc)revision_files_icon,
- rvv,
- NULL);
-
- gtk_tree_view_column_set_cell_data_func(GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder, "revision_files_column_name")),
- GTK_CELL_RENDERER(gtk_builder_get_object(builder, "revision_files_cell_renderer_name")),
- (GtkTreeCellDataFunc)revision_files_name,
- rvv,
- NULL);
-
- GtkSourceLanguageManager *manager = gtk_source_language_manager_get_default();
- GtkSourceLanguage *language = gtk_source_language_manager_get_language(manager, "gitgdiff");
- GtkSourceBuffer *buffer = gtk_source_buffer_new_with_language(language);
- g_object_unref(language);
-
- GtkSourceStyleSchemeManager *schememanager = gtk_source_style_scheme_manager_get_default();
- GtkSourceStyleScheme *scheme = gtk_source_style_scheme_manager_get_scheme(schememanager, "gitg");
- gtk_source_buffer_set_style_scheme(buffer, scheme);
-
- gitg_utils_set_monospace_font(GTK_WIDGET(rvv->priv->diff));
- gtk_text_view_set_buffer(GTK_TEXT_VIEW(rvv->priv->diff), GTK_TEXT_BUFFER(buffer));
+ rvv->priv->sha = GTK_LABEL(gtk_builder_get_object (builder, "label_sha"));
+ rvv->priv->author = GTK_LABEL(gtk_builder_get_object (builder, "label_author"));
+ rvv->priv->date = GTK_LABEL(gtk_builder_get_object (builder, "label_date"));
+ rvv->priv->subject = GTK_LABEL(gtk_builder_get_object (builder, "label_subject"));
+ rvv->priv->parents = GTK_TABLE(gtk_builder_get_object (builder, "table_parents"));
+ rvv->priv->diff = GTK_SOURCE_VIEW(gtk_builder_get_object (builder, "revision_diff"));
+ rvv->priv->diff_files = GTK_TREE_VIEW(gtk_builder_get_object (builder, "tree_view_revision_files"));
+
+ GtkTreeSelection *selection = gtk_tree_view_get_selection (rvv->priv->diff_files);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+ g_signal_connect (selection, "changed", G_CALLBACK(on_diff_files_selection_changed), rvv);
+
+ g_signal_connect (rvv->priv->diff_files,
+ "button-press-event",
+ G_CALLBACK(on_diff_files_button_press),
+ rvv);
+
+ rvv->priv->list_store_diff_files = gtk_list_store_new (1, diff_file_get_type ());
+
+ GtkTreeModel *filter = gtk_tree_model_filter_new (GTK_TREE_MODEL(rvv->priv->list_store_diff_files),
+ NULL);
+ gtk_tree_view_set_model (rvv->priv->diff_files, filter);
+
+ gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER(filter),
+ diff_file_visible,
+ NULL,
+ NULL);
+
+ GtkTreeViewColumn *column;
+
+ column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (builder,
+ "revision_files_column_icon"));
+
+ gtk_tree_view_column_set_cell_data_func (column,
+ GTK_CELL_RENDERER (gtk_builder_get_object (builder,
+ "revision_files_cell_renderer_icon")),
+ (GtkTreeCellDataFunc)revision_files_icon,
+ rvv,
+ NULL);
+
+ column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (builder,
+ "revision_files_column_name"));
+ gtk_tree_view_column_set_cell_data_func (column,
+ GTK_CELL_RENDERER (gtk_builder_get_object (builder,
+ "revision_files_cell_renderer_name")),
+ (GtkTreeCellDataFunc)revision_files_name,
+ rvv,
+ NULL);
+
+ GtkSourceLanguageManager *manager;
+ GtkSourceLanguage *language;
+ GtkSourceBuffer *buffer;
+
+ manager = gtk_source_language_manager_get_default ();
+ language = gtk_source_language_manager_get_language (manager, "gitgdiff");
+ buffer = gtk_source_buffer_new_with_language (language);
+
+ g_object_unref (language);
+
+ GtkSourceStyleSchemeManager *scheme_manager;
+ GtkSourceStyleScheme *scheme;
+
+ scheme_manager = gtk_source_style_scheme_manager_get_default ();
+ scheme = gtk_source_style_scheme_manager_get_scheme (scheme_manager,
+ "gitg");
+ gtk_source_buffer_set_style_scheme (buffer, scheme);
+
+ gitg_utils_set_monospace_font (GTK_WIDGET(rvv->priv->diff));
+ gtk_text_view_set_buffer (GTK_TEXT_VIEW(rvv->priv->diff),
+ GTK_TEXT_BUFFER(buffer));
gchar const *lbls[] = {
"label_subject_lbl",
@@ -319,15 +385,21 @@ gitg_revision_view_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
"label_parent_lbl"
};
- int i;
- for (i = 0; i < sizeof(lbls) / sizeof(gchar *); ++i)
- update_markup(gtk_builder_get_object(builder, lbls[i]));
+ gint i;
- g_signal_connect(rvv->priv->diff, "header-added", G_CALLBACK(on_header_added), rvv);
+ for (i = 0; i < sizeof (lbls) / sizeof (gchar *); ++i)
+ {
+ update_markup (gtk_builder_get_object (builder, lbls[i]));
+ }
+
+ g_signal_connect (rvv->priv->diff,
+ "header-added",
+ G_CALLBACK(on_header_added),
+ rvv);
}
static void
-gitg_revision_view_buildable_iface_init(GtkBuildableIface *iface)
+gitg_revision_view_buildable_iface_init (GtkBuildableIface *iface)
{
parent_iface = *iface;
@@ -335,49 +407,52 @@ gitg_revision_view_buildable_iface_init(GtkBuildableIface *iface)
}
static void
-free_cached_header(gpointer header)
+free_cached_header (gpointer header)
{
- g_slice_free(CachedHeader, header);
+ g_slice_free (CachedHeader, header);
}
static void
-free_cached_headers(GitgRevisionView *self)
+free_cached_headers (GitgRevisionView *self)
{
- g_slist_foreach(self->priv->cached_headers, (GFunc)free_cached_header, NULL);
- g_slist_free(self->priv->cached_headers);
+ g_slist_foreach (self->priv->cached_headers, (GFunc)free_cached_header, NULL);
+ g_slist_free (self->priv->cached_headers);
self->priv->cached_headers = NULL;
}
static void
-gitg_revision_view_finalize(GObject *object)
+gitg_revision_view_finalize (GObject *object)
{
GitgRevisionView *self = GITG_REVISION_VIEW(object);
- gitg_runner_cancel(self->priv->diff_runner);
- g_object_unref(self->priv->diff_runner);
+ gitg_runner_cancel (self->priv->diff_runner);
+ g_object_unref (self->priv->diff_runner);
- gitg_runner_cancel(self->priv->diff_files_runner);
- g_object_unref(self->priv->diff_files_runner);
+ gitg_runner_cancel (self->priv->diff_files_runner);
+ g_object_unref (self->priv->diff_files_runner);
if (self->priv->repository)
{
- g_object_unref(self->priv->repository);
+ g_object_unref (self->priv->repository);
}
- free_cached_headers(self);
+ free_cached_headers (self);
- G_OBJECT_CLASS(gitg_revision_view_parent_class)->finalize(object);
+ G_OBJECT_CLASS(gitg_revision_view_parent_class)->finalize (object);
}
static void
-gitg_revision_view_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gitg_revision_view_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
GitgRevisionView *self = GITG_REVISION_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;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@@ -386,7 +461,10 @@ gitg_revision_view_get_property(GObject *object, guint prop_id, GValue *value, G
}
static void
-gitg_revision_view_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gitg_revision_view_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
GitgRevisionView *self = GITG_REVISION_VIEW(object);
@@ -395,9 +473,11 @@ gitg_revision_view_set_property(GObject *object, guint prop_id, const GValue *va
case PROP_REPOSITORY:
{
if (self->priv->repository)
- g_object_unref(self->priv->repository);
+ {
+ g_object_unref (self->priv->repository);
+ }
- self->priv->repository = g_value_dup_object(value);
+ self->priv->repository = g_value_dup_object (value);
}
break;
default:
@@ -408,7 +488,7 @@ gitg_revision_view_set_property(GObject *object, guint prop_id, const GValue *va
static void
-gitg_revision_view_class_init(GitgRevisionViewClass *klass)
+gitg_revision_view_class_init (GitgRevisionViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
@@ -417,62 +497,74 @@ gitg_revision_view_class_init(GitgRevisionViewClass *klass)
object_class->set_property = gitg_revision_view_set_property;
object_class->get_property = gitg_revision_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));
signals[PARENT_ACTIVATED] =
- g_signal_new("parent-activated",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GitgRevisionViewClass, parent_activated),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1, G_TYPE_POINTER);
-
- g_type_class_add_private(object_class, sizeof(GitgRevisionViewPrivate));
+ g_signal_new ("parent-activated",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GitgRevisionViewClass,
+ parent_activated),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+
+ g_type_class_add_private (object_class, sizeof (GitgRevisionViewPrivate));
}
static void
-on_diff_files_begin_loading(GitgRunner *runner, GitgRevisionView *self)
+on_diff_files_begin_loading (GitgRunner *runner,
+ GitgRevisionView *self)
{
GdkCursor *cursor = gdk_cursor_new (GDK_WATCH);
- gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (self->priv->diff_files)), cursor);
+ gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (self->priv->diff_files)),
+ cursor);
gdk_cursor_unref (cursor);
}
static void
-on_diff_files_end_loading(GitgRunner *runner, gboolean cancelled, GitgRevisionView *self)
+on_diff_files_end_loading (GitgRunner *runner,
+ gboolean cancelled,
+ GitgRevisionView *self)
{
- gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET(self->priv->diff_files)), NULL);
+ gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET(self->priv->diff_files)),
+ NULL);
}
static gboolean
-match_indices(DiffFile *f, gchar const *from, gchar const *to)
+match_indices (DiffFile *f,
+ gchar const *from,
+ gchar const *to)
{
- return g_str_has_prefix(f->index_from, from) &&
- (g_str_has_prefix(f->index_to, to) ||
- g_str_has_prefix(f->index_to, "0000000"));
+ return g_str_has_prefix (f->index_from, from) &&
+ (g_str_has_prefix (f->index_to, to) ||
+ g_str_has_prefix (f->index_to, "0000000"));
}
static void
-visible_from_cached_headers(GitgRevisionView *view, DiffFile *f)
+visible_from_cached_headers (GitgRevisionView *view,
+ DiffFile *f)
{
GSList *item;
- for (item = view->priv->cached_headers; item; item = g_slist_next(item))
+ for (item = view->priv->cached_headers; item; item = g_slist_next (item))
{
CachedHeader *header = (CachedHeader *)item->data;
gchar *from;
gchar *to;
- gitg_diff_iter_get_index(&header->iter, &from, &to);
+ gitg_diff_iter_get_index (&header->iter, &from, &to);
- if (gitg_diff_iter_get_index(&header->iter, &from, &to) && match_indices(f, from, to))
+ if (gitg_diff_iter_get_index (&header->iter, &from, &to) && match_indices (f, from, to))
{
f->visible = TRUE;
f->iter = header->iter;
@@ -483,397 +575,539 @@ visible_from_cached_headers(GitgRevisionView *view, DiffFile *f)
}
static void
-add_diff_file(GitgRevisionView *view, DiffFile *f)
+add_diff_file (GitgRevisionView *view,
+ DiffFile *f)
{
GtkTreeIter iter;
- gtk_list_store_append(view->priv->list_store_diff_files, &iter);
+ gtk_list_store_append (view->priv->list_store_diff_files, &iter);
/* see if it is in the cached headers */
- visible_from_cached_headers(view, f);
- gtk_list_store_set(view->priv->list_store_diff_files, &iter, 0, f, -1);
+ visible_from_cached_headers (view, f);
+ gtk_list_store_set (view->priv->list_store_diff_files, &iter, 0, f, -1);
}
static void
-on_diff_files_update(GitgRunner *runner, gchar **buffer, GitgRevisionView *self)
+on_diff_files_update (GitgRunner *runner,
+ gchar **buffer,
+ GitgRevisionView *self)
{
gchar **line;
while (*(line = buffer++))
{
if (**line == '\0')
+ {
continue;
+ }
// Count parents
gint parents = 0;
gchar *ptr = *line;
while (*(ptr++) == ':')
+ {
++parents;
+ }
gint numparts = 3 + 2 * parents;
- gchar **parts = g_strsplit(ptr, " ", numparts);
+ gchar **parts = g_strsplit (ptr, " ", numparts);
- if (g_strv_length(parts) == numparts)
+ if (g_strv_length (parts) == numparts)
{
- gchar **files = g_strsplit(parts[numparts - 1], "\t", -1);
+ gchar **files = g_strsplit (parts[numparts - 1], "\t", -1);
- DiffFile *f = diff_file_new(parts[parents + 1], parts[numparts - 2], files[0], files[1]);
+ DiffFile *f = diff_file_new (parts[parents + 1], parts[numparts - 2], files[0], files[1]);
- add_diff_file(self, f);
- diff_file_unref(f);
+ add_diff_file (self, f);
+ diff_file_unref (f);
- g_strfreev(files);
+ g_strfreev (files);
}
- g_strfreev(parts);
+ g_strfreev (parts);
}
}
static void
-on_diff_begin_loading(GitgRunner *runner, GitgRevisionView *self)
+on_diff_begin_loading (GitgRunner *runner,
+ GitgRevisionView *self)
{
GdkCursor *cursor = gdk_cursor_new (GDK_WATCH);
- gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET(self->priv->diff)), cursor);
+ gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET(self->priv->diff)),
+ cursor);
gdk_cursor_unref (cursor);
}
static void
-on_diff_end_loading(GitgRunner *runner, gboolean cancelled, GitgRevisionView *self)
+on_diff_end_loading (GitgRunner *runner, gboolean cancelled, GitgRevisionView *self)
{
- gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET(self->priv->diff)), NULL);
+ gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET(self->priv->diff)),
+ NULL);
if (cancelled)
+ {
return;
+ }
- gchar sign = gitg_revision_get_sign(self->priv->revision);
+ gchar sign = gitg_revision_get_sign (self->priv->revision);
if (sign == 't' || sign == 'u')
{
- gchar *head = gitg_repository_parse_head(self->priv->repository);
+ gchar *head = gitg_repository_parse_head (self->priv->repository);
const gchar *cached = NULL;
if (sign == 't')
cached = "--cached";
- gitg_repository_run_commandv(self->priv->repository, self->priv->diff_files_runner, NULL,
- "diff-index", "--raw", "-M", "--abbrev=40", head, cached, NULL);
- g_free(head);
+ gitg_repository_run_commandv (self->priv->repository,
+ self->priv->diff_files_runner,
+ NULL,
+ "diff-index",
+ "--raw",
+ "-M",
+ "--abbrev=40",
+ head,
+ cached,
+ NULL);
+ g_free (head);
}
else
{
- gchar *sha = gitg_revision_get_sha1(self->priv->revision);
- gitg_repository_run_commandv(self->priv->repository, self->priv->diff_files_runner, NULL,
- "show", "--encoding=UTF-8", "--raw", "-M", "--pretty=format:", "--abbrev=40", sha, NULL);
- g_free(sha);
+ gchar *sha = gitg_revision_get_sha1 (self->priv->revision);
+ gitg_repository_run_commandv (self->priv->repository,
+ self->priv->diff_files_runner,
+ NULL,
+ "show",
+ "--encoding=UTF-8",
+ "--raw",
+ "-M",
+ "--pretty=format:",
+ "--abbrev=40",
+ sha,
+ NULL);
+ g_free (sha);
}
}
static void
-on_diff_update(GitgRunner *runner, gchar **buffer, GitgRevisionView *self)
+on_diff_update (GitgRunner *runner,
+ gchar **buffer,
+ GitgRevisionView *self)
{
gchar *line;
- GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(self->priv->diff));
+ GtkTextBuffer *buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW(self->priv->diff));
GtkTextIter iter;
- gtk_text_buffer_get_end_iter(buf, &iter);
+ gtk_text_buffer_get_end_iter (buf, &iter);
while ((line = *buffer++))
{
- gtk_text_buffer_insert(buf, &iter, line, -1);
- gtk_text_buffer_insert(buf, &iter, "\n", -1);
+ gtk_text_buffer_insert (buf, &iter, line, -1);
+ gtk_text_buffer_insert (buf, &iter, "\n", -1);
}
}
static void
-gitg_revision_view_init(GitgRevisionView *self)
+gitg_revision_view_init (GitgRevisionView *self)
{
self->priv = GITG_REVISION_VIEW_GET_PRIVATE(self);
- self->priv->diff_runner = gitg_runner_new(2000);
+ self->priv->diff_runner = gitg_runner_new (2000);
- g_signal_connect(self->priv->diff_runner, "begin-loading", G_CALLBACK(on_diff_begin_loading), self);
- g_signal_connect(self->priv->diff_runner, "update", G_CALLBACK(on_diff_update), self);
- g_signal_connect(self->priv->diff_runner, "end-loading", G_CALLBACK(on_diff_end_loading), self);
+ g_signal_connect (self->priv->diff_runner,
+ "begin-loading",
+ G_CALLBACK (on_diff_begin_loading),
+ self);
- self->priv->diff_files_runner = gitg_runner_new(2000);
+ g_signal_connect (self->priv->diff_runner,
+ "update",
+ G_CALLBACK (on_diff_update),
+ self);
- g_signal_connect(self->priv->diff_files_runner, "begin-loading", G_CALLBACK(on_diff_files_begin_loading), self);
- g_signal_connect(self->priv->diff_files_runner, "update", G_CALLBACK(on_diff_files_update), self);
- g_signal_connect(self->priv->diff_files_runner, "end-loading", G_CALLBACK(on_diff_files_end_loading), self);
+ g_signal_connect (self->priv->diff_runner,
+ "end-loading",
+ G_CALLBACK (on_diff_end_loading),
+ self);
+
+ self->priv->diff_files_runner = gitg_runner_new (2000);
+
+ g_signal_connect (self->priv->diff_files_runner,
+ "begin-loading",
+ G_CALLBACK(on_diff_files_begin_loading),
+ self);
+
+ g_signal_connect (self->priv->diff_files_runner,
+ "update",
+ G_CALLBACK(on_diff_files_update),
+ self);
+
+ g_signal_connect (self->priv->diff_files_runner,
+ "end-loading",
+ G_CALLBACK(on_diff_files_end_loading),
+ self);
}
#define HASH_KEY "GitgRevisionViewHashKey"
static gboolean
-on_parent_clicked(GtkWidget *ev, GdkEventButton *event, gpointer userdata)
+on_parent_clicked (GtkWidget *ev,
+ GdkEventButton *event,
+ gpointer userdata)
{
if (event->button != 1)
+ {
return FALSE;
+ }
GitgRevisionView *rvv = GITG_REVISION_VIEW(userdata);
- gchar *hash = (gchar *)g_object_get_data(G_OBJECT(ev), HASH_KEY);
- g_signal_emit(rvv, signals[PARENT_ACTIVATED], 0, hash);
+ gchar *hash = (gchar *)g_object_get_data (G_OBJECT(ev), HASH_KEY);
+ g_signal_emit (rvv, signals[PARENT_ACTIVATED], 0, hash);
return FALSE;
}
static GtkWidget *
-make_parent_label(GitgRevisionView *self, gchar const *hash)
+make_parent_label (GitgRevisionView *self,
+ gchar const *hash)
{
- GtkWidget *ev = gtk_event_box_new();
- GtkWidget *lbl = gtk_label_new(NULL);
+ GtkWidget *ev = gtk_event_box_new ();
+ GtkWidget *lbl = gtk_label_new (NULL);
+
+ gchar *markup = g_strconcat ("<span underline='single' foreground='#00f'>",
+ hash,
+ "</span>",
+ NULL);
- gchar *markup = g_strconcat("<span underline='single' foreground='#00f'>", hash, "</span>", NULL);
- gtk_label_set_markup(GTK_LABEL(lbl), markup);
- g_free(markup);
+ gtk_label_set_markup (GTK_LABEL(lbl), markup);
+ g_free (markup);
- gtk_misc_set_alignment(GTK_MISC(lbl), 0.0, 0.5);
- gtk_container_add(GTK_CONTAINER(ev), lbl);
+ gtk_misc_set_alignment (GTK_MISC(lbl), 0.0, 0.5);
+ gtk_container_add (GTK_CONTAINER(ev), lbl);
- gtk_widget_show(ev);
- gtk_widget_show(lbl);
+ gtk_widget_show (ev);
+ gtk_widget_show (lbl);
- g_object_set_data_full(G_OBJECT(ev), HASH_KEY, (gpointer)gitg_hash_sha1_to_hash_new(hash), (GDestroyNotify)g_free);
- g_signal_connect(ev, "button-release-event", G_CALLBACK(on_parent_clicked), self);
+ g_object_set_data_full (G_OBJECT(ev),
+ HASH_KEY,
+ (gpointer)gitg_hash_sha1_to_hash_new (hash),
+ (GDestroyNotify)g_free);
+
+ g_signal_connect (ev,
+ "button-release-event",
+ G_CALLBACK(on_parent_clicked),
+ self);
return ev;
}
static void
-update_parents(GitgRevisionView *self, GitgRevision *revision)
+update_parents (GitgRevisionView *self, GitgRevision *revision)
{
- GList *children = gtk_container_get_children(GTK_CONTAINER(self->priv->parents));
+ GList *children;
GList *item;
- for (item = children; item; item = item->next)
- gtk_container_remove(GTK_CONTAINER(self->priv->parents), GTK_WIDGET(item->data));
+ children = gtk_container_get_children (GTK_CONTAINER (self->priv->parents));
- g_list_free(children);
+ for (item = children; item; item = g_list_next (item))
+ {
+ gtk_container_remove (GTK_CONTAINER (self->priv->parents),
+ GTK_WIDGET (item->data));
+ }
+
+ g_list_free (children);
if (!revision)
+ {
return;
+ }
- gchar **parents = gitg_revision_get_parents(revision);
- gint num = g_strv_length(parents);
+ gchar **parents = gitg_revision_get_parents (revision);
+ gint num = g_strv_length (parents);
gint i;
- gtk_table_resize(self->priv->parents, num ? num : num + 1, 2);
- GdkCursor *cursor = gdk_cursor_new(GDK_HAND1);
- Hash hash;
+ gtk_table_resize (self->priv->parents, num ? num : num + 1, 2);
+ GdkCursor *cursor = gdk_cursor_new (GDK_HAND1);
+ GitgHash hash;
for (i = 0; i < num; ++i)
{
- GtkWidget *widget = make_parent_label(self, parents[i]);
- gtk_table_attach(self->priv->parents, widget, 0, 1, i, i + 1, GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0);
+ GtkWidget *widget = make_parent_label (self, parents[i]);
+ gtk_table_attach (self->priv->parents,
+ widget,
+ 0,
+ 1,
+ i,
+ i + 1,
+ GTK_FILL | GTK_SHRINK,
+ GTK_FILL | GTK_SHRINK,
+ 0,
+ 0);
gtk_widget_realize (widget);
gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
/* find subject */
- gitg_hash_sha1_to_hash(parents[i], hash);
+ gitg_hash_sha1_to_hash (parents[i], hash);
- GitgRevision *revision = gitg_repository_lookup(self->priv->repository, hash);
+ GitgRevision *revision;
+
+ revision = gitg_repository_lookup (self->priv->repository, hash);
if (revision)
{
- GtkWidget *subject = gtk_label_new(NULL);
+ GtkWidget *subject = gtk_label_new (NULL);
+
+ gchar *text;
- gchar *text = g_markup_printf_escaped (": <i>%s</i>", gitg_revision_get_subject(revision));
+ text = g_markup_printf_escaped (": <i>%s</i>",
+ gitg_revision_get_subject (revision));
- gtk_label_set_markup(GTK_LABEL(subject), text);
+ gtk_label_set_markup (GTK_LABEL(subject), text);
- g_free(text);
+ g_free (text);
- gtk_widget_show(subject);
+ gtk_widget_show (subject);
- gtk_misc_set_alignment(GTK_MISC(subject), 0.0, 0.5);
- gtk_label_set_ellipsize(GTK_LABEL(subject), PANGO_ELLIPSIZE_END);
- gtk_label_set_single_line_mode(GTK_LABEL(subject), TRUE);
+ gtk_misc_set_alignment (GTK_MISC(subject), 0.0, 0.5);
+ gtk_label_set_ellipsize (GTK_LABEL(subject), PANGO_ELLIPSIZE_END);
+ gtk_label_set_single_line_mode (GTK_LABEL(subject), TRUE);
- gtk_table_attach(self->priv->parents, subject, 1, 2, i, i + 1, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_SHRINK, 0, 0);
+ gtk_table_attach (self->priv->parents,
+ subject,
+ 1,
+ 2,
+ i,
+ i + 1,
+ GTK_FILL | GTK_EXPAND,
+ GTK_FILL | GTK_SHRINK,
+ 0,
+ 0);
}
}
- gdk_cursor_unref(cursor);
- g_strfreev(parents);
+ gdk_cursor_unref (cursor);
+ g_strfreev (parents);
}
static void
-update_diff(GitgRevisionView *self, GitgRepository *repository)
+update_diff (GitgRevisionView *self,
+ GitgRepository *repository)
{
GtkTreeSelection *selection;
// First cancel a possibly still running diff
- gitg_runner_cancel(self->priv->diff_runner);
- gitg_runner_cancel(self->priv->diff_files_runner);
+ gitg_runner_cancel (self->priv->diff_runner);
+ gitg_runner_cancel (self->priv->diff_files_runner);
- free_cached_headers(self);
+ free_cached_headers (self);
// Clear the buffer
- GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(self->priv->diff));
- gtk_text_buffer_set_text(buffer, "", 0);
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(self->priv->diff));
+ gtk_text_buffer_set_text (buffer, "", 0);
- selection = gtk_tree_view_get_selection(self->priv->diff_files);
- g_signal_handlers_block_by_func(selection,
- G_CALLBACK(on_diff_files_selection_changed),
+ selection = gtk_tree_view_get_selection (self->priv->diff_files);
+ g_signal_handlers_block_by_func (selection,
+ G_CALLBACK (on_diff_files_selection_changed),
self);
- gtk_list_store_clear(self->priv->list_store_diff_files);
+ gtk_list_store_clear (self->priv->list_store_diff_files);
- g_signal_handlers_unblock_by_func(selection,
- G_CALLBACK(on_diff_files_selection_changed),
+ g_signal_handlers_unblock_by_func (selection,
+ G_CALLBACK (on_diff_files_selection_changed),
self);
if (!self->priv->revision)
+ {
return;
+ }
- gchar sign = gitg_revision_get_sign(self->priv->revision);
+ gchar sign = gitg_revision_get_sign (self->priv->revision);
switch (sign)
{
case 't':
- gitg_repository_run_commandv(self->priv->repository, self->priv->diff_runner, NULL,
- "diff", "--cached", "-M", "--pretty=format:%s%n%n%b",
- "--encoding=UTF-8", "--no-color", NULL);
+ gitg_repository_run_commandv (self->priv->repository,
+ self->priv->diff_runner,
+ NULL,
+ "diff",
+ "--cached",
+ "-M",
+ "--pretty=format:%s%n%n%b",
+ "--encoding=UTF-8",
+ "--no-color",
+ NULL);
break;
case 'u':
- gitg_repository_run_commandv(self->priv->repository, self->priv->diff_runner, NULL,
- "diff", "-M", "--pretty=format:%s%n%n%b",
- "--encoding=UTF-8", "--no-color", NULL);
+ gitg_repository_run_commandv (self->priv->repository,
+ self->priv->diff_runner,
+ NULL,
+ "diff",
+ "-M",
+ "--pretty=format:%s%n%n%b",
+ "--encoding=UTF-8",
+ "--no-color",
+ NULL);
break;
default:
{
- gchar *hash = gitg_revision_get_sha1(self->priv->revision);
- gitg_repository_run_commandv(self->priv->repository, self->priv->diff_runner, NULL,
- "show", "-M", "--pretty=format:%s%n%n%b",
- "--encoding=UTF-8", "--no-color", hash, NULL);
-
- g_free(hash);
+ gchar *hash = gitg_revision_get_sha1 (self->priv->revision);
+ gitg_repository_run_commandv (self->priv->repository,
+ self->priv->diff_runner,
+ NULL,
+ "show",
+ "-M",
+ "--pretty=format:%s%n%n%b",
+ "--encoding=UTF-8",
+ "--no-color",
+ hash,
+ NULL);
+
+ g_free (hash);
}
break;
}
}
void
-gitg_revision_view_update(GitgRevisionView *self, GitgRepository *repository, GitgRevision *revision)
+gitg_revision_view_update (GitgRevisionView *self,
+ GitgRepository *repository,
+ GitgRevision *revision)
{
GtkClipboard *cb;
- g_return_if_fail(GITG_IS_REVISION_VIEW(self));
+ g_return_if_fail (GITG_IS_REVISION_VIEW (self));
// Update labels
if (revision)
{
- gtk_label_set_text(self->priv->author, gitg_revision_get_author(revision));
+ gtk_label_set_text (self->priv->author,
+ gitg_revision_get_author (revision));
- gchar *subject = g_markup_printf_escaped ("<b>%s</b>", gitg_revision_get_subject(revision));
+ gchar *subject;
- gtk_label_set_markup(self->priv->subject, subject);
- g_free(subject);
+ subject = g_markup_printf_escaped ("<b>%s</b>",
+ gitg_revision_get_subject (revision));
- gchar *date = gitg_revision_get_timestamp_for_display(revision);
- gtk_label_set_text(self->priv->date, date);
- g_free(date);
+ gtk_label_set_markup (self->priv->subject, subject);
+ g_free (subject);
- gchar *sha = gitg_revision_get_sha1(revision);
- gtk_label_set_text(self->priv->sha, sha);
+ gchar *date = gitg_revision_get_timestamp_for_display (revision);
+ gtk_label_set_text (self->priv->date, date);
+ g_free (date);
- cb = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
- gtk_clipboard_set_text(cb, sha, -1);
+ gchar *sha = gitg_revision_get_sha1 (revision);
+ gtk_label_set_text (self->priv->sha, sha);
- g_free(sha);
+ cb = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+ gtk_clipboard_set_text (cb, sha, -1);
+
+ g_free (sha);
}
else
{
- gtk_label_set_text(self->priv->author, "");
- gtk_label_set_text(self->priv->subject, "");
- gtk_label_set_text(self->priv->date, "");
- gtk_label_set_text(self->priv->sha, "");
+ gtk_label_set_text (self->priv->author, "");
+ gtk_label_set_text (self->priv->subject, "");
+ gtk_label_set_text (self->priv->date, "");
+ gtk_label_set_text (self->priv->sha, "");
}
// Update parents
- update_parents(self, revision);
+ update_parents (self, revision);
// Update diff
self->priv->revision = revision;
- update_diff(self, repository);
+ update_diff (self, repository);
}
-void
-gitg_revision_view_set_repository(GitgRevisionView *view, GitgRepository *repository)
+void
+gitg_revision_view_set_repository (GitgRevisionView *view,
+ GitgRepository *repository)
{
- g_return_if_fail(GITG_IS_REVISION_VIEW(view));
- g_return_if_fail(repository == NULL || GITG_IS_REPOSITORY(repository));
+ g_return_if_fail (GITG_IS_REVISION_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 (repository)
- view->priv->repository = g_object_ref(repository);
+ {
+ view->priv->repository = g_object_ref (repository);
+ }
- g_object_notify(G_OBJECT(view), "repository");
+ g_object_notify (G_OBJECT (view), "repository");
}
static gboolean
-find_diff_file(GitgRevisionView *view, GitgDiffIter *iter, GtkTreeIter *it, DiffFile **f)
+find_diff_file (GitgRevisionView *view,
+ GitgDiffIter *iter,
+ GtkTreeIter *it,
+ DiffFile **f)
{
gchar *from;
gchar *to;
- if (!gitg_diff_iter_get_index(iter, &from, &to))
+ if (!gitg_diff_iter_get_index (iter, &from, &to))
+ {
return FALSE;
+ }
- GtkTreeModel *model = GTK_TREE_MODEL(view->priv->list_store_diff_files);
+ GtkTreeModel *model = GTK_TREE_MODEL (view->priv->list_store_diff_files);
- if (!gtk_tree_model_get_iter_first(model, it))
+ if (!gtk_tree_model_get_iter_first (model, it))
+ {
return FALSE;
+ }
do
{
- gtk_tree_model_get(model, it, 0, f, -1);
+ gtk_tree_model_get (model, it, 0, f, -1);
- if (match_indices(*f, from, to))
+ if (match_indices (*f, from, to))
+ {
return TRUE;
+ }
- diff_file_unref(*f);
- } while (gtk_tree_model_iter_next(model, it));
+ diff_file_unref (*f);
+ } while (gtk_tree_model_iter_next (model, it));
return FALSE;
}
-static void
-on_header_added(GitgDiffView *view, GitgDiffIter *iter, GitgRevisionView *self)
+static void
+on_header_added (GitgDiffView *view,
+ GitgDiffIter *iter,
+ GitgRevisionView *self)
{
GtkTreeIter it;
DiffFile *f;
- if (find_diff_file(self, iter, &it, &f))
+ if (find_diff_file (self, iter, &it, &f))
{
if (!f->visible)
{
f->visible = TRUE;
f->iter = *iter;
- diff_file_unref(f);
+ diff_file_unref (f);
- GtkTreeModel *model = GTK_TREE_MODEL(self->priv->list_store_diff_files);
- GtkTreePath *path = gtk_tree_model_get_path(model, &it);
+ GtkTreeModel *model = GTK_TREE_MODEL (self->priv->list_store_diff_files);
+ GtkTreePath *path = gtk_tree_model_get_path (model, &it);
- gtk_tree_model_row_changed(model, path, &it);
- gtk_tree_path_free(path);
+ gtk_tree_model_row_changed (model, path, &it);
+ gtk_tree_path_free (path);
}
}
else
{
/* Insert in cached headers */
- CachedHeader *header = g_slice_new(CachedHeader);
+ CachedHeader *header = g_slice_new (CachedHeader);
header->iter = *iter;
- self->priv->cached_headers = g_slist_prepend(self->priv->cached_headers, header);
+ self->priv->cached_headers = g_slist_prepend (self->priv->cached_headers, header);
}
}
@@ -884,26 +1118,38 @@ typedef struct
} ForeachSelectionData;
static gboolean
-foreach_selection_changed(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, ForeachSelectionData *data)
+foreach_selection_changed (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ ForeachSelectionData *data)
{
- gboolean visible = data->numselected == 0 || gtk_tree_selection_path_is_selected(data->selection, path);
+ gboolean visible = data->numselected == 0 ||
+ gtk_tree_selection_path_is_selected (data->selection,
+ path);
DiffFile *f = NULL;
- gtk_tree_model_get(model, iter, 0, &f, -1);
+ gtk_tree_model_get (model, iter, 0, &f, -1);
if (f->visible)
{
- gitg_diff_iter_set_visible(&f->iter, visible);
+ gitg_diff_iter_set_visible (&f->iter, visible);
}
- diff_file_unref(f);
+ diff_file_unref (f);
return FALSE;
}
-static void
-on_diff_files_selection_changed(GtkTreeSelection *selection, GitgRevisionView *self)
+static void
+on_diff_files_selection_changed (GtkTreeSelection *selection,
+ GitgRevisionView *self)
{
- ForeachSelectionData data = {gtk_tree_selection_count_selected_rows(selection), selection};
- gtk_tree_model_foreach(gtk_tree_view_get_model(self->priv->diff_files), (GtkTreeModelForeachFunc)foreach_selection_changed, &data);
+ ForeachSelectionData data = {
+ gtk_tree_selection_count_selected_rows (selection),
+ selection
+ };
+
+ gtk_tree_model_foreach (gtk_tree_view_get_model (self->priv->diff_files),
+ (GtkTreeModelForeachFunc)foreach_selection_changed,
+ &data);
}
diff --git a/gitg/gitg-window.c b/gitg/gitg-window.c
index 72994ab..a847ff2 100644
--- a/gitg/gitg-window.c
+++ b/gitg/gitg-window.c
@@ -101,13 +101,18 @@ struct _GitgWindowPrivate
GitgRef *popup_refs[2];
GList *branch_actions;
- Hash select_on_load;
+ GitgHash select_on_load;
};
-static gboolean on_tree_view_motion(GtkTreeView *treeview, GdkEventMotion *event, GitgWindow *window);
-static gboolean on_tree_view_button_release(GtkTreeView *treeview, GdkEventButton *event, GitgWindow *window);
+static gboolean on_tree_view_motion (GtkTreeView *treeview,
+ GdkEventMotion *event,
+ GitgWindow *window);
-static void gitg_window_buildable_iface_init(GtkBuildableIface *iface);
+static gboolean on_tree_view_button_release (GtkTreeView *treeview,
+ GdkEventButton *event,
+ GitgWindow *window);
+
+static void gitg_window_buildable_iface_init (GtkBuildableIface *iface);
void on_subject_activate (GtkAction *action, GitgWindow *window);
void on_author_activate (GtkAction *action, GitgWindow *window);
@@ -144,14 +149,17 @@ static GtkBuildableIface parent_iface;
static GtkWindowClass *parent_class = NULL;
static void
-on_branch_action_runner_end (GitgRunner *runner, gboolean cancelled, GitgWindow *window)
+on_branch_action_runner_end (GitgRunner *runner,
+ gboolean cancelled,
+ GitgWindow *window)
{
window->priv->branch_actions = g_list_remove (window->priv->branch_actions, runner);
g_object_unref (runner);
}
gboolean
-gitg_window_add_branch_action (GitgWindow *window, GitgRunner *runner)
+gitg_window_add_branch_action (GitgWindow *window,
+ GitgRunner *runner)
{
if (runner != NULL && gitg_runner_running (runner))
{
@@ -169,12 +177,12 @@ gitg_window_add_branch_action (GitgWindow *window, GitgRunner *runner)
}
static void
-gitg_window_finalize(GObject *object)
+gitg_window_finalize (GObject *object)
{
GitgWindow *self = GITG_WINDOW(object);
- g_timer_destroy(self->priv->load_timer);
- gdk_cursor_unref(self->priv->hand);
+ g_timer_destroy (self->priv->load_timer);
+ gdk_cursor_unref (self->priv->hand);
GList *copy = g_list_copy (self->priv->branch_actions);
GList *item;
@@ -186,29 +194,37 @@ gitg_window_finalize(GObject *object)
g_list_free (copy);
- G_OBJECT_CLASS(gitg_window_parent_class)->finalize(object);
+ G_OBJECT_CLASS(gitg_window_parent_class)->finalize (object);
}
static void
-on_selection_changed(GtkTreeSelection *selection, GitgWindow *window)
+on_selection_changed (GtkTreeSelection *selection,
+ GitgWindow *window)
{
GtkTreeModel *model;
GtkTreeIter iter;
GitgRevision *revision = NULL;
- if (gtk_tree_selection_get_selected(selection, &model, &iter))
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
gtk_tree_model_get (GTK_TREE_MODEL(model), &iter, 0, &revision, -1);
}
- gitg_revision_view_update(window->priv->revision_view, window->priv->repository, revision);
- gitg_revision_tree_view_update(window->priv->revision_tree_view, window->priv->repository, revision);
+ gitg_revision_view_update (window->priv->revision_view,
+ window->priv->repository,
+ revision);
+
+ gitg_revision_tree_view_update (window->priv->revision_tree_view,
+ window->priv->repository,
+ revision);
if (revision)
{
if (gitg_repository_get_loaded (window->priv->repository))
{
- memcpy (window->priv->select_on_load, gitg_revision_get_hash (revision), HASH_BINARY_SIZE);
+ memcpy (window->priv->select_on_load,
+ gitg_revision_get_hash (revision),
+ GITG_HASH_BINARY_SIZE);
}
gitg_revision_unref (revision);
@@ -217,160 +233,226 @@ on_selection_changed(GtkTreeSelection *selection, GitgWindow *window)
{
if (gitg_repository_get_loaded (window->priv->repository))
{
- memset (window->priv->select_on_load, 0, HASH_BINARY_SIZE);
+ memset (window->priv->select_on_load, 0, GITG_HASH_BINARY_SIZE);
}
}
}
static void
-on_search_icon_release(GtkEntry *entry, GtkEntryIconPosition icon_pos, int button, GitgWindow *window)
+on_search_icon_release (GtkEntry *entry,
+ GtkEntryIconPosition icon_pos,
+ int button,
+ GitgWindow *window)
{
- gtk_menu_popup(GTK_MENU(window->priv->search_popup), NULL, NULL, NULL, NULL, button, gtk_get_current_event_time());
+ gtk_menu_popup (GTK_MENU(window->priv->search_popup),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ button,
+ gtk_get_current_event_time ());
}
static void
-search_column_activate(GtkAction *action, gint column, GtkTreeView *tree_view)
+search_column_activate (GtkAction *action,
+ gint column,
+ GtkTreeView *tree_view)
{
- if (!gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))
+ if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION(action)))
+ {
return;
+ }
- gtk_tree_view_set_search_column(tree_view, column);
+ gtk_tree_view_set_search_column (tree_view, column);
}
void
-on_subject_activate(GtkAction *action, GitgWindow *window)
+on_subject_activate (GtkAction *action,
+ GitgWindow *window)
{
- search_column_activate(action, 1, window->priv->tree_view);
+ search_column_activate (action, 1, window->priv->tree_view);
}
void
-on_author_activate(GtkAction *action, GitgWindow *window)
+on_author_activate (GtkAction *action,
+ GitgWindow *window)
{
- search_column_activate(action, 2, window->priv->tree_view);
+ search_column_activate (action, 2, window->priv->tree_view);
}
void
-on_date_activate(GtkAction *action, GitgWindow *window)
+on_date_activate (GtkAction *action,
+ GitgWindow *window)
{
- search_column_activate(action, 3, window->priv->tree_view);
+ search_column_activate (action, 3, window->priv->tree_view);
}
void
-on_hash_activate(GtkAction *action, GitgWindow *window)
+on_hash_activate (GtkAction *action,
+ GitgWindow *window)
{
- search_column_activate(action, 4, window->priv->tree_view);
+ search_column_activate (action, 4, window->priv->tree_view);
}
static gboolean
-search_hash_equal_func(GtkTreeModel *model, gchar const *key, GtkTreeIter *iter)
+search_hash_equal_func (GtkTreeModel *model,
+ gchar const *key,
+ GtkTreeIter *iter)
{
GitgRevision *rv;
- gtk_tree_model_get(model, iter, 0, &rv, -1);
+ gtk_tree_model_get (model, iter, 0, &rv, -1);
- gchar *sha = gitg_revision_get_sha1(rv);
-
- gboolean ret = !g_str_has_prefix(sha, key);
-
- g_free(sha);
- gitg_revision_unref(rv);
+ gchar *sha = gitg_revision_get_sha1 (rv);
+
+ gboolean ret = !g_str_has_prefix (sha, key);
+
+ g_free (sha);
+ gitg_revision_unref (rv);
return ret;
}
static gboolean
-search_equal_func(GtkTreeModel *model, gint column, gchar const *key, GtkTreeIter *iter, gpointer userdata)
+search_equal_func (GtkTreeModel *model,
+ gint column,
+ gchar const *key,
+ GtkTreeIter *iter,
+ gpointer userdata)
{
if (column == 4)
- return search_hash_equal_func(model, key, iter);
+ {
+ return search_hash_equal_func (model, key, iter);
+ }
gchar *cmp;
- gtk_tree_model_get(model, iter, column, &cmp, -1);
+ gtk_tree_model_get (model, iter, column, &cmp, -1);
- gchar *s1 = g_utf8_casefold(key, -1);
- gchar *s2 = g_utf8_casefold(cmp, -1);
+ gchar *s1 = g_utf8_casefold (key, -1);
+ gchar *s2 = g_utf8_casefold (cmp, -1);
- gboolean ret = strstr(s2, s1) == NULL;
+ gboolean ret = strstr (s2, s1) == NULL;
- g_free(s1);
- g_free(s2);
+ g_free (s1);
+ g_free (s2);
- g_free(cmp);
+ g_free (cmp);
return ret;
}
static void
-focus_search(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType modifier, gpointer userdata)
+focus_search (GtkAccelGroup *group,
+ GObject *acceleratable,
+ guint keyval,
+ GdkModifierType modifier,
+ gpointer userdata)
{
- gtk_widget_grab_focus(GTK_WIDGET(userdata));
+ gtk_widget_grab_focus (GTK_WIDGET(userdata));
}
static void
-build_search_entry(GitgWindow *window, GtkBuilder *builder)
+build_search_entry (GitgWindow *window,
+ GtkBuilder *builder)
{
- GtkWidget *box = GTK_WIDGET(gtk_builder_get_object(builder, "hbox_top"));
- GtkWidget *entry = gtk_entry_new ();
+ GtkWidget *box;
+ GtkWidget *entry;
+ GtkWidget *popup;
+
+ box = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_top"));
+ entry = gtk_entry_new ();
- gtk_entry_set_icon_from_stock(GTK_ENTRY(entry), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND);
+ gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ GTK_STOCK_FIND);
- gtk_tree_view_set_search_entry(window->priv->tree_view, GTK_ENTRY(entry));
- gtk_widget_show(entry);
- gtk_box_pack_end(GTK_BOX(box), entry, FALSE, FALSE, 0);
+ gtk_tree_view_set_search_entry (window->priv->tree_view, GTK_ENTRY(entry));
+ gtk_widget_show (entry);
+ gtk_box_pack_end (GTK_BOX(box), entry, FALSE, FALSE, 0);
- window->priv->search_popup = GTK_WIDGET(g_object_ref(gtk_ui_manager_get_widget(window->priv->menus_ui_manager, "/ui/search_popup")));
+ popup = gtk_ui_manager_get_widget (window->priv->menus_ui_manager,
+ "/ui/search_popup");
- g_signal_connect(entry, "icon-release", G_CALLBACK(on_search_icon_release), window);
- gtk_tree_view_set_search_column(window->priv->tree_view, 1);
+ window->priv->search_popup = popup;
+ g_object_ref (popup);
- gtk_tree_view_set_search_equal_func(window->priv->tree_view, search_equal_func, window, NULL);
+ g_signal_connect (entry,
+ "icon-release",
+ G_CALLBACK(on_search_icon_release),
+ window);
- GtkAccelGroup *group = gtk_accel_group_new();
+ gtk_tree_view_set_search_column (window->priv->tree_view, 1);
- GClosure *closure = g_cclosure_new(G_CALLBACK(focus_search), entry, NULL);
- gtk_accel_group_connect(group, GDK_f, GDK_CONTROL_MASK, 0, closure);
- gtk_window_add_accel_group(GTK_WINDOW(window), group);
+ gtk_tree_view_set_search_equal_func (window->priv->tree_view,
+ search_equal_func,
+ window,
+ NULL);
+
+ GtkAccelGroup *group = gtk_accel_group_new ();
+
+ GClosure *closure = g_cclosure_new (G_CALLBACK (focus_search), entry, NULL);
+
+ gtk_accel_group_connect (group, GDK_f, GDK_CONTROL_MASK, 0, closure);
+ gtk_window_add_accel_group (GTK_WINDOW(window), group);
}
static void
-goto_hash(GitgWindow *window, gchar const *hash)
+goto_hash (GitgWindow *window,
+ gchar const *hash)
{
GtkTreeIter iter;
- if (!gitg_repository_find_by_hash(window->priv->repository, hash, &iter))
+ if (!gitg_repository_find_by_hash (window->priv->repository, hash, &iter))
+ {
return;
+ }
- gtk_tree_selection_select_iter(gtk_tree_view_get_selection(window->priv->tree_view), &iter);
+ gtk_tree_selection_select_iter (gtk_tree_view_get_selection (window->priv->tree_view),
+ &iter);
GtkTreePath *path;
- path = gtk_tree_model_get_path(GTK_TREE_MODEL(window->priv->repository), &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL(window->priv->repository),
+ &iter);
- gtk_tree_view_scroll_to_cell(window->priv->tree_view, path, NULL, TRUE, 0.5, 0);
- gtk_tree_path_free(path);
+ gtk_tree_view_scroll_to_cell (window->priv->tree_view,
+ path,
+ NULL,
+ TRUE,
+ 0.5,
+ 0);
+ gtk_tree_path_free (path);
}
static void
-on_parent_activated(GitgRevisionView *view, gchar *hash, GitgWindow *window)
+on_parent_activated (GitgRevisionView *view,
+ gchar *hash,
+ GitgWindow *window)
{
- goto_hash(window, hash);
+ goto_hash (window, hash);
}
static void
-on_renderer_path(GtkTreeViewColumn *column, GitgCellRendererPath *renderer, GtkTreeModel *model, GtkTreeIter *iter, GitgWindow *window)
+on_renderer_path (GtkTreeViewColumn *column,
+ GitgCellRendererPath *renderer,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ GitgWindow *window)
{
GitgRevision *rv;
- gtk_tree_model_get(model, iter, 0, &rv, -1);
+ gtk_tree_model_get (model, iter, 0, &rv, -1);
GtkTreeIter iter1 = *iter;
GitgRevision *next_revision = NULL;
- if (gtk_tree_model_iter_next(model, &iter1))
- gtk_tree_model_get(model, &iter1, 0, &next_revision, -1);
+ if (gtk_tree_model_iter_next (model, &iter1))
+ {
+ gtk_tree_model_get (model, &iter1, 0, &next_revision, -1);
+ }
GSList *labels;
const gchar *lbl = NULL;
- switch (gitg_revision_get_sign(rv))
+ switch (gitg_revision_get_sign (rv))
{
case 't':
lbl = "staged";
@@ -384,32 +466,37 @@ on_renderer_path(GtkTreeViewColumn *column, GitgCellRendererPath *renderer, GtkT
if (lbl != NULL)
{
- g_object_set(renderer, "style", PANGO_STYLE_ITALIC, NULL);
- labels = g_slist_append(NULL, gitg_ref_new(gitg_revision_get_hash(rv), lbl));
+ g_object_set (renderer, "style", PANGO_STYLE_ITALIC, NULL);
+ labels = g_slist_append (NULL,
+ gitg_ref_new (gitg_revision_get_hash (rv),
+ lbl));
}
else
{
- g_object_set(renderer, "style", PANGO_STYLE_NORMAL, NULL);
- labels = gitg_repository_get_refs_for_hash(GITG_REPOSITORY(model), gitg_revision_get_hash(rv));
+ g_object_set (renderer, "style", PANGO_STYLE_NORMAL, NULL);
+ labels = gitg_repository_get_refs_for_hash (GITG_REPOSITORY(model),
+ gitg_revision_get_hash (rv));
}
- g_object_set(renderer,
+ g_object_set (renderer,
"revision", rv,
"next_revision", next_revision,
"labels", labels,
NULL);
- gitg_revision_unref(next_revision);
- gitg_revision_unref(rv);
+ gitg_revision_unref (next_revision);
+ gitg_revision_unref (rv);
}
static gboolean
-branches_separator_func(GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
+branches_separator_func (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer data)
{
gchar *name;
GitgRef *ref;
- gtk_tree_model_get(model,
+ gtk_tree_model_get (model,
iter,
COLUMN_BRANCHES_NAME, &name,
COLUMN_BRANCHES_REF, &ref,
@@ -417,24 +504,27 @@ branches_separator_func(GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
gboolean ret = (name == NULL && ref == NULL);
- g_free(name);
- gitg_ref_free(ref);
+ g_free (name);
+ gitg_ref_free (ref);
return ret;
}
static void
-on_branches_combo_changed (GtkComboBox *combo, GitgWindow *window)
+on_branches_combo_changed (GtkComboBox *combo,
+ GitgWindow *window)
{
- if (gtk_combo_box_get_active(combo) < 2)
+ if (gtk_combo_box_get_active (combo) < 2)
+ {
return;
+ }
GtkTreeIter iter;
gchar **selection;
- gtk_combo_box_get_active_iter(combo, &iter);
+ gtk_combo_box_get_active_iter (combo, &iter);
- gtk_tree_model_get (gtk_combo_box_get_model(combo),
+ gtk_tree_model_get (gtk_combo_box_get_model (combo),
&iter,
COLUMN_BRANCHES_SELECTION, &selection,
-1);
@@ -447,65 +537,84 @@ on_branches_combo_changed (GtkComboBox *combo, GitgWindow *window)
}
static void
-build_branches_combo(GitgWindow *window, GtkBuilder *builder)
+build_branches_combo (GitgWindow *window,
+ GtkBuilder *builder)
{
- GtkComboBox *combo = GTK_COMBO_BOX(gtk_builder_get_object(builder, "combo_box_branches"));
- window->priv->branches_store = gtk_tree_store_new(4, G_TYPE_STRING, GITG_TYPE_REF, G_TYPE_STRING, G_TYPE_STRV);
+ GtkComboBox *combo;
+ window->priv->branches_store = gtk_tree_store_new (4,
+ G_TYPE_STRING,
+ GITG_TYPE_REF,
+ G_TYPE_STRING,
+ G_TYPE_STRV);
+
+ combo = GTK_COMBO_BOX (gtk_builder_get_object (builder,
+ "combo_box_branches"));
+
window->priv->combo_branches = combo;
GtkTreeIter iter;
- gtk_tree_store_append(window->priv->branches_store, &iter, NULL);
- gtk_tree_store_set(window->priv->branches_store,
+ gtk_tree_store_append (window->priv->branches_store, &iter, NULL);
+ gtk_tree_store_set (window->priv->branches_store,
&iter,
- COLUMN_BRANCHES_NAME, _("Select branch"),
+ COLUMN_BRANCHES_NAME, _ ("Select branch"),
COLUMN_BRANCHES_REF, NULL,
COLUMN_BRANCHES_SELECTION, NULL,
-1);
- gtk_combo_box_set_model(combo, GTK_TREE_MODEL(window->priv->branches_store));
- gtk_combo_box_set_active(combo, 0);
+ gtk_combo_box_set_model (combo, GTK_TREE_MODEL(window->priv->branches_store));
+ gtk_combo_box_set_active (combo, 0);
- gtk_combo_box_set_row_separator_func(combo, branches_separator_func, window, NULL);
+ gtk_combo_box_set_row_separator_func (combo,
+ branches_separator_func,
+ window,
+ NULL);
- g_signal_connect(combo, "changed", G_CALLBACK(on_branches_combo_changed), window);
+ g_signal_connect (combo,
+ "changed",
+ G_CALLBACK(on_branches_combo_changed),
+ window);
}
static void
-restore_state(GitgWindow *window)
+restore_state (GitgWindow *window)
{
- GitgSettings *settings = gitg_settings_get_default();
+ GitgSettings *settings = gitg_settings_get_default ();
gint dw;
gint dh;
- gtk_window_get_default_size(GTK_WINDOW(window), &dw, &dh);
+ gtk_window_get_default_size (GTK_WINDOW(window), &dw, &dh);
- gtk_window_set_default_size(GTK_WINDOW(window),
- gitg_settings_get_window_width(settings, dw),
- gitg_settings_get_window_height(settings, dh));
+ gtk_window_set_default_size (GTK_WINDOW(window),
+ gitg_settings_get_window_width (settings,
+ dw),
+ gitg_settings_get_window_height (settings,
+ dh));
gitg_utils_restore_pane_position (GTK_PANED(window->priv->vpaned_main),
- gitg_settings_get_vpaned_main_position(settings, -1),
+ gitg_settings_get_vpaned_main_position (settings, -1),
FALSE);
gitg_utils_restore_pane_position (GTK_PANED(window->priv->vpaned_commit),
- gitg_settings_get_vpaned_commit_position(settings, -1),
+ gitg_settings_get_vpaned_commit_position (settings, -1),
FALSE);
gitg_utils_restore_pane_position (GTK_PANED(window->priv->hpaned_commit1),
- gitg_settings_get_hpaned_commit1_position(settings, 200),
+ gitg_settings_get_hpaned_commit1_position (settings, 200),
FALSE);
gitg_utils_restore_pane_position (GTK_PANED(window->priv->hpaned_commit2),
- gitg_settings_get_hpaned_commit2_position(settings, 200),
+ gitg_settings_get_hpaned_commit2_position (settings, 200),
TRUE);
gitg_utils_restore_pane_position (GTK_PANED(window->priv->revision_tree_view),
- gitg_settings_get_revision_tree_view_position(settings, -1),
+ gitg_settings_get_revision_tree_view_position (settings, -1),
FALSE);
}
static void
-update_dnd_status (GitgWindow *window, GitgRef *source, GitgRef *dest)
+update_dnd_status (GitgWindow *window,
+ GitgRef *source,
+ GitgRef *dest)
{
if (!dest)
{
@@ -520,28 +629,28 @@ update_dnd_status (GitgWindow *window, GitgRef *source, GitgRef *dest)
if (source_type == GITG_REF_TYPE_BRANCH &&
dest_type== GITG_REF_TYPE_REMOTE)
{
- message = g_strdup_printf (_("Push local branch <%s> to remote branch <%s>"),
+ message = g_strdup_printf (_ ("Push local branch <%s> to remote branch <%s>"),
gitg_ref_get_shortname (source),
gitg_ref_get_shortname (dest));
}
else if (source_type == GITG_REF_TYPE_BRANCH &&
dest_type == GITG_REF_TYPE_BRANCH)
{
- message = g_strdup_printf (_("Merge/rebase local branch <%s> with/on local branch <%s>"),
+ message = g_strdup_printf (_ ("Merge/rebase local branch <%s> with/on local branch <%s>"),
gitg_ref_get_shortname (source),
gitg_ref_get_shortname (dest));
}
else if (source_type == GITG_REF_TYPE_REMOTE &&
dest_type == GITG_REF_TYPE_BRANCH)
{
- message = g_strdup_printf (_("Merge/rebase local branch <%s> with/on remote branch <%s>"),
+ message = g_strdup_printf (_ ("Merge/rebase local branch <%s> with/on remote branch <%s>"),
gitg_ref_get_shortname (dest),
gitg_ref_get_shortname (source));
}
else if (source_type == GITG_REF_TYPE_STASH &&
dest_type == GITG_REF_TYPE_BRANCH)
{
- message = g_strdup_printf (_("Apply stash to local branch <%s>"),
+ message = g_strdup_printf (_ ("Apply stash to local branch <%s>"),
gitg_ref_get_shortname (dest));
}
@@ -555,7 +664,10 @@ update_dnd_status (GitgWindow *window, GitgRef *source, GitgRef *dest)
}
static gboolean
-on_refs_dnd (GitgRef *source, GitgRef *dest, gboolean dropped, GitgWindow *window)
+on_refs_dnd (GitgRef *source,
+ GitgRef *dest,
+ gboolean dropped,
+ GitgWindow *window)
{
if (!dropped)
{
@@ -570,24 +682,37 @@ on_refs_dnd (GitgRef *source, GitgRef *dest, gboolean dropped, GitgWindow *windo
if (source_type == GITG_REF_TYPE_BRANCH &&
dest_type == GITG_REF_TYPE_REMOTE)
{
- ret = gitg_window_add_branch_action (window, gitg_branch_actions_push (window, source, dest));
+ ret = gitg_window_add_branch_action (window,
+ gitg_branch_actions_push (window,
+ source,
+ dest));
}
else if (source_type == GITG_REF_TYPE_STASH)
{
if (dest_type == GITG_REF_TYPE_BRANCH)
{
- ret = gitg_branch_actions_apply_stash (window, source, dest);
+ ret = gitg_branch_actions_apply_stash (window,
+ source,
+ dest);
}
}
else if (dest_type == GITG_REF_TYPE_BRANCH)
{
- GtkWidget *popup = gtk_ui_manager_get_widget (window->priv->menus_ui_manager,
- "/ui/dnd_popup");
+ GtkWidget *popup;
+
+ popup = gtk_ui_manager_get_widget (window->priv->menus_ui_manager,
+ "/ui/dnd_popup");
window->priv->popup_refs[0] = source;
window->priv->popup_refs[1] = dest;
- gtk_menu_popup (GTK_MENU (popup), NULL, NULL, NULL, NULL, 1, gtk_get_current_event_time());
+ gtk_menu_popup (GTK_MENU (popup),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 1,
+ gtk_get_current_event_time ());
}
gtk_statusbar_push (window->priv->statusbar, 0, "");
@@ -595,7 +720,9 @@ on_refs_dnd (GitgRef *source, GitgRef *dest, gboolean dropped, GitgWindow *windo
}
static void
-update_revision_dnd_status (GitgWindow *window, GitgRevision *source, GitgRef *dest)
+update_revision_dnd_status (GitgWindow *window,
+ GitgRevision *source,
+ GitgRef *dest)
{
if (!dest)
{
@@ -603,7 +730,7 @@ update_revision_dnd_status (GitgWindow *window, GitgRevision *source, GitgRef *d
}
else
{
- gchar *message = g_strdup_printf (_("Cherry-pick revision on <%s>"),
+ gchar *message = g_strdup_printf (_ ("Cherry-pick revision on <%s>"),
gitg_ref_get_shortname (dest));
gtk_statusbar_push (window->priv->statusbar, 0, message);
@@ -633,13 +760,22 @@ on_revision_dnd (GitgRevision *source,
}
static void
-init_tree_view (GitgWindow *window, GtkBuilder *builder)
+init_tree_view (GitgWindow *window,
+ GtkBuilder *builder)
{
- GtkTreeViewColumn *col = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder, "rv_column_subject"));
+ GtkTreeViewColumn *col;
+
+ col = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (builder,
+ "rv_column_subject"));
- window->priv->renderer_path = GITG_CELL_RENDERER_PATH(gtk_builder_get_object(builder, "rv_renderer_subject"));
+ window->priv->renderer_path = GITG_CELL_RENDERER_PATH (gtk_builder_get_object (builder,
+ "rv_renderer_subject"));
- gtk_tree_view_column_set_cell_data_func(col, GTK_CELL_RENDERER(window->priv->renderer_path), (GtkTreeCellDataFunc)on_renderer_path, window, NULL);
+ gtk_tree_view_column_set_cell_data_func (col,
+ GTK_CELL_RENDERER (window->priv->renderer_path),
+ (GtkTreeCellDataFunc)on_renderer_path,
+ window,
+ NULL);
gitg_dnd_enable (window->priv->tree_view,
(GitgDndCallback)on_refs_dnd,
@@ -661,79 +797,114 @@ on_main_layout_vertical_cb (GitgWindow *window)
}
static void
-gitg_window_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
+gitg_window_parser_finished (GtkBuildable *buildable,
+ GtkBuilder *builder)
{
if (parent_iface.parser_finished)
- parent_iface.parser_finished(buildable, builder);
+ parent_iface.parser_finished (buildable, builder);
// Store widgets
GitgWindow *window = GITG_WINDOW(buildable);
// Insert menu from second ui file
- GtkBuilder *b = gitg_utils_new_builder("gitg-ui.xml");
+ GtkBuilder *b = gitg_utils_new_builder ("gitg-ui.xml");
GtkUIManager *uiman = GTK_UI_MANAGER (gtk_builder_get_object (b, "uiman"));
- GtkRecentChooser *chooser = GTK_RECENT_CHOOSER(gtk_builder_get_object(b, "RecentOpenAction"));
- GtkRecentFilter *filter = gtk_recent_filter_new();
- gtk_recent_filter_add_group(filter, "gitg");
+ GtkRecentChooser *chooser = GTK_RECENT_CHOOSER(gtk_builder_get_object (b, "RecentOpenAction"));
+ GtkRecentFilter *filter = gtk_recent_filter_new ();
+ gtk_recent_filter_add_group (filter, "gitg");
- gtk_recent_chooser_add_filter(chooser, filter);
- gtk_recent_chooser_set_show_tips(chooser, TRUE);
+ gtk_recent_chooser_add_filter (chooser, filter);
+ gtk_recent_chooser_set_show_tips (chooser, TRUE);
GtkWidget *menu = gtk_ui_manager_get_widget (uiman, "/ui/menubar_main");
- GtkWidget *vbox = GTK_WIDGET(gtk_builder_get_object(builder, "vbox_main"));
+ GtkWidget *vbox = GTK_WIDGET(gtk_builder_get_object (builder, "vbox_main"));
- gtk_box_pack_start(GTK_BOX(vbox), menu, FALSE, FALSE, 0);
- gtk_box_reorder_child(GTK_BOX(vbox), menu, 0);
+ gtk_box_pack_start (GTK_BOX(vbox), menu, FALSE, FALSE, 0);
+ gtk_box_reorder_child (GTK_BOX(vbox), menu, 0);
gtk_window_add_accel_group (GTK_WINDOW (window), gtk_ui_manager_get_accel_group (uiman));
- window->priv->edit_group = GTK_ACTION_GROUP(gtk_builder_get_object(b, "action_group_menu_edit"));
- window->priv->repository_group = GTK_ACTION_GROUP(gtk_builder_get_object(b, "action_group_menu_repository"));
+ window->priv->edit_group = GTK_ACTION_GROUP(gtk_builder_get_object (b, "action_group_menu_edit"));
+ window->priv->repository_group = GTK_ACTION_GROUP(gtk_builder_get_object (b, "action_group_menu_repository"));
+
+ gtk_builder_connect_signals (b, window);
+ g_object_unref (b);
+
+ window->priv->vpaned_main = GTK_WIDGET (gtk_builder_get_object (builder,
+ "vpaned_main"));
+
+ window->priv->hpaned_commit1 = GTK_WIDGET (gtk_builder_get_object (builder,
+ "hpaned_commit1"));
+
+ window->priv->hpaned_commit2 = GTK_WIDGET (gtk_builder_get_object (builder,
+ "hpaned_commit2"));
+
+ window->priv->vpaned_commit = GTK_WIDGET (gtk_builder_get_object (builder,
+ "vpaned_commit"));
- gtk_builder_connect_signals(b, window);
- g_object_unref(b);
+ window->priv->notebook_main = GTK_NOTEBOOK (gtk_builder_get_object (builder,
+ "notebook_main"));
- window->priv->vpaned_main = GTK_WIDGET(gtk_builder_get_object(builder, "vpaned_main"));
- window->priv->hpaned_commit1 = GTK_WIDGET(gtk_builder_get_object(builder, "hpaned_commit1"));
- window->priv->hpaned_commit2 = GTK_WIDGET(gtk_builder_get_object(builder, "hpaned_commit2"));
- window->priv->vpaned_commit = GTK_WIDGET(gtk_builder_get_object(builder, "vpaned_commit"));
+ window->priv->tree_view = GTK_TREE_VIEW (gtk_builder_get_object (builder,
+ "tree_view_rv"));
- window->priv->notebook_main = GTK_NOTEBOOK(gtk_builder_get_object(builder, "notebook_main"));
- window->priv->tree_view = GTK_TREE_VIEW(gtk_builder_get_object(builder, "tree_view_rv"));
- window->priv->statusbar = GTK_STATUSBAR(gtk_builder_get_object(builder, "statusbar"));
- window->priv->revision_view = GITG_REVISION_VIEW(gtk_builder_get_object(builder, "revision_view"));
- window->priv->revision_tree_view = GITG_REVISION_TREE_VIEW(gtk_builder_get_object(builder, "revision_tree_view"));
- window->priv->commit_view = GITG_COMMIT_VIEW(gtk_builder_get_object(builder, "vpaned_commit"));
+ window->priv->statusbar = GTK_STATUSBAR (gtk_builder_get_object (builder,
+ "statusbar"));
- restore_state(window);
+ window->priv->revision_view = GITG_REVISION_VIEW (gtk_builder_get_object (builder,
+ "revision_view"));
+
+ window->priv->revision_tree_view = GITG_REVISION_TREE_VIEW (gtk_builder_get_object (builder,
+ "revision_tree_view"));
+
+ window->priv->commit_view = GITG_COMMIT_VIEW (gtk_builder_get_object (builder,
+ "vpaned_commit"));
+
+ restore_state (window);
init_tree_view (window, builder);
// Intialize branches
- build_branches_combo(window, builder);
+ build_branches_combo (window, builder);
// Get menus ui
- b = gitg_utils_new_builder("gitg-menus.xml");
- window->priv->menus_ui_manager = GTK_UI_MANAGER(g_object_ref(gtk_builder_get_object(b, "uiman")));
+ b = gitg_utils_new_builder ("gitg-menus.xml");
+ window->priv->menus_ui_manager = GTK_UI_MANAGER (g_object_ref (gtk_builder_get_object (b,
+ "uiman")));
gtk_builder_connect_signals (b, window);
g_object_unref (b);
// Create search entry
- build_search_entry(window, builder);
+ build_search_entry (window, builder);
- gtk_builder_connect_signals(builder, window);
+ gtk_builder_connect_signals (builder, window);
// Connect signals
- GtkTreeSelection *selection = gtk_tree_view_get_selection(window->priv->tree_view);
- g_signal_connect(selection, "changed", G_CALLBACK(on_selection_changed), window);
- g_signal_connect(window->priv->revision_view, "parent-activated", G_CALLBACK(on_parent_activated), window);
-
- g_signal_connect(window->priv->tree_view, "motion-notify-event", G_CALLBACK(on_tree_view_motion), window);
- g_signal_connect(window->priv->tree_view, "button-release-event", G_CALLBACK(on_tree_view_button_release), window);
+ GtkTreeSelection *selection = gtk_tree_view_get_selection (window->priv->tree_view);
+ g_signal_connect (selection,
+ "changed",
+ G_CALLBACK(on_selection_changed),
+ window);
+
+ g_signal_connect (window->priv->revision_view,
+ "parent-activated",
+ G_CALLBACK(on_parent_activated),
+ window);
+
+ g_signal_connect (window->priv->tree_view,
+ "motion-notify-event",
+ G_CALLBACK(on_tree_view_motion),
+ window);
+
+ g_signal_connect (window->priv->tree_view,
+ "button-release-event",
+ G_CALLBACK(on_tree_view_button_release),
+ window);
GitgPreferences *preferences = gitg_preferences_get_default ();
+
g_signal_connect_swapped (preferences,
"notify::main-layout-vertical",
G_CALLBACK (on_main_layout_vertical_cb),
@@ -743,7 +914,7 @@ gitg_window_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
}
static void
-gitg_window_buildable_iface_init(GtkBuildableIface *iface)
+gitg_window_buildable_iface_init (GtkBuildableIface *iface)
{
parent_iface = *iface;
@@ -751,9 +922,9 @@ gitg_window_buildable_iface_init(GtkBuildableIface *iface)
}
static void
-save_state(GitgWindow *window)
+save_state (GitgWindow *window)
{
- GitgSettings *settings = gitg_settings_get_default();
+ GitgSettings *settings = gitg_settings_get_default ();
GtkAllocation allocation;
gint position;
@@ -805,9 +976,10 @@ save_state(GitgWindow *window)
}
static gboolean
-gitg_window_delete_event (GtkWidget *widget, GdkEventAny *event)
+gitg_window_delete_event (GtkWidget *widget,
+ GdkEventAny *event)
{
- save_state(GITG_WINDOW (widget));
+ save_state (GITG_WINDOW (widget));
if (GTK_WIDGET_CLASS (parent_class)->delete_event)
{
@@ -821,22 +993,25 @@ gitg_window_delete_event (GtkWidget *widget, GdkEventAny *event)
}
static void
-gitg_window_destroy(GtkObject *object)
+gitg_window_destroy (GtkObject *object)
{
GitgWindow *window = GITG_WINDOW(object);
if (!window->priv->destroy_has_run)
{
- gtk_tree_view_set_model(window->priv->tree_view, NULL);
+ gtk_tree_view_set_model (window->priv->tree_view, NULL);
window->priv->destroy_has_run = TRUE;
}
if (GTK_OBJECT_CLASS(parent_class)->destroy)
- GTK_OBJECT_CLASS(parent_class)->destroy(object);
+ {
+ GTK_OBJECT_CLASS(parent_class)->destroy (object);
+ }
}
static gboolean
-gitg_window_window_state_event (GtkWidget *widget, GdkEventWindowState *event)
+gitg_window_window_state_event (GtkWidget *widget,
+ GdkEventWindowState *event)
{
GitgWindow *window = GITG_WINDOW(widget);
@@ -922,38 +1097,41 @@ gitg_window_class_init (GitgWindowClass *klass)
}
static void
-gitg_window_init(GitgWindow *self)
+gitg_window_init (GitgWindow *self)
{
self->priv = GITG_WINDOW_GET_PRIVATE(self);
- self->priv->load_timer = g_timer_new();
- self->priv->hand = gdk_cursor_new(GDK_HAND1);
+ self->priv->load_timer = g_timer_new ();
+ self->priv->hand = gdk_cursor_new (GDK_HAND1);
}
static void
-on_repository_loaded (GitgRepository *repository, GitgWindow *window)
+on_repository_loaded (GitgRepository *repository,
+ GitgWindow *window)
{
- gchar *msg = g_strdup_printf(_("Loaded %d revisions in %.2fs"),
- gtk_tree_model_iter_n_children(GTK_TREE_MODEL(window->priv->repository), NULL),
- g_timer_elapsed(window->priv->load_timer, NULL));
+ gchar *msg = g_strdup_printf (_ ("Loaded %d revisions in %.2fs"),
+ gtk_tree_model_iter_n_children (GTK_TREE_MODEL(window->priv->repository), NULL),
+ g_timer_elapsed (window->priv->load_timer, NULL));
- gtk_statusbar_push(window->priv->statusbar, 0, msg);
+ gtk_statusbar_push (window->priv->statusbar, 0, msg);
- g_free(msg);
+ g_free (msg);
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window->priv->tree_view)), NULL);
- Hash hash = {0,};
+ GitgHash hash = {0,};
- if (memcmp (window->priv->select_on_load, hash, HASH_BINARY_SIZE) != 0)
+ if (memcmp (window->priv->select_on_load, hash, GITG_HASH_BINARY_SIZE) != 0)
{
goto_hash (window, window->priv->select_on_load);
}
}
static void
-on_update (GitgRunner *loader, gchar **revisions, GitgWindow *window)
+on_update (GitgRunner *loader,
+ gchar **revisions,
+ GitgWindow *window)
{
- gchar *msg = g_strdup_printf (_("Loading %d revisions..."),
+ gchar *msg = g_strdup_printf (_ ("Loading %d revisions..."),
gtk_tree_model_iter_n_children (GTK_TREE_MODEL(window->priv->repository), NULL));
gtk_statusbar_push (window->priv->statusbar, 0, msg);
@@ -969,9 +1147,12 @@ gitg_window_set_select_on_load (GitgWindow *window,
return;
}
- gchar *resolved = gitg_repository_parse_ref (window->priv->repository, selection);
+ gchar *resolved;
- if (resolved && strlen (resolved) == HASH_SHA_SIZE)
+ resolved = gitg_repository_parse_ref (window->priv->repository,
+ selection);
+
+ if (resolved && strlen (resolved) == GITG_HASH_SHA_SIZE)
{
gitg_hash_sha1_to_hash (resolved, window->priv->select_on_load);
}
@@ -980,7 +1161,9 @@ gitg_window_set_select_on_load (GitgWindow *window,
}
static gboolean
-parse_gitg_uri (GFile *file, GFile **work_tree, gchar **selection)
+parse_gitg_uri (GFile *file,
+ GFile **work_tree,
+ gchar **selection)
{
if (selection)
{
@@ -1023,79 +1206,93 @@ parse_gitg_uri (GFile *file, GFile **work_tree, gchar **selection)
}
static gboolean
-convert_setting_to_inactive_max(GValue const *setting, GValue *value, gpointer userdata)
+convert_setting_to_inactive_max (GValue const *setting,
+ GValue *value,
+ gpointer userdata)
{
- g_return_val_if_fail(G_VALUE_HOLDS(setting, G_TYPE_INT), FALSE);
- g_return_val_if_fail(G_VALUE_HOLDS(value, G_TYPE_INT), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS(setting, G_TYPE_INT), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS(value, G_TYPE_INT), FALSE);
- gint s = g_value_get_int(setting);
- g_value_set_int(value, 2 + s * 8);
+ gint s = g_value_get_int (setting);
+ g_value_set_int (value, 2 + s * 8);
return TRUE;
}
static gboolean
-convert_setting_to_inactive_collapse(GValue const *setting, GValue *value, gpointer userdata)
+convert_setting_to_inactive_collapse (GValue const *setting,
+ GValue *value,
+ gpointer userdata)
{
- g_return_val_if_fail(G_VALUE_HOLDS(setting, G_TYPE_INT), FALSE);
- g_return_val_if_fail(G_VALUE_HOLDS(value, G_TYPE_INT), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS(setting, G_TYPE_INT), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS(value, G_TYPE_INT), FALSE);
- gint s = g_value_get_int(setting);
- g_value_set_int(value, 1 + s * 3);
+ gint s = g_value_get_int (setting);
+ g_value_set_int (value, 1 + s * 3);
return TRUE;
}
static gboolean
-convert_setting_to_inactive_gap(GValue const *setting, GValue *value, gpointer userdata)
+convert_setting_to_inactive_gap (GValue const *setting,
+ GValue *value,
+ gpointer userdata)
{
- g_return_val_if_fail(G_VALUE_HOLDS(setting, G_TYPE_INT), FALSE);
- g_return_val_if_fail(G_VALUE_HOLDS(value, G_TYPE_INT), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS(setting, G_TYPE_INT), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS(value, G_TYPE_INT), FALSE);
- g_value_set_int(value, 10);
+ g_value_set_int (value, 10);
return TRUE;
}
static gboolean
-convert_setting_to_inactive_enabled(GValue const *setting, GValue *value, gpointer userdata)
+convert_setting_to_inactive_enabled (GValue const *setting,
+ GValue *value,
+ gpointer userdata)
{
- g_return_val_if_fail(G_VALUE_HOLDS(setting, G_TYPE_BOOLEAN), FALSE);
- g_return_val_if_fail(G_VALUE_HOLDS(value, G_TYPE_BOOLEAN), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS(setting, G_TYPE_BOOLEAN), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS(value, G_TYPE_BOOLEAN), FALSE);
- gboolean s = g_value_get_boolean(setting);
- g_value_set_boolean(value, s);
+ gboolean s = g_value_get_boolean (setting);
+ g_value_set_boolean (value, s);
return TRUE;
}
static void
-bind_repository(GitgWindow *window)
+bind_repository (GitgWindow *window)
{
GitgPreferences *preferences;
if (window->priv->repository == NULL)
return;
- preferences = gitg_preferences_get_default();
-
- gitg_data_binding_new_full(preferences, "history-collapse-inactive-lanes",
- window->priv->repository, "inactive-max",
- convert_setting_to_inactive_max,
- window);
-
- gitg_data_binding_new_full(preferences, "history-collapse-inactive-lanes",
- window->priv->repository, "inactive-collapse",
- convert_setting_to_inactive_collapse,
- window);
-
- gitg_data_binding_new_full(preferences, "history-collapse-inactive-lanes",
- window->priv->repository, "inactive-gap",
- convert_setting_to_inactive_gap,
- window);
-
- gitg_data_binding_new_full(preferences, "history-collapse-inactive-lanes-active",
+ preferences = gitg_preferences_get_default ();
+
+ gitg_data_binding_new_full (preferences,
+ "history-collapse-inactive-lanes",
+ window->priv->repository,
+ "inactive-max",
+ convert_setting_to_inactive_max,
+ window);
+
+ gitg_data_binding_new_full (preferences,
+ "history-collapse-inactive-lanes",
+ window->priv->repository,
+ "inactive-collapse",
+ convert_setting_to_inactive_collapse,
+ window);
+
+ gitg_data_binding_new_full (preferences,
+ "history-collapse-inactive-lanes",
+ window->priv->repository,
+ "inactive-gap",
+ convert_setting_to_inactive_gap,
+ window);
+
+ gitg_data_binding_new_full (preferences, "history-collapse-inactive-lanes-active",
window->priv->repository, "inactive-enabled",
convert_setting_to_inactive_enabled,
window);
@@ -1125,7 +1322,8 @@ create_repository (GitgWindow *window,
}
static int
-sort_by_ref_type (GitgRef *a, GitgRef *b)
+sort_by_ref_type (GitgRef *a,
+ GitgRef *b)
{
if (gitg_ref_get_ref_type (a) == gitg_ref_get_ref_type (b))
{
@@ -1145,22 +1343,22 @@ sort_by_ref_type (GitgRef *a, GitgRef *b)
}
else
{
- return gitg_ref_get_ref_type(a) - gitg_ref_get_ref_type(b);
+ return gitg_ref_get_ref_type (a) - gitg_ref_get_ref_type (b);
}
}
static void
-clear_branches_combo(GitgWindow *window)
+clear_branches_combo (GitgWindow *window)
{
GtkTreeIter iter;
- if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(window->priv->branches_store), &iter, NULL, 1))
+ if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(window->priv->branches_store), &iter, NULL, 1))
{
- while (gtk_tree_store_remove(window->priv->branches_store, &iter))
+ while (gtk_tree_store_remove (window->priv->branches_store, &iter))
;
}
- gtk_combo_box_set_active(window->priv->combo_branches, 0);
+ gtk_combo_box_set_active (window->priv->combo_branches, 0);
}
static gboolean
@@ -1188,19 +1386,26 @@ equal_selection (gchar const **s1,
}
static void
-fill_branches_combo(GitgWindow *window)
+fill_branches_combo (GitgWindow *window)
{
if (!window->priv->repository)
+ {
return;
+ }
- guint children = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(window->priv->branches_store), NULL);
+ guint children;
+
+ children = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (window->priv->branches_store),
+ NULL);
if (children > 1)
+ {
return;
+ }
- GSList *refs = gitg_repository_get_refs(window->priv->repository);
+ GSList *refs = gitg_repository_get_refs (window->priv->repository);
- refs = g_slist_sort(refs, (GCompareFunc)sort_by_ref_type);
+ refs = g_slist_sort (refs, (GCompareFunc)sort_by_ref_type);
GSList *item;
GitgRefType prevtype = GITG_REF_TYPE_NONE;
@@ -1209,8 +1414,11 @@ fill_branches_combo(GitgWindow *window)
GitgRef *parentref = NULL;
GtkTreeStore *store = window->priv->branches_store;
- GitgRef *current_ref = gitg_repository_get_current_ref (window->priv->repository);
- GitgRef *working_ref = gitg_repository_get_current_working_ref (window->priv->repository);
+ GitgRef *current_ref;
+ GitgRef *working_ref;
+
+ current_ref = gitg_repository_get_current_ref (window->priv->repository);
+ working_ref = gitg_repository_get_current_working_ref (window->priv->repository);
gchar const **current_selection = gitg_repository_get_current_selection (window->priv->repository);
@@ -1221,44 +1429,46 @@ fill_branches_combo(GitgWindow *window)
{
GitgRef *ref = (GitgRef *)item->data;
- if (!(gitg_ref_get_ref_type(ref) == GITG_REF_TYPE_REMOTE ||
- gitg_ref_get_ref_type(ref) == GITG_REF_TYPE_BRANCH))
+ if (!(gitg_ref_get_ref_type (ref) == GITG_REF_TYPE_REMOTE ||
+ gitg_ref_get_ref_type (ref) == GITG_REF_TYPE_BRANCH))
+ {
continue;
+ }
- if (gitg_ref_get_ref_type(ref) != prevtype)
+ if (gitg_ref_get_ref_type (ref) != prevtype)
{
/* Insert separator */
- gtk_tree_store_append(store, &iter, NULL);
- gtk_tree_store_set(store,
+ gtk_tree_store_append (store, &iter, NULL);
+ gtk_tree_store_set (store,
&iter,
COLUMN_BRANCHES_NAME, NULL,
COLUMN_BRANCHES_REF, NULL,
COLUMN_BRANCHES_SELECTION, NULL,
-1);
- prevtype = gitg_ref_get_ref_type(ref);
+ prevtype = gitg_ref_get_ref_type (ref);
}
- if (gitg_ref_get_prefix(ref))
+ if (gitg_ref_get_prefix (ref))
{
- if (!parentref || !gitg_ref_equal_prefix(parentref, ref))
+ if (!parentref || !gitg_ref_equal_prefix (parentref, ref))
{
parentref = ref;
/* Add parent item */
- gtk_tree_store_append(store, &parent, NULL);
- gtk_tree_store_set(store,
+ gtk_tree_store_append (store, &parent, NULL);
+ gtk_tree_store_set (store,
&parent,
- COLUMN_BRANCHES_NAME, gitg_ref_get_prefix(ref),
+ COLUMN_BRANCHES_NAME, gitg_ref_get_prefix (ref),
COLUMN_BRANCHES_REF, NULL,
-1);
- if (gitg_ref_get_ref_type(ref) == GITG_REF_TYPE_REMOTE)
+ if (gitg_ref_get_ref_type (ref) == GITG_REF_TYPE_REMOTE)
{
/* Add remote icon */
- gtk_tree_store_set(store,
+ gtk_tree_store_set (store,
&parent,
- COLUMN_BRANCHES_ICON, g_strdup(GTK_STOCK_NETWORK),
+ COLUMN_BRANCHES_ICON, g_strdup (GTK_STOCK_NETWORK),
-1);
}
}
@@ -1277,7 +1487,7 @@ fill_branches_combo(GitgWindow *window)
gtk_tree_store_set (store,
&iter,
- COLUMN_BRANCHES_NAME, gitg_ref_get_shortname(ref),
+ COLUMN_BRANCHES_NAME, gitg_ref_get_shortname (ref),
COLUMN_BRANCHES_REF, ref,
COLUMN_BRANCHES_SELECTION, selection,
-1);
@@ -1319,10 +1529,10 @@ fill_branches_combo(GitgWindow *window)
NULL
};
- gtk_tree_store_append(store, &iter, NULL);
- gtk_tree_store_set(store,
+ gtk_tree_store_append (store, &iter, NULL);
+ gtk_tree_store_set (store,
&iter,
- COLUMN_BRANCHES_NAME, _("Local branches"),
+ COLUMN_BRANCHES_NAME, _ ("Local branches"),
COLUMN_BRANCHES_REF, NULL,
COLUMN_BRANCHES_SELECTION, selection,
-1);
@@ -1340,10 +1550,10 @@ fill_branches_combo(GitgWindow *window)
selection[0] = "--all";
- gtk_tree_store_append(store, &iter, NULL);
- gtk_tree_store_set(store,
+ gtk_tree_store_append (store, &iter, NULL);
+ gtk_tree_store_set (store,
&iter,
- COLUMN_BRANCHES_NAME, _("All branches"),
+ COLUMN_BRANCHES_NAME, _ ("All branches"),
COLUMN_BRANCHES_REF, NULL,
COLUMN_BRANCHES_SELECTION, selection,
-1);
@@ -1370,8 +1580,8 @@ fill_branches_combo(GitgWindow *window)
gtk_combo_box_set_active_iter (window->priv->combo_branches, &active);
}
- g_slist_foreach(refs, (GFunc)gitg_ref_free, NULL);
- g_slist_free(refs);
+ g_slist_foreach (refs, (GFunc)gitg_ref_free, NULL);
+ g_slist_free (refs);
if (active_from_selection)
{
@@ -1389,7 +1599,7 @@ update_window_title (GitgWindow *window)
{
if (!window->priv->repository)
{
- gtk_window_set_title (GTK_WINDOW (window), _("gitg"));
+ gtk_window_set_title (GTK_WINDOW (window), _ ("gitg"));
return;
}
@@ -1403,7 +1613,7 @@ update_window_title (GitgWindow *window)
GFile *work_tree = gitg_repository_get_work_tree (window->priv->repository);
gchar *basename = g_file_get_basename (work_tree);
- gchar *title = g_strconcat (_("gitg"), " - ", basename, refname, NULL);
+ gchar *title = g_strconcat (_ ("gitg"), " - ", basename, refname, NULL);
gtk_window_set_title (GTK_WINDOW (window), title);
@@ -1414,13 +1624,14 @@ update_window_title (GitgWindow *window)
}
static void
-on_repository_load (GitgRepository *repository, GitgWindow *window)
+on_repository_load (GitgRepository *repository,
+ GitgWindow *window)
{
GdkCursor *cursor = gdk_cursor_new (GDK_WATCH);
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window->priv->tree_view)), cursor);
gdk_cursor_unref (cursor);
- gtk_statusbar_push (window->priv->statusbar, 0, _("Begin loading repository"));
+ gtk_statusbar_push (window->priv->statusbar, 0, _ ("Begin loading repository"));
g_timer_reset (window->priv->load_timer);
g_timer_start (window->priv->load_timer);
@@ -1472,16 +1683,16 @@ update_sensitivity (GitgWindow *window)
}
static gboolean
-load_repository (GitgWindow *window,
- GFile *git_dir,
- GFile *work_tree,
- gint argc,
+load_repository (GitgWindow *window,
+ GFile *git_dir,
+ GFile *work_tree,
+ gint argc,
gchar const **argv,
- gchar const *selection)
+ gchar const *selection)
{
if (window->priv->repository)
{
- gtk_tree_view_set_model(window->priv->tree_view, NULL);
+ gtk_tree_view_set_model (window->priv->tree_view, NULL);
g_signal_handlers_disconnect_by_func (window->priv->repository,
G_CALLBACK (on_repository_load),
@@ -1496,7 +1707,7 @@ load_repository (GitgWindow *window,
gitg_repository_dialog_close ();
- memset (window->priv->select_on_load, 0, HASH_BINARY_SIZE);
+ memset (window->priv->select_on_load, 0, GITG_HASH_BINARY_SIZE);
}
if ((git_dir || work_tree) &&
@@ -1553,12 +1764,12 @@ load_repository (GitgWindow *window,
}
gboolean
-gitg_window_load_repository (GitgWindow *window,
- GFile *git_dir,
- GFile *work_tree,
- gint argc,
+gitg_window_load_repository (GitgWindow *window,
+ GFile *git_dir,
+ GFile *work_tree,
+ gint argc,
gchar const **argv,
- gchar const *selection)
+ gchar const *selection)
{
g_return_val_if_fail (GITG_IS_WINDOW (window), FALSE);
@@ -1603,10 +1814,10 @@ find_dot_git (GFile *location)
}
static gboolean
-load_repository_for_command_line (GitgWindow *window,
- gint argc,
+load_repository_for_command_line (GitgWindow *window,
+ gint argc,
gchar const **argv,
- gchar const *selection)
+ gchar const *selection)
{
gboolean ret = FALSE;
GFile *git_dir = NULL;
@@ -1668,10 +1879,10 @@ load_repository_for_command_line (GitgWindow *window,
}
gboolean
-gitg_window_load_repository_for_command_line (GitgWindow *window,
- gint argc,
+gitg_window_load_repository_for_command_line (GitgWindow *window,
+ gint argc,
gchar const **argv,
- gchar const *selection)
+ gchar const *selection)
{
gboolean ret;
@@ -1719,31 +1930,32 @@ gitg_window_load_repository_for_command_line (GitgWindow *window,
}
void
-gitg_window_show_commit(GitgWindow *window)
+gitg_window_show_commit (GitgWindow *window)
{
- g_return_if_fail(GITG_IS_WINDOW(window));
+ g_return_if_fail (GITG_IS_WINDOW(window));
- gtk_notebook_set_current_page(window->priv->notebook_main, 1);
+ gtk_notebook_set_current_page (window->priv->notebook_main, 1);
}
GitgRepository *
-gitg_window_get_repository(GitgWindow *window)
+gitg_window_get_repository (GitgWindow *window)
{
- g_return_val_if_fail(GITG_IS_WINDOW(window), NULL);
+ g_return_val_if_fail (GITG_IS_WINDOW(window), NULL);
return window->priv->repository;
}
void
-on_file_quit( GtkAction *action, GitgWindow *window)
+on_file_quit (GtkAction *action,
+ GitgWindow *window)
{
- gtk_main_quit();
+ gtk_main_quit ();
}
static void
on_open_dialog_response (GtkFileChooser *dialog,
- gint response,
- GitgWindow *window)
+ gint response,
+ GitgWindow *window)
{
if (response != GTK_RESPONSE_ACCEPT)
{
@@ -1760,15 +1972,16 @@ on_open_dialog_response (GtkFileChooser *dialog,
}
void
-on_file_open (GtkAction *action, GitgWindow *window)
+on_file_open (GtkAction *action,
+ GitgWindow *window)
{
if (window->priv->open_dialog)
{
- gtk_window_present(GTK_WINDOW(window->priv->open_dialog));
+ gtk_window_present (GTK_WINDOW(window->priv->open_dialog));
return;
}
- window->priv->open_dialog = gtk_file_chooser_dialog_new (_("Open git repository"),
+ window->priv->open_dialog = gtk_file_chooser_dialog_new (_ ("Open git repository"),
GTK_WINDOW (window),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL,
@@ -1777,39 +1990,43 @@ on_file_open (GtkAction *action, GitgWindow *window)
GTK_RESPONSE_ACCEPT,
NULL);
- gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(window->priv->open_dialog), TRUE);
- g_object_add_weak_pointer(G_OBJECT(window->priv->open_dialog), (gpointer *)&(window->priv->open_dialog));
- gtk_window_present(GTK_WINDOW(window->priv->open_dialog));
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER(window->priv->open_dialog), TRUE);
+ g_object_add_weak_pointer (G_OBJECT(window->priv->open_dialog), (gpointer *)&(window->priv->open_dialog));
+ gtk_window_present (GTK_WINDOW(window->priv->open_dialog));
- g_signal_connect(window->priv->open_dialog, "response", G_CALLBACK(on_open_dialog_response), window);
+ g_signal_connect (window->priv->open_dialog, "response", G_CALLBACK(on_open_dialog_response), window);
}
void
-on_edit_copy (GtkAction *action, GitgWindow *window)
+on_edit_copy (GtkAction *action,
+ GitgWindow *window)
{
- GtkWidget *focus = gtk_window_get_focus (GTK_WINDOW(window));
+ GtkWidget *focus = gtk_window_get_focus (GTK_WINDOW (window));
g_signal_emit_by_name (focus, "copy-clipboard", 0);
}
void
-on_edit_cut (GtkAction *action, GitgWindow *window)
+on_edit_cut (GtkAction *action,
+ GitgWindow *window)
{
- GtkWidget *focus = gtk_window_get_focus(GTK_WINDOW(window));
+ GtkWidget *focus = gtk_window_get_focus (GTK_WINDOW (window));
- g_signal_emit_by_name(focus, "cut-clipboard", 0);
+ g_signal_emit_by_name (focus, "cut-clipboard", 0);
}
void
-on_edit_paste (GtkAction *action, GitgWindow *window)
+on_edit_paste (GtkAction *action,
+ GitgWindow *window)
{
- GtkWidget *focus = gtk_window_get_focus(GTK_WINDOW(window));
+ GtkWidget *focus = gtk_window_get_focus (GTK_WINDOW (window));
- g_signal_emit_by_name(focus, "paste-clipboard", 0);
+ g_signal_emit_by_name (focus, "paste-clipboard", 0);
}
void
-on_view_refresh (GtkAction *action, GitgWindow *window)
+on_view_refresh (GtkAction *action,
+ GitgWindow *window)
{
if (window->priv->repository &&
gitg_repository_exists (window->priv->repository))
@@ -1819,7 +2036,8 @@ on_view_refresh (GtkAction *action, GitgWindow *window)
}
void
-on_recent_open (GtkRecentChooser *chooser, GitgWindow *window)
+on_recent_open (GtkRecentChooser *chooser,
+ GitgWindow *window)
{
gchar *uri = gtk_recent_chooser_get_current_uri (chooser);
GFile *work_tree = g_file_new_for_uri (uri);
@@ -1831,13 +2049,17 @@ on_recent_open (GtkRecentChooser *chooser, GitgWindow *window)
}
static void
-url_activate_hook (GtkAboutDialog *dialog, gchar const *link, gpointer data)
+url_activate_hook (GtkAboutDialog *dialog,
+ gchar const *link,
+ gpointer data)
{
gtk_show_uri (NULL, link, GDK_CURRENT_TIME, NULL);
}
static void
-email_activate_hook (GtkAboutDialog *dialog, gchar const *link, gpointer data)
+email_activate_hook (GtkAboutDialog *dialog,
+ gchar const *link,
+ gpointer data)
{
gchar *uri;
gchar *escaped;
@@ -1852,12 +2074,13 @@ email_activate_hook (GtkAboutDialog *dialog, gchar const *link, gpointer data)
}
void
-on_help_about (GtkAction *action, GitgWindow *window)
+on_help_about (GtkAction *action,
+ GitgWindow *window)
{
static gchar const copyright[] = "Copyright \xc2\xa9 2009 Jesse van den Kieboom";
static gchar const *authors[] = {"Jesse van den Kieboom <jessevdk gnome org>", NULL};
- static gchar const *comments = N_("gitg is a git repository viewer for gtk+/GNOME");
- static gchar const *license = N_("This program is free software; you can redistribute it and/or modify\n"
+ static gchar const *comments = N_ ("gitg is a git repository viewer for gtk+/GNOME");
+ static gchar const *license = N_ ("This program is free software; you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation; either version 2 of the License, or\n"
"(at your option) any later version.\n"
@@ -1889,11 +2112,11 @@ on_help_about (GtkAction *action, GitgWindow *window)
gtk_show_about_dialog (GTK_WINDOW(window),
"authors", authors,
"copyright", copyright,
- "comments", _(comments),
+ "comments", _ (comments),
"version", VERSION,
"website", "http://trac.novowork.com/gitg",
"logo", pixbuf,
- "license", _(license),
+ "license", _ (license),
NULL);
if (pixbuf)
@@ -1903,22 +2126,25 @@ on_help_about (GtkAction *action, GitgWindow *window)
}
static gboolean
-find_lane_boundary(GitgWindow *window, GtkTreePath *path, gint cell_x, gchar const **hash)
+find_lane_boundary (GitgWindow *window,
+ GtkTreePath *path,
+ gint cell_x,
+ gchar const **hash)
{
GtkTreeModel *model = GTK_TREE_MODEL(window->priv->repository);
GtkTreeIter iter;
guint width;
GitgRevision *revision;
- gtk_tree_model_get_iter(model, &iter, path);
- gtk_tree_model_get(model, &iter, 0, &revision, -1);
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, 0, &revision, -1);
/* Determine lane at cell_x */
- g_object_get(window->priv->renderer_path, "lane-width", &width, NULL);
+ g_object_get (window->priv->renderer_path, "lane-width", &width, NULL);
guint laneidx = cell_x / width;
- GSList *lanes = gitg_revision_get_lanes(revision);
- GitgLane *lane = (GitgLane *)g_slist_nth_data(lanes, laneidx);
+ GSList *lanes = gitg_revision_get_lanes (revision);
+ GitgLane *lane = (GitgLane *)g_slist_nth_data (lanes, laneidx);
gboolean ret;
if (lane && GITG_IS_LANE_BOUNDARY(lane))
@@ -1933,45 +2159,57 @@ find_lane_boundary(GitgWindow *window, GtkTreePath *path, gint cell_x, gchar con
ret = FALSE;
}
- gitg_revision_unref(revision);
+ gitg_revision_unref (revision);
return ret;
}
static gboolean
-is_boundary_from_event(GitgWindow *window, GdkEventAny *event, gint x, gint y, gchar const **hash)
+is_boundary_from_event (GitgWindow *window,
+ GdkEventAny *event,
+ gint x,
+ gint y,
+ gchar const **hash)
{
GtkTreePath *path;
GtkTreeViewColumn *column;
gint cell_x;
gint cell_y;
- if (event->window != gtk_tree_view_get_bin_window(window->priv->tree_view))
+ if (event->window != gtk_tree_view_get_bin_window (window->priv->tree_view))
return FALSE;
- gtk_tree_view_get_path_at_pos(window->priv->tree_view, x, y, &path, &column, &cell_x, &cell_y);
+ gtk_tree_view_get_path_at_pos (window->priv->tree_view,
+ x,
+ y,
+ &path,
+ &column,
+ &cell_x,
+ &cell_y);
if (!path)
return FALSE;
/* First check on correct column */
- if (gtk_tree_view_get_column(window->priv->tree_view, 0) != column)
+ if (gtk_tree_view_get_column (window->priv->tree_view, 0) != column)
{
if (path)
- gtk_tree_path_free(path);
+ gtk_tree_path_free (path);
return FALSE;
}
/* Check for lanes that have TYPE_END or TYPE_START and where the mouse
is actually placed */
- gboolean ret = find_lane_boundary(window, path, cell_x, hash);
- gtk_tree_path_free(path);
+ gboolean ret = find_lane_boundary (window, path, cell_x, hash);
+ gtk_tree_path_free (path);
return ret;
}
static gboolean
-on_tree_view_motion(GtkTreeView *treeview, GdkEventMotion *event, GitgWindow *window)
+on_tree_view_motion (GtkTreeView *treeview,
+ GdkEventMotion *event,
+ GitgWindow *window)
{
GdkWindow *win;
@@ -1990,34 +2228,47 @@ on_tree_view_motion(GtkTreeView *treeview, GdkEventMotion *event, GitgWindow *wi
}
static gboolean
-on_tree_view_button_release(GtkTreeView *treeview, GdkEventButton *event, GitgWindow *window)
+on_tree_view_button_release (GtkTreeView *treeview,
+ GdkEventButton *event,
+ GitgWindow *window)
{
if (event->button != 1)
+ {
return FALSE;
+ }
gchar const *hash;
- if (!is_boundary_from_event(window, (GdkEventAny *)event, event->x, event->y, &hash))
+ if (!is_boundary_from_event (window,
+ (GdkEventAny *)event,
+ event->x,
+ event->y,
+ &hash))
+ {
return FALSE;
+ }
- goto_hash(window, hash);
+ goto_hash (window, hash);
return TRUE;
}
void
-on_edit_preferences (GtkAction *action, GitgWindow *window)
+on_edit_preferences (GtkAction *action,
+ GitgWindow *window)
{
gitg_preferences_dialog_present (GTK_WINDOW(window));
}
void
-on_repository_properties (GtkAction *action, GitgWindow *window)
+on_repository_properties (GtkAction *action,
+ GitgWindow *window)
{
gitg_repository_dialog_present (window);
}
static void
-on_push_activated (GtkAction *action, GitgWindow *window)
+on_push_activated (GtkAction *action,
+ GitgWindow *window)
{
gchar const *remote = g_object_get_data (G_OBJECT (action),
DYNAMIC_ACTION_DATA_REMOTE_KEY);
@@ -2029,7 +2280,8 @@ on_push_activated (GtkAction *action, GitgWindow *window)
}
static void
-on_rebase_activated (GtkAction *action, GitgWindow *window)
+on_rebase_activated (GtkAction *action,
+ GitgWindow *window)
{
GitgRef *dest = g_object_get_data (G_OBJECT (action),
DYNAMIC_ACTION_DATA_KEY);
@@ -2041,7 +2293,8 @@ on_rebase_activated (GtkAction *action, GitgWindow *window)
}
static void
-on_merge_activated (GtkAction *action, GitgWindow *window)
+on_merge_activated (GtkAction *action,
+ GitgWindow *window)
{
GitgRef *dest = g_object_get_data (G_OBJECT (action),
DYNAMIC_ACTION_DATA_KEY);
@@ -2053,7 +2306,8 @@ on_merge_activated (GtkAction *action, GitgWindow *window)
}
static void
-on_stash_activated (GtkAction *action, GitgWindow *window)
+on_stash_activated (GtkAction *action,
+ GitgWindow *window)
{
GitgRef *dest = g_object_get_data (G_OBJECT (action),
DYNAMIC_ACTION_DATA_KEY);
@@ -2062,7 +2316,10 @@ on_stash_activated (GtkAction *action, GitgWindow *window)
}
static void
-get_tracked_ref (GitgWindow *window, GitgRef *branch, gchar **retremote, gchar **retbranch)
+get_tracked_ref (GitgWindow *window,
+ GitgRef *branch,
+ gchar **retremote,
+ gchar **retbranch)
{
GitgConfig *config = gitg_config_new (window->priv->repository);
gchar *merge;
@@ -2101,7 +2358,9 @@ get_tracked_ref (GitgWindow *window, GitgRef *branch, gchar **retremote, gchar *
}
static gboolean
-repository_has_ref (GitgWindow *window, gchar const *remote, gchar const *branch)
+repository_has_ref (GitgWindow *window,
+ gchar const *remote,
+ gchar const *branch)
{
GSList *refs = gitg_repository_get_refs (window->priv->repository);
gchar *combined = g_strconcat (remote, "/", branch, NULL);
@@ -2125,10 +2384,10 @@ repository_has_ref (GitgWindow *window, gchar const *remote, gchar const *branch
}
static void
-add_push_action (GitgWindow *window,
+add_push_action (GitgWindow *window,
GtkActionGroup *group,
- gchar const *remote,
- gchar const *branch)
+ gchar const *remote,
+ gchar const *branch)
{
gchar *acname = g_strconcat ("Push", remote, branch, "Action", NULL);
gchar *name;
@@ -2146,7 +2405,7 @@ add_push_action (GitgWindow *window,
}
else
{
- name = g_strconcat (remote, "/", branch, " (", _("new"), ")", NULL);
+ name = g_strconcat (remote, "/", branch, " (", _ ("new"), ")", NULL);
}
GtkAction *pushac = gtk_action_new (acname, name, NULL, NULL);
@@ -2182,7 +2441,8 @@ add_push_action (GitgWindow *window,
}
static void
-update_merge_rebase (GitgWindow *window, GitgRef *ref)
+update_merge_rebase (GitgWindow *window,
+ GitgRef *ref)
{
if (window->priv->merge_rebase_uid != 0)
{
@@ -2245,22 +2505,22 @@ update_merge_rebase (GitgWindow *window, GitgRef *ref)
GtkAction *mergeac = gtk_action_new (merge, rname, NULL, NULL);
g_object_set_data_full (G_OBJECT (rebaseac),
- DYNAMIC_ACTION_DATA_KEY,
- gitg_ref_copy (r),
- (GDestroyNotify)gitg_ref_free);
+ DYNAMIC_ACTION_DATA_KEY,
+ gitg_ref_copy (r),
+ (GDestroyNotify)gitg_ref_free);
g_object_set_data_full (G_OBJECT (mergeac),
- DYNAMIC_ACTION_DATA_KEY,
- gitg_ref_copy (r),
- (GDestroyNotify)gitg_ref_free);
+ DYNAMIC_ACTION_DATA_KEY,
+ gitg_ref_copy (r),
+ (GDestroyNotify)gitg_ref_free);
g_signal_connect (rebaseac,
- "activate",
- G_CALLBACK (on_rebase_activated),
- window);
+ "activate",
+ G_CALLBACK (on_rebase_activated),
+ window);
g_signal_connect (mergeac,
- "activate",
- G_CALLBACK (on_merge_activated),
- window);
+ "activate",
+ G_CALLBACK (on_merge_activated),
+ window);
gtk_action_group_add_action (ac, rebaseac);
gtk_action_group_add_action (ac, mergeac);
@@ -2268,23 +2528,23 @@ update_merge_rebase (GitgWindow *window, GitgRef *ref)
gchar *name = g_strconcat ("Rebase", rname, NULL);
gtk_ui_manager_add_ui (window->priv->menus_ui_manager,
- window->priv->merge_rebase_uid,
- "/ui/ref_popup/Rebase/Placeholder",
- name,
- rebase,
- GTK_UI_MANAGER_MENUITEM,
- FALSE);
+ window->priv->merge_rebase_uid,
+ "/ui/ref_popup/Rebase/Placeholder",
+ name,
+ rebase,
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
g_free (name);
name = g_strconcat ("Merge", rname, NULL);
gtk_ui_manager_add_ui (window->priv->menus_ui_manager,
- window->priv->merge_rebase_uid,
- "/ui/ref_popup/Merge/Placeholder",
- name,
- merge,
- GTK_UI_MANAGER_MENUITEM,
- FALSE);
+ window->priv->merge_rebase_uid,
+ "/ui/ref_popup/Merge/Placeholder",
+ name,
+ merge,
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
g_free (name);
g_object_unref (rebaseac);
@@ -2300,26 +2560,26 @@ update_merge_rebase (GitgWindow *window, GitgRef *ref)
GtkAction *stashac = gtk_action_new (stash, rname, NULL, NULL);
g_object_set_data_full (G_OBJECT (stashac),
- DYNAMIC_ACTION_DATA_KEY,
- gitg_ref_copy (r),
- (GDestroyNotify)gitg_ref_free);
+ DYNAMIC_ACTION_DATA_KEY,
+ gitg_ref_copy (r),
+ (GDestroyNotify)gitg_ref_free);
g_signal_connect (stashac,
- "activate",
- G_CALLBACK (on_stash_activated),
- window);
+ "activate",
+ G_CALLBACK (on_stash_activated),
+ window);
gtk_action_group_add_action (ac, stashac);
gchar *name = g_strconcat ("Stash", rname, NULL);
gtk_ui_manager_add_ui (window->priv->menus_ui_manager,
- window->priv->merge_rebase_uid,
- "/ui/ref_popup/Stash/Placeholder",
- name,
- stash,
- GTK_UI_MANAGER_MENUITEM,
- FALSE);
+ window->priv->merge_rebase_uid,
+ "/ui/ref_popup/Stash/Placeholder",
+ name,
+ stash,
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
g_free (name);
g_object_unref (stashac);
@@ -2417,7 +2677,8 @@ has_local_ref (GitgWindow *window,
}
static gboolean
-popup_ref (GitgWindow *window, GdkEventButton *event)
+popup_ref (GitgWindow *window,
+ GdkEventButton *event)
{
gint cell_x;
gint cell_y;
@@ -2461,9 +2722,12 @@ popup_ref (GitgWindow *window, GdkEventButton *event)
GtkWidget *popup = gtk_ui_manager_get_widget (window->priv->menus_ui_manager,
"/ui/ref_popup");
- GtkAction *checkout = gtk_ui_manager_get_action (window->priv->menus_ui_manager, "/ui/ref_popup/CheckoutAction");
- GtkAction *remove = gtk_ui_manager_get_action (window->priv->menus_ui_manager, "/ui/ref_popup/RemoveAction");
- GtkAction *rename = gtk_ui_manager_get_action (window->priv->menus_ui_manager, "/ui/ref_popup/RenameAction");
+ GtkAction *checkout = gtk_ui_manager_get_action (window->priv->menus_ui_manager,
+ "/ui/ref_popup/CheckoutAction");
+ GtkAction *remove = gtk_ui_manager_get_action (window->priv->menus_ui_manager,
+ "/ui/ref_popup/RemoveAction");
+ GtkAction *rename = gtk_ui_manager_get_action (window->priv->menus_ui_manager,
+ "/ui/ref_popup/RenameAction");
if (gitg_ref_get_ref_type (ref) == GITG_REF_TYPE_REMOTE)
{
@@ -2471,7 +2735,7 @@ popup_ref (GitgWindow *window, GdkEventButton *event)
if (!has_local_ref (window, local))
{
- gchar *label = g_strdup_printf (_("New local branch <%s>"), local);
+ gchar *label = g_strdup_printf (_ ("New local branch <%s>"), local);
g_object_set (checkout, "label", label, NULL);
gtk_action_set_visible (checkout, TRUE);
@@ -2482,15 +2746,15 @@ popup_ref (GitgWindow *window, GdkEventButton *event)
gtk_action_set_visible (checkout, FALSE);
}
- g_object_set (remove, "label", _("Remove remote branch"), NULL);
+ g_object_set (remove, "label", _ ("Remove remote branch"), NULL);
gtk_action_set_visible (rename, FALSE);
}
else if (gitg_ref_get_ref_type (ref) == GITG_REF_TYPE_BRANCH)
{
- g_object_set (checkout, "label", _("Checkout working copy"), NULL);
- g_object_set (remove, "label", _("Remove local branch"), NULL);
+ g_object_set (checkout, "label", _ ("Checkout working copy"), NULL);
+ g_object_set (remove, "label", _ ("Remove local branch"), NULL);
gtk_action_set_visible (rename, TRUE);
- g_object_set (rename, "label", _("Rename local branch"), NULL);
+ g_object_set (rename, "label", _ ("Rename local branch"), NULL);
GitgRef *working = gitg_repository_get_current_working_ref (window->priv->repository);
@@ -2498,18 +2762,18 @@ popup_ref (GitgWindow *window, GdkEventButton *event)
}
else if (gitg_ref_get_ref_type (ref) == GITG_REF_TYPE_STASH)
{
- g_object_set (remove, "label", _("Remove stash"), NULL);
+ g_object_set (remove, "label", _ ("Remove stash"), NULL);
gtk_action_set_visible (rename, FALSE);
gtk_action_set_visible (checkout, FALSE);
}
else if (gitg_ref_get_ref_type (ref) == GITG_REF_TYPE_TAG)
{
- g_object_set (remove, "label", _("Remove tag"), NULL);
+ g_object_set (remove, "label", _ ("Remove tag"), NULL);
gtk_action_set_visible (rename, FALSE);
if (!has_local_ref (window, gitg_ref_get_shortname (ref)))
{
- gchar *label = g_strdup_printf (_("New local branch <%s>"), gitg_ref_get_shortname (ref));
+ gchar *label = g_strdup_printf (_ ("New local branch <%s>"), gitg_ref_get_shortname (ref));
g_object_set (checkout, "label", label, NULL);
gtk_action_set_visible (checkout, TRUE);
@@ -2529,13 +2793,15 @@ popup_ref (GitgWindow *window, GdkEventButton *event)
}
static gboolean
-consecutive_revisions (GitgWindow *window, GList *rows)
+consecutive_revisions (GitgWindow *window,
+ GList *rows)
{
return FALSE;
}
static void
-on_cherry_pick_activated (GtkAction *action, GitgWindow *window)
+on_cherry_pick_activated (GtkAction *action,
+ GitgWindow *window)
{
GtkTreeSelection *selection;
GtkTreeModel *model;
@@ -2655,7 +2921,8 @@ update_cherry_pick (GitgWindow *window)
}
static gboolean
-popup_revision (GitgWindow *window, GdkEventButton *event)
+popup_revision (GitgWindow *window,
+ GdkEventButton *event)
{
GtkTreeSelection *selection;
@@ -2710,7 +2977,9 @@ popup_revision (GitgWindow *window, GdkEventButton *event)
}
gboolean
-on_tree_view_rv_button_press_event (GtkWidget *widget, GdkEventButton *event, GitgWindow *window)
+on_tree_view_rv_button_press_event (GtkWidget *widget,
+ GdkEventButton *event,
+ GitgWindow *window)
{
if (event->button == 3)
{
@@ -2721,7 +2990,8 @@ on_tree_view_rv_button_press_event (GtkWidget *widget, GdkEventButton *event, Gi
}
void
-on_checkout_branch_action_activate (GtkAction *action, GitgWindow *window)
+on_checkout_branch_action_activate (GtkAction *action,
+ GitgWindow *window)
{
if (gitg_branch_actions_checkout (window, window->priv->popup_refs[0]))
{
@@ -2730,19 +3000,22 @@ on_checkout_branch_action_activate (GtkAction *action, GitgWindow *window)
}
void
-on_remove_branch_action_activate (GtkAction *action, GitgWindow *window)
+on_remove_branch_action_activate (GtkAction *action,
+ GitgWindow *window)
{
gitg_branch_actions_remove (window, window->priv->popup_refs[0]);
}
void
-on_rename_branch_action_activate (GtkAction *action, GitgWindow *window)
+on_rename_branch_action_activate (GtkAction *action,
+ GitgWindow *window)
{
gitg_branch_actions_rename (window, window->priv->popup_refs[0]);
}
void
-on_rebase_branch_action_activate (GtkAction *action, GitgWindow *window)
+on_rebase_branch_action_activate (GtkAction *action,
+ GitgWindow *window)
{
gint source;
@@ -2762,7 +3035,8 @@ on_rebase_branch_action_activate (GtkAction *action, GitgWindow *window)
}
void
-on_merge_branch_action_activate (GtkAction *action, GitgWindow *window)
+on_merge_branch_action_activate (GtkAction *action,
+ GitgWindow *window)
{
gitg_window_add_branch_action (window,
gitg_branch_actions_merge (window,
@@ -2787,7 +3061,9 @@ free_tag_info (TagInfo *info)
}
static void
-on_tag_dialog_response (GtkWidget *dialog, gint response, TagInfo *info)
+on_tag_dialog_response (GtkWidget *dialog,
+ gint response,
+ TagInfo *info)
{
gboolean destroy = TRUE;
@@ -2807,11 +3083,11 @@ on_tag_dialog_response (GtkWidget *dialog, gint response, TagInfo *info)
if (sign && (!*name || !*message))
{
- secondary_text = _("Please make sure to fill in both the tag name and the commit message");
+ secondary_text = _ ("Please make sure to fill in both the tag name and the commit message");
}
else if (!sign && !*name)
{
- secondary_text = _("Please make sure to fill in the tag name");
+ secondary_text = _ ("Please make sure to fill in the tag name");
}
if (secondary_text)
@@ -2820,7 +3096,7 @@ on_tag_dialog_response (GtkWidget *dialog, gint response, TagInfo *info)
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
- _("Not all fields are correctly filled in"));
+ _ ("Not all fields are correctly filled in"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg),
"%s",
secondary_text);
@@ -2895,7 +3171,8 @@ on_format_patch_response (GtkDialog *dialog,
}
void
-on_revision_format_patch_activate (GtkAction *action, GitgWindow *window)
+on_revision_format_patch_activate (GtkAction *action,
+ GitgWindow *window)
{
GtkTreeSelection *selection;
GtkTreeModel *model;
@@ -2914,7 +3191,7 @@ on_revision_format_patch_activate (GtkAction *action, GitgWindow *window)
gtk_tree_model_get (model, &iter, 0, &revision, -1);
/* Single one, pick filename */
- dialog = gtk_file_chooser_dialog_new (_("Save format patch"),
+ dialog = gtk_file_chooser_dialog_new (_ ("Save format patch"),
GTK_WINDOW (window),
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -2974,7 +3251,8 @@ on_revision_format_patch_activate (GtkAction *action, GitgWindow *window)
}
void
-on_revision_tag_activate (GtkAction *action, GitgWindow *window)
+on_revision_tag_activate (GtkAction *action,
+ GitgWindow *window)
{
GtkTreeSelection *selection;
GtkTreeModel *model;
@@ -3026,7 +3304,8 @@ on_revision_tag_activate (GtkAction *action, GitgWindow *window)
}
void
-on_revision_squash_activate (GtkAction *action, GitgWindow *window)
+on_revision_squash_activate (GtkAction *action,
+ GitgWindow *window)
{
}
diff --git a/libgitg-1.0.pc.in b/libgitg-1.0.pc.in
new file mode 100644
index 0000000..dc66560
--- /dev/null
+++ b/libgitg-1.0.pc.in
@@ -0,0 +1,11 @@
+prefix= prefix@
+exec_prefix= exec_prefix@
+libdir= libdir@
+includedir= includedir@
+
+Name: @PACKAGE_NAME@
+Description: gitg library
+Version: @PACKAGE_VERSION@
+Requires: glib-2.0 gobject-2.0 gmodule-2.0 gio-2.0 gio-unix-2.0 gthread-2.0
+Libs: -L${libdir} -lgitg-1.0
+Cflags: -I${includedir}/libgitg-1.0
diff --git a/libgitg/Makefile.am b/libgitg/Makefile.am
index 5fafe2a..0ec1f44 100644
--- a/libgitg/Makefile.am
+++ b/libgitg/Makefile.am
@@ -22,18 +22,17 @@ BUILT_SOURCES = \
INST_H_FILES = \
$(BUILT_H_FILES) \
gitg-changed-file.h \
+ gitg-color.h \
gitg-commit.h \
+ gitg-config.h \
gitg-hash.h \
gitg-lane.h \
gitg-ref.h \
gitg-repository.h \
gitg-revision.h \
- gitg-runner.h \
- gitg-types.h
+ gitg-runner.h
NOINST_H_FILES = \
- gitg-color.h \
- gitg-config.h \
gitg-convert.h \
gitg-debug.h \
gitg-i18n.h \
@@ -82,3 +81,4 @@ gitg-enum-types.h: gitg-enum-types.h.template $(ENUM_H_FILES) $(GLIB_MKENUMS)
gitg-enum-types.c: gitg-enum-types.c.template $(ENUM_H_FILES) $(GLIB_MKENUMS)
$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template gitg-enum-types.c.template $(ENUM_H_FILES)) > $@
+-include $(top_srcdir)/git.mk
diff --git a/libgitg/gitg-color.h b/libgitg/gitg-color.h
index 729df37..c3c9bd3 100644
--- a/libgitg/gitg-color.h
+++ b/libgitg/gitg-color.h
@@ -26,7 +26,9 @@
#include <glib.h>
#include <cairo.h>
-typedef struct _GitgColor GitgColor;
+G_BEGIN_DECLS
+
+typedef struct _GitgColor GitgColor;
struct _GitgColor
{
@@ -34,14 +36,16 @@ struct _GitgColor
gint8 index;
};
-void gitg_color_reset(void);
-void gitg_color_get(GitgColor *color, gdouble *r, gdouble *g, gdouble *b);
-void gitg_color_set_cairo_source(GitgColor *color, cairo_t *cr);
+void gitg_color_reset (void);
+void gitg_color_get (GitgColor *color, gdouble *r, gdouble *g, gdouble *b);
+void gitg_color_set_cairo_source (GitgColor *color, cairo_t *cr);
+
+GitgColor *gitg_color_next (void);
+GitgColor *gitg_color_next_index (GitgColor *color);
+GitgColor *gitg_color_ref (GitgColor *color);
+GitgColor *gitg_color_copy (GitgColor *color);
+GitgColor *gitg_color_unref (GitgColor *color);
-GitgColor *gitg_color_next(void);
-GitgColor *gitg_color_next_index(GitgColor *color);
-GitgColor *gitg_color_ref(GitgColor *color);
-GitgColor *gitg_color_copy(GitgColor *color);
-GitgColor *gitg_color_unref(GitgColor *color);
+G_END_DECLS
#endif /* __GITG_COLOR_H__ */
diff --git a/libgitg/gitg-commit.c b/libgitg/gitg-commit.c
index 8f9d86b..7ad4048 100644
--- a/libgitg/gitg-commit.c
+++ b/libgitg/gitg-commit.c
@@ -673,7 +673,7 @@ write_tree(GitgCommit *commit, gchar **tree, GError **error)
gchar const *argv[] = {"write-tree", NULL};
gchar **lines = gitg_repository_command_with_output(commit->priv->repository, argv, error);
- if (!lines || strlen(*lines) != HASH_SHA_SIZE)
+ if (!lines || strlen(*lines) != GITG_HASH_SHA_SIZE)
{
g_strfreev(lines);
return FALSE;
@@ -885,7 +885,7 @@ commit_tree(GitgCommit *commit, gchar const *tree, gchar const *comment, gboolea
g_free(converted);
g_object_unref (runner);
- if (buffer->len != HASH_SHA_SIZE)
+ if (buffer->len != GITG_HASH_SHA_SIZE)
{
g_string_free(buffer, TRUE);
return FALSE;
diff --git a/libgitg/gitg-commit.h b/libgitg/gitg-commit.h
index 1d21895..27e2587 100644
--- a/libgitg/gitg-commit.h
+++ b/libgitg/gitg-commit.h
@@ -24,8 +24,8 @@
#define __GITG_COMMIT_H__
#include <glib-object.h>
-#include "gitg-repository.h"
-#include "gitg-changed-file.h"
+#include <libgitg/gitg-repository.h>
+#include <libgitg/gitg-changed-file.h>
G_BEGIN_DECLS
diff --git a/libgitg/gitg-config.h b/libgitg/gitg-config.h
index 3fd612a..0fb61d0 100644
--- a/libgitg/gitg-config.h
+++ b/libgitg/gitg-config.h
@@ -24,7 +24,7 @@
#define __GITG_CONFIG_H__
#include <glib-object.h>
-#include "gitg-repository.h"
+#include <libgitg/gitg-repository.h>
G_BEGIN_DECLS
diff --git a/libgitg/gitg-convert.h b/libgitg/gitg-convert.h
index 2e4cc0a..614d26b 100644
--- a/libgitg/gitg-convert.h
+++ b/libgitg/gitg-convert.h
@@ -25,6 +25,10 @@
#include <glib.h>
-gchar *gitg_convert_utf8(gchar const *str, gssize size);
+G_BEGIN_DECLS
+
+gchar *gitg_convert_utf8 (gchar const *str, gssize size);
+
+G_END_DECLS
#endif /* __GITG_CONVERT_H__ */
diff --git a/libgitg/gitg-hash.c b/libgitg/gitg-hash.c
index fe4007e..9bb4e06 100644
--- a/libgitg/gitg-hash.c
+++ b/libgitg/gitg-hash.c
@@ -26,21 +26,27 @@
#include <math.h>
#include "gitg-hash.h"
-#include "gitg-types.h"
inline static guint8
-atoh(gchar c)
+atoh (gchar c)
{
if (c >= 'a')
+ {
return c - 'a' + 10;
+ }
+
if (c >= 'A')
+ {
return c - 'A' + 10;
+ }
return c - '0';
}
void
-gitg_hash_partial_sha1_to_hash(gchar const *sha, gint length, gchar *hash)
+gitg_hash_partial_sha1_to_hash (gchar const *sha,
+ gint length,
+ gchar *hash)
{
if (length % 2 == 1)
{
@@ -51,25 +57,27 @@ gitg_hash_partial_sha1_to_hash(gchar const *sha, gint length, gchar *hash)
for (i = 0; i < length / 2; ++i)
{
- gchar h = atoh(*(sha++)) << 4;
- hash[i] = h | atoh(*(sha++));
+ gchar h = atoh (*(sha++)) << 4;
+ hash[i] = h | atoh (*(sha++));
}
}
void
-gitg_hash_sha1_to_hash(gchar const *sha, gchar *hash)
+gitg_hash_sha1_to_hash (gchar const *sha,
+ gchar *hash)
{
- gitg_hash_partial_sha1_to_hash (sha, HASH_SHA_SIZE, hash);
+ gitg_hash_partial_sha1_to_hash (sha, GITG_HASH_SHA_SIZE, hash);
}
void
-gitg_hash_hash_to_sha1(gchar const *hash, gchar *sha)
+gitg_hash_hash_to_sha1 (gchar const *hash,
+ gchar *sha)
{
char const *repr = "0123456789abcdef";
int i;
int pos = 0;
- for (i = 0; i < HASH_BINARY_SIZE; ++i)
+ for (i = 0; i < GITG_HASH_BINARY_SIZE; ++i)
{
sha[pos++] = repr[(hash[i] >> 4) & 0x0f];
sha[pos++] = repr[(hash[i] & 0x0f)];
@@ -77,17 +85,19 @@ gitg_hash_hash_to_sha1(gchar const *hash, gchar *sha)
}
gchar *
-gitg_hash_hash_to_sha1_new(gchar const *hash)
+gitg_hash_hash_to_sha1_new (gchar const *hash)
{
- gchar *ret = g_new(gchar, HASH_SHA_SIZE + 1);
- gitg_hash_hash_to_sha1(hash, ret);
+ gchar *ret = g_new (gchar, GITG_HASH_SHA_SIZE + 1);
+ gitg_hash_hash_to_sha1 (hash, ret);
- ret[HASH_SHA_SIZE] = '\0';
+ ret[GITG_HASH_SHA_SIZE] = '\0';
return ret;
}
gchar *
-gitg_hash_partial_sha1_to_hash_new (gchar const *sha, gint length, gint *retlen)
+gitg_hash_partial_sha1_to_hash_new (gchar const *sha,
+ gint length,
+ gint *retlen)
{
if (length == -1)
{
@@ -108,30 +118,30 @@ gitg_hash_partial_sha1_to_hash_new (gchar const *sha, gint length, gint *retlen)
}
gchar *
-gitg_hash_sha1_to_hash_new(gchar const *sha1)
+gitg_hash_sha1_to_hash_new (gchar const *sha1)
{
- gchar *ret = g_new(gchar, HASH_BINARY_SIZE);
- gitg_hash_sha1_to_hash(sha1, ret);
+ gchar *ret = g_new (gchar, GITG_HASH_BINARY_SIZE);
+ gitg_hash_sha1_to_hash (sha1, ret);
return ret;
}
guint
-gitg_hash_hash(gconstpointer v)
+gitg_hash_hash (gconstpointer v)
{
/* 31 bit hash function, copied from g_str_hash */
const signed char *p = v;
guint32 h = *p;
int i;
- for (i = 1; i < HASH_BINARY_SIZE; ++i)
+ for (i = 1; i < GITG_HASH_BINARY_SIZE; ++i)
h = (h << 5) - h + p[i];
return h;
}
-gboolean
-gitg_hash_hash_equal(gconstpointer a, gconstpointer b)
+gboolean
+gitg_hash_hash_equal (gconstpointer a, gconstpointer b)
{
- return memcmp(a, b, HASH_BINARY_SIZE) == 0;
+ return memcmp (a, b, GITG_HASH_BINARY_SIZE) == 0;
}
diff --git a/libgitg/gitg-hash.h b/libgitg/gitg-hash.h
index 2b2fe4b..28238bc 100644
--- a/libgitg/gitg-hash.h
+++ b/libgitg/gitg-hash.h
@@ -25,6 +25,13 @@
#include <glib.h>
+G_BEGIN_DECLS
+
+#define GITG_HASH_BINARY_SIZE 20
+#define GITG_HASH_SHA_SIZE 40
+
+typedef gchar GitgHash[GITG_HASH_BINARY_SIZE];
+
void gitg_hash_sha1_to_hash(gchar const *sha, gchar *hash);
void gitg_hash_hash_to_sha1(gchar const *hash, gchar *sha);
@@ -38,4 +45,6 @@ gchar *gitg_hash_partial_sha1_to_hash_new (gchar const *sha, gint length, gint *
guint gitg_hash_hash(gconstpointer v);
gboolean gitg_hash_hash_equal(gconstpointer a, gconstpointer b);
+G_END_DECLS
+
#endif /* __GITG_HASH_H__ */
diff --git a/libgitg/gitg-lane.h b/libgitg/gitg-lane.h
index 444a944..61664db 100644
--- a/libgitg/gitg-lane.h
+++ b/libgitg/gitg-lane.h
@@ -24,8 +24,11 @@
#define __GITG_LANE_H__
#include <glib.h>
-#include "gitg-color.h"
-#include "gitg-types.h"
+#include <libgitg/gitg-color.h>
+#include <libgitg/gitg-hash.h>
+
+G_BEGIN_DECLS
+
#define GITG_IS_LANE_BOUNDARY(lane) (lane->type & GITG_LANE_TYPE_START || lane->type & GITG_LANE_TYPE_END)
typedef enum
@@ -50,7 +53,7 @@ typedef struct
typedef struct
{
GitgLane lane;
- Hash hash;
+ GitgHash hash;
} GitgLaneBoundary;
GitgLane *gitg_lane_new (void);
@@ -61,4 +64,6 @@ GitgLane *gitg_lane_dup (GitgLane *lane);
void gitg_lane_free (GitgLane *lane);
GitgLaneBoundary *gitg_lane_convert_boundary (GitgLane *lane, GitgLaneType type);
+G_END_DECLS
+
#endif /* __GITG_LANE_H__ */
diff --git a/libgitg/gitg-lanes.c b/libgitg/gitg-lanes.c
index 387073f..2a1903a 100644
--- a/libgitg/gitg-lanes.c
+++ b/libgitg/gitg-lanes.c
@@ -43,7 +43,7 @@ typedef struct
gchar const *to;
} LaneContainer;
-typedef struct
+typedef struct
{
GitgColor *color;
gint8 index;
@@ -71,27 +71,27 @@ struct _GitgLanesPrivate
gboolean inactive_enabled;
};
-G_DEFINE_TYPE(GitgLanes, gitg_lanes, G_TYPE_OBJECT)
+G_DEFINE_TYPE (GitgLanes, gitg_lanes, G_TYPE_OBJECT)
static void
-lane_container_free(LaneContainer *container)
+lane_container_free (LaneContainer *container)
{
- gitg_lane_free(container->lane);
- g_slice_free(LaneContainer, container);
+ gitg_lane_free (container->lane);
+ g_slice_free (LaneContainer, container);
}
static void
-collapsed_lane_free(CollapsedLane *lane)
+collapsed_lane_free (CollapsedLane *lane)
{
- gitg_color_unref(lane->color);
- g_slice_free(CollapsedLane, lane);
+ gitg_color_unref (lane->color);
+ g_slice_free (CollapsedLane, lane);
}
static CollapsedLane *
-collapsed_lane_new(LaneContainer *container)
+collapsed_lane_new (LaneContainer *container)
{
- CollapsedLane *collapsed = g_slice_new(CollapsedLane);
- collapsed->color = gitg_color_ref(container->lane->color);
+ CollapsedLane *collapsed = g_slice_new (CollapsedLane);
+ collapsed->color = gitg_color_ref (container->lane->color);
collapsed->from = container->from;
collapsed->to = container->to;
@@ -99,31 +99,37 @@ collapsed_lane_new(LaneContainer *container)
}
static void
-free_lanes(GitgLanes *lanes)
+free_lanes (GitgLanes *lanes)
{
- g_slist_foreach(lanes->priv->lanes, (GFunc)lane_container_free, NULL);
- g_slist_free(lanes->priv->lanes);
+ g_slist_foreach (lanes->priv->lanes, (GFunc)lane_container_free, NULL);
+ g_slist_free (lanes->priv->lanes);
lanes->priv->lanes = NULL;
}
static LaneContainer *
-find_lane_by_hash(GitgLanes *lanes, gchar const *hash, gint8 *pos)
+find_lane_by_hash (GitgLanes *lanes,
+ gchar const *hash,
+ gint8 *pos)
{
GSList *item;
gint8 p = 0;
if (!hash)
+ {
return NULL;
+ }
- for (item = lanes->priv->lanes; item; item = item->next)
+ for (item = lanes->priv->lanes; item; item = g_slist_next (item))
{
LaneContainer *container = (LaneContainer *)(item->data);
- if (container && container->to && gitg_hash_hash_equal(container->to, hash))
+ if (container && container->to && gitg_hash_hash_equal (container->to, hash))
{
if (pos)
+ {
*pos = p;
+ }
return container;
}
@@ -136,62 +142,68 @@ find_lane_by_hash(GitgLanes *lanes, gchar const *hash, gint8 *pos)
/* GitgLanes functions */
static void
-gitg_lanes_finalize(GObject *object)
+gitg_lanes_finalize (GObject *object)
{
- GitgLanes *self = GITG_LANES(object);
+ GitgLanes *self = GITG_LANES (object);
- gitg_lanes_reset(self);
- g_hash_table_destroy(self->priv->collapsed);
+ gitg_lanes_reset (self);
+ g_hash_table_destroy (self->priv->collapsed);
- G_OBJECT_CLASS(gitg_lanes_parent_class)->finalize(object);
+ G_OBJECT_CLASS (gitg_lanes_parent_class)->finalize (object);
}
static void
-gitg_lanes_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gitg_lanes_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GitgLanes *self = GITG_LANES(object);
+ GitgLanes *self = GITG_LANES (object);
switch (prop_id)
{
case PROP_INACTIVE_MAX:
- self->priv->inactive_max = g_value_get_int(value);
+ self->priv->inactive_max = g_value_get_int (value);
break;
case PROP_INACTIVE_COLLAPSE:
- self->priv->inactive_collapse = g_value_get_int(value);
+ self->priv->inactive_collapse = g_value_get_int (value);
break;
case PROP_INACTIVE_GAP:
- self->priv->inactive_gap = g_value_get_int(value);
+ self->priv->inactive_gap = g_value_get_int (value);
break;
case PROP_INACTIVE_ENABLED:
- self->priv->inactive_enabled = g_value_get_boolean(value);
+ self->priv->inactive_enabled = g_value_get_boolean (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
-gitg_lanes_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gitg_lanes_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
GitgLanes *self = GITG_LANES(object);
switch (prop_id)
{
case PROP_INACTIVE_MAX:
- g_value_set_int(value, self->priv->inactive_max);
+ g_value_set_int (value, self->priv->inactive_max);
break;
case PROP_INACTIVE_COLLAPSE:
- g_value_set_int(value, self->priv->inactive_collapse);
+ g_value_set_int (value, self->priv->inactive_collapse);
break;
case PROP_INACTIVE_GAP:
- g_value_set_int(value, self->priv->inactive_gap);
+ g_value_set_int (value, self->priv->inactive_gap);
break;
case PROP_INACTIVE_ENABLED:
- g_value_set_boolean(value, self->priv->inactive_enabled);
+ g_value_set_boolean (value, self->priv->inactive_enabled);
break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
@@ -205,154 +217,181 @@ gitg_lanes_class_init(GitgLanesClass *klass)
object_class->set_property = gitg_lanes_set_property;
object_class->get_property = gitg_lanes_get_property;
- g_object_class_install_property(object_class, PROP_INACTIVE_MAX,
- g_param_spec_int("inactive-max",
- "INACTIVE_MAX",
- "Maximum inactivity on a lane before collapsing",
- 1,
- G_MAXINT,
- 30,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property(object_class, PROP_INACTIVE_COLLAPSE,
- g_param_spec_int("inactive-collapse",
- "INACTIVE_COLLAPSE",
- "Number of revisions to collapse",
- 1,
- G_MAXINT,
- 10,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property(object_class, PROP_INACTIVE_GAP,
- g_param_spec_int("inactive-gap",
- "INACTIVE_GAP",
- "Minimum of revisions to leave between collapse and expand",
- 1,
- G_MAXINT,
- 10,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property(object_class, PROP_INACTIVE_ENABLED,
- g_param_spec_boolean("inactive-enabled",
- "INACTIVE_ENABLED",
- "Lane collapsing enabled",
- TRUE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_type_class_add_private(object_class, sizeof(GitgLanesPrivate));
+ g_object_class_install_property (object_class,
+ PROP_INACTIVE_MAX,
+ g_param_spec_int ("inactive-max",
+ "INACTIVE_MAX",
+ "Maximum inactivity on a lane before collapsing",
+ 1,
+ G_MAXINT,
+ 30,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class,
+ PROP_INACTIVE_COLLAPSE,
+ g_param_spec_int ("inactive-collapse",
+ "INACTIVE_COLLAPSE",
+ "Number of revisions to collapse",
+ 1,
+ G_MAXINT,
+ 10,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class,
+ PROP_INACTIVE_GAP,
+ g_param_spec_int ("inactive-gap",
+ "INACTIVE_GAP",
+ "Minimum of revisions to leave between collapse and expand",
+ 1,
+ G_MAXINT,
+ 10,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class,
+ PROP_INACTIVE_ENABLED,
+ g_param_spec_boolean ("inactive-enabled",
+ "INACTIVE_ENABLED",
+ "Lane collapsing enabled",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_type_class_add_private (object_class, sizeof (GitgLanesPrivate));
}
static void
-gitg_lanes_init(GitgLanes *self)
+gitg_lanes_init (GitgLanes *self)
{
- self->priv = GITG_LANES_GET_PRIVATE(self);
- self->priv->collapsed = g_hash_table_new_full(gitg_hash_hash, gitg_hash_hash_equal, NULL, (GDestroyNotify)collapsed_lane_free);
+ self->priv = GITG_LANES_GET_PRIVATE (self);
+ self->priv->collapsed = g_hash_table_new_full (gitg_hash_hash,
+ gitg_hash_hash_equal,
+ NULL,
+ (GDestroyNotify)collapsed_lane_free);
}
GitgLanes *
-gitg_lanes_new()
+gitg_lanes_new ()
{
- return GITG_LANES(g_object_new(GITG_TYPE_LANES, NULL));
+ return GITG_LANES (g_object_new (GITG_TYPE_LANES, NULL));
}
static LaneContainer *
-lane_container_new_with_color(gchar const *from, gchar const *to, GitgColor *color)
+lane_container_new_with_color (gchar const *from,
+ gchar const *to,
+ GitgColor *color)
{
- LaneContainer *ret = g_slice_new(LaneContainer);
+ LaneContainer *ret = g_slice_new (LaneContainer);
ret->from = from;
ret->to = to;
- ret->lane = gitg_lane_new_with_color(color);
+ ret->lane = gitg_lane_new_with_color (color);
ret->inactive = 0;
return ret;
}
static LaneContainer *
-lane_container_new(gchar const *from, gchar const *to)
+lane_container_new (gchar const *from,
+ gchar const *to)
{
- return lane_container_new_with_color(from, to, NULL);
+ return lane_container_new_with_color (from, to, NULL);
}
static GSList *
-lanes_list(GitgLanes *lanes)
+lanes_list (GitgLanes *lanes)
{
GSList *lns = NULL;
GSList *item;
for (item = lanes->priv->lanes; item; item = item->next)
- lns = g_slist_prepend(lns, gitg_lane_copy(((LaneContainer*)item->data)->lane));
+ {
+ lns = g_slist_prepend (lns, gitg_lane_copy (((LaneContainer*)item->data)->lane));
+ }
- return g_slist_reverse(lns);
+ return g_slist_reverse (lns);
}
void
-gitg_lanes_reset(GitgLanes *lanes)
+gitg_lanes_reset (GitgLanes *lanes)
{
- free_lanes(lanes);
- gitg_color_reset();
+ free_lanes (lanes);
+ gitg_color_reset ();
+
+ g_slist_foreach (lanes->priv->previous, (GFunc)gitg_revision_unref, NULL);
+ g_slist_free (lanes->priv->previous);
- g_slist_foreach(lanes->priv->previous, (GFunc)gitg_revision_unref, NULL);
- g_slist_free(lanes->priv->previous);
lanes->priv->previous = NULL;
- g_hash_table_remove_all(lanes->priv->collapsed);
+ g_hash_table_remove_all (lanes->priv->collapsed);
}
static void
-lane_container_next(LaneContainer *container, gint index)
+lane_container_next (LaneContainer *container,
+ gint index)
{
GitgLane *lane = gitg_lane_copy(container->lane);
+
lane->type = GITG_LANE_TYPE_NONE;
- g_slist_free(lane->from);
+ g_slist_free (lane->from);
- gitg_lane_free(container->lane);
+ gitg_lane_free (container->lane);
container->lane = lane;
- container->lane->from = g_slist_prepend(NULL, GINT_TO_POINTER((gint)(index)));
+ container->lane->from = g_slist_prepend (NULL, GINT_TO_POINTER ((gint)(index)));
if (container->to)
+ {
++container->inactive;
+ }
}
static void
-update_lane_merge_indices(GSList *from, gint8 index, gint direction)
+update_lane_merge_indices (GSList *from,
+ gint8 index,
+ gint direction)
{
GSList *item;
- for (item = from; item; item = g_slist_next(item))
+ for (item = from; item; item = g_slist_next (item))
{
- gint8 idx = GPOINTER_TO_INT(item->data);
+ gint8 idx = GPOINTER_TO_INT (item->data);
if ((direction < 0 && idx > index) || (direction > 0 && idx >= index))
- item->data = GINT_TO_POINTER(idx + direction);
+ {
+ item->data = GINT_TO_POINTER (idx + direction);
+ }
}
}
static void
-update_merge_indices(GSList *lanes, gint8 index, gint direction)
+update_merge_indices (GSList *lanes,
+ gint8 index,
+ gint direction)
{
GSList *item;
- for (item = lanes; item; item = g_slist_next(item))
+ for (item = lanes; item; item = g_slist_next (item))
{
GitgLane *lane = (GitgLane *)item->data;
- update_lane_merge_indices(lane->from, index, direction);
+ update_lane_merge_indices (lane->from, index, direction);
}
}
static void
-add_collapsed(GitgLanes *lanes, LaneContainer *container, gint8 index)
+add_collapsed (GitgLanes *lanes,
+ LaneContainer *container,
+ gint8 index)
{
- CollapsedLane *collapsed = collapsed_lane_new(container);
+ CollapsedLane *collapsed = collapsed_lane_new (container);
collapsed->index = index;
- g_hash_table_insert(lanes->priv->collapsed, (gpointer)container->to, collapsed);
+ g_hash_table_insert (lanes->priv->collapsed, (gpointer)container->to, collapsed);
}
static void
-collapse_lane(GitgLanes *lanes, LaneContainer *container, gint8 index)
+collapse_lane (GitgLanes *lanes,
+ LaneContainer *container,
+ gint8 index)
{
/* backtrack for inactive-collapse revisions and remove this container from
those revisions, appropriately updating merge indices etc */
@@ -377,12 +416,16 @@ collapse_lane(GitgLanes *lanes, LaneContainer *container, gint8 index)
lns = gitg_revision_remove_lane(revision, lane);
if (item->next->next)
+ {
update_merge_indices(lns, newindex, -1);
+ }
gint mylane = gitg_revision_get_mylane(revision);
if (mylane > index)
+ {
gitg_revision_set_mylane(revision, mylane - 1);
+ }
index = newindex;
}
@@ -390,26 +433,35 @@ collapse_lane(GitgLanes *lanes, LaneContainer *container, gint8 index)
{
/* the last item we keep, and set the style of the lane to END */
GSList *lstlane = g_slist_nth(lns, index);
- GitgLaneBoundary *boundary = gitg_lane_convert_boundary((GitgLane *)lstlane->data, GITG_LANE_TYPE_END);
+ GitgLaneBoundary *boundary;
+
+ boundary = gitg_lane_convert_boundary ((GitgLane *)lstlane->data,
+ GITG_LANE_TYPE_END);
/* copy parent hash over */
- memcpy(boundary->hash, container->to, HASH_BINARY_SIZE);
+ memcpy (boundary->hash, container->to, GITG_HASH_BINARY_SIZE);
lstlane->data = boundary;
}
}
}
static void
-update_current_lanes_merge_indices(GitgLanes *lanes, gint8 index, gint8 direction)
+update_current_lanes_merge_indices (GitgLanes *lanes,
+ gint8 index,
+ gint8 direction)
{
GSList *item;
- for (item = lanes->priv->lanes; item; item = g_slist_next(item))
- update_lane_merge_indices(((LaneContainer *)item->data)->lane->from, index, direction);
+ for (item = lanes->priv->lanes; item; item = g_slist_next (item))
+ {
+ update_lane_merge_indices (((LaneContainer *)item->data)->lane->from,
+ index,
+ direction);
+ }
}
static void
-collapse_lanes(GitgLanes *lanes)
+collapse_lanes (GitgLanes *lanes)
{
GSList *item = lanes->priv->lanes;
gint8 index = 0;
@@ -420,127 +472,148 @@ collapse_lanes(GitgLanes *lanes)
if (container->inactive != lanes->priv->inactive_max + lanes->priv->inactive_gap)
{
- item = g_slist_next(item);
+ item = g_slist_next (item);
++index;
continue;
}
- collapse_lane(lanes, container, GPOINTER_TO_INT(container->lane->from->data));
- update_current_lanes_merge_indices(lanes, index, -1);
+ collapse_lane (lanes,
+ container,
+ GPOINTER_TO_INT (container->lane->from->data));
+
+ update_current_lanes_merge_indices (lanes, index, -1);
- GSList *next = g_slist_next(item);
+ GSList *next = g_slist_next (item);
- lane_container_free(container);
+ lane_container_free (container);
- lanes->priv->lanes = g_slist_remove_link(lanes->priv->lanes, item);
+ lanes->priv->lanes = g_slist_remove_link (lanes->priv->lanes, item);
item = next;
}
}
static gint8
-ensure_correct_index(GitgRevision *revision, gint8 index)
+ensure_correct_index (GitgRevision *revision,
+ gint8 index)
{
- guint len = g_slist_length(gitg_revision_get_lanes(revision));
+ guint len = g_slist_length (gitg_revision_get_lanes (revision));
if (index > len)
+ {
index = len;
+ }
return index;
}
static void
-expand_lane(GitgLanes *lanes, CollapsedLane *lane)
+expand_lane (GitgLanes *lanes,
+ CollapsedLane *lane)
{
GSList *item;
gint8 index = lane->index;
- GitgLane *ln = gitg_lane_new_with_color(lane->color);
- guint len = g_slist_length(lanes->priv->lanes);
+ GitgLane *ln = gitg_lane_new_with_color (lane->color);
+ guint len = g_slist_length (lanes->priv->lanes);
gint8 next;
if (index > len)
+ {
index = len;
+ }
+
+ next = ensure_correct_index ((GitgRevision *)lanes->priv->previous->data,
+ index);
- next = ensure_correct_index((GitgRevision *)lanes->priv->previous->data, index);
- LaneContainer *container = lane_container_new_with_color(lane->from, lane->to, lane->color);
+ LaneContainer *container = lane_container_new_with_color (lane->from,
+ lane->to,
+ lane->color);
- update_current_lanes_merge_indices(lanes, index, 1);
+ update_current_lanes_merge_indices (lanes, index, 1);
- container->lane->from = g_slist_prepend(NULL, GINT_TO_POINTER((gint)next));
- lanes->priv->lanes = g_slist_insert(lanes->priv->lanes, container, index);
+ container->lane->from = g_slist_prepend (NULL, GINT_TO_POINTER ((gint)next));
+ lanes->priv->lanes = g_slist_insert (lanes->priv->lanes, container, index);
index = next;
guint cnt = 0;
- for (item = lanes->priv->previous; item; item = g_slist_next(item))
+ for (item = lanes->priv->previous; item; item = g_slist_next (item))
{
- GitgRevision *revision = GITG_REVISION(item->data);
+ GitgRevision *revision = item->data;
if (cnt == lanes->priv->inactive_collapse)
+ {
break;
+ }
/* insert new lane at the index */
- GitgLane *copy = gitg_lane_copy(ln);
- GSList *lns = gitg_revision_get_lanes(revision);
+ GitgLane *copy = gitg_lane_copy (ln);
+ GSList *lns = gitg_revision_get_lanes (revision);
if (!item->next || cnt + 1 == lanes->priv->inactive_collapse)
{
- GitgLaneBoundary *boundary = gitg_lane_convert_boundary(copy, GITG_LANE_TYPE_START);
+ GitgLaneBoundary *boundary = gitg_lane_convert_boundary (copy, GITG_LANE_TYPE_START);
/* copy child hash in boundary */
- memcpy(boundary->hash, lane->from, HASH_BINARY_SIZE);
+ memcpy (boundary->hash, lane->from, GITG_HASH_BINARY_SIZE);
copy = (GitgLane *)boundary;
}
else
{
- next = ensure_correct_index(GITG_REVISION(item->next->data), index);
- copy->from = g_slist_prepend(NULL, GINT_TO_POINTER((gint)next));
+ next = ensure_correct_index (GITG_REVISION (item->next->data), index);
+ copy->from = g_slist_prepend (NULL, GINT_TO_POINTER ((gint)next));
/* update merge indices */
- update_merge_indices(lns, index, 1);
+ update_merge_indices (lns, index, 1);
}
- lns = gitg_revision_insert_lane(revision, copy, index);
- gint mylane = gitg_revision_get_mylane(revision);
+ lns = gitg_revision_insert_lane (revision, copy, index);
+ gint mylane = gitg_revision_get_mylane (revision);
if (mylane >= index)
- gitg_revision_set_mylane(revision, mylane + 1);
+ {
+ gitg_revision_set_mylane (revision, mylane + 1);
+ }
index = next;
++cnt;
}
- gitg_lane_free(ln);
+ gitg_lane_free (ln);
}
static void
-expand_lane_from_hash(GitgLanes *lanes, gchar const *hash)
+expand_lane_from_hash (GitgLanes *lanes, gchar const *hash)
{
- CollapsedLane *collapsed = (CollapsedLane *)g_hash_table_lookup(lanes->priv->collapsed, hash);
+ CollapsedLane *collapsed = (CollapsedLane *)g_hash_table_lookup (lanes->priv->collapsed, hash);
if (!collapsed)
+ {
return;
+ }
- expand_lane(lanes, collapsed);
- g_hash_table_remove(lanes->priv->collapsed, hash);
+ expand_lane (lanes, collapsed);
+ g_hash_table_remove (lanes->priv->collapsed, hash);
}
static void
-expand_lanes(GitgLanes *lanes, GitgRevision *revision)
+expand_lanes (GitgLanes *lanes, GitgRevision *revision)
{
/* expand any lanes that revision needs (own lane and parents lanes) */
- expand_lane_from_hash(lanes, gitg_revision_get_hash(revision));
+ expand_lane_from_hash (lanes, gitg_revision_get_hash (revision));
guint num;
guint i;
- Hash *parents = gitg_revision_get_parents_hash(revision, &num);
+ GitgHash *parents = gitg_revision_get_parents_hash (revision, &num);
for (i = 0; i < num; ++i)
- expand_lane_from_hash(lanes, parents[i]);
+ {
+ expand_lane_from_hash (lanes, parents[i]);
+ }
}
static void
-init_next_layer(GitgLanes *lanes)
+init_next_layer (GitgLanes *lanes)
{
GSList *item = lanes->priv->lanes;
gint8 index = 0;
@@ -548,43 +621,46 @@ init_next_layer(GitgLanes *lanes)
/* Initialize new set of lanes based on 'lanes'. It copies the lane (refs
the color) and adds the lane index as a merge (so it basicly represents
a passthrough) */
- for (item = lanes->priv->lanes; item; item = g_slist_next(item))
+ for (item = lanes->priv->lanes; item; item = g_slist_next (item))
{
LaneContainer *container = (LaneContainer *)item->data;
- lane_container_next(container, index++);
+ lane_container_next (container, index++);
}
}
static void
-prepare_lanes(GitgLanes *lanes, GitgRevision *next, gint8 *pos)
+prepare_lanes (GitgLanes *lanes, GitgRevision *next, gint8 *pos)
{
LaneContainer *mylane;
guint num;
- Hash *parents = gitg_revision_get_parents_hash(next, &num);
+ GitgHash *parents;
guint i;
- gchar const *myhash = gitg_revision_get_hash(next);
+ gchar const *myhash;
+
+ parents = gitg_revision_get_parents_hash (next, &num);
+ myhash = gitg_revision_get_hash (next);
/* prepare the next layer */
- init_next_layer(lanes);
+ init_next_layer (lanes);
- mylane = (LaneContainer *)g_slist_nth_data(lanes->priv->lanes, *pos);
+ mylane = (LaneContainer *)g_slist_nth_data (lanes->priv->lanes, *pos);
/* Iterate over all parents and find them a lane */
for (i = 0; i < num; ++i)
{
gint8 lnpos;
- LaneContainer *container = find_lane_by_hash(lanes, parents[i], &lnpos);
+ LaneContainer *container = find_lane_by_hash (lanes, parents[i], &lnpos);
if (container)
{
/* There already is a lane for this parent. This means that we add
mypos as a merge for the lane, also this means the color of
this lane incluis the merge should change to one color */
- container->lane->from = g_slist_append(container->lane->from, GINT_TO_POINTER((gint)*pos));
- gitg_color_next_index(container->lane->color);
+ container->lane->from = g_slist_append (container->lane->from, GINT_TO_POINTER ((gint)*pos));
+ gitg_color_next_index (container->lane->color);
container->inactive = 0;
- container->from = gitg_revision_get_hash(next);
+ container->from = gitg_revision_get_hash (next);
continue;
}
@@ -598,79 +674,79 @@ prepare_lanes(GitgLanes *lanes, GitgRevision *next, gint8 *pos)
since this revision is a merge */
if (num > 1)
{
- gitg_color_unref(mylane->lane->color);
- mylane->lane->color = gitg_color_next();
+ gitg_color_unref (mylane->lane->color);
+ mylane->lane->color = gitg_color_next ();
}
else
{
- GitgColor *nc = gitg_color_copy(mylane->lane->color);
- gitg_color_unref(mylane->lane->color);
+ GitgColor *nc = gitg_color_copy (mylane->lane->color);
+ gitg_color_unref (mylane->lane->color);
mylane->lane->color = nc;
}
}
else
{
/* Generate a new lane for this parent */
- LaneContainer *newlane = lane_container_new(myhash, parents[i]);
- newlane->lane->from = g_slist_prepend(NULL, GINT_TO_POINTER((gint)*pos));
- lanes->priv->lanes = g_slist_append(lanes->priv->lanes, newlane);
+ LaneContainer *newlane = lane_container_new (myhash, parents[i]);
+ newlane->lane->from = g_slist_prepend (NULL, GINT_TO_POINTER ((gint)*pos));
+ lanes->priv->lanes = g_slist_append (lanes->priv->lanes, newlane);
}
}
/* Remove the current lane if it is no longer needed */
if (mylane && mylane->to == NULL)
{
- lanes->priv->lanes = g_slist_remove(lanes->priv->lanes, mylane);
+ lanes->priv->lanes = g_slist_remove (lanes->priv->lanes, mylane);
}
/* Store new revision in our track list */
- if (g_slist_length(lanes->priv->previous) == lanes->priv->inactive_collapse + lanes->priv->inactive_gap + 1)
+ if (g_slist_length (lanes->priv->previous) == lanes->priv->inactive_collapse + lanes->priv->inactive_gap + 1)
{
- GSList *last = g_slist_last(lanes->priv->previous);
- gitg_revision_unref(GITG_REVISION(last->data));
+ GSList *last = g_slist_last (lanes->priv->previous);
+ gitg_revision_unref (GITG_REVISION (last->data));
- lanes->priv->previous = g_slist_remove_link(lanes->priv->previous, last);
+ lanes->priv->previous = g_slist_remove_link (lanes->priv->previous, last);
}
- lanes->priv->previous = g_slist_prepend(lanes->priv->previous, gitg_revision_ref(next));
+ lanes->priv->previous = g_slist_prepend (lanes->priv->previous, gitg_revision_ref (next));
}
GSList *
-gitg_lanes_next(GitgLanes *lanes, GitgRevision *next, gint8 *nextpos)
+gitg_lanes_next (GitgLanes *lanes, GitgRevision *next, gint8 *nextpos)
{
LaneContainer *mylane;
GSList *res;
- gchar const *myhash = gitg_revision_get_hash(next);
+ gchar const *myhash = gitg_revision_get_hash (next);
if (lanes->priv->inactive_enabled)
{
- collapse_lanes(lanes);
- expand_lanes(lanes, next);
+ collapse_lanes (lanes);
+ expand_lanes (lanes, next);
}
- mylane = find_lane_by_hash(lanes, myhash, nextpos);
+ mylane = find_lane_by_hash (lanes, myhash, nextpos);
if (!mylane)
{
/* apparently, there is no lane reserved for this revision, we
add a new one */
- lanes->priv->lanes = g_slist_append(lanes->priv->lanes, lane_container_new(myhash, NULL));
- *nextpos = g_slist_length(lanes->priv->lanes) - 1;
+ lanes->priv->lanes = g_slist_append (lanes->priv->lanes, lane_container_new (myhash, NULL));
+ *nextpos = g_slist_length (lanes->priv->lanes) - 1;
}
else
{
/* copy the color here because this represents a new stop */
- GitgColor *nc = gitg_color_copy(mylane->lane->color);
- gitg_color_unref(mylane->lane->color);
+ GitgColor *nc = gitg_color_copy (mylane->lane->color);
+ gitg_color_unref (mylane->lane->color);
mylane->lane->color = nc;
mylane->to = NULL;
- mylane->from = gitg_revision_get_hash(next);
+ mylane->from = gitg_revision_get_hash (next);
mylane->inactive = 0;
}
- res = lanes_list(lanes);
- prepare_lanes(lanes, next, nextpos);
+ res = lanes_list (lanes);
+ prepare_lanes (lanes, next, nextpos);
return res;
}
diff --git a/libgitg/gitg-ref.c b/libgitg/gitg-ref.c
index 1dca7ee..0ee8b27 100644
--- a/libgitg/gitg-ref.c
+++ b/libgitg/gitg-ref.c
@@ -24,7 +24,7 @@
#include "gitg-hash.h"
#include <string.h>
-typedef struct
+typedef struct
{
gchar const *prefix;
GitgRefType type;
@@ -32,7 +32,7 @@ typedef struct
struct _GitgRef
{
- Hash hash;
+ GitgHash hash;
GitgRefType type;
gchar *name;
@@ -44,28 +44,28 @@ struct _GitgRef
gboolean working;
};
-GType
+GType
gitg_ref_get_type (void)
{
static GType our_type = 0;
if (!our_type)
{
- our_type = g_boxed_type_register_static("GitGRef",
- (GBoxedCopyFunc)gitg_ref_copy,
- (GBoxedFreeFunc)gitg_ref_free);
+ our_type = g_boxed_type_register_static ("GitGRef",
+ (GBoxedCopyFunc)gitg_ref_copy,
+ (GBoxedFreeFunc)gitg_ref_free);
}
return our_type;
-}
+}
GitgRef *
-gitg_ref_new(gchar const *hash, gchar const *name)
+gitg_ref_new (gchar const *hash, gchar const *name)
{
- GitgRef *inst = g_slice_new0(GitgRef);
+ GitgRef *inst = g_slice_new0 (GitgRef);
- gitg_hash_sha1_to_hash(hash, inst->hash);
- inst->name = g_strdup(name);
+ gitg_hash_sha1_to_hash (hash, inst->hash);
+ inst->name = g_strdup (name);
PrefixTypeMap map[] = {
{"refs/heads/", GITG_REF_TYPE_BRANCH},
@@ -78,27 +78,29 @@ gitg_ref_new(gchar const *hash, gchar const *name)
// set type from name
int i;
- for (i = 0; i < sizeof(map) / sizeof(PrefixTypeMap); ++i)
+ for (i = 0; i < sizeof (map) / sizeof (PrefixTypeMap); ++i)
{
gchar *pos;
- if (!g_str_has_prefix(name, map[i].prefix))
+ if (!g_str_has_prefix (name, map[i].prefix))
+ {
continue;
+ }
inst->type = map[i].type;
if (inst->type == GITG_REF_TYPE_STASH)
{
- inst->shortname = g_strdup("stash");
+ inst->shortname = g_strdup ("stash");
}
else
{
- inst->shortname = g_strdup(name + strlen(map[i].prefix));
+ inst->shortname = g_strdup (name + strlen (map[i].prefix));
}
- if (map[i].type == GITG_REF_TYPE_REMOTE && (pos = strchr(inst->shortname, '/')))
+ if (map[i].type == GITG_REF_TYPE_REMOTE && (pos = strchr (inst->shortname, '/')))
{
- inst->prefix = g_strndup(inst->shortname, pos - inst->shortname);
+ inst->prefix = g_strndup (inst->shortname, pos - inst->shortname);
}
break;
@@ -107,14 +109,14 @@ gitg_ref_new(gchar const *hash, gchar const *name)
if (inst->shortname == NULL)
{
inst->type = GITG_REF_TYPE_NONE;
- inst->shortname = g_strdup(name);
+ inst->shortname = g_strdup (name);
}
return inst;
}
GitgRef *
-gitg_ref_copy(GitgRef *ref)
+gitg_ref_copy (GitgRef *ref)
{
if (ref == NULL)
{
@@ -124,81 +126,94 @@ gitg_ref_copy(GitgRef *ref)
GitgRef *ret = g_slice_new0 (GitgRef);
ret->type = ref->type;
- ret->name = g_strdup(ref->name);
- ret->shortname = g_strdup(ref->shortname);
- ret->prefix = g_strdup(ref->prefix);
+ ret->name = g_strdup (ref->name);
+ ret->shortname = g_strdup (ref->shortname);
+ ret->prefix = g_strdup (ref->prefix);
ret->working = ref->working;
- int i;
- for (i = 0; i < HASH_BINARY_SIZE; ++i)
+ gint i;
+
+ for (i = 0; i < GITG_HASH_BINARY_SIZE; ++i)
+ {
ret->hash[i] = ref->hash[i];
+ }
return ret;
}
void
-gitg_ref_free(GitgRef *ref)
+gitg_ref_free (GitgRef *ref)
{
if (!ref)
+ {
return;
+ }
- g_free(ref->name);
- g_free(ref->shortname);
- g_free(ref->prefix);
+ g_free (ref->name);
+ g_free (ref->shortname);
+ g_free (ref->prefix);
- g_slice_free(GitgRef, ref);
+ g_slice_free (GitgRef, ref);
}
-gboolean
-gitg_ref_equal(GitgRef *ref, GitgRef *other)
+gboolean
+gitg_ref_equal (GitgRef *ref, GitgRef *other)
{
if (ref == NULL && other == NULL)
+ {
return TRUE;
+ }
if (ref == NULL || other == NULL)
+ {
return FALSE;
+ }
- return strcmp(ref->name, other->name) == 0;
+ return strcmp (ref->name, other->name) == 0;
}
gboolean
-gitg_ref_equal_prefix(GitgRef *ref, GitgRef *other)
+gitg_ref_equal_prefix (GitgRef *ref, GitgRef *other)
{
if (ref == NULL && other == NULL)
+ {
return TRUE;
+ }
if (ref == NULL || other == NULL)
+ {
return FALSE;
+ }
- return strcmp(ref->prefix, other->prefix) == 0;
+ return strcmp (ref->prefix, other->prefix) == 0;
}
gchar const *
-gitg_ref_get_hash(GitgRef *ref)
+gitg_ref_get_hash (GitgRef *ref)
{
return ref->hash;
}
GitgRefType
-gitg_ref_get_ref_type(GitgRef *ref)
+gitg_ref_get_ref_type (GitgRef *ref)
{
return ref->type;
}
gchar const *
-gitg_ref_get_name(GitgRef *ref)
+gitg_ref_get_name (GitgRef *ref)
{
return ref->name;
}
gchar const *
-gitg_ref_get_shortname(GitgRef *ref)
+gitg_ref_get_shortname (GitgRef *ref)
{
return ref->shortname;
}
gchar const *
-gitg_ref_get_prefix(GitgRef *ref)
+gitg_ref_get_prefix (GitgRef *ref)
{
return ref->prefix;
}
@@ -224,7 +239,7 @@ gitg_ref_get_local_name (GitgRef *ref)
if (prefix && g_str_has_prefix (shortname, prefix))
{
- return shortname + strlen(prefix) + 1;
+ return shortname + strlen (prefix) + 1;
}
else
{
diff --git a/libgitg/gitg-ref.h b/libgitg/gitg-ref.h
index 154c7a3..3fba9ba 100644
--- a/libgitg/gitg-ref.h
+++ b/libgitg/gitg-ref.h
@@ -24,13 +24,12 @@
#define __GITG_REF_H__
#include <glib-object.h>
-#include "gitg-types.h"
G_BEGIN_DECLS
-#define GITG_TYPE_REF (gitg_ref_get_type ())
-#define GITG_REF(obj) ((GitgRef *)obj)
-#define GITG_REF_CONST(obj) ((GitgRef const *)obj)
+#define GITG_TYPE_REF (gitg_ref_get_type ())
+#define GITG_REF(obj) ((GitgRef *)obj)
+#define GITG_REF_CONST(obj) ((GitgRef const *)obj)
typedef enum
{
@@ -50,36 +49,36 @@ typedef enum
typedef struct _GitgRef GitgRef;
-GType gitg_ref_get_type (void) G_GNUC_CONST;
+GType gitg_ref_get_type (void) G_GNUC_CONST;
-GitgRef *gitg_ref_new (gchar const *hash,
- gchar const *name);
+GitgRef *gitg_ref_new (gchar const *hash,
+ gchar const *name);
-gchar const *gitg_ref_get_hash (GitgRef *ref);
-GitgRefType gitg_ref_get_ref_type (GitgRef *ref);
-gchar const *gitg_ref_get_name (GitgRef *ref);
+gchar const *gitg_ref_get_hash (GitgRef *ref);
+GitgRefType gitg_ref_get_ref_type (GitgRef *ref);
+gchar const *gitg_ref_get_name (GitgRef *ref);
-gchar const *gitg_ref_get_shortname (GitgRef *ref);
-gchar const *gitg_ref_get_prefix (GitgRef *ref);
+gchar const *gitg_ref_get_shortname (GitgRef *ref);
+gchar const *gitg_ref_get_prefix (GitgRef *ref);
-gchar const *gitg_ref_get_local_name (GitgRef *ref);
+gchar const *gitg_ref_get_local_name (GitgRef *ref);
-GitgRefState gitg_ref_get_state (GitgRef *ref);
-void gitg_ref_set_state (GitgRef *ref,
- GitgRefState state);
+GitgRefState gitg_ref_get_state (GitgRef *ref);
+void gitg_ref_set_state (GitgRef *ref,
+ GitgRefState state);
-void gitg_ref_set_working (GitgRef *ref,
- gboolean working);
-gboolean gitg_ref_get_working (GitgRef *ref);
+void gitg_ref_set_working (GitgRef *ref,
+ gboolean working);
+gboolean gitg_ref_get_working (GitgRef *ref);
-GitgRef *gitg_ref_copy (GitgRef *ref);
-void gitg_ref_free (GitgRef *ref);
+GitgRef *gitg_ref_copy (GitgRef *ref);
+void gitg_ref_free (GitgRef *ref);
-gboolean gitg_ref_equal (GitgRef *ref,
- GitgRef *other);
+gboolean gitg_ref_equal (GitgRef *ref,
+ GitgRef *other);
-gboolean gitg_ref_equal_prefix (GitgRef *ref,
- GitgRef *other);
+gboolean gitg_ref_equal_prefix (GitgRef *ref,
+ GitgRef *other);
G_END_DECLS
diff --git a/libgitg/gitg-repository.c b/libgitg/gitg-repository.c
index 2c33051..7b4aa18 100644
--- a/libgitg/gitg-repository.c
+++ b/libgitg/gitg-repository.c
@@ -24,7 +24,6 @@
#include "gitg-hash.h"
#include "gitg-lanes.h"
#include "gitg-ref.h"
-#include "gitg-types.h"
#include "gitg-config.h"
#include <gio/gio.h>
@@ -33,12 +32,12 @@
#include <time.h>
#include <string.h>
-#define GITG_REPOSITORY_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GITG_TYPE_REPOSITORY, GitgRepositoryPrivate))
+#define GITG_REPOSITORY_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_REPOSITORY, GitgRepositoryPrivate))
-static void gitg_repository_tree_model_iface_init(GtkTreeModelIface *iface);
+static void gitg_repository_tree_model_iface_init (GtkTreeModelIface *iface);
-G_DEFINE_TYPE_EXTENDED(GitgRepository, gitg_repository, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE(GTK_TYPE_TREE_MODEL, gitg_repository_tree_model_iface_init));
+G_DEFINE_TYPE_EXTENDED (GitgRepository, gitg_repository, G_TYPE_OBJECT, 0,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, gitg_repository_tree_model_iface_init));
/* Properties */
enum
@@ -126,193 +125,193 @@ struct _GitgRepositoryPrivate
};
inline static gint
-gitg_repository_error_quark()
+gitg_repository_error_quark ()
{
static GQuark quark = 0;
- if (G_UNLIKELY(quark == 0))
- quark = g_quark_from_static_string("GitgRepositoryErrorQuark");
+ if (G_UNLIKELY (quark == 0))
+ quark = g_quark_from_static_string ("GitgRepositoryErrorQuark");
return quark;
}
/* GtkTreeModel implementations */
-static GtkTreeModelFlags
-tree_model_get_flags(GtkTreeModel *tree_model)
+static GtkTreeModelFlags
+tree_model_get_flags (GtkTreeModel *tree_model)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(tree_model), 0);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (tree_model), 0);
return GTK_TREE_MODEL_ITERS_PERSIST | GTK_TREE_MODEL_LIST_ONLY;
}
-static gint
-tree_model_get_n_columns(GtkTreeModel *tree_model)
+static gint
+tree_model_get_n_columns (GtkTreeModel *tree_model)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(tree_model), 0);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (tree_model), 0);
return N_COLUMNS;
}
-static GType
-tree_model_get_column_type(GtkTreeModel *tree_model, gint index)
+static GType
+tree_model_get_column_type (GtkTreeModel *tree_model, gint index)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(tree_model), G_TYPE_INVALID);
- g_return_val_if_fail(index < N_COLUMNS && index >= 0, G_TYPE_INVALID);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (tree_model), G_TYPE_INVALID);
+ g_return_val_if_fail (index < N_COLUMNS && index >= 0, G_TYPE_INVALID);
- return GITG_REPOSITORY(tree_model)->priv->column_types[index];
+ return GITG_REPOSITORY (tree_model)->priv->column_types[index];
}
static void
-fill_iter(GitgRepository *repository, gint index, GtkTreeIter *iter)
+fill_iter (GitgRepository *repository, gint index, GtkTreeIter *iter)
{
iter->stamp = repository->priv->stamp;
- iter->user_data = GINT_TO_POINTER(index);
+ iter->user_data = GINT_TO_POINTER (index);
}
static gboolean
-tree_model_get_iter(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path)
+tree_model_get_iter (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(tree_model), FALSE);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (tree_model), FALSE);
gint *indices;
gint depth;
- indices = gtk_tree_path_get_indices(path);
- depth = gtk_tree_path_get_depth(path);
+ indices = gtk_tree_path_get_indices (path);
+ depth = gtk_tree_path_get_depth (path);
- GitgRepository *rp = GITG_REPOSITORY(tree_model);
+ GitgRepository *rp = GITG_REPOSITORY (tree_model);
- g_return_val_if_fail(depth == 1, FALSE);
+ g_return_val_if_fail (depth == 1, FALSE);
if (indices[0] < 0 || indices[0] >= rp->priv->size)
return FALSE;
- fill_iter(rp, indices[0], iter);
+ fill_iter (rp, indices[0], iter);
return TRUE;
}
static GtkTreePath *
-tree_model_get_path(GtkTreeModel *tree_model, GtkTreeIter *iter)
+tree_model_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(tree_model), NULL);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (tree_model), NULL);
- GitgRepository *rp = GITG_REPOSITORY(tree_model);
- g_return_val_if_fail(iter->stamp == rp->priv->stamp, NULL);
+ GitgRepository *rp = GITG_REPOSITORY (tree_model);
+ g_return_val_if_fail (iter->stamp == rp->priv->stamp, NULL);
- return gtk_tree_path_new_from_indices(GPOINTER_TO_INT(iter->user_data), -1);
+ return gtk_tree_path_new_from_indices (GPOINTER_TO_INT (iter->user_data), -1);
}
-static void
-tree_model_get_value(GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, GValue *value)
+static void
+tree_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, GValue *value)
{
- g_return_if_fail(GITG_IS_REPOSITORY(tree_model));
- g_return_if_fail(column >= 0 && column < N_COLUMNS);
+ g_return_if_fail (GITG_IS_REPOSITORY (tree_model));
+ g_return_if_fail (column >= 0 && column < N_COLUMNS);
- GitgRepository *rp = GITG_REPOSITORY(tree_model);
- g_return_if_fail(iter->stamp == rp->priv->stamp);
+ GitgRepository *rp = GITG_REPOSITORY (tree_model);
+ g_return_if_fail (iter->stamp == rp->priv->stamp);
- gint index = GPOINTER_TO_INT(iter->user_data);
+ gint index = GPOINTER_TO_INT (iter->user_data);
- g_return_if_fail(index >= 0 && index < rp->priv->size);
+ g_return_if_fail (index >= 0 && index < rp->priv->size);
GitgRevision *rv = rp->priv->storage[index];
- g_value_init(value, rp->priv->column_types[column]);
+ g_value_init (value, rp->priv->column_types[column]);
switch (column)
{
case OBJECT_COLUMN:
- g_value_set_boxed(value, rv);
+ g_value_set_boxed (value, rv);
break;
case SUBJECT_COLUMN:
- g_value_set_string(value, gitg_revision_get_subject(rv));
+ g_value_set_string (value, gitg_revision_get_subject (rv));
break;
case AUTHOR_COLUMN:
- g_value_set_string(value, gitg_revision_get_author(rv));
+ g_value_set_string (value, gitg_revision_get_author (rv));
break;
case DATE_COLUMN:
- g_value_take_string(value, gitg_revision_get_timestamp_for_display(rv));
+ g_value_take_string (value, gitg_revision_get_timestamp_for_display (rv));
break;
default:
- g_assert_not_reached();
+ g_assert_not_reached ();
break;
}
}
static gboolean
-tree_model_iter_next(GtkTreeModel *tree_model, GtkTreeIter *iter)
+tree_model_iter_next (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(tree_model), FALSE);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (tree_model), FALSE);
- GitgRepository *rp = GITG_REPOSITORY(tree_model);
- g_return_val_if_fail(iter->stamp == rp->priv->stamp, FALSE);
+ GitgRepository *rp = GITG_REPOSITORY (tree_model);
+ g_return_val_if_fail (iter->stamp == rp->priv->stamp, FALSE);
- gint next = GPOINTER_TO_INT(iter->user_data) + 1;
+ gint next = GPOINTER_TO_INT (iter->user_data) + 1;
if (next >= rp->priv->size)
return FALSE;
- iter->user_data = GINT_TO_POINTER(next);
+ iter->user_data = GINT_TO_POINTER (next);
return TRUE;
}
static gboolean
-tree_model_iter_children(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent)
+tree_model_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(tree_model), FALSE);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (tree_model), FALSE);
// Only root has children, because it's a flat list
if (parent != NULL)
return FALSE;
- GitgRepository *rp = GITG_REPOSITORY(tree_model);
- fill_iter(rp, 0, iter);
+ GitgRepository *rp = GITG_REPOSITORY (tree_model);
+ fill_iter (rp, 0, iter);
return TRUE;
}
static gboolean
-tree_model_iter_has_child(GtkTreeModel *tree_model, GtkTreeIter *iter)
+tree_model_iter_has_child (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(tree_model), FALSE);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (tree_model), FALSE);
// Only root (NULL) has children
return iter == NULL;
}
static gint
-tree_model_iter_n_children(GtkTreeModel *tree_model, GtkTreeIter *iter)
+tree_model_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(tree_model), 0);
- GitgRepository *rp = GITG_REPOSITORY(tree_model);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (tree_model), 0);
+ GitgRepository *rp = GITG_REPOSITORY (tree_model);
return iter ? 0 : rp->priv->size;
}
static gboolean
-tree_model_iter_nth_child(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n)
+tree_model_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(tree_model), FALSE);
- g_return_val_if_fail(n >= 0, FALSE);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (tree_model), FALSE);
+ g_return_val_if_fail (n >= 0, FALSE);
if (parent)
return FALSE;
- GitgRepository *rp = GITG_REPOSITORY(tree_model);
- g_return_val_if_fail(n < rp->priv->size, FALSE);
+ GitgRepository *rp = GITG_REPOSITORY (tree_model);
+ g_return_val_if_fail (n < rp->priv->size, FALSE);
- fill_iter(rp, n, iter);
+ fill_iter (rp, n, iter);
return TRUE;
}
-static gboolean
-tree_model_iter_parent(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child)
+static gboolean
+tree_model_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(tree_model), FALSE);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (tree_model), FALSE);
return FALSE;
}
static void
-gitg_repository_tree_model_iface_init(GtkTreeModelIface *iface)
+gitg_repository_tree_model_iface_init (GtkTreeModelIface *iface)
{
iface->get_flags = tree_model_get_flags;
iface->get_n_columns = tree_model_get_n_columns;
@@ -347,11 +346,11 @@ do_clear (GitgRepository *repository, gboolean emit)
gitg_revision_unref (repository->priv->storage[i]);
}
- gtk_tree_path_free(path);
+ gtk_tree_path_free (path);
if (repository->priv->storage)
{
- g_slice_free1 (sizeof(GitgRevision *) * repository->priv->size,
+ g_slice_free1 (sizeof (GitgRevision *) * repository->priv->size,
repository->priv->storage);
}
@@ -372,18 +371,18 @@ do_clear (GitgRepository *repository, gboolean emit)
}
static void
-gitg_repository_finalize(GObject *object)
+gitg_repository_finalize (GObject *object)
{
- GitgRepository *rp = GITG_REPOSITORY(object);
+ GitgRepository *rp = GITG_REPOSITORY (object);
/* Make sure to cancel the loader */
- gitg_runner_cancel(rp->priv->loader);
- g_object_unref(rp->priv->loader);
+ gitg_runner_cancel (rp->priv->loader);
+ g_object_unref (rp->priv->loader);
- g_object_unref(rp->priv->lanes);
+ g_object_unref (rp->priv->lanes);
/* Clear the model to remove all revision objects */
- do_clear(rp, FALSE);
+ do_clear (rp, FALSE);
if (rp->priv->work_tree)
{
@@ -402,12 +401,12 @@ gitg_repository_finalize(GObject *object)
g_hash_table_destroy (rp->priv->ref_pushes);
/* Free cached args */
- g_strfreev(rp->priv->last_args);
- g_strfreev(rp->priv->selection);
+ g_strfreev (rp->priv->last_args);
+ g_strfreev (rp->priv->selection);
if (rp->priv->idle_relane_id)
{
- g_source_remove(rp->priv->idle_relane_id);
+ g_source_remove (rp->priv->idle_relane_id);
}
if (rp->priv->current_ref)
@@ -426,13 +425,13 @@ gitg_repository_finalize(GObject *object)
g_object_unref (rp->priv->monitor);
}
- G_OBJECT_CLASS (gitg_repository_parent_class)->finalize(object);
+ G_OBJECT_CLASS (gitg_repository_parent_class)->finalize (object);
}
static void
-gitg_repository_set_property(GObject *object, guint prop_id, GValue const *value, GParamSpec *pspec)
+gitg_repository_set_property (GObject *object, guint prop_id, GValue const *value, GParamSpec *pspec)
{
- GitgRepository *self = GITG_REPOSITORY(object);
+ GitgRepository *self = GITG_REPOSITORY (object);
switch (prop_id)
{
@@ -453,47 +452,47 @@ gitg_repository_set_property(GObject *object, guint prop_id, GValue const *value
self->priv->git_dir = g_value_dup_object (value);
break;
case PROP_SHOW_STAGED:
- self->priv->show_staged = g_value_get_boolean(value);
+ self->priv->show_staged = g_value_get_boolean (value);
break;
case PROP_SHOW_UNSTAGED:
- self->priv->show_unstaged = g_value_get_boolean(value);
+ self->priv->show_unstaged = g_value_get_boolean (value);
break;
case PROP_SHOW_STASH:
- self->priv->show_stash = g_value_get_boolean(value);
+ self->priv->show_stash = g_value_get_boolean (value);
break;
case PROP_TOPO_ORDER:
- self->priv->topoorder = g_value_get_boolean(value);
+ self->priv->topoorder = g_value_get_boolean (value);
break;
case PROP_INACTIVE_MAX:
- g_object_set_property(G_OBJECT(self->priv->lanes),
+ g_object_set_property (G_OBJECT (self->priv->lanes),
"inactive-max",
value);
break;
case PROP_INACTIVE_COLLAPSE:
- g_object_set_property(G_OBJECT(self->priv->lanes),
+ g_object_set_property (G_OBJECT (self->priv->lanes),
"inactive-collapse",
value);
break;
case PROP_INACTIVE_GAP:
- g_object_set_property(G_OBJECT(self->priv->lanes),
+ g_object_set_property (G_OBJECT (self->priv->lanes),
"inactive-gap",
value);
break;
case PROP_INACTIVE_ENABLED:
- g_object_set_property(G_OBJECT(self->priv->lanes),
+ g_object_set_property (G_OBJECT (self->priv->lanes),
"inactive-enabled",
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
-gitg_repository_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gitg_repository_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
- GitgRepository *self = GITG_REPOSITORY(object);
+ GitgRepository *self = GITG_REPOSITORY (object);
switch (prop_id)
{
@@ -505,42 +504,42 @@ gitg_repository_get_property(GObject *object, guint prop_id, GValue *value, GPar
break;
break;
case PROP_LOADER:
- g_value_set_object(value, self->priv->loader);
+ g_value_set_object (value, self->priv->loader);
break;
case PROP_SHOW_STAGED:
- g_value_set_boolean(value, self->priv->show_staged);
+ g_value_set_boolean (value, self->priv->show_staged);
break;
case PROP_SHOW_UNSTAGED:
- g_value_set_boolean(value, self->priv->show_unstaged);
+ g_value_set_boolean (value, self->priv->show_unstaged);
break;
case PROP_SHOW_STASH:
- g_value_set_boolean(value, self->priv->show_stash);
+ g_value_set_boolean (value, self->priv->show_stash);
break;
case PROP_TOPO_ORDER:
- g_value_set_boolean(value, self->priv->topoorder);
+ g_value_set_boolean (value, self->priv->topoorder);
break;
case PROP_INACTIVE_MAX:
- g_object_get_property(G_OBJECT(self->priv->lanes),
+ g_object_get_property (G_OBJECT (self->priv->lanes),
"inactive-max",
value);
break;
case PROP_INACTIVE_COLLAPSE:
- g_object_get_property(G_OBJECT(self->priv->lanes),
+ g_object_get_property (G_OBJECT (self->priv->lanes),
"inactive-collapse",
value);
break;
case PROP_INACTIVE_GAP:
- g_object_get_property(G_OBJECT(self->priv->lanes),
+ g_object_get_property (G_OBJECT (self->priv->lanes),
"inactive-gap",
value);
break;
case PROP_INACTIVE_ENABLED:
- g_object_get_property(G_OBJECT(self->priv->lanes),
+ g_object_get_property (G_OBJECT (self->priv->lanes),
"inactive-enabled",
value);
break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
@@ -559,14 +558,14 @@ parse_ref_intern (GitgRepository *repository, gchar const *ref, gboolean symboli
if (!ret)
return NULL;
- gchar *r = g_strdup(*ret);
- g_strfreev(ret);
+ gchar *r = g_strdup (*ret);
+ g_strfreev (ret);
return r;
}
static GitgRef *
-get_current_working_ref(GitgRepository *repository)
+get_current_working_ref (GitgRepository *repository)
{
GitgRef *ret = NULL;
@@ -654,10 +653,10 @@ gitg_repository_constructed (GObject *object)
install_head_monitor (repository);
}
-static void
-gitg_repository_class_init(GitgRepositoryClass *klass)
+static void
+gitg_repository_class_init (GitgRepositoryClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS(klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gitg_repository_finalize;
object_class->set_property = gitg_repository_set_property;
@@ -689,28 +688,28 @@ gitg_repository_class_init(GitgRepositoryClass *klass)
GITG_TYPE_RUNNER,
G_PARAM_READABLE));
- g_object_class_install_property(object_class, PROP_SHOW_STAGED,
+ g_object_class_install_property (object_class, PROP_SHOW_STAGED,
g_param_spec_boolean ("show-staged",
"Show Staged",
"Show staged",
FALSE,
G_PARAM_READWRITE));
- g_object_class_install_property(object_class, PROP_SHOW_UNSTAGED,
+ g_object_class_install_property (object_class, PROP_SHOW_UNSTAGED,
g_param_spec_boolean ("show-unstaged",
"Show Unstaged",
"Show unstaged",
FALSE,
G_PARAM_READWRITE));
- g_object_class_install_property(object_class, PROP_SHOW_STASH,
+ g_object_class_install_property (object_class, PROP_SHOW_STASH,
g_param_spec_boolean ("show-stash",
"Show Stash",
"Show stash",
FALSE,
G_PARAM_READWRITE));
- g_object_class_install_property(object_class, PROP_TOPO_ORDER,
+ g_object_class_install_property (object_class, PROP_TOPO_ORDER,
g_param_spec_boolean ("topo-order",
"Topo order",
"Show in topological order",
@@ -718,8 +717,8 @@ gitg_repository_class_init(GitgRepositoryClass *klass)
G_PARAM_READWRITE));
/* FIXME: gitg-lanes shouldn't be an object? */
- g_object_class_install_property(object_class, PROP_INACTIVE_MAX,
- g_param_spec_int("inactive-max",
+ g_object_class_install_property (object_class, PROP_INACTIVE_MAX,
+ g_param_spec_int ("inactive-max",
"INACTIVE_MAX",
"Maximum inactivity on a lane before collapsing",
1,
@@ -727,8 +726,8 @@ gitg_repository_class_init(GitgRepositoryClass *klass)
30,
G_PARAM_READWRITE));
- g_object_class_install_property(object_class, PROP_INACTIVE_COLLAPSE,
- g_param_spec_int("inactive-collapse",
+ g_object_class_install_property (object_class, PROP_INACTIVE_COLLAPSE,
+ g_param_spec_int ("inactive-collapse",
"INACTIVE_COLLAPSE",
"Number of revisions to collapse",
1,
@@ -736,8 +735,8 @@ gitg_repository_class_init(GitgRepositoryClass *klass)
10,
G_PARAM_READWRITE));
- g_object_class_install_property(object_class, PROP_INACTIVE_GAP,
- g_param_spec_int("inactive-gap",
+ g_object_class_install_property (object_class, PROP_INACTIVE_GAP,
+ g_param_spec_int ("inactive-gap",
"INACTIVE_GAP",
"Minimum of revisions to leave between collapse and expand",
1,
@@ -745,8 +744,8 @@ gitg_repository_class_init(GitgRepositoryClass *klass)
10,
G_PARAM_READWRITE));
- g_object_class_install_property(object_class, PROP_INACTIVE_ENABLED,
- g_param_spec_boolean("inactive-enabled",
+ g_object_class_install_property (object_class, PROP_INACTIVE_ENABLED,
+ g_param_spec_boolean ("inactive-enabled",
"INACTIVE_ENABLED",
"Lane collapsing enabled",
TRUE,
@@ -772,47 +771,47 @@ gitg_repository_class_init(GitgRepositoryClass *klass)
G_TYPE_NONE,
0);
- g_type_class_add_private(object_class, sizeof(GitgRepositoryPrivate));
+ g_type_class_add_private (object_class, sizeof (GitgRepositoryPrivate));
}
static void
-append_revision(GitgRepository *repository, GitgRevision *rv)
+append_revision (GitgRepository *repository, GitgRevision *rv)
{
GSList *lanes;
gint8 mylane = 0;
if (repository->priv->size == 0)
- gitg_lanes_reset(repository->priv->lanes);
+ gitg_lanes_reset (repository->priv->lanes);
- lanes = gitg_lanes_next(repository->priv->lanes, rv, &mylane);
- gitg_revision_set_lanes(rv, lanes, mylane);
+ lanes = gitg_lanes_next (repository->priv->lanes, rv, &mylane);
+ gitg_revision_set_lanes (rv, lanes, mylane);
- gitg_repository_add(repository, rv, NULL);
- gitg_revision_unref(rv);
+ gitg_repository_add (repository, rv, NULL);
+ gitg_revision_unref (rv);
}
static void
-add_dummy_commit(GitgRepository *repository, gboolean staged)
+add_dummy_commit (GitgRepository *repository, gboolean staged)
{
GitgRevision *revision;
gchar const *subject;
struct timeval tv;
- gettimeofday(&tv, NULL);
+ gettimeofday (&tv, NULL);
if (staged)
- subject = _("Staged changes");
+ subject = _ ("Staged changes");
else
- subject = _("Unstaged changes");
+ subject = _ ("Unstaged changes");
- revision = gitg_revision_new("0000000000000000000000000000000000000000", "", subject, NULL, tv.tv_sec);
- gitg_revision_set_sign(revision, staged ? 't' : 'u');
+ revision = gitg_revision_new ("0000000000000000000000000000000000000000", "", subject, NULL, tv.tv_sec);
+ gitg_revision_set_sign (revision, staged ? 't' : 'u');
- append_revision(repository, revision);
+ append_revision (repository, revision);
}
static void
-on_loader_end_loading(GitgRunner *object, gboolean cancelled, GitgRepository *repository)
+on_loader_end_loading (GitgRunner *object, gboolean cancelled, GitgRepository *repository)
{
if (cancelled)
{
@@ -833,15 +832,15 @@ on_loader_end_loading(GitgRunner *object, gboolean cancelled, GitgRepository *re
case LOAD_STAGE_STAGED:
{
/* Check if there are staged changes */
- gchar *head = gitg_repository_parse_head(repository);
+ gchar *head = gitg_repository_parse_head (repository);
const gchar *cached = NULL;
if (current == LOAD_STAGE_STAGED)
{
/* Check if there are unstaged changes */
- if (show_staged && gitg_runner_get_exit_status(object) != 0)
+ if (show_staged && gitg_runner_get_exit_status (object) != 0)
{
- add_dummy_commit(repository, TRUE);
+ add_dummy_commit (repository, TRUE);
}
}
else
@@ -849,17 +848,17 @@ on_loader_end_loading(GitgRunner *object, gboolean cancelled, GitgRepository *re
cached = "--cached";
}
- gitg_repository_run_commandv(repository, object, NULL, "diff-index", "--quiet", head, cached, NULL);
- g_free(head);
+ gitg_repository_run_commandv (repository, object, NULL, "diff-index", "--quiet", head, cached, NULL);
+ g_free (head);
}
break;
case LOAD_STAGE_UNSTAGED:
- if (show_unstaged && gitg_runner_get_exit_status(object) != 0)
+ if (show_unstaged && gitg_runner_get_exit_status (object) != 0)
{
- add_dummy_commit(repository, FALSE);
+ add_dummy_commit (repository, FALSE);
}
- gitg_repository_run_command(repository, object, (gchar const **)repository->priv->last_args, NULL);
+ gitg_repository_run_command (repository, object, (gchar const **)repository->priv->last_args, NULL);
break;
default:
@@ -911,7 +910,7 @@ add_ref (GitgRepository *self, gchar const *sha1, gchar const *name)
}
static void
-loader_update_stash(GitgRepository *repository, gchar **buffer)
+loader_update_stash (GitgRepository *repository, gchar **buffer)
{
gchar *line;
gboolean show_stash;
@@ -921,75 +920,75 @@ loader_update_stash(GitgRepository *repository, gchar **buffer)
if (!show_stash)
return;
- while ((line = *buffer++) != NULL)
+ while ( (line = *buffer++) != NULL)
{
- gchar **components = g_strsplit(line, "\01", 0);
- guint len = g_strv_length(components);
+ gchar **components = g_strsplit (line, "\01", 0);
+ guint len = g_strv_length (components);
if (len < 4)
{
- g_strfreev(components);
+ g_strfreev (components);
continue;
}
/* components -> [hash, author, subject, timestamp] */
- gint64 timestamp = g_ascii_strtoll(components[3], NULL, 0);
- GitgRevision *rv = gitg_revision_new(components[0], components[1], components[2], NULL, timestamp);
+ gint64 timestamp = g_ascii_strtoll (components[3], NULL, 0);
+ GitgRevision *rv = gitg_revision_new (components[0], components[1], components[2], NULL, timestamp);
add_ref (repository, components[0], "refs/stash");
- gitg_revision_set_sign(rv, 's');
- append_revision(repository, rv);
- g_strfreev(components);
+ gitg_revision_set_sign (rv, 's');
+ append_revision (repository, rv);
+ g_strfreev (components);
}
}
static void
-loader_update_commits(GitgRepository *self, gchar **buffer)
+loader_update_commits (GitgRepository *self, gchar **buffer)
{
gchar *line;
- while ((line = *buffer++) != NULL)
+ while ( (line = *buffer++) != NULL)
{
/* new line is read */
- gchar **components = g_strsplit(line, "\01", 0);
- guint len = g_strv_length(components);
+ gchar **components = g_strsplit (line, "\01", 0);
+ guint len = g_strv_length (components);
if (len < 5)
{
- g_strfreev(components);
+ g_strfreev (components);
continue;
}
/* components -> [hash, author, subject, parents ([1 2 3]), timestamp[, leftright]] */
- gint64 timestamp = g_ascii_strtoll(components[4], NULL, 0);
+ gint64 timestamp = g_ascii_strtoll (components[4], NULL, 0);
- GitgRevision *rv = gitg_revision_new(components[0], components[1], components[2], components[3], timestamp);
+ GitgRevision *rv = gitg_revision_new (components[0], components[1], components[2], components[3], timestamp);
- if (len > 5 && strlen(components[5]) == 1 && strchr("<>-^", *components[5]) != NULL)
+ if (len > 5 && strlen (components[5]) == 1 && strchr ("<>-^", *components[5]) != NULL)
{
- gitg_revision_set_sign(rv, *components[5]);
+ gitg_revision_set_sign (rv, *components[5]);
}
- append_revision(self, rv);
- g_strfreev(components);
+ append_revision (self, rv);
+ g_strfreev (components);
}
}
static void
-on_loader_update(GitgRunner *object, gchar **buffer, GitgRepository *repository)
+on_loader_update (GitgRunner *object, gchar **buffer, GitgRepository *repository)
{
switch (repository->priv->load_stage)
{
case LOAD_STAGE_STASH:
- loader_update_stash(repository, buffer);
+ loader_update_stash (repository, buffer);
break;
case LOAD_STAGE_STAGED:
break;
case LOAD_STAGE_UNSTAGED:
break;
case LOAD_STAGE_COMMITS:
- loader_update_commits(repository, buffer);
+ loader_update_commits (repository, buffer);
break;
default:
break;
@@ -997,53 +996,53 @@ on_loader_update(GitgRunner *object, gchar **buffer, GitgRepository *repository)
}
static void
-free_refs(GSList *refs)
+free_refs (GSList *refs)
{
- g_slist_foreach(refs, (GFunc)gitg_ref_free, NULL);
- g_slist_free(refs);
+ g_slist_foreach (refs, (GFunc)gitg_ref_free, NULL);
+ g_slist_free (refs);
}
static gboolean
-repository_relane(GitgRepository *repository)
+repository_relane (GitgRepository *repository)
{
repository->priv->idle_relane_id = 0;
- gitg_lanes_reset(repository->priv->lanes);
+ gitg_lanes_reset (repository->priv->lanes);
guint i;
GtkTreeIter iter;
- GtkTreePath *path = gtk_tree_path_new_first();
+ GtkTreePath *path = gtk_tree_path_new_first ();
for (i = 0; i < repository->priv->size; ++i)
{
gint8 mylane;
GitgRevision *revision = repository->priv->storage[i];
- GSList *lanes = gitg_lanes_next(repository->priv->lanes, revision, &mylane);
- gitg_revision_set_lanes(revision, lanes, mylane);
+ GSList *lanes = gitg_lanes_next (repository->priv->lanes, revision, &mylane);
+ gitg_revision_set_lanes (revision, lanes, mylane);
- fill_iter(repository, i, &iter);
- gtk_tree_model_row_changed(GTK_TREE_MODEL(repository), path, &iter);
+ fill_iter (repository, i, &iter);
+ gtk_tree_model_row_changed (GTK_TREE_MODEL (repository), path, &iter);
- gtk_tree_path_next(path);
+ gtk_tree_path_next (path);
}
- gtk_tree_path_free(path);
+ gtk_tree_path_free (path);
return FALSE;
}
static void
-prepare_relane(GitgRepository *repository)
+prepare_relane (GitgRepository *repository)
{
if (!repository->priv->idle_relane_id)
- repository->priv->idle_relane_id = g_idle_add((GSourceFunc)repository_relane, repository);
+ repository->priv->idle_relane_id = g_idle_add ((GSourceFunc)repository_relane, repository);
}
static void
-on_lane_setting_changed(GitgRepository *repository, GParamSpec *pspec, gpointer useless)
+on_lane_setting_changed (GitgRepository *repository, GParamSpec *pspec, gpointer useless)
{
- prepare_relane(repository);
+ prepare_relane (repository);
}
static gchar **
@@ -1052,7 +1051,7 @@ copy_strv (gchar const **ptr, gint argc)
GPtrArray *ret = g_ptr_array_new ();
gint i = 0;
- while (ptr && ((argc >= 0 && i < argc) || (argc < 0 && ptr[i])))
+ while (ptr && ( (argc >= 0 && i < argc) || (argc < 0 && ptr[i])))
{
g_ptr_array_add (ret, g_strdup (ptr[i]));
++i;
@@ -1063,35 +1062,35 @@ copy_strv (gchar const **ptr, gint argc)
}
static gboolean
-has_left_right(gchar const **av, int argc)
+has_left_right (gchar const **av, int argc)
{
int i;
for (i = 0; i < argc; ++i)
- if (strcmp(av[i], "--left-right") == 0)
+ if (strcmp (av[i], "--left-right") == 0)
return TRUE;
return FALSE;
}
static void
-build_log_args(GitgRepository *self, gint argc, gchar const **av)
+build_log_args (GitgRepository *self, gint argc, gchar const **av)
{
gboolean topoorder;
topoorder = self->priv->topoorder;
- gchar **argv = g_new0(gchar *, 6 + topoorder + (argc > 0 ? argc - 1 : 0));
+ gchar **argv = g_new0 (gchar *, 6 + topoorder + (argc > 0 ? argc - 1 : 0));
- argv[0] = g_strdup("log");
+ argv[0] = g_strdup ("log");
- if (has_left_right(av, argc))
+ if (has_left_right (av, argc))
{
- argv[1] = g_strdup("--pretty=format:%H\x01%an\x01%s\x01%P\x01%at\x01%m");
+ argv[1] = g_strdup ("--pretty=format:%H\x01%an\x01%s\x01%P\x01%at\x01%m");
}
else
{
- argv[1] = g_strdup("--pretty=format:%H\x01%an\x01%s\x01%P\x01%at");
+ argv[1] = g_strdup ("--pretty=format:%H\x01%an\x01%s\x01%P\x01%at");
}
argv[2] = g_strdup ("--encoding=UTF-8");
@@ -1107,14 +1106,14 @@ build_log_args(GitgRepository *self, gint argc, gchar const **av)
if (argc <= 0)
{
- head = gitg_repository_parse_ref(self, "HEAD");
+ head = gitg_repository_parse_ref (self, "HEAD");
if (head)
{
- argv[start] = g_strdup("HEAD");
+ argv[start] = g_strdup ("HEAD");
}
- g_free(head);
+ g_free (head);
}
else
{
@@ -1122,11 +1121,11 @@ build_log_args(GitgRepository *self, gint argc, gchar const **av)
for (i = 0; i < argc; ++i)
{
- argv[start + i] = g_strdup(av[i]);
+ argv[start + i] = g_strdup (av[i]);
}
}
- g_strfreev(self->priv->last_args);
+ g_strfreev (self->priv->last_args);
self->priv->last_args = argv;
gchar **newselection = copy_strv (av, argc);
@@ -1136,7 +1135,7 @@ build_log_args(GitgRepository *self, gint argc, gchar const **av)
}
static void
-on_update_topo_order(GitgRepository *repository, GParamSpec *spec, gpointer useless)
+on_update_topo_order (GitgRepository *repository, GParamSpec *spec, gpointer useless)
{
build_log_args (repository,
g_strv_length (repository->priv->selection),
@@ -1146,13 +1145,13 @@ on_update_topo_order(GitgRepository *repository, GParamSpec *spec, gpointer usel
}
static void
-on_update_virtual(GitgRepository *repository, GParamSpec *spec, gpointer useless)
+on_update_virtual (GitgRepository *repository, GParamSpec *spec, gpointer useless)
{
- gitg_repository_reload(repository);
+ gitg_repository_reload (repository);
}
static void
-gitg_repository_init(GitgRepository *object)
+gitg_repository_init (GitgRepository *object)
{
object->priv = GITG_REPOSITORY_GET_PRIVATE (object);
@@ -1178,11 +1177,11 @@ gitg_repository_init(GitgRepository *object)
NULL,
(GDestroyNotify)free_refs);
- object->priv->loader = gitg_runner_new(10000);
+ object->priv->loader = gitg_runner_new (10000);
g_signal_connect (object->priv->loader,
"update",
- G_CALLBACK(on_loader_update),
+ G_CALLBACK (on_loader_update),
object);
g_signal_connect (object->priv->loader,
@@ -1190,63 +1189,63 @@ gitg_repository_init(GitgRepository *object)
G_CALLBACK (on_loader_end_loading),
object);
- g_signal_connect(object,
+ g_signal_connect (object,
"notify::show-stash",
- G_CALLBACK(on_update_virtual),
+ G_CALLBACK (on_update_virtual),
NULL);
- g_signal_connect(object,
+ g_signal_connect (object,
"notify::show-unstaged",
- G_CALLBACK(on_update_virtual),
+ G_CALLBACK (on_update_virtual),
NULL);
- g_signal_connect(object,
+ g_signal_connect (object,
"notify::show-staged",
- G_CALLBACK(on_update_virtual),
+ G_CALLBACK (on_update_virtual),
NULL);
- g_signal_connect(object,
+ g_signal_connect (object,
"notify::topo-order",
- G_CALLBACK(on_update_topo_order),
+ G_CALLBACK (on_update_topo_order),
NULL);
- g_signal_connect(object,
+ g_signal_connect (object,
"notify::inactive_mac",
- G_CALLBACK(on_lane_setting_changed),
+ G_CALLBACK (on_lane_setting_changed),
NULL);
- g_signal_connect(object,
+ g_signal_connect (object,
"notify::inactive_collapse",
- G_CALLBACK(on_lane_setting_changed),
+ G_CALLBACK (on_lane_setting_changed),
NULL);
- g_signal_connect(object,
+ g_signal_connect (object,
"notify::inactive_gap",
- G_CALLBACK(on_lane_setting_changed),
+ G_CALLBACK (on_lane_setting_changed),
NULL);
- g_signal_connect(object,
+ g_signal_connect (object,
"notify::inactive_enabled",
- G_CALLBACK(on_lane_setting_changed),
+ G_CALLBACK (on_lane_setting_changed),
NULL);
}
static void
-grow_storage(GitgRepository *repository, gint size)
+grow_storage (GitgRepository *repository, gint size)
{
if (repository->priv->size + size <= repository->priv->allocated)
return;
gulong prevallocated = repository->priv->allocated;
repository->priv->allocated += repository->priv->grow_size;
- GitgRevision **newstorage = g_slice_alloc(sizeof(GitgRevision *) * repository->priv->allocated);
+ GitgRevision **newstorage = g_slice_alloc (sizeof (GitgRevision *) * repository->priv->allocated);
int i;
for (i = 0; i < repository->priv->size; ++i)
newstorage[i] = repository->priv->storage[i];
if (repository->priv->storage)
- g_slice_free1(sizeof(GitgRevision *) * prevallocated, repository->priv->storage);
+ g_slice_free1 (sizeof (GitgRevision *) * prevallocated, repository->priv->storage);
repository->priv->storage = newstorage;
}
@@ -1263,7 +1262,7 @@ gitg_repository_new (GFile *git_dir, GFile *work_tree)
GFile *
gitg_repository_get_work_tree (GitgRepository *self)
{
- g_return_val_if_fail (GITG_IS_REPOSITORY(self), NULL);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (self), NULL);
return g_file_dup (self->priv->work_tree);
}
@@ -1277,14 +1276,14 @@ gitg_repository_get_git_dir (GitgRepository *self)
}
GitgRunner *
-gitg_repository_get_loader(GitgRepository *self)
+gitg_repository_get_loader (GitgRepository *self)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(self), NULL);
- return GITG_RUNNER(g_object_ref(self->priv->loader));
+ g_return_val_if_fail (GITG_IS_REPOSITORY (self), NULL);
+ return GITG_RUNNER (g_object_ref (self->priv->loader));
}
static gboolean
-reload_revisions(GitgRepository *repository, GError **error)
+reload_revisions (GitgRepository *repository, GError **error)
{
if (repository->priv->working_ref)
{
@@ -1292,24 +1291,24 @@ reload_revisions(GitgRepository *repository, GError **error)
repository->priv->working_ref = NULL;
}
- g_signal_emit(repository, repository_signals[LOAD], 0);
+ g_signal_emit (repository, repository_signals[LOAD], 0);
repository->priv->load_stage = LOAD_STAGE_STASH;
- return gitg_repository_run_commandv(repository, repository->priv->loader, error, "log", "--pretty=format:%H\x01%an\x01%s\x01%at", "--encoding=UTF-8", "-g", "refs/stash", NULL);
+ return gitg_repository_run_commandv (repository, repository->priv->loader, error, "log", "--pretty=format:%H\x01%an\x01%s\x01%at", "--encoding=UTF-8", "-g", "refs/stash", NULL);
}
static gchar *
-load_current_ref(GitgRepository *self)
+load_current_ref (GitgRepository *self)
{
gchar **out;
gchar *ret = NULL;
gint i;
gint numargs;
- numargs = g_strv_length(self->priv->last_args);
+ numargs = g_strv_length (self->priv->last_args);
- gchar const **argv = g_new0(gchar const *, numargs + 3);
+ gchar const **argv = g_new0 (gchar const *, numargs + 3);
argv[0] = "rev-parse";
argv[1] = "--no-flags";
@@ -1320,26 +1319,26 @@ load_current_ref(GitgRepository *self)
argv[2 + i] = self->priv->last_args[i];
}
- out = gitg_repository_command_with_output(self, argv, NULL);
+ out = gitg_repository_command_with_output (self, argv, NULL);
if (!out)
{
return NULL;
}
- if (*out && !*(out + 1))
+ if (*out && !* (out + 1))
{
- ret = g_strdup(*out);
+ ret = g_strdup (*out);
}
- g_strfreev(out);
+ g_strfreev (out);
return ret;
}
static void
-load_refs(GitgRepository *self)
+load_refs (GitgRepository *self)
{
- gchar **refs = gitg_repository_command_with_outputv(self, NULL, "for-each-ref", "--format=%(refname) %(objectname) %(*objectname)", "refs", NULL);
+ gchar **refs = gitg_repository_command_with_outputv (self, NULL, "for-each-ref", "--format=% (refname) % (objectname) % (*objectname)", "refs", NULL);
if (!refs)
{
@@ -1348,25 +1347,25 @@ load_refs(GitgRepository *self)
gchar **buffer = refs;
gchar *buf;
- gchar *current = load_current_ref(self);
+ gchar *current = load_current_ref (self);
GitgRef *working = gitg_repository_get_current_working_ref (self);
-
+
while (buffer != NULL && (buf = *buffer++) != NULL)
{
// each line will look like <name> <hash>
- gchar **components = g_strsplit(buf, " ", 3);
- guint len = g_strv_length(components);
+ gchar **components = g_strsplit (buf, " ", 3);
+ guint len = g_strv_length (components);
if (len == 2 || len == 3)
{
gchar const *obj = len == 3 && *components[2] ? components[2] : components[1];
- GitgRef *ref = add_ref(self, obj, components[0]);
+ GitgRef *ref = add_ref (self, obj, components[0]);
- if (current != NULL && strcmp(gitg_ref_get_name(ref), current) == 0)
+ if (current != NULL && strcmp (gitg_ref_get_name (ref), current) == 0)
{
- self->priv->current_ref = gitg_ref_copy(ref);
+ self->priv->current_ref = gitg_ref_copy (ref);
}
if (working != NULL && gitg_ref_equal (working, ref))
@@ -1375,15 +1374,15 @@ load_refs(GitgRepository *self)
}
}
- g_strfreev(components);
+ g_strfreev (components);
}
- g_strfreev(refs);
- g_free(current);
+ g_strfreev (refs);
+ g_free (current);
}
void
-gitg_repository_reload(GitgRepository *repository)
+gitg_repository_reload (GitgRepository *repository)
{
g_return_if_fail (GITG_IS_REPOSITORY (repository));
g_return_if_fail (repository->priv->git_dir != NULL);
@@ -1406,47 +1405,47 @@ gitg_repository_load (GitgRepository *self, int argc, gchar const **av, GError *
{
if (error)
{
- *error = g_error_new_literal(gitg_repository_error_quark(), GITG_REPOSITORY_ERROR_NOT_FOUND, _("Not a valid git repository"));
+ *error = g_error_new_literal (gitg_repository_error_quark (), GITG_REPOSITORY_ERROR_NOT_FOUND, _ ("Not a valid git repository"));
}
return FALSE;
}
- gitg_runner_cancel(self->priv->loader);
- gitg_repository_clear(self);
+ gitg_runner_cancel (self->priv->loader);
+ gitg_repository_clear (self);
- build_log_args(self, argc, av);
+ build_log_args (self, argc, av);
/* first get the refs */
- load_refs(self);
+ load_refs (self);
/* request log (all the revision) */
- return reload_revisions(self, error);
+ return reload_revisions (self, error);
}
void
-gitg_repository_add(GitgRepository *self, GitgRevision *obj, GtkTreeIter *iter)
+gitg_repository_add (GitgRepository *self, GitgRevision *obj, GtkTreeIter *iter)
{
GtkTreeIter iter1;
/* validate our parameters */
- g_return_if_fail(GITG_IS_REPOSITORY(self));
+ g_return_if_fail (GITG_IS_REPOSITORY (self));
- grow_storage(self, 1);
+ grow_storage (self, 1);
/* put this object in our data storage */
- self->priv->storage[self->priv->size++] = gitg_revision_ref(obj);
+ self->priv->storage[self->priv->size++] = gitg_revision_ref (obj);
- g_hash_table_insert(self->priv->hashtable, (gpointer)gitg_revision_get_hash(obj), GUINT_TO_POINTER(self->priv->size - 1));
+ g_hash_table_insert (self->priv->hashtable, (gpointer)gitg_revision_get_hash (obj), GUINT_TO_POINTER (self->priv->size - 1));
iter1.stamp = self->priv->stamp;
- iter1.user_data = GINT_TO_POINTER(self->priv->size - 1);
+ iter1.user_data = GINT_TO_POINTER (self->priv->size - 1);
iter1.user_data2 = NULL;
iter1.user_data3 = NULL;
- GtkTreePath *path = gtk_tree_path_new_from_indices(self->priv->size - 1, -1);
- gtk_tree_model_row_inserted(GTK_TREE_MODEL(self), path, &iter1);
- gtk_tree_path_free(path);
+ GtkTreePath *path = gtk_tree_path_new_from_indices (self->priv->size - 1, -1);
+ gtk_tree_model_row_inserted (GTK_TREE_MODEL (self), path, &iter1);
+ gtk_tree_path_free (path);
/* return the iter if the user cares */
if (iter)
@@ -1454,38 +1453,38 @@ gitg_repository_add(GitgRepository *self, GitgRevision *obj, GtkTreeIter *iter)
}
void
-gitg_repository_clear(GitgRepository *repository)
+gitg_repository_clear (GitgRepository *repository)
{
- g_return_if_fail(GITG_IS_REPOSITORY(repository));
- do_clear(repository, TRUE);
+ g_return_if_fail (GITG_IS_REPOSITORY (repository));
+ do_clear (repository, TRUE);
}
GitgRevision *
-gitg_repository_lookup(GitgRepository *store, gchar const *hash)
+gitg_repository_lookup (GitgRepository *store, gchar const *hash)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(store), NULL);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (store), NULL);
- gpointer result = g_hash_table_lookup(store->priv->hashtable, hash);
+ gpointer result = g_hash_table_lookup (store->priv->hashtable, hash);
if (!result)
return NULL;
- return store->priv->storage[GPOINTER_TO_UINT(result)];
+ return store->priv->storage[GPOINTER_TO_UINT (result)];
}
gboolean
-gitg_repository_find_by_hash(GitgRepository *store, gchar const *hash, GtkTreeIter *iter)
+gitg_repository_find_by_hash (GitgRepository *store, gchar const *hash, GtkTreeIter *iter)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(store), FALSE);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (store), FALSE);
- gpointer result = g_hash_table_lookup(store->priv->hashtable, hash);
+ gpointer result = g_hash_table_lookup (store->priv->hashtable, hash);
if (!result)
return FALSE;
- GtkTreePath *path = gtk_tree_path_new_from_indices(GPOINTER_TO_UINT(result), -1);
- gtk_tree_model_get_iter(GTK_TREE_MODEL(store), iter, path);
- gtk_tree_path_free(path);
+ GtkTreePath *path = gtk_tree_path_new_from_indices (GPOINTER_TO_UINT (result), -1);
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (store), iter, path);
+ gtk_tree_path_free (path);
return TRUE;
}
@@ -1511,7 +1510,7 @@ gitg_repository_get_refs (GitgRepository *repository)
for (val = (GSList *)item->data; val; val = val->next)
{
- ret = g_slist_prepend (ret, gitg_ref_copy ((GitgRef *)val->data));
+ ret = g_slist_prepend (ret, gitg_ref_copy ( (GitgRef *)val->data));
}
}
@@ -1522,10 +1521,10 @@ gitg_repository_get_refs (GitgRepository *repository)
}
GSList *
-gitg_repository_get_refs_for_hash(GitgRepository *repository, gchar const *hash)
+gitg_repository_get_refs_for_hash (GitgRepository *repository, gchar const *hash)
{
g_return_val_if_fail (GITG_IS_REPOSITORY (repository), NULL);
- return g_slist_copy ((GSList *)g_hash_table_lookup (repository->priv->refs, hash));
+ return g_slist_copy ( (GSList *)g_hash_table_lookup (repository->priv->refs, hash));
}
GitgRef *
@@ -1556,7 +1555,7 @@ gitg_repository_run_command_with_input (GitgRepository *repository,
g_return_val_if_fail (GITG_IS_RUNNER (runner), FALSE);
g_return_val_if_fail (repository->priv->git_dir != NULL, FALSE);
- guint num = g_strv_length ((gchar **)argv);
+ guint num = g_strv_length ( (gchar **)argv);
guint i;
gchar const **args = g_new0 (gchar const *, num + 6);
@@ -1605,7 +1604,7 @@ gitg_repository_run_command (GitgRepository *repository,
error);
}
-gboolean
+gboolean
gitg_repository_command_with_input (GitgRepository *repository,
gchar const **argv,
gchar const *input,
@@ -1621,7 +1620,7 @@ gitg_repository_command_with_input (GitgRepository *repository,
argv,
input,
error);
- g_object_unref(runner);
+ g_object_unref (runner);
return ret;
}
@@ -1644,61 +1643,61 @@ typedef struct
} CommandOutput;
static void
-command_with_output_update(GitgRunner *runner, gchar **buffer, CommandOutput *output)
+command_with_output_update (GitgRunner *runner, gchar **buffer, CommandOutput *output)
{
- guint num = g_strv_length(buffer);
+ guint num = g_strv_length (buffer);
guint i;
- output->buffer = g_realloc(output->buffer, sizeof(gchar *) * (output->size + num + 1));
+ output->buffer = g_realloc (output->buffer, sizeof (gchar *) * (output->size + num + 1));
for (i = 0; i < num; ++i)
- output->buffer[output->size + i] = g_strdup(buffer[i]);
+ output->buffer[output->size + i] = g_strdup (buffer[i]);
output->size += num;
output->buffer[output->size] = NULL;
}
gchar **
-gitg_repository_command_with_input_and_output(GitgRepository *repository, gchar const **argv, gchar const *input, GError **error)
+gitg_repository_command_with_input_and_output (GitgRepository *repository, gchar const **argv, gchar const *input, GError **error)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(repository), NULL);
- g_return_val_if_fail(repository->priv->git_dir != NULL, NULL);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (repository), NULL);
+ g_return_val_if_fail (repository->priv->git_dir != NULL, NULL);
- GitgRunner *runner = gitg_runner_new_synchronized(1000);
+ GitgRunner *runner = gitg_runner_new_synchronized (1000);
CommandOutput output = {NULL, 0};
- g_signal_connect(runner, "update", G_CALLBACK(command_with_output_update), &output);
- gboolean ret = gitg_repository_run_command_with_input(repository, runner, argv, input, error);
+ g_signal_connect (runner, "update", G_CALLBACK (command_with_output_update), &output);
+ gboolean ret = gitg_repository_run_command_with_input (repository, runner, argv, input, error);
if (!ret)
{
- g_strfreev(output.buffer);
+ g_strfreev (output.buffer);
output.buffer = NULL;
}
- g_object_unref(runner);
+ g_object_unref (runner);
return output.buffer;
}
gchar **
-gitg_repository_command_with_output(GitgRepository *repository, gchar const **argv, GError **error)
+gitg_repository_command_with_output (GitgRepository *repository, gchar const **argv, GError **error)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(repository), NULL);
- g_return_val_if_fail(repository->priv->git_dir != NULL, NULL);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (repository), NULL);
+ g_return_val_if_fail (repository->priv->git_dir != NULL, NULL);
- return gitg_repository_command_with_input_and_output(repository, argv, NULL, error);
+ return gitg_repository_command_with_input_and_output (repository, argv, NULL, error);
}
static gchar const **
-parse_valist(va_list ap)
+parse_valist (va_list ap)
{
gchar const *a;
gchar const **ret = NULL;
guint num = 0;
- while ((a = va_arg(ap, gchar const *)) != NULL)
+ while ( (a = va_arg (ap, gchar const *)) != NULL)
{
- ret = g_realloc(ret, sizeof(gchar const *) * (++num + 1));
+ ret = g_realloc (ret, sizeof (gchar const *) * (++num + 1));
ret[num - 1] = a;
}
@@ -1706,107 +1705,107 @@ parse_valist(va_list ap)
return ret;
}
-gboolean
-gitg_repository_commandv(GitgRepository *repository, GError **error, ...)
+gboolean
+gitg_repository_commandv (GitgRepository *repository, GError **error, ...)
{
va_list ap;
- va_start(ap, error);
- gchar const **argv = parse_valist(ap);
- va_end(ap);
+ va_start (ap, error);
+ gchar const **argv = parse_valist (ap);
+ va_end (ap);
- gboolean ret = gitg_repository_command(repository, argv, error);
- g_free(argv);
+ gboolean ret = gitg_repository_command (repository, argv, error);
+ g_free (argv);
return ret;
}
-gboolean
-gitg_repository_command_with_inputv(GitgRepository *repository, gchar const *input, GError **error, ...)
+gboolean
+gitg_repository_command_with_inputv (GitgRepository *repository, gchar const *input, GError **error, ...)
{
va_list ap;
- va_start(ap, error);
- gchar const **argv = parse_valist(ap);
- va_end(ap);
+ va_start (ap, error);
+ gchar const **argv = parse_valist (ap);
+ va_end (ap);
- gboolean ret = gitg_repository_command_with_input(repository, argv, input, error);
- g_free(argv);
+ gboolean ret = gitg_repository_command_with_input (repository, argv, input, error);
+ g_free (argv);
return ret;
}
-gboolean
-gitg_repository_run_commandv(GitgRepository *repository, GitgRunner *runner, GError **error, ...)
+gboolean
+gitg_repository_run_commandv (GitgRepository *repository, GitgRunner *runner, GError **error, ...)
{
va_list ap;
- va_start(ap, error);
- gchar const **argv = parse_valist(ap);
- va_end(ap);
+ va_start (ap, error);
+ gchar const **argv = parse_valist (ap);
+ va_end (ap);
- gboolean ret = gitg_repository_run_command(repository, runner, argv, error);
- g_free(argv);
+ gboolean ret = gitg_repository_run_command (repository, runner, argv, error);
+ g_free (argv);
return ret;
}
-gboolean
-gitg_repository_run_command_with_inputv(GitgRepository *repository, GitgRunner *runner, gchar const *input, GError **error, ...)
+gboolean
+gitg_repository_run_command_with_inputv (GitgRepository *repository, GitgRunner *runner, gchar const *input, GError **error, ...)
{
va_list ap;
- va_start(ap, error);
- gchar const **argv = parse_valist(ap);
- va_end(ap);
+ va_start (ap, error);
+ gchar const **argv = parse_valist (ap);
+ va_end (ap);
- gboolean ret = gitg_repository_run_command_with_input(repository, runner, argv, input, error);
- g_free(argv);
+ gboolean ret = gitg_repository_run_command_with_input (repository, runner, argv, input, error);
+ g_free (argv);
return ret;
}
gchar **
-gitg_repository_command_with_outputv(GitgRepository *repository, GError **error, ...)
+gitg_repository_command_with_outputv (GitgRepository *repository, GError **error, ...)
{
va_list ap;
- va_start(ap, error);
- gchar const **argv = parse_valist(ap);
- va_end(ap);
+ va_start (ap, error);
+ gchar const **argv = parse_valist (ap);
+ va_end (ap);
- gchar **ret = gitg_repository_command_with_output(repository, argv, error);
- g_free(argv);
+ gchar **ret = gitg_repository_command_with_output (repository, argv, error);
+ g_free (argv);
return ret;
}
gchar **
-gitg_repository_command_with_input_and_outputv(GitgRepository *repository, gchar const *input, GError **error, ...)
+gitg_repository_command_with_input_and_outputv (GitgRepository *repository, gchar const *input, GError **error, ...)
{
va_list ap;
- va_start(ap, error);
- gchar const **argv = parse_valist(ap);
- va_end(ap);
+ va_start (ap, error);
+ gchar const **argv = parse_valist (ap);
+ va_end (ap);
- gchar **ret = gitg_repository_command_with_input_and_output(repository, argv, input, error);
- g_free(argv);
+ gchar **ret = gitg_repository_command_with_input_and_output (repository, argv, input, error);
+ g_free (argv);
return ret;
}
gchar *
-gitg_repository_parse_ref(GitgRepository *repository, gchar const *ref)
+gitg_repository_parse_ref (GitgRepository *repository, gchar const *ref)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(repository), NULL);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (repository), NULL);
return parse_ref_intern (repository, ref, FALSE);
}
gchar *
-gitg_repository_parse_head(GitgRepository *repository)
+gitg_repository_parse_head (GitgRepository *repository)
{
- g_return_val_if_fail(GITG_IS_REPOSITORY(repository), NULL);
+ g_return_val_if_fail (GITG_IS_REPOSITORY (repository), NULL);
- gchar *ret = gitg_repository_parse_ref(repository, "HEAD");
+ gchar *ret = gitg_repository_parse_ref (repository, "HEAD");
if (!ret)
- ret = g_strdup("4b825dc642cb6eb9a060e54bf8d69288fbee4904");
+ ret = g_strdup ("4b825dc642cb6eb9a060e54bf8d69288fbee4904");
return ret;
}
GitgRef *
-gitg_repository_get_current_working_ref(GitgRepository *repository)
+gitg_repository_get_current_working_ref (GitgRepository *repository)
{
if (repository->priv->working_ref)
{
@@ -1835,12 +1834,12 @@ gitg_repository_get_remotes (GitgRepository *repository)
return (gchar **)g_ptr_array_free (remotes, FALSE);
}
- gchar **lines = g_strsplit(ret, "\n", -1);
+ gchar **lines = g_strsplit (ret, "\n", -1);
gchar **ptr = lines;
g_free (ret);
- GRegex *regex = g_regex_new ("remote\\.(.+?)\\.url\\s+(.*)", 0, 0, NULL);
+ GRegex *regex = g_regex_new ("remote\\. (.+?)\\.url\\s+ (.*)", 0, 0, NULL);
while (*ptr)
{
@@ -1917,7 +1916,7 @@ gitg_repository_get_ref_pushes (GitgRepository *repository, GitgRef *ref)
g_free (pushes);
- GRegex *regex = g_regex_new ("remote\\.(.+?)\\.push\\s+.*:refs/heads/(.*)", 0, 0, NULL);
+ GRegex *regex = g_regex_new ("remote\\. (.+?)\\.push\\s+.*:refs/heads/ (.*)", 0, 0, NULL);
GSList *refs = NULL;
while (*ptr)
diff --git a/libgitg/gitg-repository.h b/libgitg/gitg-repository.h
index a631742..01f4ed0 100644
--- a/libgitg/gitg-repository.h
+++ b/libgitg/gitg-repository.h
@@ -25,9 +25,9 @@
#include <gtk/gtk.h>
-#include "gitg-revision.h"
-#include "gitg-runner.h"
-#include "gitg-ref.h"
+#include <libgitg/gitg-revision.h>
+#include <libgitg/gitg-runner.h>
+#include <libgitg/gitg-ref.h>
G_BEGIN_DECLS
diff --git a/libgitg/gitg-revision.c b/libgitg/gitg-revision.c
index e3b522c..5c0b9f9 100644
--- a/libgitg/gitg-revision.c
+++ b/libgitg/gitg-revision.c
@@ -28,10 +28,12 @@ struct _GitgRevision
{
gint refcount;
- Hash hash;
+ GitgHash hash;
+
gchar *author;
gchar *subject;
- Hash *parents;
+
+ GitgHash *parents;
guint num_parents;
char sign;
@@ -42,73 +44,82 @@ struct _GitgRevision
};
static void
-free_lanes(GitgRevision *rv)
+free_lanes (GitgRevision *rv)
{
- g_slist_foreach(rv->lanes, (GFunc)gitg_lane_free, NULL);
- g_slist_free(rv->lanes);
+ g_slist_foreach (rv->lanes, (GFunc)gitg_lane_free, NULL);
+ g_slist_free (rv->lanes);
rv->lanes = NULL;
}
static void
-gitg_revision_finalize(GitgRevision *revision)
+gitg_revision_finalize (GitgRevision *revision)
{
- g_free(revision->author);
- g_free(revision->subject);
- g_free(revision->parents);
+ g_free (revision->author);
+ g_free (revision->subject);
+ g_free (revision->parents);
- free_lanes(revision);
+ free_lanes (revision);
- g_slice_free(GitgRevision, revision);
+ g_slice_free (GitgRevision, revision);
}
GitgRevision *
-gitg_revision_ref(GitgRevision *revision)
+gitg_revision_ref (GitgRevision *revision)
{
if (revision == NULL)
+ {
return NULL;
+ }
- g_atomic_int_inc(&revision->refcount);
+ g_atomic_int_inc (&revision->refcount);
return revision;
}
void
-gitg_revision_unref(GitgRevision *revision)
+gitg_revision_unref (GitgRevision *revision)
{
if (revision == NULL)
+ {
return;
+ }
- if (!g_atomic_int_dec_and_test(&revision->refcount))
+ if (!g_atomic_int_dec_and_test (&revision->refcount))
+ {
return;
+ }
- gitg_revision_finalize(revision);
+ gitg_revision_finalize (revision);
}
-GitgRevision *gitg_revision_new(gchar const *sha,
- gchar const *author,
- gchar const *subject,
- gchar const *parents,
+GitgRevision *gitg_revision_new (gchar const *sha,
+ gchar const *author,
+ gchar const *subject,
+ gchar const *parents,
gint64 timestamp)
{
GitgRevision *rv = g_slice_new0 (GitgRevision);
rv->refcount = 1;
- gitg_hash_sha1_to_hash(sha, rv->hash);
- rv->author = g_strdup(author);
- rv->subject = g_strdup(subject);
+ gitg_hash_sha1_to_hash (sha, rv->hash);
+ rv->author = g_strdup (author);
+ rv->subject = g_strdup (subject);
rv->timestamp = timestamp;
if (parents)
{
- gchar **shas = g_strsplit(parents, " ", 0);
- gint num = g_strv_length(shas);
- rv->parents = g_new(Hash, num + 1);
+ gchar **shas = g_strsplit (parents, " ", 0);
+ gint num = g_strv_length (shas);
+ rv->parents = g_new (GitgHash, num + 1);
gint i;
+
for (i = 0; i < num; ++i)
- gitg_hash_sha1_to_hash(shas[i], rv->parents[i]);
+ {
+ gitg_hash_sha1_to_hash (shas[i], rv->parents[i]);
+ }
- g_strfreev(shas);
+ g_strfreev (shas);
rv->num_parents = num;
}
@@ -116,59 +127,63 @@ GitgRevision *gitg_revision_new(gchar const *sha,
}
gchar const *
-gitg_revision_get_author(GitgRevision *revision)
+gitg_revision_get_author (GitgRevision *revision)
{
return revision->author;
}
gchar const *
-gitg_revision_get_subject(GitgRevision *revision)
+gitg_revision_get_subject (GitgRevision *revision)
{
return revision->subject;
}
guint64
-gitg_revision_get_timestamp(GitgRevision *revision)
+gitg_revision_get_timestamp (GitgRevision *revision)
{
return revision->timestamp;
}
gchar const *
-gitg_revision_get_hash(GitgRevision *revision)
+gitg_revision_get_hash (GitgRevision *revision)
{
return revision->hash;
}
gchar *
-gitg_revision_get_sha1(GitgRevision *revision)
+gitg_revision_get_sha1 (GitgRevision *revision)
{
- char res[HASH_SHA_SIZE];
- gitg_hash_hash_to_sha1(revision->hash, res);
+ char res[GITG_HASH_SHA_SIZE];
+ gitg_hash_hash_to_sha1 (revision->hash, res);
- return g_strndup(res, HASH_SHA_SIZE);
+ return g_strndup (res, GITG_HASH_SHA_SIZE);
}
-Hash *
-gitg_revision_get_parents_hash(GitgRevision *revision, guint *num_parents)
+GitgHash *
+gitg_revision_get_parents_hash (GitgRevision *revision,
+ guint *num_parents)
{
if (num_parents)
+ {
*num_parents = revision->num_parents;
+ }
return revision->parents;
}
gchar **
-gitg_revision_get_parents(GitgRevision *revision)
+gitg_revision_get_parents (GitgRevision *revision)
{
- gchar **ret = g_new(gchar *, revision->num_parents + 1);
+ gchar **ret = g_new (gchar *, revision->num_parents + 1);
+
+ gint i;
- int i;
for (i = 0; i < revision->num_parents; ++i)
{
- ret[i] = g_new(gchar, HASH_SHA_SIZE + 1);
- gitg_hash_hash_to_sha1(revision->parents[i], ret[i]);
+ ret[i] = g_new (gchar, GITG_HASH_SHA_SIZE + 1);
+ gitg_hash_hash_to_sha1 (revision->parents[i], ret[i]);
- ret[i][HASH_SHA_SIZE] = '\0';
+ ret[i][GITG_HASH_SHA_SIZE] = '\0';
}
ret[revision->num_parents] = NULL;
@@ -177,38 +192,43 @@ gitg_revision_get_parents(GitgRevision *revision)
}
GSList *
-gitg_revision_get_lanes(GitgRevision *revision)
+gitg_revision_get_lanes (GitgRevision *revision)
{
return revision->lanes;
}
GSList *
-gitg_revision_remove_lane(GitgRevision *revision, GitgLane *lane)
+gitg_revision_remove_lane (GitgRevision *revision,
+ GitgLane *lane)
{
- revision->lanes = g_slist_remove(revision->lanes, lane);
- gitg_lane_free(lane);
+ revision->lanes = g_slist_remove (revision->lanes, lane);
+ gitg_lane_free (lane);
return revision->lanes;
}
GSList *
-gitg_revision_insert_lane(GitgRevision *revision, GitgLane *lane, gint index)
+gitg_revision_insert_lane (GitgRevision *revision,
+ GitgLane *lane,
+ gint index)
{
- revision->lanes = g_slist_insert(revision->lanes, lane, index);
+ revision->lanes = g_slist_insert (revision->lanes, lane, index);
return revision->lanes;
}
static void
-update_lane_type(GitgRevision *revision)
+update_lane_type (GitgRevision *revision)
{
- GitgLane *lane = (GitgLane *)g_slist_nth_data(revision->lanes, revision->mylane);
+ GitgLane *lane = (GitgLane *)g_slist_nth_data (revision->lanes, revision->mylane);
if (lane == NULL)
+ {
return;
+ }
- lane->type &= ~(GITG_LANE_SIGN_LEFT |
- GITG_LANE_SIGN_RIGHT |
+ lane->type &= ~ (GITG_LANE_SIGN_LEFT |
+ GITG_LANE_SIGN_RIGHT |
GITG_LANE_SIGN_STASH |
GITG_LANE_SIGN_STAGED |
GITG_LANE_SIGN_UNSTAGED);
@@ -233,63 +253,70 @@ update_lane_type(GitgRevision *revision)
}
}
-void
-gitg_revision_set_lanes(GitgRevision *revision, GSList *lanes, gint8 mylane)
+void
+gitg_revision_set_lanes (GitgRevision *revision,
+ GSList *lanes,
+ gint8 mylane)
{
- free_lanes(revision);
+ free_lanes (revision);
revision->lanes = lanes;
if (mylane >= 0)
+ {
revision->mylane = mylane;
+ }
- update_lane_type(revision);
+ update_lane_type (revision);
}
gint8
-gitg_revision_get_mylane(GitgRevision *revision)
+gitg_revision_get_mylane (GitgRevision *revision)
{
return revision->mylane;
}
-void
-gitg_revision_set_mylane(GitgRevision *revision, gint8 mylane)
+void
+gitg_revision_set_mylane (GitgRevision *revision,
+ gint8 mylane)
{
- g_return_if_fail(mylane >= 0);
+ g_return_if_fail (mylane >= 0);
revision->mylane = mylane;
- update_lane_type(revision);
+ update_lane_type (revision);
}
void
-gitg_revision_set_sign(GitgRevision *revision, char sign)
+gitg_revision_set_sign (GitgRevision *revision,
+ char sign)
{
revision->sign = sign;
}
char
-gitg_revision_get_sign(GitgRevision *revision)
+gitg_revision_get_sign (GitgRevision *revision)
{
return revision->sign;
}
-GType
+GType
gitg_revision_get_type (void)
{
static GType our_type = 0;
if (!our_type)
- our_type = g_boxed_type_register_static(
- "GitgRevision",
- (GBoxedCopyFunc)gitg_revision_ref,
- (GBoxedFreeFunc)gitg_revision_unref);
+ {
+ our_type = g_boxed_type_register_static ("GitgRevision",
+ (GBoxedCopyFunc)gitg_revision_ref,
+ (GBoxedFreeFunc)gitg_revision_unref);
+ }
return our_type;
-}
+}
GitgLane *
-gitg_revision_get_lane(GitgRevision *revision)
+gitg_revision_get_lane (GitgRevision *revision)
{
- return (GitgLane *)g_slist_nth_data(revision->lanes, revision->mylane);
+ return (GitgLane *)g_slist_nth_data (revision->lanes, revision->mylane);
}
gchar *
@@ -304,19 +331,19 @@ gitg_revision_get_format_patch_name (GitgRevision *revision)
{
*ptr = '-';
}
- } while (*(ptr = g_utf8_next_char (ptr)));
+ } while (* (ptr = g_utf8_next_char (ptr)));
return ret;
}
gchar *
-gitg_revision_get_timestamp_for_display(GitgRevision *revision)
+gitg_revision_get_timestamp_for_display (GitgRevision *revision)
{
time_t t = gitg_revision_get_timestamp (revision);
- struct tm *tms = localtime(&t);
+ struct tm *tms = localtime (&t);
gchar buf[255];
- strftime(buf, 254, "%c", tms);
- return gitg_convert_utf8(buf, -1);
+ strftime (buf, 254, "%c", tms);
+ return gitg_convert_utf8 (buf, -1);
}
diff --git a/libgitg/gitg-revision.h b/libgitg/gitg-revision.h
index 1f67b00..35a954c 100644
--- a/libgitg/gitg-revision.h
+++ b/libgitg/gitg-revision.h
@@ -24,14 +24,13 @@
#define __GITG_REVISION_H__
#include <glib-object.h>
-#include "gitg-lane.h"
-#include "gitg-types.h"
+#include <libgitg/gitg-lane.h>
G_BEGIN_DECLS
-#define GITG_TYPE_REVISION (gitg_revision_get_type ())
-#define GITG_REVISION(obj) ((GitgRevision *)obj)
-#define GITG_REVISION_CONST(obj) ((GitgRevision const *)obj)
+#define GITG_TYPE_REVISION (gitg_revision_get_type ())
+#define GITG_REVISION(obj) ((GitgRevision *)obj)
+#define GITG_REVISION_CONST(obj) ((GitgRevision const *)obj)
typedef struct _GitgRevision GitgRevision;
@@ -44,7 +43,7 @@ inline gchar const *gitg_revision_get_author(GitgRevision *revision);
inline gchar const *gitg_revision_get_subject(GitgRevision *revision);
inline guint64 gitg_revision_get_timestamp(GitgRevision *revision);
inline gchar const *gitg_revision_get_hash(GitgRevision *revision);
-inline Hash *gitg_revision_get_parents_hash(GitgRevision *revision, guint *num_parents);
+inline GitgHash *gitg_revision_get_parents_hash(GitgRevision *revision, guint *num_parents);
gchar *gitg_revision_get_sha1(GitgRevision *revision);
gchar **gitg_revision_get_parents(GitgRevision *revision);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]