mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-09-18 07:22:39 +00:00
Move the backend part of gitg into a libgitg library.
This commit is contained in:
parent
9583ad558a
commit
2796d4caf6
|
@ -1,6 +1,6 @@
|
||||||
## Process this file with automake to produce Makefile.in
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
SUBDIRS = gitg data po
|
SUBDIRS = libgitg gitg data po
|
||||||
|
|
||||||
DISTCLEANFILES = \
|
DISTCLEANFILES = \
|
||||||
intltool-extract \
|
intltool-extract \
|
||||||
|
|
12
configure.ac
12
configure.ac
|
@ -54,13 +54,18 @@ PKG_CHECK_EXISTS([gtk+-3.0 >= 2.90],
|
||||||
GTK_REQUIRED_VERSION=2.20.0
|
GTK_REQUIRED_VERSION=2.20.0
|
||||||
])
|
])
|
||||||
|
|
||||||
PKG_CHECK_MODULES(PACKAGE, [
|
PKG_CHECK_MODULES(GITG, [
|
||||||
$GTK_REQUIRED >= $GTK_REQUIRED_VERSION
|
$GTK_REQUIRED >= $GTK_REQUIRED_VERSION
|
||||||
gthread-2.0
|
gthread-2.0
|
||||||
gtksourceview-2.0 >= 2.8
|
glib-2.0
|
||||||
|
gobject-2.0
|
||||||
|
gmodule-2.0
|
||||||
gio-2.0
|
gio-2.0
|
||||||
gio-unix-2.0
|
gio-unix-2.0
|
||||||
gmodule-2.0
|
])
|
||||||
|
|
||||||
|
PKG_CHECK_MODULES(PACKAGE, [
|
||||||
|
gtksourceview-2.0 >= 2.8
|
||||||
gconf-2.0
|
gconf-2.0
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -97,6 +102,7 @@ AM_GCONF_SOURCE_2
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
Makefile
|
Makefile
|
||||||
|
libgitg/Makefile
|
||||||
gitg/Makefile
|
gitg/Makefile
|
||||||
data/Makefile
|
data/Makefile
|
||||||
data/gitg.desktop.in
|
data/gitg.desktop.in
|
||||||
|
|
|
@ -3,6 +3,7 @@ bin_PROGRAMS = gitg
|
||||||
AM_CPPFLAGS = \
|
AM_CPPFLAGS = \
|
||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
-I$(srcdir) \
|
-I$(srcdir) \
|
||||||
|
$(GITG_CFLAGS) \
|
||||||
$(PACKAGE_CFLAGS) \
|
$(PACKAGE_CFLAGS) \
|
||||||
$(WARN_CFLAGS) \
|
$(WARN_CFLAGS) \
|
||||||
$(DISABLE_DEPRECATED_CFLAGS) \
|
$(DISABLE_DEPRECATED_CFLAGS) \
|
||||||
|
@ -10,39 +11,23 @@ AM_CPPFLAGS = \
|
||||||
-DGITG_DATADIR=\""$(datadir)/gitg"\" \
|
-DGITG_DATADIR=\""$(datadir)/gitg"\" \
|
||||||
-DGITG_LOCALEDIR=\""$(datadir)/locale"\"
|
-DGITG_LOCALEDIR=\""$(datadir)/locale"\"
|
||||||
|
|
||||||
BUILT_SOURCES = \
|
|
||||||
gitg-enum-types.c \
|
|
||||||
gitg-enum-types.h
|
|
||||||
|
|
||||||
NOINST_H_FILES = \
|
NOINST_H_FILES = \
|
||||||
gitg-branch-actions.h \
|
gitg-branch-actions.h \
|
||||||
gitg-cell-renderer-path.h \
|
gitg-cell-renderer-path.h \
|
||||||
gitg-changed-file.h \
|
|
||||||
gitg-color.h \
|
|
||||||
gitg-config.h \
|
|
||||||
gitg-commit.h \
|
|
||||||
gitg-commit-view.h \
|
gitg-commit-view.h \
|
||||||
gitg-data-binding.h \
|
gitg-data-binding.h \
|
||||||
gitg-debug.h \
|
|
||||||
gitg-diff-line-renderer.h \
|
gitg-diff-line-renderer.h \
|
||||||
gitg-diff-view.h \
|
gitg-diff-view.h \
|
||||||
gitg-dirs.h \
|
gitg-dirs.h \
|
||||||
gitg-dnd.h \
|
gitg-dnd.h \
|
||||||
gitg-label-renderer.h \
|
gitg-label-renderer.h \
|
||||||
gitg-lane.h \
|
|
||||||
gitg-lanes.h \
|
|
||||||
gitg-preferences-dialog.h \
|
gitg-preferences-dialog.h \
|
||||||
gitg-preferences.h \
|
gitg-preferences.h \
|
||||||
gitg-ref.h \
|
|
||||||
gitg-repository.h \
|
|
||||||
gitg-repository-dialog.h \
|
gitg-repository-dialog.h \
|
||||||
gitg-revision.h \
|
|
||||||
gitg-revision-tree-store.h \
|
gitg-revision-tree-store.h \
|
||||||
gitg-revision-tree-view.h \
|
gitg-revision-tree-view.h \
|
||||||
gitg-revision-view.h \
|
gitg-revision-view.h \
|
||||||
gitg-runner.h \
|
|
||||||
gitg-settings.h \
|
gitg-settings.h \
|
||||||
gitg-types.h \
|
|
||||||
gitg-utils.h \
|
gitg-utils.h \
|
||||||
gitg-window.h \
|
gitg-window.h \
|
||||||
gseal-gtk-compat.h
|
gseal-gtk-compat.h
|
||||||
|
@ -52,39 +37,29 @@ gitg_SOURCES = \
|
||||||
gitg.c \
|
gitg.c \
|
||||||
gitg-branch-actions.c \
|
gitg-branch-actions.c \
|
||||||
gitg-cell-renderer-path.c \
|
gitg-cell-renderer-path.c \
|
||||||
gitg-changed-file.c \
|
|
||||||
gitg-color.c \
|
|
||||||
gitg-config.c \
|
|
||||||
gitg-commit.c \
|
|
||||||
gitg-commit-view.c \
|
gitg-commit-view.c \
|
||||||
gitg-data-binding.c \
|
gitg-data-binding.c \
|
||||||
gitg-debug.c \
|
|
||||||
gitg-diff-line-renderer.c \
|
gitg-diff-line-renderer.c \
|
||||||
gitg-diff-view.c \
|
gitg-diff-view.c \
|
||||||
gitg-dirs.c \
|
gitg-dirs.c \
|
||||||
gitg-dnd.c \
|
gitg-dnd.c \
|
||||||
gitg-label-renderer.c \
|
gitg-label-renderer.c \
|
||||||
gitg-lane.c \
|
|
||||||
gitg-lanes.c \
|
|
||||||
gitg-preferences.c \
|
gitg-preferences.c \
|
||||||
gitg-preferences-dialog.c \
|
gitg-preferences-dialog.c \
|
||||||
gitg-ref.c \
|
|
||||||
gitg-repository.c \
|
|
||||||
gitg-repository-dialog.c \
|
gitg-repository-dialog.c \
|
||||||
gitg-revision.c \
|
|
||||||
gitg-revision-tree-store.c \
|
gitg-revision-tree-store.c \
|
||||||
gitg-revision-tree-view.c \
|
gitg-revision-tree-view.c \
|
||||||
gitg-revision-view.c \
|
gitg-revision-view.c \
|
||||||
gitg-runner.c \
|
|
||||||
gitg-settings.c \
|
gitg-settings.c \
|
||||||
gitg-utils.c \
|
gitg-utils.c \
|
||||||
gitg-window.c \
|
gitg-window.c \
|
||||||
$(NOINST_H_FILES)
|
$(NOINST_H_FILES)
|
||||||
|
|
||||||
ENUM_H_FILES = \
|
gitg_LDADD = \
|
||||||
gitg-changed-file.h
|
$(GITG_LIBS) \
|
||||||
|
$(PACKAGE_LIBS) \
|
||||||
|
$(top_builddir)/libgitg/libgitg-1.0.la
|
||||||
|
|
||||||
gitg_LDADD = $(PACKAGE_LIBS)
|
|
||||||
gitg_LDFLAGS = -export-dynamic -no-undefined -export-symbols-regex "^[[^_]].*"
|
gitg_LDFLAGS = -export-dynamic -no-undefined -export-symbols-regex "^[[^_]].*"
|
||||||
|
|
||||||
uidir = $(datadir)/gitg/ui/
|
uidir = $(datadir)/gitg/ui/
|
||||||
|
@ -97,22 +72,8 @@ ui_DATA = \
|
||||||
gitg-tag.ui \
|
gitg-tag.ui \
|
||||||
gitg-repository.ui
|
gitg-repository.ui
|
||||||
|
|
||||||
gitg-enum-types.h: gitg-enum-types.h.template $(ENUM_H_FILES) $(GLIB_MKENUMS)
|
|
||||||
$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template gitg-enum-types.h.template $(ENUM_H_FILES)) > $@
|
|
||||||
|
|
||||||
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)) > $@
|
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
$(ui_DATA) \
|
$(ui_DATA)
|
||||||
gitg-enum-types.h.template \
|
|
||||||
gitg-enum-types.c.template
|
|
||||||
|
|
||||||
|
|
||||||
CLEANFILES = $(BUILT_SOURCES)
|
|
||||||
|
|
||||||
dist-hook:
|
|
||||||
cd $(distdir); rm -f $(BUILT_SOURCES)
|
|
||||||
|
|
||||||
bundle: $(bin_PROGRAMS) $(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 $(SUBDIRS); do (cd $$i && $(MAKE) top_bundledir="$(top_bundledir)" $(AM_MAKEFLAGS) bundle); done; \
|
||||||
|
|
|
@ -21,10 +21,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
#include <libgitg/gitg-hash.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "gitg-branch-actions.h"
|
#include "gitg-branch-actions.h"
|
||||||
#include "gitg-utils.h"
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -378,7 +378,7 @@ get_stash_refspec (GitgRepository *repository, GitgRef *stash)
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gchar **ptr = out;
|
gchar **ptr = out;
|
||||||
gchar *sha1 = gitg_utils_hash_to_sha1_new (gitg_ref_get_hash (stash));
|
gchar *sha1 = gitg_hash_hash_to_sha1_new (gitg_ref_get_hash (stash));
|
||||||
gchar *ret = NULL;
|
gchar *ret = NULL;
|
||||||
|
|
||||||
while (ptr && *ptr)
|
while (ptr && *ptr)
|
||||||
|
@ -1308,10 +1308,10 @@ gitg_branch_actions_rebase (GitgWindow *window,
|
||||||
gchar *head = gitg_repository_parse_head (repository);
|
gchar *head = gitg_repository_parse_head (repository);
|
||||||
Hash hash;
|
Hash hash;
|
||||||
|
|
||||||
gitg_utils_sha1_to_hash (head, hash);
|
gitg_hash_sha1_to_hash (head, hash);
|
||||||
g_free (head);
|
g_free (head);
|
||||||
|
|
||||||
if (gitg_utils_hash_equal (hash, gitg_ref_get_hash (dest)))
|
if (gitg_hash_hash_equal (hash, gitg_ref_get_hash (dest)))
|
||||||
{
|
{
|
||||||
message_dialog (window,
|
message_dialog (window,
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
|
@ -1327,7 +1327,7 @@ gitg_branch_actions_rebase (GitgWindow *window,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *merge_head = gitg_utils_hash_to_sha1_new (gitg_ref_get_hash (dest));
|
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>"),
|
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_ref_type (source) == GITG_REF_TYPE_BRANCH ? _("local") : _("remote"),
|
||||||
|
@ -1538,7 +1538,7 @@ gitg_branch_actions_apply_stash (GitgWindow *window,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *sha1 = gitg_utils_hash_to_sha1_new (gitg_ref_get_hash (stash));
|
gchar *sha1 = gitg_hash_hash_to_sha1_new (gitg_ref_get_hash (stash));
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
if (!gitg_repository_commandv (repository,
|
if (!gitg_repository_commandv (repository,
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
#ifndef __GITG_BRANCH_ACTIONS_H__
|
#ifndef __GITG_BRANCH_ACTIONS_H__
|
||||||
#define __GITG_BRANCH_ACTIONS_H__
|
#define __GITG_BRANCH_ACTIONS_H__
|
||||||
|
|
||||||
|
#include <libgitg/gitg-ref.h>
|
||||||
#include "gitg-window.h"
|
#include "gitg-window.h"
|
||||||
#include "gitg-ref.h"
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <libgitg/gitg-lane.h>
|
||||||
|
#include <libgitg/gitg-revision.h>
|
||||||
|
|
||||||
#include "gitg-cell-renderer-path.h"
|
#include "gitg-cell-renderer-path.h"
|
||||||
#include "gitg-lane.h"
|
|
||||||
#include "gitg-utils.h"
|
|
||||||
#include "gitg-label-renderer.h"
|
#include "gitg-label-renderer.h"
|
||||||
|
|
||||||
#define GITG_CELL_RENDERER_PATH_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_CELL_RENDERER_PATH, GitgCellRendererPathPrivate))
|
#define GITG_CELL_RENDERER_PATH_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_CELL_RENDERER_PATH, GitgCellRendererPathPrivate))
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#define __GITG_CELL_RENDERER_PATH_H__
|
#define __GITG_CELL_RENDERER_PATH_H__
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "gitg-ref.h"
|
#include <libgitg/gitg-ref.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,13 @@
|
||||||
#include <gtksourceview/gtksourcestyleschememanager.h>
|
#include <gtksourceview/gtksourcestyleschememanager.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <libgitg/gitg-commit.h>
|
||||||
|
|
||||||
#include "gitg-commit-view.h"
|
#include "gitg-commit-view.h"
|
||||||
#include "gitg-commit.h"
|
|
||||||
#include "gitg-utils.h"
|
|
||||||
#include "gitg-diff-view.h"
|
#include "gitg-diff-view.h"
|
||||||
#include "gitg-preferences.h"
|
#include "gitg-preferences.h"
|
||||||
#include "gitg-data-binding.h"
|
#include "gitg-data-binding.h"
|
||||||
|
#include "gitg-utils.h"
|
||||||
|
|
||||||
#define GITG_COMMIT_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_COMMIT_VIEW, GitgCommitViewPrivate))
|
#define GITG_COMMIT_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_COMMIT_VIEW, GitgCommitViewPrivate))
|
||||||
#define CATEGORY_UNSTAGE_HUNK "CategoryUnstageHunk"
|
#define CATEGORY_UNSTAGE_HUNK "CategoryUnstageHunk"
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#define __GITG_COMMIT_VIEW_H__
|
#define __GITG_COMMIT_VIEW_H__
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "gitg-repository.h"
|
#include <libgitg/gitg-repository.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gitg-diff-line-renderer.h"
|
|
||||||
#include "gitg-utils.h"
|
#include "gitg-utils.h"
|
||||||
|
#include "gitg-diff-line-renderer.h"
|
||||||
|
|
||||||
#define GITG_DIFF_LINE_RENDERER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_DIFF_LINE_RENDERER, GitgDiffLineRendererPrivate))
|
#define GITG_DIFF_LINE_RENDERER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_DIFF_LINE_RENDERER, GitgDiffLineRendererPrivate))
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,9 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <libgitg/gitg-types.h>
|
||||||
|
|
||||||
#include "gitg-diff-view.h"
|
#include "gitg-diff-view.h"
|
||||||
#include "gitg-types.h"
|
|
||||||
#include "gitg-diff-line-renderer.h"
|
#include "gitg-diff-line-renderer.h"
|
||||||
#include "gitg-utils.h"
|
#include "gitg-utils.h"
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,13 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "gitg-dnd.h"
|
#include "gitg-dnd.h"
|
||||||
#include "gitg-ref.h"
|
|
||||||
#include "gitg-cell-renderer-path.h"
|
#include "gitg-cell-renderer-path.h"
|
||||||
#include "gitg-utils.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include "gitg-window.h"
|
#include "gitg-window.h"
|
||||||
#include "gitg-branch-actions.h"
|
#include "gitg-branch-actions.h"
|
||||||
#include "gseal-gtk-compat.h"
|
#include "gseal-gtk-compat.h"
|
||||||
|
#include "gitg-utils.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
#define __GITG_DND_H__
|
#define __GITG_DND_H__
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "gitg-ref.h"
|
#include <libgitg/gitg-ref.h>
|
||||||
#include "gitg-revision.h"
|
#include <libgitg/gitg-revision.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gitg-label-renderer.h"
|
#include "gitg-label-renderer.h"
|
||||||
#include "gitg-ref.h"
|
|
||||||
#include "gitg-utils.h"
|
#include "gitg-utils.h"
|
||||||
|
|
||||||
|
#include <libgitg/gitg-ref.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define PADDING 4
|
#define PADDING 4
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <pango/pango.h>
|
#include <pango/pango.h>
|
||||||
#include "gitg-ref.h"
|
#include <libgitg/gitg-ref.h>
|
||||||
|
|
||||||
gint gitg_label_renderer_width(GtkWidget *widget, PangoFontDescription *description, GSList *labels);
|
gint gitg_label_renderer_width(GtkWidget *widget, PangoFontDescription *description, GSList *labels);
|
||||||
void gitg_label_renderer_draw(GtkWidget *widget, PangoFontDescription *description, cairo_t *context, GSList *labels, GdkRectangle *area);
|
void gitg_label_renderer_draw(GtkWidget *widget, PangoFontDescription *description, cairo_t *context, GSList *labels, GdkRectangle *area);
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
#include "gitg-preferences.h"
|
#include "gitg-preferences.h"
|
||||||
#include "gitg-data-binding.h"
|
#include "gitg-data-binding.h"
|
||||||
#include "gitg-utils.h"
|
#include "gitg-utils.h"
|
||||||
#include "gitg-config.h"
|
|
||||||
|
|
||||||
|
#include <libgitg/gitg-config.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,10 @@
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <libgitg/gitg-config.h>
|
||||||
|
|
||||||
#include "gitg-repository-dialog.h"
|
#include "gitg-repository-dialog.h"
|
||||||
#include "gitg-utils.h"
|
#include "gitg-utils.h"
|
||||||
#include "gitg-config.h"
|
|
||||||
|
|
||||||
void on_button_fetch_remote_clicked (GtkButton *button,
|
void on_button_fetch_remote_clicked (GtkButton *button,
|
||||||
GitgRepositoryDialog *dialog);
|
GitgRepositoryDialog *dialog);
|
||||||
|
|
|
@ -26,12 +26,12 @@
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <libgitg/gitg-revision.h>
|
||||||
|
#include <libgitg/gitg-runner.h>
|
||||||
|
|
||||||
#include "gitg-revision-tree-view.h"
|
#include "gitg-revision-tree-view.h"
|
||||||
#include "gitg-revision-tree-store.h"
|
#include "gitg-revision-tree-store.h"
|
||||||
#include "gitg-runner.h"
|
|
||||||
#include "gitg-utils.h"
|
#include "gitg-utils.h"
|
||||||
#include "gitg-revision.h"
|
|
||||||
|
|
||||||
#define GITG_REVISION_TREE_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_REVISION_TREE, GitgRevisionTreeViewPrivate))
|
#define GITG_REVISION_TREE_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_REVISION_TREE, GitgRevisionTreeViewPrivate))
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
#define __GITG_REVISION_TREE_VIEW_H__
|
#define __GITG_REVISION_TREE_VIEW_H__
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "gitg-repository.h"
|
#include <libgitg/gitg-repository.h>
|
||||||
#include "gitg-revision.h"
|
#include <libgitg/gitg-revision.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,12 @@
|
||||||
#include <gtksourceview/gtksourcelanguagemanager.h>
|
#include <gtksourceview/gtksourcelanguagemanager.h>
|
||||||
#include <gtksourceview/gtksourcestyleschememanager.h>
|
#include <gtksourceview/gtksourcestyleschememanager.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <libgitg/gitg-revision.h>
|
||||||
|
#include <libgitg/gitg-runner.h>
|
||||||
|
#include <libgitg/gitg-hash.h>
|
||||||
|
|
||||||
#include "gitg-revision-view.h"
|
#include "gitg-revision-view.h"
|
||||||
#include "gitg-diff-view.h"
|
#include "gitg-diff-view.h"
|
||||||
#include "gitg-revision.h"
|
|
||||||
#include "gitg-runner.h"
|
|
||||||
#include "gitg-utils.h"
|
#include "gitg-utils.h"
|
||||||
|
|
||||||
#define GITG_REVISION_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_REVISION_VIEW, GitgRevisionViewPrivate))
|
#define GITG_REVISION_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_REVISION_VIEW, GitgRevisionViewPrivate))
|
||||||
|
@ -633,7 +634,7 @@ make_parent_label(GitgRevisionView *self, gchar const *hash)
|
||||||
gtk_widget_show(ev);
|
gtk_widget_show(ev);
|
||||||
gtk_widget_show(lbl);
|
gtk_widget_show(lbl);
|
||||||
|
|
||||||
g_object_set_data_full(G_OBJECT(ev), HASH_KEY, (gpointer)gitg_utils_sha1_to_hash_new(hash), (GDestroyNotify)g_free);
|
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_signal_connect(ev, "button-release-event", G_CALLBACK(on_parent_clicked), self);
|
||||||
|
|
||||||
return ev;
|
return ev;
|
||||||
|
@ -670,7 +671,7 @@ update_parents(GitgRevisionView *self, GitgRevision *revision)
|
||||||
gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
|
gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
|
||||||
|
|
||||||
/* find subject */
|
/* find subject */
|
||||||
gitg_utils_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 = gitg_repository_lookup(self->priv->repository, hash);
|
||||||
|
|
||||||
|
@ -771,7 +772,7 @@ gitg_revision_view_update(GitgRevisionView *self, GitgRepository *repository, Gi
|
||||||
gtk_label_set_markup(self->priv->subject, subject);
|
gtk_label_set_markup(self->priv->subject, subject);
|
||||||
g_free(subject);
|
g_free(subject);
|
||||||
|
|
||||||
gchar *date = gitg_utils_timestamp_to_str(gitg_revision_get_timestamp(revision));
|
gchar *date = gitg_revision_get_timestamp_for_display(revision);
|
||||||
gtk_label_set_text(self->priv->date, date);
|
gtk_label_set_text(self->priv->date, date);
|
||||||
g_free(date);
|
g_free(date);
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
#define __GITG_REVISION_VIEW_H__
|
#define __GITG_REVISION_VIEW_H__
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "gitg-revision.h"
|
#include <libgitg/gitg-revision.h>
|
||||||
#include "gitg-repository.h"
|
#include <libgitg/gitg-repository.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
|
@ -20,133 +20,51 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include "gitg-dirs.h"
|
||||||
#include <glib.h>
|
#include "gitg-utils.h"
|
||||||
#include <stdlib.h>
|
|
||||||
#include <gconf/gconf-client.h>
|
#include <gconf/gconf-client.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "gitg-utils.h"
|
gchar *
|
||||||
#include "gitg-dirs.h"
|
gitg_utils_get_content_type(GFile *file)
|
||||||
|
|
||||||
inline static guint8
|
|
||||||
atoh(gchar c)
|
|
||||||
{
|
{
|
||||||
if (c >= 'a')
|
GFileInfo *info = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
|
||||||
return c - 'a' + 10;
|
|
||||||
if (c >= 'A')
|
|
||||||
return c - 'A' + 10;
|
|
||||||
|
|
||||||
return c - '0';
|
if (!info || !g_file_info_has_attribute(info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
gchar *content_type = g_strdup(g_file_info_get_content_type(info));
|
||||||
|
g_object_unref(info);
|
||||||
|
|
||||||
|
return content_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
gboolean
|
||||||
gitg_utils_partial_sha1_to_hash(gchar const *sha, gint length, gchar *hash)
|
gitg_utils_can_display_content_type (gchar const *content_type)
|
||||||
{
|
{
|
||||||
if (length % 2 == 1)
|
return g_content_type_is_a (content_type, "text/plain") ||
|
||||||
{
|
g_content_type_equals (content_type, "application/octet-stream");
|
||||||
--length;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < length / 2; ++i)
|
|
||||||
{
|
|
||||||
gchar h = atoh(*(sha++)) << 4;
|
|
||||||
hash[i] = h | atoh(*(sha++));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gitg_utils_sha1_to_hash(gchar const *sha, gchar *hash)
|
|
||||||
{
|
|
||||||
gitg_utils_partial_sha1_to_hash (sha, HASH_SHA_SIZE, hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gitg_utils_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)
|
|
||||||
{
|
|
||||||
sha[pos++] = repr[(hash[i] >> 4) & 0x0f];
|
|
||||||
sha[pos++] = repr[(hash[i] & 0x0f)];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
gitg_utils_hash_to_sha1_new(gchar const *hash)
|
gitg_utils_guess_content_type(GtkTextBuffer *buffer)
|
||||||
{
|
{
|
||||||
gchar *ret = g_new(gchar, HASH_SHA_SIZE + 1);
|
GtkTextIter start;
|
||||||
gitg_utils_hash_to_sha1(hash, ret);
|
GtkTextIter end;
|
||||||
|
|
||||||
ret[HASH_SHA_SIZE] = '\0';
|
gtk_text_buffer_get_start_iter(buffer, &start);
|
||||||
return ret;
|
end = start;
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
gtk_text_iter_forward_chars(&end, 256);
|
||||||
gitg_utils_partial_sha1_to_hash_new (gchar const *sha, gint length, gint *retlen)
|
gchar *data = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
|
||||||
{
|
|
||||||
if (length == -1)
|
|
||||||
{
|
|
||||||
length = strlen (sha);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (length % 2 != 0)
|
gchar *content_type = g_content_type_guess(NULL, (guchar *)data, strlen(data), NULL);
|
||||||
{
|
g_free(data);
|
||||||
--length;
|
|
||||||
}
|
|
||||||
|
|
||||||
*retlen = length / 2;
|
return content_type;
|
||||||
gchar *ret = g_new (gchar, *retlen);
|
|
||||||
|
|
||||||
gitg_utils_partial_sha1_to_hash (sha, length, ret);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
|
||||||
gitg_utils_sha1_to_hash_new(gchar const *sha1)
|
|
||||||
{
|
|
||||||
gchar *ret = g_new(gchar, HASH_BINARY_SIZE);
|
|
||||||
gitg_utils_sha1_to_hash(sha1, ret);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
GFile *
|
|
||||||
gitg_utils_find_dot_git (GFile *location)
|
|
||||||
{
|
|
||||||
location = g_file_dup (location);
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
GFile *tmp;
|
|
||||||
gboolean exists;
|
|
||||||
|
|
||||||
tmp = g_file_get_child (location, ".git");
|
|
||||||
exists = g_file_query_exists (tmp, NULL);
|
|
||||||
|
|
||||||
if (exists)
|
|
||||||
{
|
|
||||||
g_object_unref (location);
|
|
||||||
location = tmp;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref (tmp);
|
|
||||||
|
|
||||||
tmp = g_file_get_parent (location);
|
|
||||||
|
|
||||||
g_object_unref (location);
|
|
||||||
location = tmp;
|
|
||||||
} while (location != NULL);
|
|
||||||
|
|
||||||
return location;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -205,151 +123,6 @@ gitg_utils_export_files (GitgRepository *repository,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
utf8_validate_fallback (gchar *text,
|
|
||||||
gssize size)
|
|
||||||
{
|
|
||||||
gchar const *end;
|
|
||||||
|
|
||||||
while (!g_utf8_validate (text, size, &end))
|
|
||||||
{
|
|
||||||
*((gchar *)end) = '?';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gchar *
|
|
||||||
convert_fallback (gchar const *text,
|
|
||||||
gssize size,
|
|
||||||
gchar const *fallback)
|
|
||||||
{
|
|
||||||
gchar *res;
|
|
||||||
gsize read, written;
|
|
||||||
GString *str = g_string_new ("");
|
|
||||||
|
|
||||||
while ((res = g_convert(text,
|
|
||||||
size,
|
|
||||||
"UTF-8",
|
|
||||||
"ASCII",
|
|
||||||
&read,
|
|
||||||
&written,
|
|
||||||
NULL)) == NULL)
|
|
||||||
{
|
|
||||||
res = g_convert (text, read, "UTF-8", "ASCII", NULL, NULL, NULL);
|
|
||||||
str = g_string_append (str, res);
|
|
||||||
|
|
||||||
str = g_string_append (str, fallback);
|
|
||||||
text = text + read + 1;
|
|
||||||
size = size - read;
|
|
||||||
}
|
|
||||||
|
|
||||||
str = g_string_append (str, res);
|
|
||||||
g_free (res);
|
|
||||||
|
|
||||||
utf8_validate_fallback (str->str, str->len);
|
|
||||||
return g_string_free (str, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
|
||||||
gitg_utils_convert_utf8 (gchar const *str, gssize size)
|
|
||||||
{
|
|
||||||
static gchar *encodings[] = {
|
|
||||||
"ISO-8859-15",
|
|
||||||
"ASCII"
|
|
||||||
};
|
|
||||||
|
|
||||||
if (str == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size == -1)
|
|
||||||
{
|
|
||||||
size = strlen (str);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_utf8_validate (str, size, NULL))
|
|
||||||
{
|
|
||||||
return g_strndup (str, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < sizeof (encodings) / sizeof (gchar *); ++i)
|
|
||||||
{
|
|
||||||
gsize read;
|
|
||||||
gsize written;
|
|
||||||
|
|
||||||
gchar *ret = g_convert (str,
|
|
||||||
size,
|
|
||||||
"UTF-8",
|
|
||||||
encodings[i],
|
|
||||||
&read,
|
|
||||||
&written,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (ret && read == size)
|
|
||||||
{
|
|
||||||
utf8_validate_fallback (ret, written);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
return convert_fallback (str, size, "?");
|
|
||||||
}
|
|
||||||
|
|
||||||
guint
|
|
||||||
gitg_utils_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)
|
|
||||||
h = (h << 5) - h + p[i];
|
|
||||||
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gitg_utils_hash_equal(gconstpointer a, gconstpointer b)
|
|
||||||
{
|
|
||||||
return memcmp(a, b, HASH_BINARY_SIZE) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
gint
|
|
||||||
gitg_utils_null_length(gconstpointer *ptr)
|
|
||||||
{
|
|
||||||
gint ret = 0;
|
|
||||||
|
|
||||||
while (*ptr++)
|
|
||||||
++ret;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
|
||||||
gitg_utils_get_content_type(GFile *file)
|
|
||||||
{
|
|
||||||
GFileInfo *info = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
|
|
||||||
|
|
||||||
if (!info || !g_file_info_has_attribute(info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
gchar *content_type = g_strdup(g_file_info_get_content_type(info));
|
|
||||||
g_object_unref(info);
|
|
||||||
|
|
||||||
return content_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gitg_utils_can_display_content_type (gchar const *content_type)
|
|
||||||
{
|
|
||||||
return g_content_type_is_a (content_type, "text/plain") ||
|
|
||||||
g_content_type_equals (content_type, "application/octet-stream");
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkSourceLanguage *
|
GtkSourceLanguage *
|
||||||
gitg_utils_get_language(gchar const *filename, gchar const *content_type)
|
gitg_utils_get_language(gchar const *filename, gchar const *content_type)
|
||||||
{
|
{
|
||||||
|
@ -360,6 +133,57 @@ gitg_utils_get_language(gchar const *filename, gchar const *content_type)
|
||||||
return gtk_source_language_manager_guess_language(manager, filename, content_type);
|
return gtk_source_language_manager_guess_language(manager, filename, content_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
gitg_utils_get_monospace_font_name(void)
|
||||||
|
{
|
||||||
|
GConfClient *client = gconf_client_get_default();
|
||||||
|
gchar *name = gconf_client_get_string(client, "/desktop/gnome/interface/monospace_font_name", NULL);
|
||||||
|
|
||||||
|
g_object_unref(client);
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gitg_utils_set_monospace_font(GtkWidget *widget)
|
||||||
|
{
|
||||||
|
gchar *name = gitg_utils_get_monospace_font_name();
|
||||||
|
|
||||||
|
if (name)
|
||||||
|
{
|
||||||
|
PangoFontDescription *description = pango_font_description_from_string(name);
|
||||||
|
|
||||||
|
if (description)
|
||||||
|
{
|
||||||
|
gtk_widget_modify_font(widget, description);
|
||||||
|
pango_font_description_free(description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkBuilder *
|
||||||
|
gitg_utils_new_builder(gchar const *filename)
|
||||||
|
{
|
||||||
|
GtkBuilder *b = gtk_builder_new();
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
gchar *path = gitg_dirs_get_data_filename("ui", filename, NULL);
|
||||||
|
|
||||||
|
if (!gtk_builder_add_from_file(b, path, &error))
|
||||||
|
{
|
||||||
|
g_critical("Could not open UI file: %s (%s)", path, error->message);
|
||||||
|
g_error_free(error);
|
||||||
|
|
||||||
|
g_free(path);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(path);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
gitg_utils_sort_names(gchar const *s1, gchar const *s2)
|
gitg_utils_sort_names(gchar const *s1, gchar const *s2)
|
||||||
{
|
{
|
||||||
|
@ -380,24 +204,6 @@ gitg_utils_sort_names(gchar const *s1, gchar const *s2)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
|
||||||
gitg_utils_guess_content_type(GtkTextBuffer *buffer)
|
|
||||||
{
|
|
||||||
GtkTextIter start;
|
|
||||||
GtkTextIter end;
|
|
||||||
|
|
||||||
gtk_text_buffer_get_start_iter(buffer, &start);
|
|
||||||
end = start;
|
|
||||||
|
|
||||||
gtk_text_iter_forward_chars(&end, 256);
|
|
||||||
gchar *data = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
|
|
||||||
|
|
||||||
gchar *content_type = g_content_type_guess(NULL, (guchar *)data, strlen(data), NULL);
|
|
||||||
g_free(data);
|
|
||||||
|
|
||||||
return content_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copied from gedit-utils.c */
|
/* Copied from gedit-utils.c */
|
||||||
void
|
void
|
||||||
gitg_utils_menu_position_under_widget (GtkMenu *menu,
|
gitg_utils_menu_position_under_widget (GtkMenu *menu,
|
||||||
|
@ -479,66 +285,61 @@ gitg_utils_menu_position_under_tree_view (GtkMenu *menu,
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
gitg_utils_get_monospace_font_name (void)
|
gitg_utils_rewrite_hunk_counters (gchar const *header,
|
||||||
|
guint old_count,
|
||||||
|
guint new_count)
|
||||||
{
|
{
|
||||||
GConfClient *client = gconf_client_get_default();
|
if (!header)
|
||||||
gchar *name = gconf_client_get_string(client, "/desktop/gnome/interface/monospace_font_name", NULL);
|
|
||||||
|
|
||||||
g_object_unref(client);
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gitg_utils_set_monospace_font(GtkWidget *widget)
|
|
||||||
{
|
|
||||||
gchar *name = gitg_utils_get_monospace_font_name();
|
|
||||||
|
|
||||||
if (name)
|
|
||||||
{
|
{
|
||||||
PangoFontDescription *description = pango_font_description_from_string(name);
|
return NULL;
|
||||||
|
|
||||||
if (description)
|
|
||||||
{
|
|
||||||
gtk_widget_modify_font(widget, description);
|
|
||||||
pango_font_description_free(description);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(name);
|
gchar *copy = g_strdup (header);
|
||||||
}
|
gchar *ptr1 = g_utf8_strchr (copy, -1, ',');
|
||||||
|
|
||||||
GtkBuilder *
|
if (!ptr1)
|
||||||
gitg_utils_new_builder(gchar const *filename)
|
|
||||||
{
|
|
||||||
GtkBuilder *b = gtk_builder_new();
|
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
gchar *path = gitg_dirs_get_data_filename("ui", filename, NULL);
|
|
||||||
|
|
||||||
if (!gtk_builder_add_from_file(b, path, &error))
|
|
||||||
{
|
{
|
||||||
g_critical("Could not open UI file: %s (%s)", path, error->message);
|
g_free (copy);
|
||||||
g_error_free(error);
|
return NULL;
|
||||||
|
|
||||||
g_free(path);
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(path);
|
gchar *ptrs1 = g_utf8_strchr (ptr1 + 1, -1, ' ');
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
if (!ptrs1)
|
||||||
gitg_utils_timestamp_to_str(guint64 timestamp)
|
{
|
||||||
{
|
g_free (copy);
|
||||||
time_t t = timestamp;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
struct tm *tms = localtime(&t);
|
gchar *ptr2 = g_utf8_strchr (ptrs1 + 1, -1, ',');
|
||||||
gchar buf[255];
|
|
||||||
|
|
||||||
strftime(buf, 254, "%c", tms);
|
if (!ptr2)
|
||||||
return gitg_utils_convert_utf8(buf, -1);
|
{
|
||||||
|
g_free (copy);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *ptrs2 = g_utf8_strchr (ptr2 + 1, -1, ' ');
|
||||||
|
|
||||||
|
if (!ptrs2)
|
||||||
|
{
|
||||||
|
g_free (copy);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ptr1 = *ptr2 = '\0';
|
||||||
|
|
||||||
|
gchar *ret;
|
||||||
|
|
||||||
|
ret = g_strdup_printf ("%s,%d%s,%d%s",
|
||||||
|
copy,
|
||||||
|
old_count,
|
||||||
|
ptrs1,
|
||||||
|
new_count,
|
||||||
|
ptrs2);
|
||||||
|
|
||||||
|
g_free (copy);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkCellRenderer *
|
GtkCellRenderer *
|
||||||
|
@ -645,64 +446,6 @@ gitg_utils_restore_pane_position (GtkPaned *paned, gint position, gboolean rever
|
||||||
G_CONNECT_AFTER);
|
G_CONNECT_AFTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
|
||||||
gitg_utils_rewrite_hunk_counters (gchar const *header,
|
|
||||||
guint old_count,
|
|
||||||
guint new_count)
|
|
||||||
{
|
|
||||||
if (!header)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *copy = g_strdup (header);
|
|
||||||
gchar *ptr1 = g_utf8_strchr (copy, -1, ',');
|
|
||||||
|
|
||||||
if (!ptr1)
|
|
||||||
{
|
|
||||||
g_free (copy);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *ptrs1 = g_utf8_strchr (ptr1 + 1, -1, ' ');
|
|
||||||
|
|
||||||
if (!ptrs1)
|
|
||||||
{
|
|
||||||
g_free (copy);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *ptr2 = g_utf8_strchr (ptrs1 + 1, -1, ',');
|
|
||||||
|
|
||||||
if (!ptr2)
|
|
||||||
{
|
|
||||||
g_free (copy);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *ptrs2 = g_utf8_strchr (ptr2 + 1, -1, ' ');
|
|
||||||
|
|
||||||
if (!ptrs2)
|
|
||||||
{
|
|
||||||
g_free (copy);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ptr1 = *ptr2 = '\0';
|
|
||||||
|
|
||||||
gchar *ret;
|
|
||||||
|
|
||||||
ret = g_strdup_printf ("%s,%d%s,%d%s",
|
|
||||||
copy,
|
|
||||||
old_count,
|
|
||||||
ptrs1,
|
|
||||||
new_count,
|
|
||||||
ptrs2);
|
|
||||||
|
|
||||||
g_free (copy);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gitg_utils_rounded_rectangle(cairo_t *ctx, gdouble x, gdouble y, gdouble width, gdouble height, gdouble radius)
|
gitg_utils_rounded_rectangle(cairo_t *ctx, gdouble x, gdouble y, gdouble width, gdouble height, gdouble radius)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,54 +25,36 @@
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gtksourceview/gtksourcelanguagemanager.h>
|
#include <gtksourceview/gtksourcelanguagemanager.h>
|
||||||
#include <gio/gio.h>
|
#include <gtksourceview/gtksourcelanguage.h>
|
||||||
|
|
||||||
#include "gitg-repository.h"
|
#include <libgitg/gitg-repository.h>
|
||||||
#include "gitg-revision.h"
|
#include <libgitg/gitg-revision.h>
|
||||||
|
|
||||||
void gitg_utils_sha1_to_hash(gchar const *sha, gchar *hash);
|
gchar *gitg_utils_get_content_type(GFile *file);
|
||||||
void gitg_utils_hash_to_sha1(gchar const *hash, gchar *sha);
|
gboolean gitg_utils_can_display_content_type(gchar const *content_type);
|
||||||
|
gchar *gitg_utils_guess_content_type(GtkTextBuffer *buffer);
|
||||||
void gitg_utils_partial_sha1_to_hash (gchar const *sha, gint length, gchar *hash);
|
|
||||||
|
|
||||||
gchar *gitg_utils_sha1_to_hash_new(gchar const *sha);
|
|
||||||
gchar *gitg_utils_hash_to_sha1_new(gchar const *hash);
|
|
||||||
|
|
||||||
gchar *gitg_utils_partial_sha1_to_hash_new (gchar const *sha, gint length, gint *retlen);
|
|
||||||
|
|
||||||
GFile *gitg_utils_find_dot_git (GFile *location);
|
|
||||||
|
|
||||||
gboolean gitg_utils_export_files(GitgRepository *repository, GitgRevision *revision,
|
gboolean gitg_utils_export_files(GitgRepository *repository, GitgRevision *revision,
|
||||||
gchar const *todir, gchar * const *paths);
|
gchar const *todir, gchar * const *paths);
|
||||||
|
|
||||||
gchar *gitg_utils_convert_utf8(gchar const *str, gssize size);
|
|
||||||
|
|
||||||
guint gitg_utils_hash_hash(gconstpointer v);
|
|
||||||
gboolean gitg_utils_hash_equal(gconstpointer a, gconstpointer b);
|
|
||||||
gint gitg_utils_null_length(gconstpointer *ptr);
|
|
||||||
|
|
||||||
gchar *gitg_utils_get_content_type(GFile *file);
|
|
||||||
GtkSourceLanguage *gitg_utils_get_language(gchar const *filename, gchar const *content_type);
|
GtkSourceLanguage *gitg_utils_get_language(gchar const *filename, gchar const *content_type);
|
||||||
gboolean gitg_utils_can_display_content_type(gchar const *content_type);
|
|
||||||
gchar *gitg_utils_guess_content_type(GtkTextBuffer *buffer);
|
gchar *gitg_utils_get_monospace_font_name(void);
|
||||||
|
void gitg_utils_set_monospace_font(GtkWidget *widget);
|
||||||
|
|
||||||
|
GtkBuilder *gitg_utils_new_builder(gchar const *filename);
|
||||||
|
|
||||||
gint gitg_utils_sort_names(gchar const *s1, gchar const *s2);
|
gint gitg_utils_sort_names(gchar const *s1, gchar const *s2);
|
||||||
|
|
||||||
void gitg_utils_menu_position_under_widget(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data);
|
void gitg_utils_menu_position_under_widget(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data);
|
||||||
void gitg_utils_menu_position_under_tree_view(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data);
|
void gitg_utils_menu_position_under_tree_view(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data);
|
||||||
|
|
||||||
gchar *gitg_utils_get_monospace_font_name (void);
|
gchar *gitg_utils_rewrite_hunk_counters (gchar const *hunk, guint old_count, guint new_count);
|
||||||
void gitg_utils_set_monospace_font(GtkWidget *widget);
|
|
||||||
|
|
||||||
gchar *gitg_utils_timestamp_to_str(guint64 timestamp);
|
|
||||||
|
|
||||||
GtkBuilder *gitg_utils_new_builder(gchar const *filename);
|
|
||||||
GtkCellRenderer *gitg_utils_find_cell_at_pos (GtkTreeView *tree_view, GtkTreeViewColumn *column, GtkTreePath *path, gint x);
|
GtkCellRenderer *gitg_utils_find_cell_at_pos (GtkTreeView *tree_view, GtkTreeViewColumn *column, GtkTreePath *path, gint x);
|
||||||
|
|
||||||
void gitg_utils_restore_pane_position (GtkPaned *paned, gint position, gboolean reversed);
|
void gitg_utils_restore_pane_position (GtkPaned *paned, gint position, gboolean reversed);
|
||||||
|
|
||||||
gchar *gitg_utils_rewrite_hunk_counters (gchar const *hunk, guint old_count, guint new_count);
|
|
||||||
void gitg_utils_rounded_rectangle (cairo_t *ctx, gdouble x, gdouble y, gdouble width, gdouble height, gdouble radius);
|
void gitg_utils_rounded_rectangle (cairo_t *ctx, gdouble x, gdouble y, gdouble width, gdouble height, gdouble radius);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GITG_UTILS_H__ */
|
#endif /* __GITG_UTILS_H__ */
|
||||||
|
|
|
@ -24,13 +24,15 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
#include <libgitg/gitg-config.h>
|
||||||
|
#include <libgitg/gitg-ref.h>
|
||||||
|
#include <libgitg/gitg-runner.h>
|
||||||
|
#include <libgitg/gitg-hash.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "gitg-data-binding.h"
|
||||||
#include "gitg-dirs.h"
|
#include "gitg-dirs.h"
|
||||||
#include "gitg-ref.h"
|
|
||||||
#include "gitg-utils.h"
|
|
||||||
#include "gitg-runner.h"
|
|
||||||
#include "gitg-window.h"
|
#include "gitg-window.h"
|
||||||
#include "gitg-revision-view.h"
|
#include "gitg-revision-view.h"
|
||||||
#include "gitg-revision-tree-view.h"
|
#include "gitg-revision-tree-view.h"
|
||||||
|
@ -42,7 +44,7 @@
|
||||||
#include "gitg-dnd.h"
|
#include "gitg-dnd.h"
|
||||||
#include "gitg-branch-actions.h"
|
#include "gitg-branch-actions.h"
|
||||||
#include "gitg-preferences.h"
|
#include "gitg-preferences.h"
|
||||||
#include "gitg-config.h"
|
#include "gitg-utils.h"
|
||||||
|
|
||||||
#define DYNAMIC_ACTION_DATA_KEY "GitgDynamicActionDataKey"
|
#define DYNAMIC_ACTION_DATA_KEY "GitgDynamicActionDataKey"
|
||||||
#define DYNAMIC_ACTION_DATA_REMOTE_KEY "GitgDynamicActionDataRemoteKey"
|
#define DYNAMIC_ACTION_DATA_REMOTE_KEY "GitgDynamicActionDataRemoteKey"
|
||||||
|
@ -971,7 +973,7 @@ gitg_window_set_select_on_load (GitgWindow *window,
|
||||||
|
|
||||||
if (resolved && strlen (resolved) == HASH_SHA_SIZE)
|
if (resolved && strlen (resolved) == HASH_SHA_SIZE)
|
||||||
{
|
{
|
||||||
gitg_utils_sha1_to_hash (resolved, window->priv->select_on_load);
|
gitg_hash_sha1_to_hash (resolved, window->priv->select_on_load);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (resolved);
|
g_free (resolved);
|
||||||
|
@ -1020,6 +1022,85 @@ parse_gitg_uri (GFile *file, GFile **work_tree, gchar **selection)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
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);
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
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_value_set_int(value, 10);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
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);
|
||||||
|
|
||||||
|
gboolean s = g_value_get_boolean(setting);
|
||||||
|
g_value_set_boolean(value, s);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
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",
|
||||||
|
window->priv->repository, "inactive-enabled",
|
||||||
|
convert_setting_to_inactive_enabled,
|
||||||
|
window);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
create_repository (GitgWindow *window,
|
create_repository (GitgWindow *window,
|
||||||
GFile *git_dir,
|
GFile *git_dir,
|
||||||
|
@ -1038,6 +1119,8 @@ create_repository (GitgWindow *window,
|
||||||
gitg_window_set_select_on_load (window, selection);
|
gitg_window_set_select_on_load (window, selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bind_repository (window);
|
||||||
|
|
||||||
return window->priv->repository != NULL;
|
return window->priv->repository != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1487,6 +1570,38 @@ gitg_window_load_repository (GitgWindow *window,
|
||||||
selection);
|
selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GFile *
|
||||||
|
find_dot_git (GFile *location)
|
||||||
|
{
|
||||||
|
location = g_file_dup (location);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
GFile *tmp;
|
||||||
|
gboolean exists;
|
||||||
|
|
||||||
|
tmp = g_file_get_child (location, ".git");
|
||||||
|
exists = g_file_query_exists (tmp, NULL);
|
||||||
|
|
||||||
|
if (exists)
|
||||||
|
{
|
||||||
|
g_object_unref (location);
|
||||||
|
location = tmp;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (tmp);
|
||||||
|
|
||||||
|
tmp = g_file_get_parent (location);
|
||||||
|
|
||||||
|
g_object_unref (location);
|
||||||
|
location = tmp;
|
||||||
|
} while (location != NULL);
|
||||||
|
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
load_repository_for_command_line (GitgWindow *window,
|
load_repository_for_command_line (GitgWindow *window,
|
||||||
gint argc,
|
gint argc,
|
||||||
|
@ -1504,7 +1619,7 @@ load_repository_for_command_line (GitgWindow *window,
|
||||||
|
|
||||||
if (!parse_gitg_uri (first_arg, &work_tree, &sel))
|
if (!parse_gitg_uri (first_arg, &work_tree, &sel))
|
||||||
{
|
{
|
||||||
git_dir = gitg_utils_find_dot_git (first_arg);
|
git_dir = find_dot_git (first_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (git_dir || (work_tree && g_file_query_exists (work_tree, NULL)))
|
if (git_dir || (work_tree && g_file_query_exists (work_tree, NULL)))
|
||||||
|
@ -1526,7 +1641,7 @@ load_repository_for_command_line (GitgWindow *window,
|
||||||
gchar *cwd = g_get_current_dir ();
|
gchar *cwd = g_get_current_dir ();
|
||||||
|
|
||||||
GFile *file = g_file_new_for_path (cwd);
|
GFile *file = g_file_new_for_path (cwd);
|
||||||
git_dir = gitg_utils_find_dot_git (file);
|
git_dir = find_dot_git (file);
|
||||||
|
|
||||||
g_free (cwd);
|
g_free (cwd);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#define __GITG_WINDOW_H__
|
#define __GITG_WINDOW_H__
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "gitg-repository.h"
|
#include <libgitg/gitg-repository.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gtksourceview/gtksourcelanguagemanager.h>
|
#include <gtksourceview/gtksourcelanguagemanager.h>
|
||||||
#include <gtksourceview/gtksourcestyleschememanager.h>
|
#include <gtksourceview/gtksourcestyleschememanager.h>
|
||||||
|
#include <libgitg/gitg-debug.h>
|
||||||
|
|
||||||
#include "gitg-debug.h"
|
|
||||||
#include "gitg-window.h"
|
#include "gitg-window.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gitg-settings.h"
|
#include "gitg-settings.h"
|
||||||
|
|
84
libgitg/Makefile.am
Normal file
84
libgitg/Makefile.am
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
lib_LTLIBRARIES = libgitg-1.0.la
|
||||||
|
|
||||||
|
INCLUDES = \
|
||||||
|
-I$(top_srcdir) \
|
||||||
|
-I$(srcdir) \
|
||||||
|
$(GITG_CFLAGS) \
|
||||||
|
$(WARN_CFLAGS) \
|
||||||
|
$(DISABLE_DEPRECATED_CFLAGS) \
|
||||||
|
-DDATADIR=\""$(datadir)"\" \
|
||||||
|
-DLIBDIR=\""$(libdir)"\" \
|
||||||
|
-DGITG_LOCALEDIR=\""$(datadir)/locale"\"
|
||||||
|
|
||||||
|
libgitg_1_0_la_LDFLAGS = \
|
||||||
|
-export-dynamic -no-undefined -export-symbols-regex "^[^_].*"
|
||||||
|
|
||||||
|
libgitg_1_0_la_LIBADD = $(GITG_LIBS)
|
||||||
|
|
||||||
|
BUILT_SOURCES = \
|
||||||
|
gitg-enum-types.h \
|
||||||
|
gitg-enum-types.c
|
||||||
|
|
||||||
|
INST_H_FILES = \
|
||||||
|
$(BUILT_H_FILES) \
|
||||||
|
gitg-changed-file.h \
|
||||||
|
gitg-commit.h \
|
||||||
|
gitg-hash.h \
|
||||||
|
gitg-lane.h \
|
||||||
|
gitg-ref.h \
|
||||||
|
gitg-repository.h \
|
||||||
|
gitg-revision.h \
|
||||||
|
gitg-runner.h \
|
||||||
|
gitg-types.h
|
||||||
|
|
||||||
|
NOINST_H_FILES = \
|
||||||
|
gitg-color.h \
|
||||||
|
gitg-config.h \
|
||||||
|
gitg-convert.h \
|
||||||
|
gitg-debug.h \
|
||||||
|
gitg-i18n.h \
|
||||||
|
gitg-lanes.h
|
||||||
|
|
||||||
|
C_FILES = \
|
||||||
|
$(BUILT_SOURCES) \
|
||||||
|
gitg-changed-file.c \
|
||||||
|
gitg-color.c \
|
||||||
|
gitg-commit.c \
|
||||||
|
gitg-config.c \
|
||||||
|
gitg-convert.c \
|
||||||
|
gitg-debug.c \
|
||||||
|
gitg-hash.c \
|
||||||
|
gitg-i18n.c \
|
||||||
|
gitg-lane.c \
|
||||||
|
gitg-lanes.c \
|
||||||
|
gitg-ref.c \
|
||||||
|
gitg-repository.c \
|
||||||
|
gitg-revision.c \
|
||||||
|
gitg-runner.c
|
||||||
|
|
||||||
|
ENUM_H_FILES = \
|
||||||
|
gitg-changed-file.h
|
||||||
|
|
||||||
|
libgitg_1_0_la_SOURCES = \
|
||||||
|
$(INST_H_FILES) \
|
||||||
|
$(NOINST_H_FILES) \
|
||||||
|
$(C_FILES)
|
||||||
|
|
||||||
|
headerdir = $(prefix)/include/libgitg-1.0/libgitg
|
||||||
|
header_DATA = $(INST_H_FILES)
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
gitg-enum-types.h.template \
|
||||||
|
gitg-enum-types.c.template
|
||||||
|
|
||||||
|
CLEANFILES = $(BUILT_SOURCES)
|
||||||
|
|
||||||
|
dist-hook:
|
||||||
|
cd $(distdir); rm -f $(BUILT_SOURCES)
|
||||||
|
|
||||||
|
gitg-enum-types.h: gitg-enum-types.h.template $(ENUM_H_FILES) $(GLIB_MKENUMS)
|
||||||
|
$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template gitg-enum-types.h.template $(ENUM_H_FILES)) > $@
|
||||||
|
|
||||||
|
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)) > $@
|
||||||
|
|
|
@ -34,14 +34,14 @@ struct _GitgColor
|
||||||
gint8 index;
|
gint8 index;
|
||||||
};
|
};
|
||||||
|
|
||||||
void gitg_color_reset (void);
|
void gitg_color_reset(void);
|
||||||
void gitg_color_get (GitgColor *color, gdouble *r, gdouble *g, gdouble *b);
|
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_set_cairo_source(GitgColor *color, cairo_t *cr);
|
||||||
|
|
||||||
GitgColor *gitg_color_next (void);
|
GitgColor *gitg_color_next(void);
|
||||||
GitgColor *gitg_color_next_index (GitgColor *color);
|
GitgColor *gitg_color_next_index(GitgColor *color);
|
||||||
GitgColor *gitg_color_ref (GitgColor *color);
|
GitgColor *gitg_color_ref(GitgColor *color);
|
||||||
GitgColor *gitg_color_copy (GitgColor *color);
|
GitgColor *gitg_color_copy(GitgColor *color);
|
||||||
GitgColor *gitg_color_unref (GitgColor *color);
|
GitgColor *gitg_color_unref(GitgColor *color);
|
||||||
|
|
||||||
#endif /* __GITG_COLOR_H__ */
|
#endif /* __GITG_COLOR_H__ */
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
#include "gitg-commit.h"
|
#include "gitg-commit.h"
|
||||||
#include "gitg-runner.h"
|
#include "gitg-runner.h"
|
||||||
#include "gitg-utils.h"
|
|
||||||
#include "gitg-changed-file.h"
|
#include "gitg-changed-file.h"
|
||||||
#include "gitg-config.h"
|
#include "gitg-config.h"
|
||||||
|
|
118
libgitg/gitg-convert.c
Normal file
118
libgitg/gitg-convert.c
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
/*
|
||||||
|
* gitg-convert.c
|
||||||
|
* This file is part of gitg - git repository viewer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gitg-convert.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
utf8_validate_fallback (gchar *text,
|
||||||
|
gssize size)
|
||||||
|
{
|
||||||
|
gchar const *end;
|
||||||
|
|
||||||
|
while (!g_utf8_validate (text, size, &end))
|
||||||
|
{
|
||||||
|
*((gchar *)end) = '?';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
convert_fallback (gchar const *text,
|
||||||
|
gssize size,
|
||||||
|
gchar const *fallback)
|
||||||
|
{
|
||||||
|
gchar *res;
|
||||||
|
gsize read, written;
|
||||||
|
GString *str = g_string_new ("");
|
||||||
|
|
||||||
|
while ((res = g_convert(text,
|
||||||
|
size,
|
||||||
|
"UTF-8",
|
||||||
|
"ASCII",
|
||||||
|
&read,
|
||||||
|
&written,
|
||||||
|
NULL)) == NULL)
|
||||||
|
{
|
||||||
|
res = g_convert (text, read, "UTF-8", "ASCII", NULL, NULL, NULL);
|
||||||
|
str = g_string_append (str, res);
|
||||||
|
|
||||||
|
str = g_string_append (str, fallback);
|
||||||
|
text = text + read + 1;
|
||||||
|
size = size - read;
|
||||||
|
}
|
||||||
|
|
||||||
|
str = g_string_append (str, res);
|
||||||
|
g_free (res);
|
||||||
|
|
||||||
|
utf8_validate_fallback (str->str, str->len);
|
||||||
|
return g_string_free (str, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
gitg_convert_utf8 (gchar const *str, gssize size)
|
||||||
|
{
|
||||||
|
static gchar *encodings[] = {
|
||||||
|
"ISO-8859-15",
|
||||||
|
"ASCII"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (str == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size == -1)
|
||||||
|
{
|
||||||
|
size = strlen (str);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_utf8_validate (str, size, NULL))
|
||||||
|
{
|
||||||
|
return g_strndup (str, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < sizeof (encodings) / sizeof (gchar *); ++i)
|
||||||
|
{
|
||||||
|
gsize read;
|
||||||
|
gsize written;
|
||||||
|
|
||||||
|
gchar *ret = g_convert (str,
|
||||||
|
size,
|
||||||
|
"UTF-8",
|
||||||
|
encodings[i],
|
||||||
|
&read,
|
||||||
|
&written,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (ret && read == size)
|
||||||
|
{
|
||||||
|
utf8_validate_fallback (ret, written);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
return convert_fallback (str, size, "?");
|
||||||
|
}
|
30
libgitg/gitg-convert.h
Normal file
30
libgitg/gitg-convert.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* gitg-convert.h
|
||||||
|
* This file is part of gitg - git repository viewer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GITG_CONVERT_H__
|
||||||
|
#define __GITG_CONVERT_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
gchar *gitg_convert_utf8(gchar const *str, gssize size);
|
||||||
|
|
||||||
|
#endif /* __GITG_CONVERT_H__ */
|
137
libgitg/gitg-hash.c
Normal file
137
libgitg/gitg-hash.c
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
/*
|
||||||
|
* gitg-hash.c
|
||||||
|
* This file is part of gitg - git repository viewer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "gitg-hash.h"
|
||||||
|
#include "gitg-types.h"
|
||||||
|
|
||||||
|
inline static guint8
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (length % 2 == 1)
|
||||||
|
{
|
||||||
|
--length;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < length / 2; ++i)
|
||||||
|
{
|
||||||
|
gchar h = atoh(*(sha++)) << 4;
|
||||||
|
hash[i] = h | atoh(*(sha++));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gitg_hash_sha1_to_hash(gchar const *sha, gchar *hash)
|
||||||
|
{
|
||||||
|
gitg_hash_partial_sha1_to_hash (sha, HASH_SHA_SIZE, hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
sha[pos++] = repr[(hash[i] >> 4) & 0x0f];
|
||||||
|
sha[pos++] = repr[(hash[i] & 0x0f)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
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);
|
||||||
|
|
||||||
|
ret[HASH_SHA_SIZE] = '\0';
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
gitg_hash_partial_sha1_to_hash_new (gchar const *sha, gint length, gint *retlen)
|
||||||
|
{
|
||||||
|
if (length == -1)
|
||||||
|
{
|
||||||
|
length = strlen (sha);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (length % 2 != 0)
|
||||||
|
{
|
||||||
|
--length;
|
||||||
|
}
|
||||||
|
|
||||||
|
*retlen = length / 2;
|
||||||
|
gchar *ret = g_new (gchar, *retlen);
|
||||||
|
|
||||||
|
gitg_hash_partial_sha1_to_hash (sha, length, ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
gitg_hash_sha1_to_hash_new(gchar const *sha1)
|
||||||
|
{
|
||||||
|
gchar *ret = g_new(gchar, HASH_BINARY_SIZE);
|
||||||
|
gitg_hash_sha1_to_hash(sha1, ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint
|
||||||
|
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)
|
||||||
|
h = (h << 5) - h + p[i];
|
||||||
|
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gitg_hash_hash_equal(gconstpointer a, gconstpointer b)
|
||||||
|
{
|
||||||
|
return memcmp(a, b, HASH_BINARY_SIZE) == 0;
|
||||||
|
}
|
41
libgitg/gitg-hash.h
Normal file
41
libgitg/gitg-hash.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* gitg-hash.h
|
||||||
|
* This file is part of gitg - git repository viewer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GITG_HASH_H__
|
||||||
|
#define __GITG_HASH_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
void gitg_hash_sha1_to_hash(gchar const *sha, gchar *hash);
|
||||||
|
void gitg_hash_hash_to_sha1(gchar const *hash, gchar *sha);
|
||||||
|
|
||||||
|
void gitg_hash_partial_sha1_to_hash (gchar const *sha, gint length, gchar *hash);
|
||||||
|
|
||||||
|
gchar *gitg_hash_sha1_to_hash_new(gchar const *sha);
|
||||||
|
gchar *gitg_hash_hash_to_sha1_new(gchar const *hash);
|
||||||
|
|
||||||
|
gchar *gitg_hash_partial_sha1_to_hash_new (gchar const *sha, gint length, gint *retlen);
|
||||||
|
|
||||||
|
guint gitg_hash_hash(gconstpointer v);
|
||||||
|
gboolean gitg_hash_hash_equal(gconstpointer a, gconstpointer b);
|
||||||
|
|
||||||
|
#endif /* __GITG_HASH_H__ */
|
52
libgitg/gitg-i18n.c
Normal file
52
libgitg/gitg-i18n.c
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "gitg-i18n.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* _gitg_gettext:
|
||||||
|
* @msgid: The string to be translated
|
||||||
|
*
|
||||||
|
* Returns the translated string from the libgitg translations.
|
||||||
|
* This is an internal function and should only be used by
|
||||||
|
* the internals of libgitg
|
||||||
|
*
|
||||||
|
* Returns: the transation of @msgid to the current locale
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
_gitg_gettext (const gchar *msgid)
|
||||||
|
{
|
||||||
|
static gboolean initialized = FALSE;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (!initialized))
|
||||||
|
{
|
||||||
|
bindtextdomain (GETTEXT_PACKAGE, GITG_LOCALEDIR);
|
||||||
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||||
|
|
||||||
|
initialized = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_dgettext (GETTEXT_PACKAGE, msgid);
|
||||||
|
}
|
71
libgitg/gitg-i18n.h
Normal file
71
libgitg/gitg-i18n.h
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Handles all of the internationalization configuration options.
|
||||||
|
* Author: Tom Tromey <tromey@creche.cygnus.com>
|
||||||
|
*
|
||||||
|
* This is a modified version of gtksourceview-i18n.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __PEAS_18N_H__
|
||||||
|
#define __PEAS_18N_H__
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#ifdef ENABLE_NLS
|
||||||
|
# include <libintl.h>
|
||||||
|
# undef _
|
||||||
|
# define _(String) _gitg_gettext (String)
|
||||||
|
# undef N_
|
||||||
|
# ifdef gettext_noop
|
||||||
|
# define N_(String) gettext_noop (String)
|
||||||
|
# else
|
||||||
|
# define N_(String) (String)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
/* Stubs that do something close enough. */
|
||||||
|
# undef textdomain
|
||||||
|
# define textdomain(String) (String)
|
||||||
|
# undef gettext
|
||||||
|
# define gettext(String) (String)
|
||||||
|
# undef dgettext
|
||||||
|
# define dgettext(Domain,Message) (Message)
|
||||||
|
# undef dcgettext
|
||||||
|
# define dcgettext(Domain,Message,Type) (Message)
|
||||||
|
# undef bindtextdomain
|
||||||
|
# define bindtextdomain(Domain,Directory) (Domain)
|
||||||
|
# undef bind_textdomain_codeset
|
||||||
|
# define bind_textdomain_codeset(Domain,CodeSet) (Domain)
|
||||||
|
# undef _
|
||||||
|
# define _(String) (String)
|
||||||
|
# undef N_
|
||||||
|
# define N_(String) (String)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const gchar *_gitg_gettext (const char *msgid) G_GNUC_FORMAT(1);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __PEAS_I18N_H__ */
|
|
@ -21,7 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gitg-lanes.h"
|
#include "gitg-lanes.h"
|
||||||
#include "gitg-utils.h"
|
#include "gitg-hash.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define GITG_LANES_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_LANES, GitgLanesPrivate))
|
#define GITG_LANES_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_LANES, GitgLanesPrivate))
|
||||||
|
@ -120,7 +120,7 @@ find_lane_by_hash(GitgLanes *lanes, gchar const *hash, gint8 *pos)
|
||||||
{
|
{
|
||||||
LaneContainer *container = (LaneContainer *)(item->data);
|
LaneContainer *container = (LaneContainer *)(item->data);
|
||||||
|
|
||||||
if (container && container->to && gitg_utils_hash_equal(container->to, hash))
|
if (container && container->to && gitg_hash_hash_equal(container->to, hash))
|
||||||
{
|
{
|
||||||
if (pos)
|
if (pos)
|
||||||
*pos = p;
|
*pos = p;
|
||||||
|
@ -246,7 +246,7 @@ static void
|
||||||
gitg_lanes_init(GitgLanes *self)
|
gitg_lanes_init(GitgLanes *self)
|
||||||
{
|
{
|
||||||
self->priv = GITG_LANES_GET_PRIVATE(self);
|
self->priv = GITG_LANES_GET_PRIVATE(self);
|
||||||
self->priv->collapsed = g_hash_table_new_full(gitg_utils_hash_hash, gitg_utils_hash_equal, NULL, (GDestroyNotify)collapsed_lane_free);
|
self->priv->collapsed = g_hash_table_new_full(gitg_hash_hash, gitg_hash_hash_equal, NULL, (GDestroyNotify)collapsed_lane_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
GitgLanes *
|
GitgLanes *
|
|
@ -21,7 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gitg-ref.h"
|
#include "gitg-ref.h"
|
||||||
#include "gitg-utils.h"
|
#include "gitg-hash.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -64,7 +64,7 @@ gitg_ref_new(gchar const *hash, gchar const *name)
|
||||||
{
|
{
|
||||||
GitgRef *inst = g_slice_new0(GitgRef);
|
GitgRef *inst = g_slice_new0(GitgRef);
|
||||||
|
|
||||||
gitg_utils_sha1_to_hash(hash, inst->hash);
|
gitg_hash_sha1_to_hash(hash, inst->hash);
|
||||||
inst->name = g_strdup(name);
|
inst->name = g_strdup(name);
|
||||||
|
|
||||||
PrefixTypeMap map[] = {
|
PrefixTypeMap map[] = {
|
|
@ -21,12 +21,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gitg-repository.h"
|
#include "gitg-repository.h"
|
||||||
#include "gitg-utils.h"
|
#include "gitg-hash.h"
|
||||||
#include "gitg-lanes.h"
|
#include "gitg-lanes.h"
|
||||||
#include "gitg-ref.h"
|
#include "gitg-ref.h"
|
||||||
#include "gitg-types.h"
|
#include "gitg-types.h"
|
||||||
#include "gitg-preferences.h"
|
|
||||||
#include "gitg-data-binding.h"
|
|
||||||
#include "gitg-config.h"
|
#include "gitg-config.h"
|
||||||
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
@ -46,10 +44,18 @@ G_DEFINE_TYPE_EXTENDED(GitgRepository, gitg_repository, G_TYPE_OBJECT, 0,
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
|
||||||
PROP_WORK_TREE,
|
PROP_WORK_TREE,
|
||||||
PROP_GIT_DIR,
|
PROP_GIT_DIR,
|
||||||
PROP_LOADER
|
PROP_PATH,
|
||||||
|
PROP_LOADER,
|
||||||
|
PROP_SHOW_STAGED,
|
||||||
|
PROP_SHOW_UNSTAGED,
|
||||||
|
PROP_SHOW_STASH,
|
||||||
|
PROP_TOPO_ORDER,
|
||||||
|
PROP_INACTIVE_MAX,
|
||||||
|
PROP_INACTIVE_COLLAPSE,
|
||||||
|
PROP_INACTIVE_GAP,
|
||||||
|
PROP_INACTIVE_ENABLED
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
|
@ -112,6 +118,11 @@ struct _GitgRepositoryPrivate
|
||||||
LoadStage load_stage;
|
LoadStage load_stage;
|
||||||
|
|
||||||
GFileMonitor *monitor;
|
GFileMonitor *monitor;
|
||||||
|
|
||||||
|
guint show_staged : 1;
|
||||||
|
guint show_unstaged : 1;
|
||||||
|
guint show_stash : 1;
|
||||||
|
guint topoorder : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline static gint
|
inline static gint
|
||||||
|
@ -218,7 +229,7 @@ tree_model_get_value(GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, G
|
||||||
g_value_set_string(value, gitg_revision_get_author(rv));
|
g_value_set_string(value, gitg_revision_get_author(rv));
|
||||||
break;
|
break;
|
||||||
case DATE_COLUMN:
|
case DATE_COLUMN:
|
||||||
g_value_take_string(value, gitg_utils_timestamp_to_str(gitg_revision_get_timestamp(rv)));
|
g_value_take_string(value, gitg_revision_get_timestamp_for_display(rv));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached();
|
g_assert_not_reached();
|
||||||
|
@ -441,6 +452,38 @@ gitg_repository_set_property(GObject *object, guint prop_id, GValue const *value
|
||||||
|
|
||||||
self->priv->git_dir = g_value_dup_object (value);
|
self->priv->git_dir = g_value_dup_object (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_SHOW_STAGED:
|
||||||
|
self->priv->show_staged = g_value_get_boolean(value);
|
||||||
|
break;
|
||||||
|
case PROP_SHOW_UNSTAGED:
|
||||||
|
self->priv->show_unstaged = g_value_get_boolean(value);
|
||||||
|
break;
|
||||||
|
case PROP_SHOW_STASH:
|
||||||
|
self->priv->show_stash = g_value_get_boolean(value);
|
||||||
|
break;
|
||||||
|
case PROP_TOPO_ORDER:
|
||||||
|
self->priv->topoorder = g_value_get_boolean(value);
|
||||||
|
break;
|
||||||
|
case PROP_INACTIVE_MAX:
|
||||||
|
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),
|
||||||
|
"inactive-collapse",
|
||||||
|
value);
|
||||||
|
break;
|
||||||
|
case PROP_INACTIVE_GAP:
|
||||||
|
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),
|
||||||
|
"inactive-enabled",
|
||||||
|
value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -464,6 +507,38 @@ gitg_repository_get_property(GObject *object, guint prop_id, GValue *value, GPar
|
||||||
case PROP_LOADER:
|
case PROP_LOADER:
|
||||||
g_value_set_object(value, self->priv->loader);
|
g_value_set_object(value, self->priv->loader);
|
||||||
break;
|
break;
|
||||||
|
case PROP_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);
|
||||||
|
break;
|
||||||
|
case PROP_SHOW_STASH:
|
||||||
|
g_value_set_boolean(value, self->priv->show_stash);
|
||||||
|
break;
|
||||||
|
case PROP_TOPO_ORDER:
|
||||||
|
g_value_set_boolean(value, self->priv->topoorder);
|
||||||
|
break;
|
||||||
|
case PROP_INACTIVE_MAX:
|
||||||
|
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),
|
||||||
|
"inactive-collapse",
|
||||||
|
value);
|
||||||
|
break;
|
||||||
|
case PROP_INACTIVE_GAP:
|
||||||
|
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),
|
||||||
|
"inactive-enabled",
|
||||||
|
value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -614,6 +689,69 @@ gitg_repository_class_init(GitgRepositoryClass *klass)
|
||||||
GITG_TYPE_RUNNER,
|
GITG_TYPE_RUNNER,
|
||||||
G_PARAM_READABLE));
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
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_param_spec_boolean ("show-unstaged",
|
||||||
|
"Show Unstaged",
|
||||||
|
"Show unstaged",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
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_param_spec_boolean ("topo-order",
|
||||||
|
"Topo order",
|
||||||
|
"Show in topological order",
|
||||||
|
FALSE,
|
||||||
|
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",
|
||||||
|
"INACTIVE_MAX",
|
||||||
|
"Maximum inactivity on a lane before collapsing",
|
||||||
|
1,
|
||||||
|
G_MAXINT,
|
||||||
|
30,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
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_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_object_class_install_property(object_class, PROP_INACTIVE_ENABLED,
|
||||||
|
g_param_spec_boolean("inactive-enabled",
|
||||||
|
"INACTIVE_ENABLED",
|
||||||
|
"Lane collapsing enabled",
|
||||||
|
TRUE,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
repository_signals[LOAD] =
|
repository_signals[LOAD] =
|
||||||
g_signal_new ("load",
|
g_signal_new ("load",
|
||||||
G_OBJECT_CLASS_TYPE (object_class),
|
G_OBJECT_CLASS_TYPE (object_class),
|
||||||
|
@ -683,14 +821,11 @@ on_loader_end_loading(GitgRunner *object, gboolean cancelled, GitgRepository *re
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadStage current = repository->priv->load_stage++;
|
LoadStage current = repository->priv->load_stage++;
|
||||||
GitgPreferences *preferences = gitg_preferences_get_default();
|
|
||||||
gboolean show_unstaged;
|
gboolean show_unstaged;
|
||||||
gboolean show_staged;
|
gboolean show_staged;
|
||||||
|
|
||||||
g_object_get(preferences,
|
show_unstaged = repository->priv->show_unstaged;
|
||||||
"history-show-virtual-staged", &show_staged,
|
show_staged = repository->priv->show_staged;
|
||||||
"history-show-virtual-unstaged", &show_unstaged,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
switch (current)
|
switch (current)
|
||||||
{
|
{
|
||||||
|
@ -779,10 +914,9 @@ static void
|
||||||
loader_update_stash(GitgRepository *repository, gchar **buffer)
|
loader_update_stash(GitgRepository *repository, gchar **buffer)
|
||||||
{
|
{
|
||||||
gchar *line;
|
gchar *line;
|
||||||
GitgPreferences *preferences = gitg_preferences_get_default();
|
|
||||||
gboolean show_stash;
|
gboolean show_stash;
|
||||||
|
|
||||||
g_object_get(preferences, "history-show-virtual-stash", &show_stash, NULL);
|
show_stash = repository->priv->show_stash;
|
||||||
|
|
||||||
if (!show_stash)
|
if (!show_stash)
|
||||||
return;
|
return;
|
||||||
|
@ -906,61 +1040,10 @@ prepare_relane(GitgRepository *repository)
|
||||||
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 gboolean
|
|
||||||
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);
|
|
||||||
|
|
||||||
gint s = g_value_get_int(setting);
|
|
||||||
g_value_set_int(value, 2 + s * 8);
|
|
||||||
|
|
||||||
prepare_relane(GITG_REPOSITORY(userdata));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
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);
|
|
||||||
|
|
||||||
gint s = g_value_get_int(setting);
|
|
||||||
g_value_set_int(value, 1 + s * 3);
|
|
||||||
|
|
||||||
prepare_relane(GITG_REPOSITORY(userdata));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
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_value_set_int(value, 10);
|
|
||||||
|
|
||||||
prepare_relane(GITG_REPOSITORY(userdata));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
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);
|
|
||||||
|
|
||||||
gboolean s = g_value_get_boolean(setting);
|
|
||||||
g_value_set_boolean(value, s);
|
|
||||||
|
|
||||||
prepare_relane(GITG_REPOSITORY(userdata));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_update_virtual(GObject *object, GParamSpec *spec, GitgRepository *repository)
|
on_lane_setting_changed(GitgRepository *repository, GParamSpec *pspec, gpointer useless)
|
||||||
{
|
{
|
||||||
gitg_repository_reload (repository);
|
prepare_relane(repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar **
|
static gchar **
|
||||||
|
@ -994,10 +1077,9 @@ has_left_right(gchar const **av, int argc)
|
||||||
static void
|
static void
|
||||||
build_log_args(GitgRepository *self, gint argc, gchar const **av)
|
build_log_args(GitgRepository *self, gint argc, gchar const **av)
|
||||||
{
|
{
|
||||||
GitgPreferences *preferences = gitg_preferences_get_default ();
|
|
||||||
gboolean topoorder;
|
gboolean topoorder;
|
||||||
|
|
||||||
g_object_get (preferences, "history-topo-order", &topoorder, NULL);
|
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));
|
||||||
|
|
||||||
|
@ -1054,7 +1136,7 @@ build_log_args(GitgRepository *self, gint argc, gchar const **av)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_update_topo_order(GObject *object, GParamSpec *spec, GitgRepository *repository)
|
on_update_topo_order(GitgRepository *repository, GParamSpec *spec, gpointer useless)
|
||||||
{
|
{
|
||||||
build_log_args (repository,
|
build_log_args (repository,
|
||||||
g_strv_length (repository->priv->selection),
|
g_strv_length (repository->priv->selection),
|
||||||
|
@ -1064,49 +1146,9 @@ on_update_topo_order(GObject *object, GParamSpec *spec, GitgRepository *reposito
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
initialize_bindings(GitgRepository *repository)
|
on_update_virtual(GitgRepository *repository, GParamSpec *spec, gpointer useless)
|
||||||
{
|
{
|
||||||
GitgPreferences *preferences = gitg_preferences_get_default();
|
gitg_repository_reload(repository);
|
||||||
|
|
||||||
gitg_data_binding_new_full(preferences, "history-collapse-inactive-lanes",
|
|
||||||
repository->priv->lanes, "inactive-max",
|
|
||||||
convert_setting_to_inactive_max,
|
|
||||||
repository);
|
|
||||||
|
|
||||||
gitg_data_binding_new_full(preferences, "history-collapse-inactive-lanes",
|
|
||||||
repository->priv->lanes, "inactive-collapse",
|
|
||||||
convert_setting_to_inactive_collapse,
|
|
||||||
repository);
|
|
||||||
|
|
||||||
gitg_data_binding_new_full(preferences, "history-collapse-inactive-lanes",
|
|
||||||
repository->priv->lanes, "inactive-gap",
|
|
||||||
convert_setting_to_inactive_gap,
|
|
||||||
repository);
|
|
||||||
|
|
||||||
gitg_data_binding_new_full(preferences, "history-collapse-inactive-lanes-active",
|
|
||||||
repository->priv->lanes, "inactive-enabled",
|
|
||||||
convert_setting_to_inactive_enabled,
|
|
||||||
repository);
|
|
||||||
|
|
||||||
g_signal_connect(preferences,
|
|
||||||
"notify::history-show-virtual-stash",
|
|
||||||
G_CALLBACK(on_update_virtual),
|
|
||||||
repository);
|
|
||||||
|
|
||||||
g_signal_connect(preferences,
|
|
||||||
"notify::history-show-virtual-unstaged",
|
|
||||||
G_CALLBACK(on_update_virtual),
|
|
||||||
repository);
|
|
||||||
|
|
||||||
g_signal_connect(preferences,
|
|
||||||
"notify::history-show-virtual-staged",
|
|
||||||
G_CALLBACK(on_update_virtual),
|
|
||||||
repository);
|
|
||||||
|
|
||||||
g_signal_connect(preferences,
|
|
||||||
"notify::history-topo-order",
|
|
||||||
G_CALLBACK(on_update_topo_order),
|
|
||||||
repository);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1114,11 +1156,11 @@ gitg_repository_init(GitgRepository *object)
|
||||||
{
|
{
|
||||||
object->priv = GITG_REPOSITORY_GET_PRIVATE (object);
|
object->priv = GITG_REPOSITORY_GET_PRIVATE (object);
|
||||||
|
|
||||||
object->priv->hashtable = g_hash_table_new (gitg_utils_hash_hash,
|
object->priv->hashtable = g_hash_table_new (gitg_hash_hash,
|
||||||
gitg_utils_hash_equal);
|
gitg_hash_hash_equal);
|
||||||
|
|
||||||
object->priv->ref_pushes = g_hash_table_new (gitg_utils_hash_hash,
|
object->priv->ref_pushes = g_hash_table_new (gitg_hash_hash,
|
||||||
gitg_utils_hash_equal);
|
gitg_hash_hash_equal);
|
||||||
|
|
||||||
object->priv->ref_names = g_hash_table_new (g_str_hash, g_str_equal);
|
object->priv->ref_names = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
|
|
||||||
|
@ -1131,8 +1173,8 @@ gitg_repository_init(GitgRepository *object)
|
||||||
object->priv->grow_size = 1000;
|
object->priv->grow_size = 1000;
|
||||||
object->priv->stamp = g_random_int ();
|
object->priv->stamp = g_random_int ();
|
||||||
|
|
||||||
object->priv->refs = g_hash_table_new_full (gitg_utils_hash_hash,
|
object->priv->refs = g_hash_table_new_full (gitg_hash_hash,
|
||||||
gitg_utils_hash_equal,
|
gitg_hash_hash_equal,
|
||||||
NULL,
|
NULL,
|
||||||
(GDestroyNotify)free_refs);
|
(GDestroyNotify)free_refs);
|
||||||
|
|
||||||
|
@ -1148,7 +1190,45 @@ gitg_repository_init(GitgRepository *object)
|
||||||
G_CALLBACK (on_loader_end_loading),
|
G_CALLBACK (on_loader_end_loading),
|
||||||
object);
|
object);
|
||||||
|
|
||||||
initialize_bindings (object);
|
g_signal_connect(object,
|
||||||
|
"notify::show-stash",
|
||||||
|
G_CALLBACK(on_update_virtual),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_signal_connect(object,
|
||||||
|
"notify::show-unstaged",
|
||||||
|
G_CALLBACK(on_update_virtual),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_signal_connect(object,
|
||||||
|
"notify::show-staged",
|
||||||
|
G_CALLBACK(on_update_virtual),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_signal_connect(object,
|
||||||
|
"notify::topo-order",
|
||||||
|
G_CALLBACK(on_update_topo_order),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_signal_connect(object,
|
||||||
|
"notify::inactive_mac",
|
||||||
|
G_CALLBACK(on_lane_setting_changed),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_signal_connect(object,
|
||||||
|
"notify::inactive_collapse",
|
||||||
|
G_CALLBACK(on_lane_setting_changed),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_signal_connect(object,
|
||||||
|
"notify::inactive_gap",
|
||||||
|
G_CALLBACK(on_lane_setting_changed),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_signal_connect(object,
|
||||||
|
"notify::inactive_enabled",
|
||||||
|
G_CALLBACK(on_lane_setting_changed),
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
|
@ -20,8 +20,9 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "gitg-convert.h"
|
||||||
#include "gitg-revision.h"
|
#include "gitg-revision.h"
|
||||||
#include "gitg-utils.h"
|
#include "gitg-hash.h"
|
||||||
|
|
||||||
struct _GitgRevision
|
struct _GitgRevision
|
||||||
{
|
{
|
||||||
|
@ -92,7 +93,7 @@ GitgRevision *gitg_revision_new(gchar const *sha,
|
||||||
|
|
||||||
rv->refcount = 1;
|
rv->refcount = 1;
|
||||||
|
|
||||||
gitg_utils_sha1_to_hash(sha, rv->hash);
|
gitg_hash_sha1_to_hash(sha, rv->hash);
|
||||||
rv->author = g_strdup(author);
|
rv->author = g_strdup(author);
|
||||||
rv->subject = g_strdup(subject);
|
rv->subject = g_strdup(subject);
|
||||||
rv->timestamp = timestamp;
|
rv->timestamp = timestamp;
|
||||||
|
@ -105,7 +106,7 @@ GitgRevision *gitg_revision_new(gchar const *sha,
|
||||||
|
|
||||||
gint i;
|
gint i;
|
||||||
for (i = 0; i < num; ++i)
|
for (i = 0; i < num; ++i)
|
||||||
gitg_utils_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;
|
rv->num_parents = num;
|
||||||
|
@ -142,7 +143,7 @@ gchar *
|
||||||
gitg_revision_get_sha1(GitgRevision *revision)
|
gitg_revision_get_sha1(GitgRevision *revision)
|
||||||
{
|
{
|
||||||
char res[HASH_SHA_SIZE];
|
char res[HASH_SHA_SIZE];
|
||||||
gitg_utils_hash_to_sha1(revision->hash, res);
|
gitg_hash_hash_to_sha1(revision->hash, res);
|
||||||
|
|
||||||
return g_strndup(res, HASH_SHA_SIZE);
|
return g_strndup(res, HASH_SHA_SIZE);
|
||||||
}
|
}
|
||||||
|
@ -165,7 +166,7 @@ gitg_revision_get_parents(GitgRevision *revision)
|
||||||
for (i = 0; i < revision->num_parents; ++i)
|
for (i = 0; i < revision->num_parents; ++i)
|
||||||
{
|
{
|
||||||
ret[i] = g_new(gchar, HASH_SHA_SIZE + 1);
|
ret[i] = g_new(gchar, HASH_SHA_SIZE + 1);
|
||||||
gitg_utils_hash_to_sha1(revision->parents[i], ret[i]);
|
gitg_hash_hash_to_sha1(revision->parents[i], ret[i]);
|
||||||
|
|
||||||
ret[i][HASH_SHA_SIZE] = '\0';
|
ret[i][HASH_SHA_SIZE] = '\0';
|
||||||
}
|
}
|
||||||
|
@ -307,3 +308,15 @@ gitg_revision_get_format_patch_name (GitgRevision *revision)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
gitg_revision_get_timestamp_for_display(GitgRevision *revision)
|
||||||
|
{
|
||||||
|
time_t t = gitg_revision_get_timestamp (revision);
|
||||||
|
|
||||||
|
struct tm *tms = localtime(&t);
|
||||||
|
gchar buf[255];
|
||||||
|
|
||||||
|
strftime(buf, 254, "%c", tms);
|
||||||
|
return gitg_convert_utf8(buf, -1);
|
||||||
|
}
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include "gitg-lane.h"
|
#include "gitg-lane.h"
|
||||||
|
#include "gitg-types.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -32,8 +33,6 @@ G_BEGIN_DECLS
|
||||||
#define GITG_REVISION(obj) ((GitgRevision *)obj)
|
#define GITG_REVISION(obj) ((GitgRevision *)obj)
|
||||||
#define GITG_REVISION_CONST(obj) ((GitgRevision const *)obj)
|
#define GITG_REVISION_CONST(obj) ((GitgRevision const *)obj)
|
||||||
|
|
||||||
#include "gitg-types.h"
|
|
||||||
|
|
||||||
typedef struct _GitgRevision GitgRevision;
|
typedef struct _GitgRevision GitgRevision;
|
||||||
|
|
||||||
GType gitg_revision_get_type (void) G_GNUC_CONST;
|
GType gitg_revision_get_type (void) G_GNUC_CONST;
|
||||||
|
@ -68,6 +67,8 @@ void gitg_revision_unref(GitgRevision *revision);
|
||||||
|
|
||||||
gchar *gitg_revision_get_format_patch_name (GitgRevision *revision);
|
gchar *gitg_revision_get_format_patch_name (GitgRevision *revision);
|
||||||
|
|
||||||
|
gchar *gitg_revision_get_timestamp_for_display(GitgRevision *revision);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GITG_REVISION_H__ */
|
#endif /* __GITG_REVISION_H__ */
|
|
@ -20,12 +20,13 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "gitg-convert.h"
|
||||||
|
#include "gitg-debug.h"
|
||||||
#include "gitg-runner.h"
|
#include "gitg-runner.h"
|
||||||
#include "gitg-utils.h"
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include "gitg-debug.h"
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -326,12 +327,12 @@ parse_lines(GitgRunner *runner, gchar *buffer, gssize size)
|
||||||
g_free(runner->priv->buffer);
|
g_free(runner->priv->buffer);
|
||||||
runner->priv->buffer = NULL;
|
runner->priv->buffer = NULL;
|
||||||
|
|
||||||
runner->priv->lines[i++] = gitg_utils_convert_utf8(buffered, -1);
|
runner->priv->lines[i++] = gitg_convert_utf8(buffered, -1);
|
||||||
g_free(buffered);
|
g_free(buffered);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
runner->priv->lines[i++] = gitg_utils_convert_utf8(ptr, linesize);
|
runner->priv->lines[i++] = gitg_convert_utf8(ptr, linesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr += linesize + 1;
|
ptr += linesize + 1;
|
||||||
|
@ -470,8 +471,8 @@ read_output_ready(GInputStream *stream, GAsyncResult *result, AsyncData *data)
|
||||||
if (read == 0)
|
if (read == 0)
|
||||||
{
|
{
|
||||||
/* End */
|
/* End */
|
||||||
gchar *converted = gitg_utils_convert_utf8 (data->runner->priv->buffer,
|
gchar *converted = gitg_convert_utf8 (data->runner->priv->buffer,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
gchar *b[] = {converted, NULL};
|
gchar *b[] = {converted, NULL};
|
||||||
|
|
Loading…
Reference in a new issue