mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-08-27 11:59:17 +00:00
Merge branch 'gtk3' into master
Conflicts: NEWS README configure.ac data/Makefile.am gitg/gitg-commit-view.c gitg/gitg-revision-details-panel.c gitg/gitg-window.c gitg/gitg.c gitg/gseal-gtk-compat.h
This commit is contained in:
commit
c579e3fea0
42
NEWS
42
NEWS
|
@ -1,3 +1,45 @@
|
|||
= gitg 0.2.3 =
|
||||
Version 0.2.3 was released on 2011-07-21
|
||||
|
||||
== Features ==
|
||||
* Use ustar format for distcheck
|
||||
|
||||
== Bug fixes ==
|
||||
* Use GLADE_CATALOG_DIR instead of GLADE_CATALOGDIR
|
||||
* Fix spinner in repository dialog
|
||||
* No longer use Gtk[HV]Box as it is deprecated
|
||||
* Fix repository dialog
|
||||
* Remove and reattach model while loading repository
|
||||
* Fix ENABLE_DEBUG use in Makefile.am
|
||||
* Fix --disable-debug
|
||||
|
||||
== Features ==
|
||||
|
||||
= gitg 0.2.2 =
|
||||
Version 0.2.2 was released on 2011-03-27
|
||||
|
||||
== Features ==
|
||||
* Added glade catalog file
|
||||
|
||||
== Bug fixes ==
|
||||
* Disable auto-utf8 for repository loading
|
||||
|
||||
= gitg 0.2.1 =
|
||||
Version 0.2.1 was released on 2011-03-25
|
||||
|
||||
== Features ==
|
||||
* Improved debugging
|
||||
* Add UTF8 as the first candidate encoding
|
||||
|
||||
== Bug fixes ==
|
||||
* Adjust to GtkSourceView API break
|
||||
|
||||
= gitg 0.2.0 =
|
||||
Version 0.2.0 was released on 2011-02-26
|
||||
|
||||
== Features ==
|
||||
* Port gitg to gtk+ 3
|
||||
|
||||
= gitg 0.1.2 =
|
||||
Version 0.1.2 was released on 2011-03-27
|
||||
|
||||
|
|
6
README
6
README
|
@ -3,7 +3,7 @@ gitg is a GitX clone for GNOME/gtk+. It aims at being a small, fast and
|
|||
convenient tool to visualize git history and actions that benefit from a
|
||||
graphical presentation.
|
||||
|
||||
The latest version of gitg is 0.1.2.
|
||||
The latest version of gitg is 0.2.3.
|
||||
|
||||
Website: http://trac.novowork.com/gitg
|
||||
Bugs: http://bugzilla.gnome.org/browse.cgi?product=gitg
|
||||
|
@ -15,8 +15,8 @@ To install the latest version of gitg, make sure to download gitg-0.1.2.tar.bz2
|
|||
from the download site. After downloading the following procedure installs
|
||||
gitg:
|
||||
|
||||
$ tar -xjf gitg-0.1.2.tar.bz2
|
||||
$ cd gitg-0.1.0
|
||||
$ tar Jxf gitg-0.2.3.tar.bz2
|
||||
$ cd gitg-0.2.3
|
||||
$ ./configure
|
||||
$ make
|
||||
$ sudo make install
|
||||
|
|
59
configure.ac
59
configure.ac
|
@ -3,8 +3,8 @@ dnl Process this file with autoconf to produce a configure script.
|
|||
AC_PREREQ([2.64])
|
||||
|
||||
m4_define(gitg_major_version, 0)
|
||||
m4_define(gitg_minor_version, 1)
|
||||
m4_define(gitg_micro_version, 2)
|
||||
m4_define(gitg_minor_version, 2)
|
||||
m4_define(gitg_micro_version, 3)
|
||||
m4_define(gitg_version, gitg_major_version.gitg_minor_version.gitg_micro_version)
|
||||
|
||||
AC_INIT([gitg],
|
||||
|
@ -25,7 +25,7 @@ AC_SUBST(GITG_MINOR_VERSION, gitg_minor_version)
|
|||
AC_DEFINE(GITG_MICRO_VERSION, gitg_micro_version, [GitG micro version])
|
||||
AC_SUBST(GITG_MICRO_VERSION, gitg_micro_version)
|
||||
|
||||
AM_INIT_AUTOMAKE([1.11 dist-bzip2 no-dist-gzip])
|
||||
AM_INIT_AUTOMAKE([1.11 tar-ustar dist-xz no-dist-gzip -Wno-portability])
|
||||
AM_MAINTAINER_MODE([enable])
|
||||
|
||||
AM_SILENT_RULES([yes])
|
||||
|
@ -52,20 +52,14 @@ GETTEXT_PACKAGE=gitg
|
|||
AC_SUBST(GETTEXT_PACKAGE)
|
||||
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
|
||||
|
||||
|
||||
AC_CHECK_LIB([m], [sinf])
|
||||
|
||||
# Which gtk+ API version to compile against
|
||||
|
||||
GTK_REQUIRED=gtk+-2.0
|
||||
GTK_REQUIRED_VERSION=2.18.0
|
||||
GTKSOURCEVIEW_REQUIRED=gtksourceview-2.0
|
||||
GTKSOURCEVIEW_REQUIRED_VERSION=2.8.0
|
||||
|
||||
GLIB_REQUIRED_VERSION=2.26
|
||||
GTK_REQUIRED_VERSION=3.0.0
|
||||
GTKSOURCEVIEW_REQUIRED_VERSION=3.0.0
|
||||
|
||||
PKG_CHECK_MODULES(GITG, [
|
||||
$GTK_REQUIRED >= $GTK_REQUIRED_VERSION
|
||||
gtk+-3.0 >= $GTK_REQUIRED_VERSION
|
||||
gthread-2.0 >= $GLIB_REQUIRED_VERSION
|
||||
glib-2.0 >= $GLIB_REQUIRED_VERSION
|
||||
gobject-2.0 >= $GLIB_REQUIRED_VERSION
|
||||
|
@ -75,7 +69,7 @@ PKG_CHECK_MODULES(GITG, [
|
|||
])
|
||||
|
||||
PKG_CHECK_MODULES(PACKAGE, [
|
||||
$GTKSOURCEVIEW_REQUIRED >= $GTKSOURCEVIEW_REQUIRED_VERSION
|
||||
gtksourceview-3.0 >= $GTKSOURCEVIEW_REQUIRED_VERSION
|
||||
gsettings-desktop-schemas
|
||||
])
|
||||
|
||||
|
@ -100,35 +94,26 @@ if test "$enable_deprecations" = "yes"; then
|
|||
-DGDK_DISABLE_DEPRECATED \
|
||||
-DGTK_DISABLE_DEPRECATED \
|
||||
-DGDK_PIXBUF_DISABLE_DEPRECATED \
|
||||
-DGNOME_DISABLE_DEPRECATED"
|
||||
-DGNOME_DISABLE_DEPRECATED \
|
||||
-DGSEAL_ENABLE"
|
||||
fi
|
||||
|
||||
if $PKG_CONFIG --atleast-version 2.19.0 $GTK_REQUIRED; then
|
||||
gtkatleast=
|
||||
else
|
||||
gtkatleast=no
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(BUILD_SPINNER, test "$gtkatleast" = "no")
|
||||
if test "$gtkatleast" = "no"; then
|
||||
AC_DEFINE([BUILD_SPINNER],[1],[Whether to use GitgSpinner instead of GtkSpinner])
|
||||
fi
|
||||
|
||||
if $PKG_CONFIG --atleast-version 2.21.0 $GTK_REQUIRED; then
|
||||
gtkatleast=yes
|
||||
else
|
||||
gtkatleast=
|
||||
fi
|
||||
|
||||
if test "$gtkatleast" = "yes"; then
|
||||
DISABLE_DEPRECATED_CFLAGS="$DISABLE_DEPRECATED_CFLAGS -DGSEAL_ENABLE"
|
||||
fi
|
||||
|
||||
AC_SUBST(DISABLE_DEPRECATED_CFLAGS)
|
||||
|
||||
PACKAGE_LIBS="$PACKAGE_LIBS -lm"
|
||||
|
||||
|
||||
AC_ARG_ENABLE(debug,
|
||||
[AS_HELP_STRING([--disable-debug],
|
||||
[disable debug information [default=yes]])],
|
||||
[enable_debug=$enableval], [enable_debug=yes])
|
||||
|
||||
if test "x$enable_debug" = "xyes"; then
|
||||
PACKAGE_CFLAGS="$PACKAGE_CFLAGS -g"
|
||||
AC_DEFINE([ENABLE_DEBUG],[1],[Whether debugging support is enabled])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([ENABLE_DEBUG], [test "$enable_debug" = "yes"])
|
||||
|
||||
|
||||
AC_ARG_ENABLE(debug,
|
||||
[AS_HELP_STRING([--disable-debug],
|
||||
[disable debug information [default=yes]])],
|
||||
|
|
|
@ -16,7 +16,7 @@ gitgstyles_DATA = gitgstyle.xml
|
|||
gsettings_SCHEMAS = org.gnome.gitg.gschema.xml
|
||||
|
||||
if GLADE_CATALOG
|
||||
catalogdir = $(GLADE_CATALOGDIR)
|
||||
catalogdir = $(GLADE_CATALOG_DIR)
|
||||
dist_catalog_DATA = gitg-glade.xml
|
||||
endif
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ AM_CPPFLAGS = \
|
|||
|
||||
NOINST_H_FILES = \
|
||||
gitg-activatable.h \
|
||||
gitg-avatar-cache.h \
|
||||
gitg-branch-actions.h \
|
||||
gitg-cell-renderer-path.h \
|
||||
gitg-commit-view.h \
|
||||
|
@ -30,13 +31,13 @@ NOINST_H_FILES = \
|
|||
gitg-stat-view.h \
|
||||
gitg-uri.h \
|
||||
gitg-utils.h \
|
||||
gitg-window.h \
|
||||
gseal-gtk-compat.h
|
||||
gitg-window.h
|
||||
|
||||
gitg_SOURCES = \
|
||||
$(BUILT_SOURCES) \
|
||||
gitg.c \
|
||||
gitg-activatable.c \
|
||||
gitg-avatar-cache.c \
|
||||
gitg-branch-actions.c \
|
||||
gitg-cell-renderer-path.c \
|
||||
gitg-commit-view.c \
|
||||
|
@ -55,14 +56,8 @@ gitg_SOURCES = \
|
|||
gitg-uri.c \
|
||||
gitg-utils.c \
|
||||
gitg-window.c \
|
||||
gseal-gtk-compat.c \
|
||||
$(NOINST_H_FILES)
|
||||
|
||||
if BUILD_SPINNER
|
||||
gitg_SOURCES += gitg-spinner.c
|
||||
NOINST_H_FILES += gitg-spinner.h
|
||||
endif
|
||||
|
||||
gitg_LDADD = \
|
||||
$(GITG_LIBS) \
|
||||
$(PACKAGE_LIBS) \
|
||||
|
|
416
gitg/gitg-avatar-cache.c
Normal file
416
gitg/gitg-avatar-cache.c
Normal file
|
@ -0,0 +1,416 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* Copyright (C) 2009 Mathias Hasselmann
|
||||
*
|
||||
* 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 "config.h"
|
||||
#include "gitg-avatar-cache.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <gio/gio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define AVATAR_SIZE 80
|
||||
|
||||
typedef struct _GitgAvatarCacheLoader GitgAvatarCacheLoader;
|
||||
struct _GitgAvatarCacheLoader
|
||||
{
|
||||
gchar *uri;
|
||||
GitgAvatarCache *cache;
|
||||
GCancellable *cancellable;
|
||||
gchar buffer[8192];
|
||||
GdkPixbufLoader *pixbuf_loader;
|
||||
GdkPixbuf *pixbuf;
|
||||
GSimpleAsyncResult *result;
|
||||
};
|
||||
|
||||
struct _GitgAvatarCachePrivate
|
||||
{
|
||||
GChecksum *checksum;
|
||||
GHashTable *pixbuf_table;
|
||||
GList *active_loaders;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GitgAvatarCache, gitg_avatar_cache, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
avatar_cache_loader_finish (GitgAvatarCacheLoader *loader,
|
||||
GError *error)
|
||||
{
|
||||
if (loader->cache)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (loader->cache),
|
||||
(gpointer) &loader->cache);
|
||||
}
|
||||
|
||||
if (loader->cancellable)
|
||||
{
|
||||
g_cancellable_cancel (loader->cancellable);
|
||||
g_object_unref (loader->cancellable);
|
||||
}
|
||||
|
||||
if (loader->pixbuf_loader)
|
||||
{
|
||||
gdk_pixbuf_loader_close (loader->pixbuf_loader, NULL);
|
||||
g_object_unref (loader->pixbuf_loader);
|
||||
}
|
||||
|
||||
if (loader->pixbuf)
|
||||
{
|
||||
g_simple_async_result_set_op_res_gpointer (loader->result,
|
||||
g_object_ref (loader->pixbuf),
|
||||
g_object_unref);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_simple_async_result_set_from_error (loader->result, error);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_simple_async_result_complete_in_idle (loader->result);
|
||||
g_object_unref (loader->result);
|
||||
|
||||
g_slice_free (GitgAvatarCacheLoader, loader);
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_avatar_cache_init (GitgAvatarCache *cache)
|
||||
{
|
||||
cache->priv = G_TYPE_INSTANCE_GET_PRIVATE (cache,
|
||||
GITG_TYPE_AVATAR_CACHE,
|
||||
GitgAvatarCachePrivate);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
cached_pixbuf_unref0 (gpointer pixbuf)
|
||||
{
|
||||
if (pixbuf != NULL)
|
||||
{
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
avatar_cache_insert (GitgAvatarCache *cache,
|
||||
const gchar *uri,
|
||||
GdkPixbuf *pixbuf)
|
||||
{
|
||||
GitgAvatarCachePrivate *priv = cache->priv;
|
||||
|
||||
if (!priv->pixbuf_table)
|
||||
{
|
||||
priv->pixbuf_table = g_hash_table_new_full (g_str_hash,
|
||||
g_str_equal,
|
||||
g_free,
|
||||
cached_pixbuf_unref0);
|
||||
}
|
||||
|
||||
if (pixbuf != NULL)
|
||||
{
|
||||
g_object_ref (pixbuf);
|
||||
}
|
||||
|
||||
g_hash_table_insert (priv->pixbuf_table, g_strdup (uri), pixbuf);
|
||||
}
|
||||
|
||||
static void
|
||||
avatar_cache_close_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GitgAvatarCacheLoader *loader = user_data;
|
||||
GInputStream *stream = G_INPUT_STREAM (object);
|
||||
GError *error = NULL;
|
||||
|
||||
if (g_input_stream_close_finish (stream, result, &error) &&
|
||||
gdk_pixbuf_loader_close (loader->pixbuf_loader, &error))
|
||||
{
|
||||
loader->pixbuf = gdk_pixbuf_loader_get_pixbuf (loader->pixbuf_loader);
|
||||
avatar_cache_insert (loader->cache, loader->uri, loader->pixbuf);
|
||||
g_object_unref (loader->pixbuf_loader);
|
||||
loader->pixbuf_loader = NULL;
|
||||
}
|
||||
|
||||
if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_warning ("%s: %s", G_STRFUNC, error->message);
|
||||
|
||||
avatar_cache_loader_finish (loader, error);
|
||||
}
|
||||
|
||||
static void
|
||||
avatar_cache_read_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GitgAvatarCacheLoader *loader = user_data;
|
||||
GInputStream *stream = G_INPUT_STREAM (object);
|
||||
GError *error = NULL;
|
||||
gssize len;
|
||||
|
||||
len = g_input_stream_read_finish (stream, result, &error);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
if (gdk_pixbuf_loader_write (loader->pixbuf_loader, (gpointer)
|
||||
loader->buffer, len, &error))
|
||||
{
|
||||
g_input_stream_read_async (stream, loader->buffer,
|
||||
sizeof (loader->buffer),
|
||||
G_PRIORITY_DEFAULT,
|
||||
loader->cancellable,
|
||||
avatar_cache_read_cb,
|
||||
loader);
|
||||
}
|
||||
else
|
||||
{
|
||||
len = -2;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 >= len)
|
||||
{
|
||||
g_input_stream_close_async (stream, G_PRIORITY_DEFAULT,
|
||||
loader->cancellable,
|
||||
avatar_cache_close_cb, loader);
|
||||
}
|
||||
|
||||
if (error)
|
||||
{
|
||||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_warning ("%s: %s", G_STRFUNC, error->message);
|
||||
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
avatar_cache_open_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GitgAvatarCacheLoader *loader = user_data;
|
||||
GError *error = NULL;
|
||||
GFileInputStream *stream;
|
||||
|
||||
stream = g_file_read_finish (G_FILE (object), result, &error);
|
||||
|
||||
if (stream)
|
||||
{
|
||||
g_input_stream_read_async (G_INPUT_STREAM (stream),
|
||||
loader->buffer, sizeof (loader->buffer),
|
||||
G_PRIORITY_DEFAULT, loader->cancellable,
|
||||
avatar_cache_read_cb, loader);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* At the moment G_IO_ERROR_NOT_FOUND is not being returned
|
||||
* and instead an error code of 404 is. This is HTTP's
|
||||
* File Not Found error.
|
||||
*/
|
||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) ||
|
||||
(error != NULL && error->code == 404))
|
||||
{
|
||||
avatar_cache_insert (loader->cache, loader->uri, NULL);
|
||||
}
|
||||
else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
{
|
||||
g_warning ("%s: %s", G_STRFUNC, error->message);
|
||||
}
|
||||
|
||||
avatar_cache_loader_finish (loader, error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
avatar_cache_finalize (GObject *object)
|
||||
{
|
||||
GitgAvatarCachePrivate *priv = GITG_AVATAR_CACHE (object)->priv;
|
||||
GitgAvatarCacheLoader *loader;
|
||||
GList *l;
|
||||
|
||||
if (priv->pixbuf_table)
|
||||
{
|
||||
g_hash_table_unref (priv->pixbuf_table);
|
||||
}
|
||||
|
||||
if (priv->checksum)
|
||||
{
|
||||
g_checksum_free (priv->checksum);
|
||||
}
|
||||
|
||||
for (l = priv->active_loaders; l; l = g_list_delete_link (l, l))
|
||||
{
|
||||
loader = priv->active_loaders->data;
|
||||
g_cancellable_cancel (loader->cancellable);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gitg_avatar_cache_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_avatar_cache_class_init (GitgAvatarCacheClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->finalize = avatar_cache_finalize;
|
||||
|
||||
g_type_class_add_private (class, sizeof (GitgAvatarCachePrivate));
|
||||
}
|
||||
|
||||
GitgAvatarCache *
|
||||
gitg_avatar_cache_new (void)
|
||||
{
|
||||
return g_object_new (GITG_TYPE_AVATAR_CACHE, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gitg_avatar_cache_load_uri_async (GitgAvatarCache *cache,
|
||||
const gchar *uri,
|
||||
gint io_priority,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GitgAvatarCachePrivate *priv;
|
||||
gboolean found = FALSE;
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
GSimpleAsyncResult *result;
|
||||
GitgAvatarCacheLoader *loader;
|
||||
GFile *file;
|
||||
|
||||
g_return_if_fail (GITG_IS_AVATAR_CACHE (cache));
|
||||
g_return_if_fail (NULL != callback);
|
||||
g_return_if_fail (NULL != uri);
|
||||
|
||||
priv = cache->priv;
|
||||
|
||||
result = g_simple_async_result_new (G_OBJECT (cache), callback, user_data,
|
||||
gitg_avatar_cache_load_uri_async);
|
||||
|
||||
if (priv->pixbuf_table)
|
||||
{
|
||||
found = g_hash_table_lookup_extended (priv->pixbuf_table, uri,
|
||||
NULL, (gpointer *) &pixbuf);
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
if (pixbuf == NULL)
|
||||
{
|
||||
g_simple_async_result_set_error (result, G_IO_ERROR,
|
||||
G_IO_ERROR_NOT_FOUND,
|
||||
"Not Found");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_simple_async_result_set_op_res_gpointer (result,
|
||||
g_object_ref (pixbuf),
|
||||
g_object_unref);
|
||||
}
|
||||
|
||||
g_simple_async_result_complete_in_idle (result);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cancellable)
|
||||
{
|
||||
g_object_ref (cancellable);
|
||||
}
|
||||
else
|
||||
{
|
||||
cancellable = g_cancellable_new ();
|
||||
}
|
||||
|
||||
loader = g_slice_new0 (GitgAvatarCacheLoader);
|
||||
loader->pixbuf_loader = gdk_pixbuf_loader_new ();
|
||||
loader->result = g_object_ref (result);
|
||||
loader->cancellable = cancellable;
|
||||
loader->uri = g_strdup (uri);
|
||||
loader->cache = cache;
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (loader->cache),
|
||||
(gpointer) &loader->cache);
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
|
||||
g_file_read_async (file, G_PRIORITY_DEFAULT, loader->cancellable,
|
||||
avatar_cache_open_cb, loader);
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
g_object_unref (result);
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
gitg_avatar_cache_load_finish (GitgAvatarCache *cache,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *simple;
|
||||
gpointer source_tag;
|
||||
|
||||
g_return_val_if_fail (GITG_IS_AVATAR_CACHE (cache), NULL);
|
||||
g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);
|
||||
|
||||
simple = G_SIMPLE_ASYNC_RESULT (result);
|
||||
source_tag = g_simple_async_result_get_source_tag (simple);
|
||||
|
||||
g_return_val_if_fail (source_tag == gitg_avatar_cache_load_uri_async, NULL);
|
||||
|
||||
if (g_simple_async_result_propagate_error (simple, error))
|
||||
return NULL;
|
||||
|
||||
return g_simple_async_result_get_op_res_gpointer (simple);
|
||||
}
|
||||
|
||||
gchar *
|
||||
gitg_avatar_cache_get_gravatar_uri (GitgAvatarCache *cache,
|
||||
const gchar *gravatar_id)
|
||||
{
|
||||
GitgAvatarCachePrivate *priv;
|
||||
gssize len;
|
||||
gchar *lowercase_id;
|
||||
|
||||
g_return_val_if_fail (GITG_IS_AVATAR_CACHE (cache), NULL);
|
||||
g_return_val_if_fail (NULL != gravatar_id, NULL);
|
||||
|
||||
priv = cache->priv;
|
||||
|
||||
if (priv->checksum)
|
||||
{
|
||||
g_checksum_reset (priv->checksum);
|
||||
}
|
||||
else
|
||||
{
|
||||
priv->checksum = g_checksum_new (G_CHECKSUM_MD5);
|
||||
}
|
||||
|
||||
len = strlen (gravatar_id);
|
||||
lowercase_id = g_ascii_strdown (gravatar_id, len);
|
||||
|
||||
g_checksum_update (priv->checksum, (gpointer) lowercase_id, len);
|
||||
|
||||
g_free (lowercase_id);
|
||||
|
||||
/* d=404 will return a File Not Found if the avatar does not exist */
|
||||
return g_strdup_printf ("http://www.gravatar.com/avatar/%s?d=404&s=%d",
|
||||
g_checksum_get_string (priv->checksum),
|
||||
AVATAR_SIZE);
|
||||
}
|
73
gitg/gitg-avatar-cache.h
Normal file
73
gitg/gitg-avatar-cache.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* Copyright (C) 2009 Mathias Hasselmann
|
||||
*
|
||||
* 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_AVATAR_CACHE_H__
|
||||
#define __GITG_AVATAR_CACHE_H__
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GITG_TYPE_AVATAR_CACHE (gitg_avatar_cache_get_type ())
|
||||
#define GITG_AVATAR_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_AVATAR_CACHE, GitgAvatarCache))
|
||||
#define GITG_AVATAR_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_AVATAR_CACHE, GitgAvatarCacheClass))
|
||||
#define GITG_IS_AVATAR_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_AVATAR_CACHE))
|
||||
#define GITG_IS_AVATAR_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_AVATAR_CACHE))
|
||||
#define GITG_AVATAR_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_AVATAR_CACHE, GitgAvatarCacheClass))
|
||||
|
||||
typedef struct _GitgAvatarCache GitgAvatarCache;
|
||||
typedef struct _GitgAvatarCachePrivate GitgAvatarCachePrivate;
|
||||
typedef struct _GitgAvatarCacheClass GitgAvatarCacheClass;
|
||||
|
||||
struct _GitgAvatarCache
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GitgAvatarCachePrivate *priv;
|
||||
};
|
||||
|
||||
struct _GitgAvatarCacheClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
GType gitg_avatar_cache_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GitgAvatarCache *gitg_avatar_cache_new (void);
|
||||
|
||||
void gitg_avatar_cache_load_uri_async (GitgAvatarCache *cache,
|
||||
const gchar *uri,
|
||||
gint io_priority,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GdkPixbuf *gitg_avatar_cache_load_finish (GitgAvatarCache *cache,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gchar *gitg_avatar_cache_get_gravatar_uri (GitgAvatarCache *cache,
|
||||
const gchar *gravatar_id);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GITG_AVATAR_CACHE_H__ */
|
||||
|
|
@ -622,13 +622,9 @@ rename_dialog (GitgWindow *window, const gchar *oldname)
|
|||
"_Rename", GTK_RESPONSE_OK,
|
||||
NULL);
|
||||
|
||||
#if ! GTK_CHECK_VERSION(2, 22, 0)
|
||||
gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
|
||||
#endif
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK);
|
||||
|
||||
GtkWidget *box = gtk_hbox_new (FALSE, 6);
|
||||
GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
GtkWidget *label = gtk_label_new (_("Name:"));
|
||||
GtkWidget *entry = gtk_entry_new ();
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ gitg_cell_renderer_path_finalize(GObject *object)
|
|||
}
|
||||
|
||||
static void
|
||||
renderer_get_size(GtkCellRenderer *renderer, GtkWidget *widget, GdkRectangle *area, gint *xoffset, gint *yoffset, gint *width, gint *height)
|
||||
renderer_get_size(GtkCellRenderer *renderer, GtkWidget *widget, const GdkRectangle *area, gint *xoffset, gint *yoffset, gint *width, gint *height)
|
||||
{
|
||||
GitgCellRendererPath *self = GITG_CELL_RENDERER_PATH(renderer);
|
||||
|
||||
|
@ -131,7 +131,7 @@ renderer_get_size(GtkCellRenderer *renderer, GtkWidget *widget, GdkRectangle *ar
|
|||
}
|
||||
|
||||
static void
|
||||
draw_arrow(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area, gint8 laneidx, gboolean top)
|
||||
draw_arrow(GitgCellRendererPath *self, cairo_t *cr, const GdkRectangle *area, gint8 laneidx, gboolean top)
|
||||
{
|
||||
gdouble cw = self->priv->lane_width;
|
||||
gdouble xpos = area->x + laneidx * cw + cw / 2.0;
|
||||
|
@ -154,7 +154,7 @@ draw_arrow(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area, gint8 la
|
|||
}
|
||||
|
||||
static void
|
||||
draw_paths_real(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area, GitgRevision *revision, gdouble yoffset)
|
||||
draw_paths_real(GitgCellRendererPath *self, cairo_t *cr, const GdkRectangle *area, GitgRevision *revision, gdouble yoffset)
|
||||
{
|
||||
if (!revision)
|
||||
return;
|
||||
|
@ -190,19 +190,19 @@ draw_paths_real(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area, Git
|
|||
}
|
||||
|
||||
static void
|
||||
draw_top_paths(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area)
|
||||
draw_top_paths(GitgCellRendererPath *self, cairo_t *cr, const GdkRectangle *area)
|
||||
{
|
||||
draw_paths_real(self, cr, area, self->priv->revision, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_bottom_paths(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area)
|
||||
draw_bottom_paths(GitgCellRendererPath *self, cairo_t *cr, const GdkRectangle *area)
|
||||
{
|
||||
draw_paths_real(self, cr, area, self->priv->next_revision, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_arrows(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area)
|
||||
draw_arrows(GitgCellRendererPath *self, cairo_t *cr, const GdkRectangle *area)
|
||||
{
|
||||
GSList *item;
|
||||
gint8 to = 0;
|
||||
|
@ -222,7 +222,7 @@ draw_arrows(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area)
|
|||
}
|
||||
|
||||
static void
|
||||
draw_paths(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area)
|
||||
draw_paths(GitgCellRendererPath *self, cairo_t *cr, const GdkRectangle *area)
|
||||
{
|
||||
cairo_set_line_width(cr, 2);
|
||||
//cairo_set_source_rgb(cr, 0.45, 0.6, 0.74);
|
||||
|
@ -234,7 +234,7 @@ draw_paths(GitgCellRendererPath *self, cairo_t *cr, GdkRectangle *area)
|
|||
}
|
||||
|
||||
static void
|
||||
draw_labels(GitgCellRendererPath *self, GtkWidget *widget, cairo_t *context, GdkRectangle *area)
|
||||
draw_labels(GitgCellRendererPath *self, GtkWidget *widget, cairo_t *context, const GdkRectangle *area)
|
||||
{
|
||||
gint offset = num_lanes(self) * self->priv->lane_width;
|
||||
PangoFontDescription *font;
|
||||
|
@ -249,7 +249,7 @@ draw_labels(GitgCellRendererPath *self, GtkWidget *widget, cairo_t *context, Gdk
|
|||
}
|
||||
|
||||
static void
|
||||
draw_indicator_triangle(GitgCellRendererPath *self, GitgLane *lane, cairo_t *context, GdkRectangle *area)
|
||||
draw_indicator_triangle(GitgCellRendererPath *self, GitgLane *lane, cairo_t *context, const GdkRectangle *area)
|
||||
{
|
||||
gdouble offset = gitg_revision_get_mylane(self->priv->revision) * self->priv->lane_width + (self->priv->lane_width - self->priv->triangle_width) / 2.0;
|
||||
gdouble radius = self->priv->triangle_width / 2.0;
|
||||
|
@ -281,7 +281,7 @@ draw_indicator_triangle(GitgCellRendererPath *self, GitgLane *lane, cairo_t *con
|
|||
}
|
||||
|
||||
static void
|
||||
draw_indicator_circle(GitgCellRendererPath *self, GitgLane *lane, cairo_t *context, GdkRectangle *area)
|
||||
draw_indicator_circle(GitgCellRendererPath *self, GitgLane *lane, cairo_t *context, const GdkRectangle *area)
|
||||
{
|
||||
gdouble offset = gitg_revision_get_mylane(self->priv->revision) * self->priv->lane_width + (self->priv->lane_width - self->priv->dot_width) / 2.0;
|
||||
gdouble radius = self->priv->dot_width / 2.0;
|
||||
|
@ -307,7 +307,7 @@ draw_indicator_circle(GitgCellRendererPath *self, GitgLane *lane, cairo_t *conte
|
|||
}
|
||||
|
||||
static void
|
||||
draw_indicator(GitgCellRendererPath *self, cairo_t *context, GdkRectangle *area)
|
||||
draw_indicator(GitgCellRendererPath *self, cairo_t *context, const GdkRectangle *area)
|
||||
{
|
||||
GitgLane *lane = gitg_revision_get_lane(self->priv->revision);
|
||||
|
||||
|
@ -318,14 +318,12 @@ draw_indicator(GitgCellRendererPath *self, cairo_t *context, GdkRectangle *area)
|
|||
}
|
||||
|
||||
static void
|
||||
renderer_render(GtkCellRenderer *renderer, GdkDrawable *window, GtkWidget *widget, GdkRectangle *area, GdkRectangle *cell_area, GdkRectangle *expose_area, GtkCellRendererState flags)
|
||||
renderer_render(GtkCellRenderer *renderer, cairo_t *cr, GtkWidget *widget, const GdkRectangle *area, const GdkRectangle *cell_area, GtkCellRendererState flags)
|
||||
{
|
||||
GitgCellRendererPath *self = GITG_CELL_RENDERER_PATH(renderer);
|
||||
|
||||
self->priv->last_height = area->height;
|
||||
|
||||
cairo_t *cr = gdk_cairo_create(window);
|
||||
|
||||
gdk_cairo_rectangle (cr, area);
|
||||
cairo_clip(cr);
|
||||
|
||||
|
@ -336,13 +334,12 @@ renderer_render(GtkCellRenderer *renderer, GdkDrawable *window, GtkWidget *widge
|
|||
|
||||
/* draw labels */
|
||||
draw_labels(self, widget, cr, area);
|
||||
cairo_destroy(cr);
|
||||
|
||||
area->x += total_width(self, widget);
|
||||
cell_area->x += total_width(self, widget);
|
||||
((GdkRectangle *) area)->x += total_width(self, widget);
|
||||
((GdkRectangle *) cell_area)->x += total_width(self, widget);
|
||||
|
||||
if (GTK_CELL_RENDERER_CLASS(parent_class)->render)
|
||||
GTK_CELL_RENDERER_CLASS(parent_class)->render(renderer, window, widget, area, cell_area, expose_area, flags);
|
||||
GTK_CELL_RENDERER_CLASS(parent_class)->render(renderer, cr, widget, area, cell_area, flags);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "gitg-commit-view.h"
|
||||
#include "gitg-diff-view.h"
|
||||
#include "gitg-utils.h"
|
||||
#include "gseal-gtk-compat.h"
|
||||
|
||||
#define GITG_COMMIT_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_COMMIT_VIEW, GitgCommitViewPrivate))
|
||||
#define CATEGORY_UNSTAGE_HUNK "CategoryUnstageHunk"
|
||||
|
@ -147,7 +146,7 @@ gitg_commit_view_finalize (GObject *object)
|
|||
g_object_unref (view->priv->shell);
|
||||
g_object_unref (view->priv->ui_manager);
|
||||
|
||||
gdk_cursor_unref (view->priv->hand);
|
||||
g_object_unref (view->priv->hand);
|
||||
|
||||
G_OBJECT_CLASS (gitg_commit_view_parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -370,8 +369,7 @@ get_selected_files(GtkTreeView *tree_view,
|
|||
}
|
||||
else
|
||||
{
|
||||
g_list_foreach(items, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free(items);
|
||||
g_list_free_full (items, (GDestroyNotify)gtk_tree_path_free);
|
||||
}
|
||||
|
||||
if (files)
|
||||
|
@ -422,8 +420,7 @@ check_selection(GtkTreeView *tree_view,
|
|||
ret = TRUE;
|
||||
}
|
||||
|
||||
g_list_foreach(paths, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free(paths);
|
||||
g_list_free_full (paths, (GDestroyNotify)gtk_tree_path_free);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -559,11 +556,6 @@ staged_selection_changed (GtkTreeSelection *selection, GitgCommitView *view)
|
|||
}
|
||||
else
|
||||
{
|
||||
gchar *basename;
|
||||
basename = g_file_get_basename(f);
|
||||
|
||||
g_free(basename);
|
||||
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (view->priv->hscale_context),
|
||||
FALSE);
|
||||
|
||||
|
@ -1249,8 +1241,7 @@ on_tree_view_drag_data_get (GtkWidget *widget,
|
|||
|
||||
g_strfreev(uris);
|
||||
|
||||
g_list_foreach(selected, (GFunc)g_object_unref, NULL);
|
||||
g_list_free(selected);
|
||||
g_list_free_full (selected, g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1363,6 +1354,8 @@ on_tag_added (GtkTextTagTable *table,
|
|||
static void
|
||||
gitg_commit_view_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
|
||||
{
|
||||
GtkSourceMarkAttributes *attrs;
|
||||
|
||||
if (parent_iface.parser_finished)
|
||||
parent_iface.parser_finished(buildable, builder);
|
||||
|
||||
|
@ -1428,16 +1421,30 @@ gitg_commit_view_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
|
|||
|
||||
if (pixbuf)
|
||||
{
|
||||
gtk_source_view_set_mark_category_icon_from_pixbuf(self->priv->changes_view, CATEGORY_STAGE_HUNK, pixbuf);
|
||||
g_object_unref(pixbuf);
|
||||
attrs = gtk_source_mark_attributes_new ();
|
||||
gtk_source_mark_attributes_set_pixbuf (attrs, pixbuf);
|
||||
|
||||
gtk_source_view_set_mark_attributes (self->priv->changes_view,
|
||||
CATEGORY_STAGE_HUNK,
|
||||
attrs, 1);
|
||||
|
||||
g_object_unref (pixbuf);
|
||||
g_object_unref (attrs);
|
||||
}
|
||||
|
||||
pixbuf = gtk_icon_theme_load_icon(theme, GTK_STOCK_REMOVE, 12, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
|
||||
|
||||
if (pixbuf)
|
||||
{
|
||||
gtk_source_view_set_mark_category_icon_from_pixbuf(self->priv->changes_view, CATEGORY_UNSTAGE_HUNK, pixbuf);
|
||||
g_object_unref(pixbuf);
|
||||
attrs = gtk_source_mark_attributes_new ();
|
||||
gtk_source_mark_attributes_set_pixbuf (attrs, pixbuf);
|
||||
|
||||
gtk_source_view_set_mark_attributes (self->priv->changes_view,
|
||||
CATEGORY_UNSTAGE_HUNK,
|
||||
attrs, 2);
|
||||
|
||||
g_object_unref (pixbuf);
|
||||
g_object_unref (attrs);
|
||||
}
|
||||
|
||||
gitg_utils_set_monospace_font(GTK_WIDGET(self->priv->changes_view));
|
||||
|
|
|
@ -39,9 +39,16 @@ struct _GitgDiffLineRendererPrivate
|
|||
gint line_old;
|
||||
gint line_new;
|
||||
gchar *label;
|
||||
gint num_digits;
|
||||
|
||||
PangoLayout *cached_layout;
|
||||
PangoAttribute *fg_attr;
|
||||
PangoAttrList *cached_attr_list;
|
||||
|
||||
glong changed_handler_id;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GitgDiffLineRenderer, gitg_diff_line_renderer, GTK_TYPE_CELL_RENDERER)
|
||||
G_DEFINE_TYPE (GitgDiffLineRenderer, gitg_diff_line_renderer, GTK_SOURCE_TYPE_GUTTER_RENDERER)
|
||||
|
||||
static void
|
||||
gitg_diff_line_renderer_set_property (GObject *object,
|
||||
|
@ -94,15 +101,68 @@ gitg_diff_line_renderer_get_property (GObject *object,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_diff_line_renderer_finalize (GObject *object)
|
||||
{
|
||||
GitgDiffLineRenderer *self = GITG_DIFF_LINE_RENDERER (object);
|
||||
|
||||
g_free (self->priv->label);
|
||||
|
||||
G_OBJECT_CLASS (gitg_diff_line_renderer_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
create_layout (GitgDiffLineRenderer *renderer,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
PangoLayout *layout;
|
||||
PangoAttribute *attr;
|
||||
GtkStyleContext *context;
|
||||
GdkRGBA color;
|
||||
PangoAttrList *attr_list;
|
||||
|
||||
layout = gtk_widget_create_pango_layout (widget, NULL);
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color);
|
||||
|
||||
attr = pango_attr_foreground_new (color.red * 65535,
|
||||
color.green * 65535,
|
||||
color.blue * 65535);
|
||||
|
||||
attr->start_index = 0;
|
||||
attr->end_index = G_MAXINT;
|
||||
|
||||
attr_list = pango_attr_list_new ();
|
||||
pango_attr_list_insert (attr_list, attr);
|
||||
|
||||
renderer->priv->fg_attr = attr;
|
||||
renderer->priv->cached_layout = layout;
|
||||
renderer->priv->cached_attr_list = attr_list;
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_diff_line_renderer_begin (GtkSourceGutterRenderer *renderer,
|
||||
cairo_t *cr,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GtkTextIter *start,
|
||||
GtkTextIter *end)
|
||||
{
|
||||
GitgDiffLineRenderer *lr = GITG_DIFF_LINE_RENDERER (renderer);
|
||||
|
||||
create_layout (lr, GTK_WIDGET (gtk_source_gutter_renderer_get_view (renderer)));
|
||||
}
|
||||
|
||||
static void
|
||||
darken_or_lighten (cairo_t *ctx,
|
||||
GdkColor const *color)
|
||||
GdkRGBA const *color)
|
||||
{
|
||||
float r, g, b;
|
||||
|
||||
r = color->red / 65535.0;
|
||||
g = color->green / 65535.0;
|
||||
b = color->blue / 65535.0;
|
||||
r = color->red;
|
||||
g = color->green;
|
||||
b = color->blue;
|
||||
|
||||
if ((r + g + b) / 3 > 0.5)
|
||||
{
|
||||
|
@ -121,20 +181,24 @@ darken_or_lighten (cairo_t *ctx,
|
|||
}
|
||||
|
||||
static void
|
||||
render_label (GitgDiffLineRenderer *lr,
|
||||
GdkDrawable *window,
|
||||
GtkWidget *widget,
|
||||
render_label (GtkSourceGutterRenderer *renderer,
|
||||
cairo_t *ctx,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags)
|
||||
GtkTextIter *start,
|
||||
GtkTextIter *end,
|
||||
GtkSourceGutterRendererState renderer_state)
|
||||
{
|
||||
GitgDiffLineRenderer *lr = GITG_DIFF_LINE_RENDERER (renderer);
|
||||
GtkWidget *widget;
|
||||
PangoLayout *layout;
|
||||
GtkStyle *style;
|
||||
GtkStyleContext *style_context;
|
||||
GtkStateType state;
|
||||
gint pixel_height;
|
||||
GdkRGBA fg_color, bg_color;
|
||||
|
||||
layout = gtk_widget_create_pango_layout (widget, "");
|
||||
widget = GTK_WIDGET (gtk_source_gutter_renderer_get_view (renderer));
|
||||
layout = lr->priv->cached_layout;
|
||||
|
||||
pango_layout_set_markup (layout, lr->priv->label, -1);
|
||||
pango_layout_set_width (layout, cell_area->width);
|
||||
|
@ -143,15 +207,13 @@ render_label (GitgDiffLineRenderer *lr,
|
|||
|
||||
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
|
||||
|
||||
style = gtk_widget_get_style (widget);
|
||||
style_context = gtk_widget_get_style_context (widget);
|
||||
state = gtk_widget_get_state (widget);
|
||||
|
||||
cairo_t *ctx = gdk_cairo_create (window);
|
||||
gtk_style_context_get_color (style_context, state, &fg_color);
|
||||
gtk_style_context_get_background_color (style_context, state, &bg_color);
|
||||
|
||||
gdk_cairo_rectangle (ctx, expose_area);
|
||||
cairo_clip (ctx);
|
||||
|
||||
gdk_cairo_set_source_color (ctx, &(style->fg[state]));
|
||||
gdk_cairo_set_source_rgba (ctx, &fg_color);
|
||||
|
||||
gitg_utils_rounded_rectangle (ctx,
|
||||
cell_area->x + 0.5,
|
||||
|
@ -162,12 +224,12 @@ render_label (GitgDiffLineRenderer *lr,
|
|||
|
||||
cairo_fill_preserve (ctx);
|
||||
|
||||
darken_or_lighten (ctx, &(style->fg[state]));
|
||||
darken_or_lighten (ctx, &fg_color);
|
||||
|
||||
cairo_set_line_width (ctx, 1);
|
||||
cairo_stroke (ctx);
|
||||
|
||||
gdk_cairo_set_source_color (ctx, &(style->base[state]));
|
||||
gdk_cairo_set_source_rgba (ctx, &bg_color);
|
||||
|
||||
cairo_move_to (ctx,
|
||||
cell_area->x + cell_area->width / 2,
|
||||
|
@ -175,37 +237,33 @@ render_label (GitgDiffLineRenderer *lr,
|
|||
|
||||
pango_cairo_show_layout (ctx, layout);
|
||||
|
||||
cairo_destroy (ctx);
|
||||
|
||||
/*gtk_paint_layout (style,
|
||||
window,
|
||||
state,
|
||||
FALSE,
|
||||
NULL,
|
||||
widget,
|
||||
NULL,
|
||||
/*gtk_render_layout (style_context,
|
||||
ctx,
|
||||
cell_area->x + cell_area->width / 2,
|
||||
cell_area->y,
|
||||
layout);*/
|
||||
}
|
||||
|
||||
static void
|
||||
render_lines (GitgDiffLineRenderer *lr,
|
||||
GdkDrawable *window,
|
||||
GtkWidget *widget,
|
||||
render_lines (GtkSourceGutterRenderer *renderer,
|
||||
cairo_t *ctx,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags)
|
||||
GtkTextIter *start,
|
||||
GtkTextIter *end,
|
||||
GtkSourceGutterRendererState renderer_state)
|
||||
{
|
||||
GitgDiffLineRenderer *lr = GITG_DIFF_LINE_RENDERER (renderer);
|
||||
/* Render new/old in the cell area */
|
||||
gchar old_str[16];
|
||||
gchar new_str[16];
|
||||
guint xpad;
|
||||
guint ypad;
|
||||
GtkStyle *style;
|
||||
PangoLayout *layout;
|
||||
GtkWidget *widget;
|
||||
GtkStyleContext *style_context;
|
||||
|
||||
widget = GTK_WIDGET (gtk_source_gutter_renderer_get_view (renderer));
|
||||
layout = lr->priv->cached_layout;
|
||||
|
||||
PangoLayout *layout = gtk_widget_create_pango_layout (widget, "");
|
||||
pango_layout_set_width (layout, cell_area->width / 2);
|
||||
|
||||
pango_layout_set_alignment (layout, PANGO_ALIGN_RIGHT);
|
||||
|
@ -228,171 +286,234 @@ render_lines (GitgDiffLineRenderer *lr,
|
|||
*new_str = '\0';
|
||||
}
|
||||
|
||||
g_object_get (lr, "xpad", &xpad, "ypad", &ypad, NULL);
|
||||
|
||||
pango_layout_set_text (layout, old_str, -1);
|
||||
style = gtk_widget_get_style (widget);
|
||||
style_context = gtk_widget_get_style_context (widget);
|
||||
|
||||
gtk_paint_layout (style,
|
||||
window,
|
||||
gtk_widget_get_state (widget),
|
||||
FALSE,
|
||||
NULL,
|
||||
widget,
|
||||
NULL,
|
||||
cell_area->x + cell_area->width / 2 - 1 - xpad,
|
||||
gtk_render_layout (style_context,
|
||||
ctx,
|
||||
cell_area->x + cell_area->width / 2 - 1,
|
||||
cell_area->y,
|
||||
layout);
|
||||
|
||||
pango_layout_set_text (layout, new_str, -1);
|
||||
gtk_paint_layout (style,
|
||||
window,
|
||||
gtk_widget_get_state (widget),
|
||||
FALSE,
|
||||
NULL,
|
||||
widget,
|
||||
NULL,
|
||||
cell_area->x + cell_area->width - xpad,
|
||||
gtk_render_layout (style_context,
|
||||
ctx,
|
||||
cell_area->x + cell_area->width,
|
||||
cell_area->y,
|
||||
layout);
|
||||
|
||||
g_object_unref (layout);
|
||||
|
||||
gtk_paint_vline (style,
|
||||
window,
|
||||
gtk_widget_get_state (widget),
|
||||
NULL,
|
||||
widget,
|
||||
NULL,
|
||||
background_area->y,
|
||||
background_area->y + background_area->height,
|
||||
background_area->x + background_area->width / 2);
|
||||
gtk_render_line (style_context,
|
||||
ctx,
|
||||
background_area->x + background_area->width / 2,
|
||||
background_area->y - 1,
|
||||
background_area->x + background_area->width / 2,
|
||||
background_area->y + background_area->height);
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_diff_line_renderer_render_impl (GtkCellRenderer *cell,
|
||||
GdkDrawable *window,
|
||||
GtkWidget *widget,
|
||||
gitg_diff_line_renderer_draw (GtkSourceGutterRenderer *renderer,
|
||||
cairo_t *ctx,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags)
|
||||
GtkTextIter *start,
|
||||
GtkTextIter *end,
|
||||
GtkSourceGutterRendererState renderer_state)
|
||||
{
|
||||
GitgDiffLineRenderer *lr = GITG_DIFF_LINE_RENDERER (cell);
|
||||
GitgDiffLineRenderer *lr = GITG_DIFF_LINE_RENDERER (renderer);
|
||||
|
||||
/* Chain up to draw background */
|
||||
GTK_SOURCE_GUTTER_RENDERER_CLASS (
|
||||
gitg_diff_line_renderer_parent_class)->draw (renderer,
|
||||
ctx,
|
||||
background_area,
|
||||
cell_area,
|
||||
start,
|
||||
end,
|
||||
renderer_state);
|
||||
|
||||
if (lr->priv->label)
|
||||
{
|
||||
render_label (lr,
|
||||
window,
|
||||
widget,
|
||||
render_label (renderer,
|
||||
ctx,
|
||||
background_area,
|
||||
cell_area,
|
||||
expose_area,
|
||||
flags);
|
||||
start,
|
||||
end,
|
||||
renderer_state);
|
||||
}
|
||||
else
|
||||
{
|
||||
render_lines (lr,
|
||||
window,
|
||||
widget,
|
||||
render_lines (renderer,
|
||||
ctx,
|
||||
background_area,
|
||||
cell_area,
|
||||
expose_area,
|
||||
flags);
|
||||
start,
|
||||
end,
|
||||
renderer_state);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_diff_line_renderer_get_size_impl (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gitg_diff_line_renderer_end (GtkSourceGutterRenderer *renderer)
|
||||
{
|
||||
GitgDiffLineRenderer *lr = GITG_DIFF_LINE_RENDERER (renderer);
|
||||
|
||||
g_object_unref (lr->priv->cached_layout);
|
||||
lr->priv->cached_layout = NULL;
|
||||
|
||||
pango_attr_list_unref (lr->priv->cached_attr_list);
|
||||
lr->priv->cached_attr_list = NULL;
|
||||
|
||||
lr->priv->fg_attr = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
measure_text (GitgDiffLineRenderer *lr,
|
||||
const gchar *markup,
|
||||
const gchar *text,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GitgDiffLineRenderer *lr = GITG_DIFF_LINE_RENDERER (cell);
|
||||
|
||||
/* Get size of this rendering */
|
||||
PangoLayout *layout;
|
||||
gchar str[16];
|
||||
gint pixel_width;
|
||||
gint pixel_height;
|
||||
guint xpad;
|
||||
guint ypad;
|
||||
gint w;
|
||||
gint h;
|
||||
GtkSourceGutterRenderer *r;
|
||||
GtkTextView *view;
|
||||
|
||||
g_snprintf(str, sizeof(str), "%d", MAX(MAX(99, lr->priv->line_old), lr->priv->line_new));
|
||||
layout = gtk_widget_create_pango_layout (widget, str);
|
||||
pango_layout_get_pixel_size(layout, &pixel_width, &pixel_height);
|
||||
r = GTK_SOURCE_GUTTER_RENDERER (lr);
|
||||
view = gtk_source_gutter_renderer_get_view (r);
|
||||
|
||||
g_object_get (cell, "xpad", &xpad, "ypad", &ypad, NULL);
|
||||
pixel_width += pixel_width + xpad * 2 + 3;
|
||||
layout = gtk_widget_create_pango_layout (GTK_WIDGET (view), NULL);
|
||||
|
||||
if (lr->priv->label)
|
||||
if (markup)
|
||||
{
|
||||
PangoLayout *lbl_layout;
|
||||
gint lbl_pixel_width;
|
||||
gint lbl_pixel_height;
|
||||
|
||||
lbl_layout = gtk_widget_create_pango_layout (widget,
|
||||
"");
|
||||
|
||||
pango_layout_set_markup (lbl_layout, lr->priv->label, -1);
|
||||
|
||||
pango_layout_get_pixel_size (lbl_layout,
|
||||
&lbl_pixel_width,
|
||||
&lbl_pixel_height);
|
||||
|
||||
lbl_pixel_width += 4;
|
||||
|
||||
if (lbl_pixel_width > pixel_width)
|
||||
pango_layout_set_markup (layout,
|
||||
markup,
|
||||
-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel_width = lbl_pixel_width;
|
||||
pango_layout_set_text (layout,
|
||||
text,
|
||||
-1);
|
||||
}
|
||||
|
||||
if (lbl_pixel_height > pixel_height)
|
||||
{
|
||||
pixel_height = lbl_pixel_height;
|
||||
}
|
||||
}
|
||||
|
||||
pixel_width += xpad * 2;
|
||||
pixel_height += ypad * 2;
|
||||
pango_layout_get_size (layout, &w, &h);
|
||||
|
||||
if (width)
|
||||
{
|
||||
*width = pixel_width;
|
||||
*width = w / PANGO_SCALE;
|
||||
}
|
||||
|
||||
if (height)
|
||||
{
|
||||
*height = pixel_height;
|
||||
*height = h / PANGO_SCALE;
|
||||
}
|
||||
|
||||
if (x_offset)
|
||||
g_object_unref (layout);
|
||||
}
|
||||
|
||||
static void
|
||||
recalculate_size (GitgDiffLineRenderer *lr)
|
||||
{
|
||||
/* Get size of this rendering */
|
||||
gint num_digits, num;
|
||||
|
||||
num_digits = 0;
|
||||
num = lr->priv->line_old;
|
||||
|
||||
while (num > 0)
|
||||
{
|
||||
*x_offset = 0;
|
||||
num /= 10;
|
||||
++num_digits;
|
||||
}
|
||||
|
||||
if (y_offset)
|
||||
num = lr->priv->line_new;
|
||||
|
||||
while (num > 0)
|
||||
{
|
||||
*y_offset = 0;
|
||||
num /= 10;
|
||||
++num_digits;
|
||||
}
|
||||
|
||||
g_object_unref (G_OBJECT (layout));
|
||||
num_digits = MAX (num_digits, 2);
|
||||
|
||||
if (num_digits != lr->priv->num_digits)
|
||||
{
|
||||
gchar *markup;
|
||||
gint size;
|
||||
|
||||
lr->priv->num_digits = num_digits;
|
||||
|
||||
markup = g_strdup_printf ("<b>%d %d</b>",
|
||||
lr->priv->line_old,
|
||||
lr->priv->line_new);
|
||||
|
||||
measure_text (lr, markup, NULL, &size, NULL);
|
||||
g_free (markup);
|
||||
|
||||
gtk_source_gutter_renderer_set_size (GTK_SOURCE_GUTTER_RENDERER (lr),
|
||||
size);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_buffer_changed (GtkSourceBuffer *buffer,
|
||||
GitgDiffLineRenderer *renderer)
|
||||
{
|
||||
recalculate_size (renderer);
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_diff_line_renderer_change_buffer (GtkSourceGutterRenderer *renderer,
|
||||
GtkTextBuffer *old_buffer)
|
||||
{
|
||||
GitgDiffLineRenderer *lr;
|
||||
GtkTextView *view;
|
||||
|
||||
lr = GITG_DIFF_LINE_RENDERER (renderer);
|
||||
|
||||
if (old_buffer)
|
||||
{
|
||||
g_signal_handler_disconnect (old_buffer,
|
||||
lr->priv->changed_handler_id);
|
||||
}
|
||||
|
||||
view = gtk_source_gutter_renderer_get_view (renderer);
|
||||
|
||||
if (view)
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (view);
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
lr->priv->changed_handler_id =
|
||||
g_signal_connect (buffer,
|
||||
"changed",
|
||||
G_CALLBACK (on_buffer_changed),
|
||||
lr);
|
||||
|
||||
recalculate_size (lr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_diff_line_renderer_class_init (GitgDiffLineRendererClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkCellRendererClass *cell_renderer_class = GTK_CELL_RENDERER_CLASS (klass);
|
||||
GtkSourceGutterRendererClass *renderer_class = GTK_SOURCE_GUTTER_RENDERER_CLASS (klass);
|
||||
|
||||
cell_renderer_class->render = gitg_diff_line_renderer_render_impl;
|
||||
cell_renderer_class->get_size = gitg_diff_line_renderer_get_size_impl;
|
||||
renderer_class->begin = gitg_diff_line_renderer_begin;
|
||||
renderer_class->draw = gitg_diff_line_renderer_draw;
|
||||
renderer_class->end= gitg_diff_line_renderer_end;
|
||||
renderer_class->change_buffer = gitg_diff_line_renderer_change_buffer;
|
||||
|
||||
object_class->set_property = gitg_diff_line_renderer_set_property;
|
||||
object_class->get_property = gitg_diff_line_renderer_get_property;
|
||||
object_class->finalize = gitg_diff_line_renderer_finalize;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_LINE_OLD,
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#ifndef __GITG_DIFF_LINE_RENDERER_H__
|
||||
#define __GITG_DIFF_LINE_RENDERER_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtksourceview/gtksourceview.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -40,13 +40,13 @@ typedef struct _GitgDiffLineRendererClass GitgDiffLineRendererClass;
|
|||
typedef struct _GitgDiffLineRendererPrivate GitgDiffLineRendererPrivate;
|
||||
|
||||
struct _GitgDiffLineRenderer {
|
||||
GtkCellRenderer parent;
|
||||
GtkSourceGutterRenderer parent;
|
||||
|
||||
GitgDiffLineRendererPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GitgDiffLineRendererClass {
|
||||
GtkCellRendererClass parent_class;
|
||||
GtkSourceGutterRendererClass parent_class;
|
||||
};
|
||||
|
||||
GType gitg_diff_line_renderer_get_type (void) G_GNUC_CONST;
|
||||
|
|
|
@ -56,17 +56,16 @@ static void on_buffer_delete_range (GtkTextBuffer *buffer,
|
|||
GtkTextIter *end,
|
||||
GitgDiffView *view);
|
||||
|
||||
static void
|
||||
/*static void
|
||||
line_renderer_size_func (GtkSourceGutter *gutter,
|
||||
GtkCellRenderer *cell,
|
||||
GitgDiffView *view);
|
||||
static void
|
||||
line_renderer_data_func (GtkSourceGutter *gutter,
|
||||
GtkCellRenderer *cell,
|
||||
gint line_number,
|
||||
gboolean current_line,
|
||||
*/
|
||||
static void line_renderer_query_data_cb (GtkSourceGutterRenderer *renderer,
|
||||
GtkTextIter *start,
|
||||
GtkTextIter *end,
|
||||
GtkSourceGutterRendererState state,
|
||||
GitgDiffView *view);
|
||||
|
||||
static void disable_diff_view (GitgDiffView *view);
|
||||
static void enable_diff_view (GitgDiffView *view);
|
||||
|
||||
|
@ -143,9 +142,9 @@ struct _GitgDiffViewPrivate
|
|||
GDestroyNotify label_func_destroy_notify;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GitgDiffView, gitg_diff_view, GTK_TYPE_SOURCE_VIEW)
|
||||
G_DEFINE_TYPE (GitgDiffView, gitg_diff_view, GTK_SOURCE_TYPE_VIEW)
|
||||
|
||||
static gboolean gitg_diff_view_expose (GtkWidget *widget, GdkEventExpose *event);
|
||||
static gboolean gitg_diff_view_draw (GtkWidget *widget, cairo_t *cr);
|
||||
static guint diff_view_signals[NUM_SIGNALS] = {0,};
|
||||
|
||||
static void
|
||||
|
@ -295,10 +294,7 @@ gitg_diff_view_constructed (GObject *object)
|
|||
{
|
||||
g_object_set (object, "show-line-numbers", FALSE, NULL);
|
||||
|
||||
if (G_OBJECT_CLASS (gitg_diff_view_parent_class)->constructed)
|
||||
{
|
||||
G_OBJECT_CLASS (gitg_diff_view_parent_class)->constructed (object);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -314,7 +310,7 @@ gitg_diff_view_class_init (GitgDiffViewClass *klass)
|
|||
|
||||
object_class->constructed = gitg_diff_view_constructed;
|
||||
|
||||
widget_class->expose_event = gitg_diff_view_expose;
|
||||
widget_class->draw = gitg_diff_view_draw;
|
||||
|
||||
diff_view_signals[HEADER_ADDED] =
|
||||
g_signal_new ("header-added",
|
||||
|
@ -392,7 +388,7 @@ disable_diff_view (GitgDiffView *view)
|
|||
GTK_TEXT_WINDOW_LEFT);
|
||||
|
||||
gtk_source_gutter_remove (gutter,
|
||||
GTK_CELL_RENDERER (view->priv->line_renderer));
|
||||
GTK_SOURCE_GUTTER_RENDERER (view->priv->line_renderer));
|
||||
}
|
||||
|
||||
view->priv->diff_enabled = FALSE;
|
||||
|
@ -446,20 +442,25 @@ enable_diff_view (GitgDiffView *view)
|
|||
GTK_TEXT_WINDOW_LEFT);
|
||||
|
||||
gtk_source_gutter_insert (gutter,
|
||||
GTK_CELL_RENDERER (view->priv->line_renderer),
|
||||
GTK_SOURCE_GUTTER_RENDERER (view->priv->line_renderer),
|
||||
0);
|
||||
|
||||
gtk_source_gutter_set_cell_data_func (gutter,
|
||||
GTK_CELL_RENDERER (view->priv->line_renderer),
|
||||
/*gtk_source_gutter_set_cell_data_func (gutter,
|
||||
GTK_SOURCE_GUTTER_RENDERER (view->priv->line_renderer),
|
||||
(GtkSourceGutterDataFunc)line_renderer_data_func,
|
||||
view,
|
||||
NULL);
|
||||
|
||||
gtk_source_gutter_set_cell_size_func (gutter,
|
||||
GTK_CELL_RENDERER (view->priv->line_renderer),
|
||||
GTK_SOURCE_GUTTER_RENDERER (view->priv->line_renderer),
|
||||
(GtkSourceGutterSizeFunc)line_renderer_size_func,
|
||||
view,
|
||||
NULL);
|
||||
NULL);*/
|
||||
|
||||
g_signal_connect (view->priv->line_renderer,
|
||||
"query-data",
|
||||
(GCallback) line_renderer_query_data_cb,
|
||||
view);
|
||||
|
||||
view->priv->diff_enabled = TRUE;
|
||||
}
|
||||
|
@ -768,7 +769,7 @@ get_initial_counters (GitgDiffView *view, Region *region, guint line, guint coun
|
|||
++counters[1];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
static void
|
||||
line_renderer_size_func (GtkSourceGutter *gutter,
|
||||
GtkCellRenderer *cell,
|
||||
|
@ -788,19 +789,22 @@ line_renderer_size_func (GtkSourceGutter *gutter,
|
|||
g_object_set (cell, "label", label, NULL);
|
||||
g_free (label);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
static void
|
||||
line_renderer_data_func (GtkSourceGutter *gutter,
|
||||
GtkCellRenderer *cell,
|
||||
gint line_number,
|
||||
gboolean current_line,
|
||||
line_renderer_query_data_cb (GtkSourceGutterRenderer *renderer,
|
||||
GtkTextIter *start,
|
||||
GtkTextIter *end,
|
||||
GtkSourceGutterRendererState state,
|
||||
GitgDiffView *view)
|
||||
{
|
||||
gint line_old = -1;
|
||||
gint line_new = -1;
|
||||
gint line_number;
|
||||
Region **current = &view->priv->lines_current_region;
|
||||
|
||||
line_number = gtk_text_iter_get_line (start) + 1;
|
||||
|
||||
ensure_scan (view, line_number);
|
||||
|
||||
if (!*current || view->priv->lines_previous_line + 1 != line_number)
|
||||
|
@ -835,7 +839,7 @@ line_renderer_data_func (GtkSourceGutter *gutter,
|
|||
}
|
||||
}
|
||||
|
||||
g_object_set (cell, "line_old", line_old, "line_new", line_new, NULL);
|
||||
g_object_set (renderer, "line_old", line_old, "line_new", line_new, NULL);
|
||||
|
||||
if (*current && (*current)->next && line_number == (*current)->next->line - 1)
|
||||
{
|
||||
|
@ -849,26 +853,26 @@ line_renderer_data_func (GtkSourceGutter *gutter,
|
|||
line_number,
|
||||
view->priv->label_func_user_data);
|
||||
|
||||
g_object_set (cell, "label", label, NULL);
|
||||
g_object_set (renderer, "label", label, NULL);
|
||||
g_free (label);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
gitg_diff_view_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event)
|
||||
gitg_diff_view_draw (GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GitgDiffView *view = GITG_DIFF_VIEW (widget);
|
||||
|
||||
/* Prepare for new round of expose on the line renderer */
|
||||
/* Prepare for new round of draw on the line renderer */
|
||||
view->priv->lines_current_region = NULL;
|
||||
view->priv->lines_previous_line = -1;
|
||||
view->priv->lines_counters[0] = 0;
|
||||
view->priv->lines_counters[1] = 0;
|
||||
|
||||
if (GTK_WIDGET_CLASS (gitg_diff_view_parent_class)->expose_event)
|
||||
if (GTK_WIDGET_CLASS (gitg_diff_view_parent_class)->draw)
|
||||
{
|
||||
return GTK_WIDGET_CLASS (gitg_diff_view_parent_class)->expose_event (widget, event);
|
||||
return GTK_WIDGET_CLASS (gitg_diff_view_parent_class)->draw (widget, cr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "gitg-cell-renderer-path.h"
|
||||
#include "gitg-window.h"
|
||||
#include "gitg-branch-actions.h"
|
||||
#include "gseal-gtk-compat.h"
|
||||
#include "gitg-utils.h"
|
||||
|
||||
#include <string.h>
|
||||
|
@ -532,7 +531,7 @@ vertical_autoscroll (GitgDndData *data)
|
|||
}
|
||||
}
|
||||
|
||||
GtkAdjustment *adj = gtk_tree_view_get_vadjustment (data->tree_view);
|
||||
GtkAdjustment *adj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (data->tree_view));
|
||||
|
||||
value = CLAMP (gtk_adjustment_get_value (adj) + offset, 0.0,
|
||||
gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj));
|
||||
|
|
|
@ -184,7 +184,7 @@ render_label (cairo_t *context, PangoLayout *layout, GitgRef *ref, gint x, gint
|
|||
}
|
||||
|
||||
void
|
||||
gitg_label_renderer_draw(GtkWidget *widget, PangoFontDescription *description, cairo_t *context, GSList *labels, GdkRectangle *area)
|
||||
gitg_label_renderer_draw(GtkWidget *widget, PangoFontDescription *description, cairo_t *context, GSList *labels, const GdkRectangle *area)
|
||||
{
|
||||
GSList *item;
|
||||
double pos = MARGIN + 0.5;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <libgitg/gitg-ref.h>
|
||||
|
||||
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, const GdkRectangle *area);
|
||||
|
||||
GitgRef *gitg_label_renderer_get_ref_at_pos (GtkWidget *widget, PangoFontDescription *description, GSList *labels, gint x, gint *hot_x);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<object class="GtkNotebook" id="notebook1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="expand">True</property>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox_history">
|
||||
<property name="visible">True</property>
|
||||
|
@ -104,6 +105,7 @@
|
|||
<object class="GtkVBox" id="vbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="expand">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label10">
|
||||
<property name="visible">True</property>
|
||||
|
@ -302,6 +304,7 @@
|
|||
<object class="GtkVBox" id="vbox11">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="expand">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
|
@ -510,6 +513,7 @@
|
|||
<object class="GtkVBox" id="vbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="expand">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label5">
|
||||
<property name="visible">True</property>
|
||||
|
|
|
@ -33,10 +33,6 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_SPINNER
|
||||
#include "gitg-spinner.h"
|
||||
#endif
|
||||
|
||||
void on_button_fetch_remote_clicked (GtkButton *button,
|
||||
GitgRepositoryDialog *dialog);
|
||||
|
||||
|
@ -104,11 +100,7 @@ typedef struct
|
|||
GitgShell *shell;
|
||||
GtkTreeRowReference *reference;
|
||||
|
||||
#ifdef BUILD_SPINNER
|
||||
GitgSpinner *spinner;
|
||||
#else
|
||||
guint pulse_id;
|
||||
#endif
|
||||
} FetchInfo;
|
||||
|
||||
static void
|
||||
|
@ -125,13 +117,6 @@ fetch_cleanup (FetchInfo *info)
|
|||
&iter,
|
||||
path);
|
||||
|
||||
#ifdef BUILD_SPINNER
|
||||
gtk_list_store_set (info->dialog->priv->list_store_remotes,
|
||||
&iter,
|
||||
COLUMN_SPINNER, NULL,
|
||||
-1);
|
||||
#endif
|
||||
|
||||
gtk_list_store_set (info->dialog->priv->list_store_remotes,
|
||||
&iter,
|
||||
COLUMN_FETCH, FALSE,
|
||||
|
@ -140,14 +125,7 @@ fetch_cleanup (FetchInfo *info)
|
|||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
#ifdef BUILD_SPINNER
|
||||
if (info->spinner)
|
||||
{
|
||||
g_object_unref (info->spinner);
|
||||
}
|
||||
#else
|
||||
g_source_remove (info->pulse_id);
|
||||
#endif
|
||||
|
||||
gtk_tree_row_reference_free (info->reference);
|
||||
g_object_unref (info->shell);
|
||||
|
@ -252,8 +230,7 @@ update_fetch (GitgRepositoryDialog *dialog)
|
|||
|
||||
dialog->priv->show_fetch = show_fetch;
|
||||
|
||||
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free (rows);
|
||||
g_list_free_full (rows, (GDestroyNotify)gtk_tree_path_free);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -270,8 +247,7 @@ update_sensitivity (GitgRepositoryDialog *dialog)
|
|||
|
||||
update_fetch (dialog);
|
||||
|
||||
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free (rows);
|
||||
g_list_free_full (rows, (GDestroyNotify)gtk_tree_path_free);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -290,25 +266,6 @@ add_remote (GitgRepositoryDialog *dialog, gchar const *name, gchar const *url, G
|
|||
-1);
|
||||
}
|
||||
|
||||
#ifdef BUILD_SPINNER
|
||||
static void
|
||||
on_spinner_frame (GitgSpinner *spinner, GdkPixbuf *pixbuf, FetchInfo *info)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path = gtk_tree_row_reference_get_path (info->reference);
|
||||
|
||||
gtk_tree_model_get_iter (GTK_TREE_MODEL (info->dialog->priv->list_store_remotes),
|
||||
&iter,
|
||||
path);
|
||||
|
||||
gtk_list_store_set (info->dialog->priv->list_store_remotes,
|
||||
&iter,
|
||||
COLUMN_SPINNER, pixbuf,
|
||||
-1);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
#else
|
||||
static gboolean
|
||||
pulse_row (FetchInfo *info)
|
||||
{
|
||||
|
@ -339,7 +296,6 @@ pulse_row (FetchInfo *info)
|
|||
|
||||
return fetch;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
on_fetch_begin_loading (GitgShell *shell, FetchInfo *info)
|
||||
|
@ -356,33 +312,14 @@ on_fetch_begin_loading (GitgShell *shell, FetchInfo *info)
|
|||
COLUMN_FETCH, TRUE,
|
||||
-1);
|
||||
|
||||
#ifdef BUILD_SPINNER
|
||||
info->spinner = gitg_spinner_new (GTK_ICON_SIZE_MENU);
|
||||
gitg_spinner_set_screen (info->spinner, gtk_widget_get_screen (GTK_WIDGET (info->dialog)));
|
||||
|
||||
g_signal_connect (info->spinner, "frame", G_CALLBACK (on_spinner_frame), info);
|
||||
gitg_spinner_start (info->spinner);
|
||||
#else
|
||||
GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (info->dialog->priv->tree_view_remotes));
|
||||
|
||||
GValue cycle_duration = {0,};
|
||||
GValue num_steps = {0,};
|
||||
|
||||
g_value_init (&cycle_duration, G_TYPE_UINT);
|
||||
g_value_init (&num_steps, G_TYPE_UINT);
|
||||
|
||||
gtk_style_get_style_property (style, GTK_TYPE_SPINNER, "num-steps", &num_steps);
|
||||
gtk_style_get_style_property (style, GTK_TYPE_SPINNER, "cycle-duration", &cycle_duration);
|
||||
|
||||
info->pulse_id = g_timeout_add (g_value_get_uint (&cycle_duration) /
|
||||
g_value_get_uint (&num_steps),
|
||||
/* We can't tell how often we are supposed to pulse so just pulse
|
||||
* at the interval of the default engine. Yes this is annoying but,
|
||||
* mclasen said to "blame the engine."
|
||||
*/
|
||||
info->pulse_id = g_timeout_add (750 / 12,
|
||||
(GSourceFunc)pulse_row,
|
||||
info);
|
||||
|
||||
g_value_unset (&cycle_duration);
|
||||
g_value_unset (&num_steps);
|
||||
#endif
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
update_fetch (info->dialog);
|
||||
}
|
||||
|
@ -516,7 +453,6 @@ init_properties(GitgRepositoryDialog *dialog)
|
|||
init_remotes(dialog);
|
||||
}
|
||||
|
||||
#ifndef BUILD_SPINNER
|
||||
static void
|
||||
fetch_data_spinner_cb (GtkTreeViewColumn *column,
|
||||
GtkCellRenderer *cell,
|
||||
|
@ -538,7 +474,6 @@ fetch_data_spinner_cb (GtkTreeViewColumn *column,
|
|||
"pulse", pulse,
|
||||
NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
fetch_data_icon_cb (GtkTreeViewColumn *column,
|
||||
|
@ -547,21 +482,6 @@ fetch_data_icon_cb (GtkTreeViewColumn *column,
|
|||
GtkTreeIter *iter,
|
||||
GitgRepositoryDialog *dialog)
|
||||
{
|
||||
#ifdef BUILD_SPINNER
|
||||
GdkPixbuf *fetch;
|
||||
|
||||
gtk_tree_model_get (model, iter, COLUMN_SPINNER, &fetch, -1);
|
||||
|
||||
if (fetch)
|
||||
{
|
||||
g_object_set (cell, "pixbuf", fetch, NULL);
|
||||
g_object_unref (fetch);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_object_set (cell, "stock-id", GTK_STOCK_NETWORK, NULL);
|
||||
}
|
||||
#else
|
||||
gboolean fetch;
|
||||
|
||||
gtk_tree_model_get (model, iter, COLUMN_FETCH, &fetch, -1);
|
||||
|
@ -569,7 +489,6 @@ fetch_data_icon_cb (GtkTreeViewColumn *column,
|
|||
g_object_set (G_OBJECT (cell),
|
||||
"visible", !fetch,
|
||||
NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -603,7 +522,6 @@ create_repository_dialog (GitgWindow *window)
|
|||
|
||||
GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (b, "tree_view_remotes_column_name"));
|
||||
|
||||
#ifndef BUILD_SPINNER
|
||||
GtkCellRenderer *spinner_renderer = gtk_cell_renderer_spinner_new ();
|
||||
g_object_set (spinner_renderer, "visible", FALSE, NULL);
|
||||
|
||||
|
@ -615,7 +533,6 @@ create_repository_dialog (GitgWindow *window)
|
|||
(GtkTreeCellDataFunc)fetch_data_spinner_cb,
|
||||
repository_dialog,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
GtkCellRenderer *icon_renderer = GTK_CELL_RENDERER (gtk_builder_get_object (b, "tree_view_remotes_renderer_icon"));
|
||||
gtk_tree_view_column_set_cell_data_func (column,
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
<property name="default_width">500</property>
|
||||
<property name="default_height">300</property>
|
||||
<property name="type_hint">normal</property>
|
||||
<property name="has_separator">False</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkVBox" id="dialog_vbox_main">
|
||||
<property name="visible">True</property>
|
||||
|
@ -197,6 +196,7 @@
|
|||
<property name="n_columns">2</property>
|
||||
<property name="column_spacing">6</property>
|
||||
<property name="row_spacing">6</property>
|
||||
<property name="expand">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_configuration_user_name">
|
||||
<property name="visible">True</property>
|
||||
|
|
|
@ -485,16 +485,11 @@ free_cached_header (gpointer header)
|
|||
static void
|
||||
free_cached_headers (GitgRevisionChangesPanel *changes_panel)
|
||||
{
|
||||
g_slist_foreach (changes_panel->priv->cached_headers,
|
||||
(GFunc)free_cached_header,
|
||||
NULL);
|
||||
|
||||
g_slist_free (changes_panel->priv->cached_headers);
|
||||
g_slist_free_full (changes_panel->priv->cached_headers, free_cached_header);
|
||||
|
||||
changes_panel->priv->cached_headers = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gitg_revision_changes_panel_finalize (GObject *object)
|
||||
{
|
||||
|
@ -704,7 +699,7 @@ on_diff_files_begin_loading (GitgShell *shell,
|
|||
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (self->priv->diff_files)),
|
||||
cursor);
|
||||
|
||||
gdk_cursor_unref (cursor);
|
||||
g_object_unref (cursor);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -819,7 +814,7 @@ on_diff_begin_loading (GitgShell *shell,
|
|||
GdkCursor *cursor = gdk_cursor_new (GDK_WATCH);
|
||||
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET(self->priv->diff)),
|
||||
cursor);
|
||||
gdk_cursor_unref (cursor);
|
||||
g_object_unref (cursor);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "gitg-revision-panel.h"
|
||||
#include "gitg-stat-view.h"
|
||||
#include "gitg-uri.h"
|
||||
#include "gitg-avatar-cache.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -46,6 +47,7 @@ struct _GitgRevisionDetailsPanelPrivate
|
|||
GtkLabel *committer;
|
||||
GtkLabel *subject;
|
||||
GtkTable *parents;
|
||||
GtkImage *avatar;
|
||||
|
||||
GtkWidget *panel_widget;
|
||||
GtkTextView *text_view;
|
||||
|
@ -60,6 +62,8 @@ struct _GitgRevisionDetailsPanelPrivate
|
|||
|
||||
GSList *stats;
|
||||
GitgWindow *window;
|
||||
|
||||
GitgAvatarCache *cache;
|
||||
};
|
||||
|
||||
static void gitg_revision_panel_iface_init (GitgRevisionPanelInterface *iface);
|
||||
|
@ -125,6 +129,7 @@ initialize_ui (GitgRevisionDetailsPanel *panel)
|
|||
priv->subject = GTK_LABEL (gtk_builder_get_object (priv->builder, "label_subject"));
|
||||
priv->parents = GTK_TABLE (gtk_builder_get_object (priv->builder, "table_parents"));
|
||||
priv->text_view = GTK_TEXT_VIEW (gtk_builder_get_object (priv->builder, "text_view_details"));
|
||||
priv->avatar = GTK_IMAGE (gtk_builder_get_object (priv->builder, "image_avatar"));
|
||||
|
||||
gchar const *lbls[] = {
|
||||
"label_subject_lbl",
|
||||
|
@ -211,6 +216,12 @@ gitg_revision_details_panel_dispose (GObject *object)
|
|||
panel->priv->shell = NULL;
|
||||
}
|
||||
|
||||
if (panel->priv->cache)
|
||||
{
|
||||
g_object_unref (panel->priv->cache);
|
||||
panel->priv->cache = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gitg_revision_details_panel_parent_class)->dispose (object);
|
||||
}
|
||||
static void
|
||||
|
@ -236,7 +247,7 @@ on_shell_begin (GitgShell *shell,
|
|||
|
||||
panel->priv->in_stat = FALSE;
|
||||
|
||||
gdk_cursor_unref (cursor);
|
||||
g_object_unref (cursor);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -369,7 +380,7 @@ make_stats_table (GitgRevisionDetailsPanel *panel)
|
|||
0,
|
||||
0.5);
|
||||
g_signal_connect (file,
|
||||
"clicked",
|
||||
"activate-link",
|
||||
G_CALLBACK (link_button_activate_link_cb),
|
||||
panel->priv->window);
|
||||
|
||||
|
@ -548,6 +559,8 @@ gitg_revision_details_panel_init (GitgRevisionDetailsPanel *self)
|
|||
"update",
|
||||
G_CALLBACK (on_shell_update),
|
||||
self);
|
||||
|
||||
self->priv->cache = gitg_avatar_cache_new ();
|
||||
}
|
||||
|
||||
#define HASH_KEY "GitgRevisionDetailsPanelHashKey"
|
||||
|
@ -691,7 +704,7 @@ update_parents (GitgRevisionDetailsPanel *self)
|
|||
}
|
||||
}
|
||||
|
||||
gdk_cursor_unref (cursor);
|
||||
g_object_unref (cursor);
|
||||
g_strfreev (parents);
|
||||
}
|
||||
|
||||
|
@ -725,6 +738,51 @@ update_details (GitgRevisionDetailsPanel *panel)
|
|||
g_free (sha1);
|
||||
}
|
||||
|
||||
static void
|
||||
avatar_ready (GObject *source_object,
|
||||
GAsyncResult *res,
|
||||
GitgRevisionDetailsPanel *panel)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GError *error = NULL;
|
||||
|
||||
pixbuf = gitg_avatar_cache_load_finish (panel->priv->cache,
|
||||
res,
|
||||
&error);
|
||||
|
||||
gtk_widget_set_visible (GTK_WIDGET (panel->priv->avatar),
|
||||
error == NULL);
|
||||
|
||||
if (error == NULL)
|
||||
{
|
||||
gtk_image_set_from_pixbuf (panel->priv->avatar, pixbuf);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_avatar (GitgRevisionDetailsPanel *panel,
|
||||
const gchar *email)
|
||||
{
|
||||
if (email == NULL || *email == '\0')
|
||||
{
|
||||
gtk_widget_hide (GTK_WIDGET (panel->priv->avatar));
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *uri;
|
||||
|
||||
uri = gitg_avatar_cache_get_gravatar_uri (panel->priv->cache,
|
||||
email);
|
||||
gitg_avatar_cache_load_uri_async (panel->priv->cache,
|
||||
uri,
|
||||
G_PRIORITY_DEFAULT,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)avatar_ready,
|
||||
panel);
|
||||
g_free (uri);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
reload (GitgRevisionDetailsPanel *panel)
|
||||
{
|
||||
|
@ -775,6 +833,8 @@ reload (GitgRevisionDetailsPanel *panel)
|
|||
gtk_clipboard_set_text (cb, sha, -1);
|
||||
|
||||
g_free (sha);
|
||||
|
||||
set_avatar (panel, gitg_revision_get_author_email (panel->priv->revision));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -782,6 +842,7 @@ reload (GitgRevisionDetailsPanel *panel)
|
|||
gtk_label_set_text (panel->priv->committer, "");
|
||||
gtk_label_set_text (panel->priv->subject, "");
|
||||
gtk_label_set_text (panel->priv->sha, "");
|
||||
set_avatar (panel, NULL);
|
||||
}
|
||||
|
||||
// Update parents
|
||||
|
|
|
@ -1,127 +1,99 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 2.12 -->
|
||||
<!-- interface-naming-policy toplevel-contextual -->
|
||||
<object class="GtkVBox" id="revision_details_page">
|
||||
<object class="GtkBox" id="revision_details_page">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">3</property>
|
||||
<child>
|
||||
<object class="GtkTable" id="table1">
|
||||
<object class="GtkGrid" id="grid1">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">5</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="column_spacing">6</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="row_spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_author">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="selectable">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_sha">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="selectable">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="y_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_author_lbl">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Author:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<property name="column_spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_sha_lbl">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">SHA:</property>
|
||||
<property name="use_markup">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options">GTK_FILL</property>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_author_lbl">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Author:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_committer_lbl">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Committer:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_committer">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="selectable">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_subject">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="selectable">True</property>
|
||||
<property name="ellipsize">end</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_subject_lbl">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Subject:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options">GTK_FILL</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_parent_lbl">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="yalign">0</property>
|
||||
<property name="label" translatable="yes">Parent:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTable" id="table_parents">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="column_spacing">3</property>
|
||||
<property name="row_spacing">2</property>
|
||||
|
@ -134,29 +106,140 @@
|
|||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_parent_lbl">
|
||||
<object class="GtkLabel" id="label_subject">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="yalign">0</property>
|
||||
<property name="label" translatable="yes">Parent:</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="selectable">True</property>
|
||||
<property name="ellipsize">end</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options">GTK_FILL</property>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_committer">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="selectable">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_author">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="selectable">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_sha">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="selectable">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image_avatar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-missing-image</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="padding">3</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
@ -164,21 +247,22 @@
|
|||
<object class="GtkScrolledWindow" id="scrolled_window_details">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">automatic</property>
|
||||
<property name="vscrollbar_policy">automatic</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="shadow_type">etched-in</property>
|
||||
<child>
|
||||
<object class="GtkTextView" id="text_view_details">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">False</property>
|
||||
<property name="wrap_mode">word-char</property>
|
||||
<property name="cursor_visible">False</property>
|
||||
<property name="accepts_tab">False</property>
|
||||
<property name="wrap-mode">word-char</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
|
|
@ -287,8 +287,7 @@ on_selection_changed (GtkTreeSelection *selection,
|
|||
path = gtk_tree_path_copy ((GtkTreePath *)rows->data);
|
||||
}
|
||||
|
||||
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free (rows);
|
||||
g_list_free_full (rows, (GDestroyNotify)gtk_tree_path_free);
|
||||
|
||||
if (!path)
|
||||
{
|
||||
|
@ -526,9 +525,6 @@ gitg_revision_files_view_parser_finished (GtkBuildable *buildable,
|
|||
files_view->priv->contents = GTK_SOURCE_VIEW (gtk_builder_get_object (builder,
|
||||
"revision_files_contents"));
|
||||
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW(files_view->priv->contents),
|
||||
GTK_TEXT_BUFFER(gtk_source_buffer_new (NULL)));
|
||||
|
||||
gitg_utils_set_monospace_font (GTK_WIDGET(files_view->priv->contents));
|
||||
gtk_tree_view_set_model (files_view->priv->tree_view,
|
||||
GTK_TREE_MODEL(files_view->priv->store));
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<interface>
|
||||
<object class="GtkSourceBuffer" id="source_buffer"></object>
|
||||
<object class="GitgRevisionFilesView" id="revision_files_view">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
|
@ -50,6 +51,7 @@
|
|||
<property name="shadow_type">etched-in</property>
|
||||
<child>
|
||||
<object class="GtkSourceView" id="revision_files_contents">
|
||||
<property name="buffer">source_buffer</property>
|
||||
<property name="editable">False</property>
|
||||
<property name="show_line_numbers">True</property>
|
||||
</object>
|
||||
|
|
|
@ -1,794 +0,0 @@
|
|||
/*
|
||||
* gitg-spinner.c
|
||||
* This file is part of gitg
|
||||
*
|
||||
* Copyright (C) 2009 - Jesse van den kieboom
|
||||
* Copyright (C) 2005 - Paolo Maggi
|
||||
* Copyright (C) 2002-2004 Marco Pesenti Gritti
|
||||
* Copyright (C) 2004 Christian Persch
|
||||
* Copyright (C) 2000 - Eazel, Inc.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This widget was originally written by Andy Hertzfeld <andy@eazel.com> for
|
||||
* Nautilus. It was then modified by Marco Pesenti Gritti and Christian Persch
|
||||
* for Epiphany.
|
||||
*
|
||||
* Modified by the gitg Team, 2005. See the AUTHORS file for a
|
||||
* list of people on the gitg Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*
|
||||
* Modified by the gitg team, 2009.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "gitg-spinner.h"
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
/* Spinner cache implementation */
|
||||
|
||||
#define GITG_TYPE_SPINNER_CACHE (gitg_spinner_cache_get_type())
|
||||
#define GITG_SPINNER_CACHE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), GITG_TYPE_SPINNER_CACHE, GitgSpinnerCache))
|
||||
#define GITG_SPINNER_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GITG_TYPE_SPINNER_CACHE, GitgSpinnerCacheClass))
|
||||
#define GITG_IS_SPINNER_CACHE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), GITG_TYPE_SPINNER_CACHE))
|
||||
#define GITG_IS_SPINNER_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GITG_TYPE_SPINNER_CACHE))
|
||||
#define GITG_SPINNER_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GITG_TYPE_SPINNER_CACHE, GitgSpinnerCacheClass))
|
||||
|
||||
typedef struct _GitgSpinnerCache GitgSpinnerCache;
|
||||
typedef struct _GitgSpinnerCacheClass GitgSpinnerCacheClass;
|
||||
typedef struct _GitgSpinnerCachePrivate GitgSpinnerCachePrivate;
|
||||
|
||||
struct _GitgSpinnerCacheClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
struct _GitgSpinnerCache
|
||||
{
|
||||
GObject parent_object;
|
||||
|
||||
/*< private >*/
|
||||
GitgSpinnerCachePrivate *priv;
|
||||
};
|
||||
|
||||
#define GITG_SPINNER_CACHE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GITG_TYPE_SPINNER_CACHE, GitgSpinnerCachePrivate))
|
||||
|
||||
struct _GitgSpinnerCachePrivate
|
||||
{
|
||||
/* Hash table of GdkScreen -> GitgSpinnerCacheData */
|
||||
GHashTable *hash;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
guint ref_count;
|
||||
GtkIconSize size;
|
||||
gint width;
|
||||
gint height;
|
||||
GdkPixbuf **animation_pixbufs;
|
||||
guint n_animation_pixbufs;
|
||||
} GitgSpinnerImages;
|
||||
|
||||
#define LAST_ICON_SIZE GTK_ICON_SIZE_DIALOG + 1
|
||||
#define SPINNER_ICON_NAME "process-working"
|
||||
#define SPINNER_FALLBACK_ICON_NAME "gnome-spinner"
|
||||
#define GITG_SPINNER_IMAGES_INVALID ((GitgSpinnerImages *) 0x1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GtkIconTheme *icon_theme;
|
||||
GitgSpinnerImages *images[LAST_ICON_SIZE];
|
||||
} GitgSpinnerCacheData;
|
||||
|
||||
static void gitg_spinner_cache_class_init (GitgSpinnerCacheClass *klass);
|
||||
static void gitg_spinner_cache_init (GitgSpinnerCache *cache);
|
||||
|
||||
static GObjectClass *gitg_spinner_cache_parent_class;
|
||||
|
||||
static GType
|
||||
gitg_spinner_cache_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (G_UNLIKELY (type == 0))
|
||||
{
|
||||
const GTypeInfo our_info =
|
||||
{
|
||||
sizeof (GitgSpinnerCacheClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc) gitg_spinner_cache_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GitgSpinnerCache),
|
||||
0,
|
||||
(GInstanceInitFunc) gitg_spinner_cache_init
|
||||
};
|
||||
|
||||
type = g_type_register_static (G_TYPE_OBJECT,
|
||||
"GitgSpinnerCache",
|
||||
&our_info, 0);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static GitgSpinnerImages *
|
||||
gitg_spinner_images_ref (GitgSpinnerImages *images)
|
||||
{
|
||||
g_return_val_if_fail (images != NULL, NULL);
|
||||
|
||||
images->ref_count++;
|
||||
|
||||
return images;
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_spinner_images_unref (GitgSpinnerImages *images)
|
||||
{
|
||||
g_return_if_fail (images != NULL);
|
||||
|
||||
images->ref_count--;
|
||||
|
||||
if (images->ref_count == 0)
|
||||
{
|
||||
guint i;
|
||||
|
||||
/* LOG ("Freeing spinner images %p for size %d", images, images->size); */
|
||||
|
||||
for (i = 0; i < images->n_animation_pixbufs; ++i)
|
||||
{
|
||||
g_object_unref (images->animation_pixbufs[i]);
|
||||
}
|
||||
|
||||
g_free (images->animation_pixbufs);
|
||||
g_free (images);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_spinner_cache_data_unload (GitgSpinnerCacheData *data)
|
||||
{
|
||||
GtkIconSize size;
|
||||
GitgSpinnerImages *images;
|
||||
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
/* LOG ("GitgSpinnerDataCache unload for screen %p", data->screen); */
|
||||
|
||||
for (size = GTK_ICON_SIZE_INVALID; size < LAST_ICON_SIZE; ++size)
|
||||
{
|
||||
images = data->images[size];
|
||||
data->images[size] = NULL;
|
||||
|
||||
if (images != NULL && images != GITG_SPINNER_IMAGES_INVALID)
|
||||
{
|
||||
gitg_spinner_images_unref (images);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static GdkPixbuf *
|
||||
extract_frame (GdkPixbuf *grid_pixbuf,
|
||||
int x,
|
||||
int y,
|
||||
int size)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
if (x + size > gdk_pixbuf_get_width (grid_pixbuf) ||
|
||||
y + size > gdk_pixbuf_get_height (grid_pixbuf))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pixbuf = gdk_pixbuf_new_subpixbuf (grid_pixbuf,
|
||||
x, y,
|
||||
size, size);
|
||||
g_return_val_if_fail (pixbuf != NULL, NULL);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
static GdkPixbuf *
|
||||
scale_to_size (GdkPixbuf *pixbuf,
|
||||
int dw,
|
||||
int dh)
|
||||
{
|
||||
GdkPixbuf *result;
|
||||
int pw, ph;
|
||||
|
||||
g_return_val_if_fail (pixbuf != NULL, NULL);
|
||||
|
||||
pw = gdk_pixbuf_get_width (pixbuf);
|
||||
ph = gdk_pixbuf_get_height (pixbuf);
|
||||
|
||||
if (pw != dw || ph != dh)
|
||||
{
|
||||
result = gdk_pixbuf_scale_simple (pixbuf, dw, dh,
|
||||
GDK_INTERP_BILINEAR);
|
||||
g_object_unref (pixbuf);
|
||||
return result;
|
||||
}
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
static GitgSpinnerImages *
|
||||
gitg_spinner_images_load (GdkScreen *screen,
|
||||
GtkIconTheme *icon_theme,
|
||||
GtkIconSize icon_size)
|
||||
{
|
||||
GitgSpinnerImages *images;
|
||||
GdkPixbuf *icon_pixbuf, *pixbuf;
|
||||
GtkIconInfo *icon_info = NULL;
|
||||
int grid_width, grid_height, x, y, requested_size, size, isw, ish, n;
|
||||
const char *icon;
|
||||
GSList *list = NULL, *l;
|
||||
|
||||
/* LOG ("GitgSpinnerCacheData loading for screen %p at size %d", screen, icon_size); */
|
||||
|
||||
/* START_PROFILER ("loading spinner animation") */
|
||||
|
||||
if (screen == NULL)
|
||||
screen = gdk_screen_get_default ();
|
||||
|
||||
if (!gtk_icon_size_lookup_for_settings (gtk_settings_get_for_screen (screen),
|
||||
icon_size, &isw, &ish))
|
||||
goto loser;
|
||||
|
||||
requested_size = MAX (ish, isw);
|
||||
|
||||
/* Load the animation. The 'rest icon' is the 0th frame */
|
||||
icon_info = gtk_icon_theme_lookup_icon (icon_theme,
|
||||
SPINNER_ICON_NAME,
|
||||
requested_size, 0);
|
||||
|
||||
if (icon_info == NULL)
|
||||
{
|
||||
g_warning ("Throbber animation not found");
|
||||
|
||||
/* If the icon naming spec compliant name wasn't found, try the old name */
|
||||
icon_info = gtk_icon_theme_lookup_icon (icon_theme,
|
||||
SPINNER_FALLBACK_ICON_NAME,
|
||||
requested_size, 0);
|
||||
if (icon_info == NULL)
|
||||
{
|
||||
g_warning ("Throbber fallback animation not found either");
|
||||
goto loser;
|
||||
}
|
||||
}
|
||||
|
||||
g_assert (icon_info != NULL);
|
||||
|
||||
size = gtk_icon_info_get_base_size (icon_info);
|
||||
icon = gtk_icon_info_get_filename (icon_info);
|
||||
|
||||
if (icon == NULL)
|
||||
goto loser;
|
||||
|
||||
icon_pixbuf = gdk_pixbuf_new_from_file (icon, NULL);
|
||||
gtk_icon_info_free (icon_info);
|
||||
icon_info = NULL;
|
||||
|
||||
if (icon_pixbuf == NULL)
|
||||
{
|
||||
g_warning ("Could not load the spinner file");
|
||||
goto loser;
|
||||
}
|
||||
|
||||
grid_width = gdk_pixbuf_get_width (icon_pixbuf);
|
||||
grid_height = gdk_pixbuf_get_height (icon_pixbuf);
|
||||
|
||||
n = 0;
|
||||
for (y = 0; y < grid_height; y += size)
|
||||
{
|
||||
for (x = 0; x < grid_width ; x += size)
|
||||
{
|
||||
pixbuf = extract_frame (icon_pixbuf, x, y, size);
|
||||
|
||||
if (pixbuf)
|
||||
{
|
||||
list = g_slist_prepend (list, pixbuf);
|
||||
++n;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Cannot extract frame (%d, %d) from the grid\n", x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_object_unref (icon_pixbuf);
|
||||
|
||||
if (list == NULL)
|
||||
goto loser;
|
||||
|
||||
/* g_assert (n > 0); */
|
||||
|
||||
if (size > requested_size)
|
||||
{
|
||||
for (l = list; l != NULL; l = l->next)
|
||||
{
|
||||
l->data = scale_to_size (l->data, isw, ish);
|
||||
}
|
||||
}
|
||||
|
||||
/* Now we've successfully got all the data */
|
||||
images = g_new (GitgSpinnerImages, 1);
|
||||
images->ref_count = 1;
|
||||
|
||||
images->size = icon_size;
|
||||
images->width = images->height = requested_size;
|
||||
|
||||
images->n_animation_pixbufs = n;
|
||||
images->animation_pixbufs = g_new (GdkPixbuf *, n);
|
||||
|
||||
for (l = list; l != NULL; l = l->next)
|
||||
{
|
||||
g_assert (l->data != NULL);
|
||||
images->animation_pixbufs[--n] = l->data;
|
||||
}
|
||||
g_assert (n == 0);
|
||||
|
||||
g_slist_free (list);
|
||||
|
||||
/* STOP_PROFILER ("loading spinner animation") */
|
||||
return images;
|
||||
|
||||
loser:
|
||||
if (icon_info)
|
||||
{
|
||||
gtk_icon_info_free (icon_info);
|
||||
}
|
||||
|
||||
g_slist_foreach (list, (GFunc) g_object_unref, NULL);
|
||||
|
||||
/* STOP_PROFILER ("loading spinner animation") */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GitgSpinnerCacheData *
|
||||
gitg_spinner_cache_data_new (GdkScreen *screen)
|
||||
{
|
||||
GitgSpinnerCacheData *data;
|
||||
|
||||
data = g_new0 (GitgSpinnerCacheData, 1);
|
||||
|
||||
data->screen = screen;
|
||||
data->icon_theme = gtk_icon_theme_get_for_screen (screen);
|
||||
|
||||
g_signal_connect_swapped (data->icon_theme,
|
||||
"changed",
|
||||
G_CALLBACK (gitg_spinner_cache_data_unload),
|
||||
data);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_spinner_cache_data_free (GitgSpinnerCacheData *data)
|
||||
{
|
||||
g_return_if_fail (data != NULL);
|
||||
g_return_if_fail (data->icon_theme != NULL);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (data->icon_theme,
|
||||
G_CALLBACK (gitg_spinner_cache_data_unload),
|
||||
data);
|
||||
|
||||
gitg_spinner_cache_data_unload (data);
|
||||
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
static GitgSpinnerImages *
|
||||
gitg_spinner_cache_get_images (GitgSpinnerCache *cache,
|
||||
GdkScreen *screen,
|
||||
GtkIconSize icon_size)
|
||||
{
|
||||
GitgSpinnerCachePrivate *priv = cache->priv;
|
||||
GitgSpinnerCacheData *data;
|
||||
GitgSpinnerImages *images;
|
||||
|
||||
g_return_val_if_fail (icon_size >= 0 && icon_size < LAST_ICON_SIZE, NULL);
|
||||
|
||||
data = g_hash_table_lookup (priv->hash, screen);
|
||||
|
||||
if (data == NULL)
|
||||
{
|
||||
data = gitg_spinner_cache_data_new (screen);
|
||||
|
||||
/* FIXME: think about what happens when the screen's display is closed later on */
|
||||
g_hash_table_insert (priv->hash, screen, data);
|
||||
}
|
||||
|
||||
images = data->images[icon_size];
|
||||
|
||||
if (images == GITG_SPINNER_IMAGES_INVALID)
|
||||
{
|
||||
/* Load failed, but don't try endlessly again! */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (images != NULL)
|
||||
{
|
||||
/* Return cached data */
|
||||
return gitg_spinner_images_ref (images);
|
||||
}
|
||||
|
||||
images = gitg_spinner_images_load (screen, data->icon_theme, icon_size);
|
||||
|
||||
if (images == NULL)
|
||||
{
|
||||
/* Mark as failed-to-load */
|
||||
data->images[icon_size] = GITG_SPINNER_IMAGES_INVALID;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data->images[icon_size] = images;
|
||||
|
||||
return gitg_spinner_images_ref (images);
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_spinner_cache_init (GitgSpinnerCache *cache)
|
||||
{
|
||||
GitgSpinnerCachePrivate *priv;
|
||||
|
||||
priv = cache->priv = GITG_SPINNER_CACHE_GET_PRIVATE (cache);
|
||||
|
||||
/* LOG ("GitgSpinnerCache initialising"); */
|
||||
|
||||
priv->hash = g_hash_table_new_full (g_direct_hash,
|
||||
g_direct_equal,
|
||||
NULL,
|
||||
(GDestroyNotify) gitg_spinner_cache_data_free);
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_spinner_cache_finalize (GObject *object)
|
||||
{
|
||||
GitgSpinnerCache *cache = GITG_SPINNER_CACHE (object);
|
||||
GitgSpinnerCachePrivate *priv = cache->priv;
|
||||
|
||||
g_hash_table_destroy (priv->hash);
|
||||
|
||||
/* LOG ("GitgSpinnerCache finalised"); */
|
||||
|
||||
G_OBJECT_CLASS (gitg_spinner_cache_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_spinner_cache_class_init (GitgSpinnerCacheClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gitg_spinner_cache_parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gitg_spinner_cache_finalize;
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (GitgSpinnerCachePrivate));
|
||||
}
|
||||
|
||||
static GitgSpinnerCache *spinner_cache = NULL;
|
||||
|
||||
static GitgSpinnerCache *
|
||||
gitg_spinner_cache_ref (void)
|
||||
{
|
||||
if (spinner_cache == NULL)
|
||||
{
|
||||
GitgSpinnerCache **cache_ptr;
|
||||
|
||||
spinner_cache = g_object_new (GITG_TYPE_SPINNER_CACHE, NULL);
|
||||
cache_ptr = &spinner_cache;
|
||||
g_object_add_weak_pointer (G_OBJECT (spinner_cache),
|
||||
(gpointer *) cache_ptr);
|
||||
|
||||
return spinner_cache;
|
||||
}
|
||||
|
||||
return g_object_ref (spinner_cache);
|
||||
}
|
||||
|
||||
/* Spinner implementation */
|
||||
|
||||
#define SPINNER_TIMEOUT 50 /* ms */
|
||||
|
||||
#define GITG_SPINNER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GITG_TYPE_SPINNER, GitgSpinnerPrivate))
|
||||
|
||||
struct _GitgSpinnerPrivate
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GitgSpinnerCache *cache;
|
||||
GtkIconSize size;
|
||||
GitgSpinnerImages *images;
|
||||
guint current_image;
|
||||
guint timeout;
|
||||
guint timer_task;
|
||||
guint spinning : 1;
|
||||
guint need_load : 1;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
FRAME,
|
||||
NUM_SIGNALS
|
||||
};
|
||||
|
||||
static guint spinner_signals[NUM_SIGNALS] = {0,};
|
||||
|
||||
static void gitg_spinner_class_init (GitgSpinnerClass *class);
|
||||
static void gitg_spinner_init (GitgSpinner *spinner);
|
||||
|
||||
static GObjectClass *parent_class;
|
||||
|
||||
GType
|
||||
gitg_spinner_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (G_UNLIKELY (type == 0))
|
||||
{
|
||||
const GTypeInfo our_info =
|
||||
{
|
||||
sizeof (GitgSpinnerClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gitg_spinner_class_init,
|
||||
NULL,
|
||||
NULL, /* class_data */
|
||||
sizeof (GitgSpinner),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gitg_spinner_init
|
||||
};
|
||||
|
||||
type = g_type_register_static (G_TYPE_OBJECT,
|
||||
"GitgSpinner",
|
||||
&our_info, 0);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gitg_spinner_load_images (GitgSpinner *spinner)
|
||||
{
|
||||
GitgSpinnerPrivate *priv = spinner->priv;
|
||||
|
||||
if (priv->need_load)
|
||||
{
|
||||
priv->images = gitg_spinner_cache_get_images (priv->cache, priv->screen, priv->size);
|
||||
|
||||
priv->current_image = 0; /* 'rest' icon */
|
||||
priv->need_load = FALSE;
|
||||
}
|
||||
|
||||
return priv->images != NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_spinner_unload_images (GitgSpinner *spinner)
|
||||
{
|
||||
GitgSpinnerPrivate *priv = spinner->priv;
|
||||
|
||||
if (priv->images != NULL)
|
||||
{
|
||||
gitg_spinner_images_unref (priv->images);
|
||||
priv->images = NULL;
|
||||
}
|
||||
|
||||
priv->current_image = 0;
|
||||
priv->need_load = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_spinner_init (GitgSpinner *spinner)
|
||||
{
|
||||
spinner->priv = GITG_SPINNER_GET_PRIVATE (spinner);
|
||||
|
||||
spinner->priv->cache = gitg_spinner_cache_ref ();
|
||||
spinner->priv->size = GTK_ICON_SIZE_MENU;
|
||||
spinner->priv->timeout = SPINNER_TIMEOUT;
|
||||
spinner->priv->need_load = TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
bump_spinner_frame_cb (GitgSpinner *spinner)
|
||||
{
|
||||
GitgSpinnerPrivate *priv = spinner->priv;
|
||||
|
||||
/* This can happen when we've unloaded the images on a theme
|
||||
* change, but haven't been in the queued size request yet.
|
||||
* Just skip this update.
|
||||
*/
|
||||
if (priv->images == NULL)
|
||||
{
|
||||
if (!gitg_spinner_load_images (spinner))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
priv->current_image++;
|
||||
|
||||
if (priv->current_image >= priv->images->n_animation_pixbufs)
|
||||
{
|
||||
/* the 0th frame is the 'rest' icon */
|
||||
priv->current_image = MIN (1, priv->images->n_animation_pixbufs);
|
||||
}
|
||||
|
||||
g_signal_emit (spinner, spinner_signals[FRAME], 0, priv->images->animation_pixbufs[priv->current_image]);
|
||||
|
||||
/* run again */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gitg_spinner_start:
|
||||
* @spinner: a #GitgSpinner
|
||||
*
|
||||
* Start the spinner animation.
|
||||
**/
|
||||
void
|
||||
gitg_spinner_start (GitgSpinner *spinner)
|
||||
{
|
||||
GitgSpinnerPrivate *priv = spinner->priv;
|
||||
|
||||
priv->spinning = TRUE;
|
||||
|
||||
if (priv->timer_task == 0 && gitg_spinner_load_images (spinner))
|
||||
{
|
||||
/* the 0th frame is the 'rest' icon */
|
||||
priv->current_image = MIN (0, priv->images->n_animation_pixbufs);
|
||||
|
||||
priv->timer_task = g_timeout_add_full (G_PRIORITY_LOW,
|
||||
priv->timeout,
|
||||
(GSourceFunc) bump_spinner_frame_cb,
|
||||
spinner,
|
||||
NULL);
|
||||
|
||||
bump_spinner_frame_cb (spinner);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_spinner_remove_update_callback (GitgSpinner *spinner)
|
||||
{
|
||||
GitgSpinnerPrivate *priv = spinner->priv;
|
||||
|
||||
if (priv->timer_task != 0)
|
||||
{
|
||||
g_source_remove (priv->timer_task);
|
||||
priv->timer_task = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gitg_spinner_stop:
|
||||
* @spinner: a #GitgSpinner
|
||||
*
|
||||
* Stop the spinner animation.
|
||||
**/
|
||||
void
|
||||
gitg_spinner_stop (GitgSpinner *spinner)
|
||||
{
|
||||
GitgSpinnerPrivate *priv = spinner->priv;
|
||||
|
||||
priv->spinning = FALSE;
|
||||
priv->current_image = 0;
|
||||
|
||||
if (priv->timer_task != 0)
|
||||
{
|
||||
gitg_spinner_remove_update_callback (spinner);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gitg_spinner_set_screen (GitgSpinner *spinner, GdkScreen *screen)
|
||||
{
|
||||
g_return_if_fail (GITG_IS_SPINNER (spinner));
|
||||
g_return_if_fail (GDK_IS_SCREEN (screen));
|
||||
|
||||
if (spinner->priv->screen != screen)
|
||||
{
|
||||
gitg_spinner_unload_images (spinner);
|
||||
|
||||
if (spinner->priv->screen)
|
||||
{
|
||||
g_object_unref (spinner->priv->screen);
|
||||
}
|
||||
|
||||
spinner->priv->screen = g_object_ref (screen);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_spinner_dispose (GObject *object)
|
||||
{
|
||||
//GitgSpinner *spinner = GITG_SPINNER (object);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_spinner_finalize (GObject *object)
|
||||
{
|
||||
GitgSpinner *spinner = GITG_SPINNER (object);
|
||||
|
||||
gitg_spinner_remove_update_callback (spinner);
|
||||
gitg_spinner_unload_images (spinner);
|
||||
|
||||
g_object_unref (spinner->priv->cache);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gitg_spinner_class_init (GitgSpinnerClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
object_class->dispose = gitg_spinner_dispose;
|
||||
object_class->finalize = gitg_spinner_finalize;
|
||||
|
||||
spinner_signals[FRAME] =
|
||||
g_signal_new ("frame",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GitgSpinnerClass, frame),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
GDK_TYPE_PIXBUF);
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (GitgSpinnerPrivate));
|
||||
}
|
||||
|
||||
GitgSpinner *
|
||||
gitg_spinner_new (GtkIconSize size)
|
||||
{
|
||||
GitgSpinner *spinner = g_object_new (GITG_TYPE_SPINNER, NULL);
|
||||
|
||||
spinner->priv->size = size;
|
||||
return spinner;
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
gitg_spinner_get_pixbuf (GitgSpinner *spinner)
|
||||
{
|
||||
g_return_val_if_fail (GITG_IS_SPINNER (spinner), NULL);
|
||||
|
||||
if (spinner->priv->timer_task == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_object_ref (spinner->priv->images->animation_pixbufs[spinner->priv->current_image]);
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
* gitg-spinner.h
|
||||
* This file is part of gitg
|
||||
*
|
||||
* Copyright (C) 2009 - Jesse van den Kieboom
|
||||
* Copyright (C) 2005 - Paolo Maggi
|
||||
* Copyright (C) 2000 - Eazel, Inc.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This widget was originally written by Andy Hertzfeld <andy@eazel.com> for
|
||||
* Nautilus.
|
||||
*
|
||||
* Modified by the gitg Team, 2005. See the AUTHORS file for a
|
||||
* list of people on the gitg Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*
|
||||
* Modified by the gitg Team, 2009
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __GITG_SPINNER_H__
|
||||
#define __GITG_SPINNER_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Type checking and casting macros
|
||||
*/
|
||||
#define GITG_TYPE_SPINNER (gitg_spinner_get_type ())
|
||||
#define GITG_SPINNER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GITG_TYPE_SPINNER, GitgSpinner))
|
||||
#define GITG_SPINNER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GITG_TYPE_SPINNER, GitgSpinnerClass))
|
||||
#define GITG_IS_SPINNER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GITG_TYPE_SPINNER))
|
||||
#define GITG_IS_SPINNER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GITG_TYPE_SPINNER))
|
||||
#define GITG_SPINNER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GITG_TYPE_SPINNER, GitgSpinnerClass))
|
||||
|
||||
|
||||
/* Private structure type */
|
||||
typedef struct _GitgSpinnerPrivate GitgSpinnerPrivate;
|
||||
|
||||
/*
|
||||
* Main object structure
|
||||
*/
|
||||
typedef struct _GitgSpinner GitgSpinner;
|
||||
|
||||
struct _GitgSpinner
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
/*< private >*/
|
||||
GitgSpinnerPrivate *priv;
|
||||
};
|
||||
|
||||
/*
|
||||
* Class definition
|
||||
*/
|
||||
typedef struct _GitgSpinnerClass GitgSpinnerClass;
|
||||
|
||||
struct _GitgSpinnerClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*frame)(GitgSpinner *spinner, GdkPixbuf *pixbuf);
|
||||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
*/
|
||||
GType gitg_spinner_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GitgSpinner *gitg_spinner_new (GtkIconSize size);
|
||||
void gitg_spinner_set_screen (GitgSpinner *spinner,
|
||||
GdkScreen *screen);
|
||||
void gitg_spinner_start (GitgSpinner *spinner);
|
||||
void gitg_spinner_stop (GitgSpinner *spinner);
|
||||
|
||||
GdkPixbuf *gitg_spinner_get_pixbuf (GitgSpinner *spinner);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GITG_SPINNER_H__ */
|
|
@ -3,7 +3,6 @@
|
|||
#include "gitg-utils.h"
|
||||
#include <math.h>
|
||||
#include <cairo.h>
|
||||
#include "gseal-gtk-compat.h"
|
||||
|
||||
#define GITG_STAT_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_STAT_VIEW, GitgStatViewPrivate))
|
||||
|
||||
|
@ -64,9 +63,9 @@ gitg_stat_view_finalize (GObject *object)
|
|||
static void
|
||||
update_colors (GitgStatView *view)
|
||||
{
|
||||
GtkStyle *style;
|
||||
GdkColor bg_color;
|
||||
gdouble r, g, b;
|
||||
GtkStyleContext *style_context;
|
||||
GtkStateFlags state;
|
||||
GdkRGBA bg_color;
|
||||
gdouble hue, sat, val;
|
||||
|
||||
if (!gtk_widget_get_realized (GTK_WIDGET (view)))
|
||||
|
@ -74,14 +73,11 @@ update_colors (GitgStatView *view)
|
|||
return;
|
||||
}
|
||||
|
||||
style = gtk_widget_get_style (GTK_WIDGET (view));
|
||||
bg_color = style->base[gtk_widget_get_state (GTK_WIDGET (view))];
|
||||
style_context = gtk_widget_get_style_context (GTK_WIDGET (view));
|
||||
state = gtk_widget_get_state (GTK_WIDGET (view));
|
||||
gtk_style_context_get_background_color (style_context, state, &bg_color);
|
||||
|
||||
r = bg_color.red / 65535.0;
|
||||
g = bg_color.green / 65535.0;
|
||||
b = bg_color.blue / 65535.0;
|
||||
|
||||
gtk_rgb_to_hsv (r, g, b, &hue, &sat, &val);
|
||||
gtk_rgb_to_hsv (bg_color.red, bg_color.green, bg_color.blue, &hue, &sat, &val);
|
||||
|
||||
sat = MIN(sat * 0.5 + 0.5, 1);
|
||||
val = MIN((pow(val + 1, 3) - 1) / 7 * 0.6 + 0.2, 1);
|
||||
|
@ -117,8 +113,8 @@ gitg_stat_view_realize (GtkWidget *widget)
|
|||
static void
|
||||
update_styles (GitgStatView *view)
|
||||
{
|
||||
gtk_style_get (gtk_widget_get_style (GTK_WIDGET (view)),
|
||||
GITG_TYPE_STAT_VIEW,
|
||||
gtk_style_context_get_style (gtk_widget_get_style_context (GTK_WIDGET (view)),
|
||||
gtk_widget_get_state (GTK_WIDGET (view)),
|
||||
"radius", &view->priv->radius,
|
||||
"stat-padding", &view->priv->stat_padding,
|
||||
"show-lines", &view->priv->show_lines,
|
||||
|
@ -127,11 +123,11 @@ update_styles (GitgStatView *view)
|
|||
}
|
||||
|
||||
static void
|
||||
gitg_stat_view_style_set (GtkWidget *widget, GtkStyle *prev_style)
|
||||
gitg_stat_view_style_updated (GtkWidget *widget)
|
||||
{
|
||||
if (GTK_WIDGET_CLASS (gitg_stat_view_parent_class)->style_set)
|
||||
if (GTK_WIDGET_CLASS (gitg_stat_view_parent_class)->style_updated)
|
||||
{
|
||||
GTK_WIDGET_CLASS (gitg_stat_view_parent_class)->style_set (widget, prev_style);
|
||||
GTK_WIDGET_CLASS (gitg_stat_view_parent_class)->style_updated (widget);
|
||||
}
|
||||
|
||||
update_colors (GITG_STAT_VIEW (widget));
|
||||
|
@ -255,9 +251,9 @@ draw_stat (GitgStatView *view,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gitg_stat_view_expose (GtkWidget *widget, GdkEventExpose *event)
|
||||
gitg_stat_view_draw (GtkWidget *widget,
|
||||
cairo_t *ctx)
|
||||
{
|
||||
cairo_t *ctx;
|
||||
GdkRectangle alloc;
|
||||
guint added_width;
|
||||
guint removed_width;
|
||||
|
@ -265,9 +261,9 @@ gitg_stat_view_expose (GtkWidget *widget, GdkEventExpose *event)
|
|||
GitgStatView *view;
|
||||
guint padding;
|
||||
|
||||
if (GTK_WIDGET_CLASS (gitg_stat_view_parent_class)->expose_event)
|
||||
if (GTK_WIDGET_CLASS (gitg_stat_view_parent_class)->draw)
|
||||
{
|
||||
GTK_WIDGET_CLASS (gitg_stat_view_parent_class)->expose_event (widget, event);
|
||||
GTK_WIDGET_CLASS (gitg_stat_view_parent_class)->draw (widget, ctx);
|
||||
}
|
||||
|
||||
view = GITG_STAT_VIEW (widget);
|
||||
|
@ -287,11 +283,6 @@ gitg_stat_view_expose (GtkWidget *widget, GdkEventExpose *event)
|
|||
padding = 2;
|
||||
}
|
||||
|
||||
ctx = gdk_cairo_create (event->window);
|
||||
|
||||
gdk_cairo_rectangle (ctx, &event->area);
|
||||
cairo_clip (ctx);
|
||||
|
||||
gtk_widget_get_allocation (widget, &alloc);
|
||||
|
||||
update_gradients (view, &alloc);
|
||||
|
@ -329,8 +320,6 @@ gitg_stat_view_expose (GtkWidget *widget, GdkEventExpose *event)
|
|||
alloc.height);
|
||||
}
|
||||
|
||||
cairo_destroy (ctx);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -413,8 +402,8 @@ gitg_stat_view_class_init (GitgStatViewClass *klass)
|
|||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
widget_class->expose_event = gitg_stat_view_expose;
|
||||
widget_class->style_set = gitg_stat_view_style_set;
|
||||
widget_class->draw = gitg_stat_view_draw;
|
||||
widget_class->style_updated = gitg_stat_view_style_updated;
|
||||
widget_class->realize = gitg_stat_view_realize;
|
||||
widget_class->configure_event = gitg_stat_view_configure;
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
<property name="default_height">200</property>
|
||||
<property name="destroy_with_parent">True</property>
|
||||
<property name="type_hint">normal</property>
|
||||
<property name="has_separator">False</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkVBox" id="dialog_vbox_main">
|
||||
<property name="visible">True</property>
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "gseal-gtk-compat.h"
|
||||
|
||||
gchar *
|
||||
gitg_utils_get_content_type(GFile *file)
|
||||
{
|
||||
|
@ -159,7 +157,7 @@ gitg_utils_set_monospace_font(GtkWidget *widget)
|
|||
|
||||
if (description)
|
||||
{
|
||||
gtk_widget_modify_font(widget, description);
|
||||
gtk_widget_override_font(widget, description);
|
||||
pango_font_description_free(description);
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +218,7 @@ gitg_utils_menu_position_under_widget (GtkMenu *menu,
|
|||
GtkRequisition requisition;
|
||||
|
||||
gdk_window_get_origin (gtk_widget_get_window (w), x, y);
|
||||
gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
|
||||
gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL);
|
||||
|
||||
GtkAllocation alloc;
|
||||
gtk_widget_get_allocation (w, &alloc);
|
||||
|
@ -275,7 +273,7 @@ gitg_utils_menu_position_under_tree_view (GtkMenu *menu,
|
|||
if (gtk_widget_get_direction (GTK_WIDGET (tree)) == GTK_TEXT_DIR_RTL)
|
||||
{
|
||||
GtkRequisition requisition;
|
||||
gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
|
||||
gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL);
|
||||
*x += rect.width - requisition.width;
|
||||
}
|
||||
}
|
||||
|
@ -372,7 +370,7 @@ gitg_utils_find_cell_at_pos (GtkTreeView *tree_view, GtkTreeViewColumn *column,
|
|||
continue;
|
||||
}
|
||||
|
||||
gtk_cell_renderer_get_size (renderer, GTK_WIDGET (tree_view), NULL, NULL, NULL, &width, 0);
|
||||
gtk_cell_renderer_get_preferred_width (renderer, GTK_WIDGET (tree_view), &width, NULL);
|
||||
|
||||
if (x >= start && x <= start + width)
|
||||
{
|
||||
|
|
|
@ -46,8 +46,6 @@
|
|||
#include "gitg-activatable.h"
|
||||
#include "gitg-uri.h"
|
||||
|
||||
#include "gseal-gtk-compat.h"
|
||||
|
||||
#define DYNAMIC_ACTION_DATA_KEY "GitgDynamicActionDataKey"
|
||||
#define DYNAMIC_ACTION_DATA_REMOTE_KEY "GitgDynamicActionDataRemoteKey"
|
||||
#define DYNAMIC_ACTION_DATA_BRANCH_KEY "GitgDynamicActionDataBranchKey"
|
||||
|
@ -192,7 +190,7 @@ gitg_window_finalize (GObject *object)
|
|||
GitgWindow *self = GITG_WINDOW(object);
|
||||
|
||||
g_timer_destroy (self->priv->load_timer);
|
||||
gdk_cursor_unref (self->priv->hand);
|
||||
g_object_unref (self->priv->hand);
|
||||
|
||||
GList *copy = g_list_copy (self->priv->branch_actions);
|
||||
GList *item;
|
||||
|
@ -520,7 +518,7 @@ build_search_entry (GitgWindow *window,
|
|||
|
||||
GClosure *closure = g_cclosure_new (G_CALLBACK (focus_search), entry, NULL);
|
||||
|
||||
gtk_accel_group_connect (group, GDK_f, GDK_CONTROL_MASK, 0, closure);
|
||||
gtk_accel_group_connect (group, GDK_KEY_f, GDK_CONTROL_MASK, 0, closure);
|
||||
gtk_window_add_accel_group (GTK_WINDOW(window), group);
|
||||
}
|
||||
|
||||
|
@ -1085,19 +1083,16 @@ gitg_window_delete_event (GtkWidget *widget,
|
|||
}
|
||||
|
||||
static void
|
||||
gitg_window_destroy (GtkObject *object)
|
||||
gitg_window_destroy (GtkWidget *widget)
|
||||
{
|
||||
GitgWindow *window = GITG_WINDOW(object);
|
||||
GitgWindow *window = GITG_WINDOW(widget);
|
||||
|
||||
if (!window->priv->destroy_has_run)
|
||||
{
|
||||
gtk_tree_view_set_model (window->priv->tree_view, NULL);
|
||||
|
||||
g_slist_foreach (window->priv->revision_panels, (GFunc)g_object_unref, NULL);
|
||||
g_slist_free (window->priv->revision_panels);
|
||||
|
||||
g_slist_foreach (window->priv->activatables, (GFunc)g_object_unref, NULL);
|
||||
g_slist_free (window->priv->activatables);
|
||||
g_slist_free_full (window->priv->revision_panels, g_object_unref);
|
||||
g_slist_free_full (window->priv->activatables, g_object_unref);
|
||||
|
||||
window->priv->revision_panels = NULL;
|
||||
window->priv->activatables = NULL;
|
||||
|
@ -1105,9 +1100,9 @@ gitg_window_destroy (GtkObject *object)
|
|||
window->priv->destroy_has_run = TRUE;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS(parent_class)->destroy)
|
||||
if (GTK_WIDGET_CLASS(parent_class)->destroy)
|
||||
{
|
||||
GTK_OBJECT_CLASS(parent_class)->destroy (object);
|
||||
GTK_WIDGET_CLASS(parent_class)->destroy (widget);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1125,7 +1120,7 @@ gitg_window_window_state_event (GtkWidget *widget,
|
|||
show = !(event->new_window_state &
|
||||
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN));
|
||||
|
||||
gtk_statusbar_set_has_resize_grip (window->priv->statusbar, show);
|
||||
gtk_window_set_has_resize_grip (GTK_WINDOW (window), show);
|
||||
}
|
||||
|
||||
/* Save the window state */
|
||||
|
@ -1182,7 +1177,6 @@ static void
|
|||
gitg_window_class_init (GitgWindowClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GtkWindowClass *window_class = GTK_WINDOW_CLASS (klass);
|
||||
|
||||
|
@ -1190,8 +1184,8 @@ gitg_window_class_init (GitgWindowClass *klass)
|
|||
|
||||
object_class->finalize = gitg_window_finalize;
|
||||
object_class->dispose = gitg_window_dispose;
|
||||
gtkobject_class->destroy = gitg_window_destroy;
|
||||
|
||||
widget_class->destroy = gitg_window_destroy;
|
||||
widget_class->delete_event = gitg_window_delete_event;
|
||||
widget_class->window_state_event = gitg_window_window_state_event;
|
||||
window_class->set_focus = gitg_window_set_focus;
|
||||
|
@ -1651,8 +1645,7 @@ fill_branches_combo (GitgWindow *window)
|
|||
gtk_combo_box_set_active_iter (window->priv->combo_branches, &active);
|
||||
}
|
||||
|
||||
g_slist_foreach (refs, (GFunc)gitg_ref_free, NULL);
|
||||
g_slist_free (refs);
|
||||
g_slist_free_full (refs, (GDestroyNotify)gitg_ref_free);
|
||||
|
||||
if (active_from_selection)
|
||||
{
|
||||
|
@ -1700,7 +1693,7 @@ on_repository_load (GitgRepository *repository,
|
|||
{
|
||||
GdkCursor *cursor = gdk_cursor_new (GDK_WATCH);
|
||||
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window->priv->tree_view)), cursor);
|
||||
gdk_cursor_unref (cursor);
|
||||
g_object_unref (cursor);
|
||||
|
||||
gtk_statusbar_push (window->priv->statusbar, 0, _ ("Begin loading repository"));
|
||||
|
||||
|
@ -2217,20 +2210,7 @@ on_help_about (GtkAction *action,
|
|||
static gchar const copyright[] = "Copyright \xc2\xa9 2009 Jesse van den Kieboom";
|
||||
static gchar const *authors[] = {"Jesse van den Kieboom <jessevdk@gnome.org>", NULL};
|
||||
static gchar const *comments = N_ ("gitg is a git repository viewer for gtk+/GNOME");
|
||||
static gchar const *license = N_ ("This program is free software; you can redistribute it and/or modify\n"
|
||||
"it under the terms of the GNU General Public License as published by\n"
|
||||
"the Free Software Foundation; either version 2 of the License, or\n"
|
||||
"(at your option) any later version.\n"
|
||||
"\n"
|
||||
"This program is distributed in the hope that it will be useful,\n"
|
||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||
"GNU General Public License for more details.\n"
|
||||
"\n"
|
||||
"You should have received a copy of the GNU General Public License\n"
|
||||
"along with this program; if not, write to the Free Software\n"
|
||||
"Foundation, Inc., 59 Temple Place, Suite 330,\n"
|
||||
"Boston, MA 02111-1307, USA.");
|
||||
|
||||
|
||||
gchar *path = gitg_dirs_get_data_filename ("icons", "gitg.svg", NULL);
|
||||
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (path, NULL);
|
||||
|
@ -2249,8 +2229,9 @@ on_help_about (GtkAction *action,
|
|||
"comments", _ (comments),
|
||||
"version", VERSION,
|
||||
"website", PACKAGE_URL,
|
||||
"website-label", "gitg homepage",
|
||||
"logo", pixbuf,
|
||||
"license", _ (license),
|
||||
"license-type", GTK_LICENSE_GPL_2_0,
|
||||
NULL);
|
||||
|
||||
if (pixbuf)
|
||||
|
@ -2721,8 +2702,7 @@ update_merge_rebase (GitgWindow *window,
|
|||
}
|
||||
}
|
||||
|
||||
g_slist_foreach (refs, (GFunc)gitg_ref_free, NULL);
|
||||
g_slist_free (refs);
|
||||
g_slist_free_full (refs, (GDestroyNotify)gitg_ref_free);
|
||||
|
||||
if (gitg_ref_get_ref_type (ref) == GITG_REF_TYPE_BRANCH)
|
||||
{
|
||||
|
@ -2804,8 +2784,7 @@ has_local_ref (GitgWindow *window,
|
|||
}
|
||||
}
|
||||
|
||||
g_slist_foreach (refs, (GFunc)gitg_ref_free, NULL);
|
||||
g_slist_free (refs);
|
||||
g_slist_free_full (refs, (GDestroyNotify)gitg_ref_free);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -2964,8 +2943,7 @@ on_cherry_pick_activated (GtkAction *action,
|
|||
|
||||
gitg_revision_unref (rev);
|
||||
|
||||
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free (rows);
|
||||
g_list_free_full (rows, (GDestroyNotify)gtk_tree_path_free);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -3050,8 +3028,7 @@ update_cherry_pick (GitgWindow *window)
|
|||
}
|
||||
}
|
||||
|
||||
g_slist_foreach (refs, (GFunc)gitg_ref_free, NULL);
|
||||
g_slist_free (refs);
|
||||
g_slist_free_full (refs, (GDestroyNotify)gitg_ref_free);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -3117,8 +3094,7 @@ popup_revision (GitgWindow *window,
|
|||
gtk_action_set_visible (tag, FALSE);
|
||||
}
|
||||
|
||||
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free (rows);
|
||||
g_list_free_full (rows, (GDestroyNotify)gtk_tree_path_free);
|
||||
|
||||
if (!show)
|
||||
{
|
||||
|
@ -3394,9 +3370,7 @@ on_format_patch_response (GtkDialog *dialog,
|
|||
}
|
||||
}
|
||||
|
||||
g_list_foreach (info->revisions, (GFunc)gitg_revision_unref, NULL);
|
||||
g_list_free (info->revisions);
|
||||
|
||||
g_list_free_full (info->revisions, (GDestroyNotify)gitg_revision_unref);
|
||||
g_slice_free (FormatPatchInfo, info);
|
||||
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
|
@ -3481,8 +3455,7 @@ on_revision_format_patch_activate (GtkAction *action,
|
|||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free (rows);
|
||||
g_list_free_full (rows, (GDestroyNotify)gtk_tree_path_free);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3525,8 +3498,7 @@ on_revision_new_branch_activate (GtkAction *action,
|
|||
gitg_revision_unref (rev);
|
||||
}
|
||||
|
||||
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free (rows);
|
||||
g_list_free_full (rows, (GDestroyNotify)gtk_tree_path_free);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3577,8 +3549,7 @@ on_revision_tag_activate (GtkAction *action,
|
|||
gitg_revision_unref (rev);
|
||||
}
|
||||
|
||||
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free (rows);
|
||||
g_list_free_full (rows, (GDestroyNotify)gtk_tree_path_free);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -162,8 +162,7 @@ set_icons ()
|
|||
|
||||
gtk_window_set_default_icon_list (icons);
|
||||
|
||||
g_list_foreach (icons, (GFunc)g_object_unref, NULL);
|
||||
g_list_free (icons);
|
||||
g_list_free_full (icons, g_object_unref);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
#include "gseal-gtk-compat.h"
|
||||
|
||||
#if !GTK_CHECK_VERSION (2, 24, 0)
|
||||
gint
|
||||
gitg_gseal_gtk_compat_window_get_width (GdkWindow *window)
|
||||
{
|
||||
gint width;
|
||||
|
||||
gdk_drawable_get_size (GDK_DRAWABLE (window), &width, NULL);
|
||||
return width;
|
||||
}
|
||||
|
||||
gint
|
||||
gitg_gseal_gtk_compat_window_get_height (GdkWindow *window)
|
||||
{
|
||||
gint height;
|
||||
|
||||
gdk_drawable_get_size (GDK_DRAWABLE (window), NULL, &height);
|
||||
return height;
|
||||
}
|
||||
#endif
|
|
@ -1,47 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* Copyright (C) 2009 Thomas H.P. Andersen <phomes@gmail.com>,
|
||||
* 2009 Javier Jardón <jjardon@gnome.org>
|
||||
*
|
||||
* This runtime 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This runtime is distributed in the hope runtime 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 runtime; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef GSEAL_GTK_COMPAT_H
|
||||
#define GSEAL_GTK_COMPAT_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#if !GTK_CHECK_VERSION(2, 24, 0)
|
||||
gint gitg_gseal_gtk_compat_window_get_width (GdkWindow *window);
|
||||
gint gitg_gseal_gtk_compat_window_get_height (GdkWindow *window);
|
||||
|
||||
#define gdk_window_get_width(window) gitg_gseal_gtk_compat_window_get_width(window)
|
||||
#define gdk_window_get_height(window) gitg_gseal_gtk_compat_window_get_height(window)
|
||||
#endif /* GTK < 2.24.0 */
|
||||
#if !GTK_CHECK_VERSION (2, 22, 0)
|
||||
#define gdk_drag_context_list_targets(context) ((context)->targets)
|
||||
#endif /* GTK < 2.22.0 */
|
||||
#if !GTK_CHECK_VERSION (2, 20, 0)
|
||||
#define gtk_widget_get_mapped(widget) (GTK_WIDGET_MAPPED ((widget)))
|
||||
#define gtk_widget_get_realized(widget) (GTK_WIDGET_REALIZED ((widget)))
|
||||
#endif /* GTK < 2.20.0 */
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GSEAL_GTK_COMPAT_H */
|
||||
|
||||
/* ex:ts=8:noet: */
|
|
@ -101,8 +101,7 @@ collapsed_lane_new (LaneContainer *container)
|
|||
static void
|
||||
free_lanes (GitgLanes *lanes)
|
||||
{
|
||||
g_slist_foreach (lanes->priv->lanes, (GFunc)lane_container_free, NULL);
|
||||
g_slist_free (lanes->priv->lanes);
|
||||
g_slist_free_full (lanes->priv->lanes, (GDestroyNotify)lane_container_free);
|
||||
|
||||
lanes->priv->lanes = NULL;
|
||||
}
|
||||
|
@ -316,8 +315,7 @@ gitg_lanes_reset (GitgLanes *lanes)
|
|||
free_lanes (lanes);
|
||||
gitg_color_reset ();
|
||||
|
||||
g_slist_foreach (lanes->priv->previous, (GFunc)gitg_revision_unref, NULL);
|
||||
g_slist_free (lanes->priv->previous);
|
||||
g_slist_free_full (lanes->priv->previous, (GDestroyNotify)gitg_revision_unref);
|
||||
|
||||
lanes->priv->previous = NULL;
|
||||
|
||||
|
|
|
@ -327,10 +327,7 @@ gitg_line_parser_constructed (GObject *object)
|
|||
|
||||
stream->priv->read_buffer = g_slice_alloc (sizeof (gchar) * (stream->priv->buffer_size + 1));
|
||||
|
||||
if (G_OBJECT_CLASS (gitg_line_parser_parent_class)->constructed)
|
||||
{
|
||||
G_OBJECT_CLASS (gitg_line_parser_parent_class)->constructed (object);
|
||||
}
|
||||
}
|
||||
|
||||
static void start_read_lines (AsyncData *data);
|
||||
|
|
|
@ -719,10 +719,7 @@ gitg_repository_constructed (GObject *object)
|
|||
|
||||
install_head_monitor (repository);
|
||||
|
||||
if (G_OBJECT_CLASS (gitg_repository_parent_class)->constructed)
|
||||
{
|
||||
G_OBJECT_CLASS (gitg_repository_parent_class)->constructed (object);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1140,8 +1137,7 @@ on_loader_update (GitgShell *object,
|
|||
static void
|
||||
free_refs (GSList *refs)
|
||||
{
|
||||
g_slist_foreach (refs, (GFunc)gitg_ref_free, NULL);
|
||||
g_slist_free (refs);
|
||||
g_slist_free_full (refs, (GDestroyNotify)gitg_ref_free);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -53,8 +53,7 @@ G_DEFINE_BOXED_TYPE (GitgRevision, gitg_revision, gitg_revision_ref, gitg_revisi
|
|||
static void
|
||||
free_lanes (GitgRevision *rv)
|
||||
{
|
||||
g_slist_foreach (rv->lanes, (GFunc)gitg_lane_free, NULL);
|
||||
g_slist_free (rv->lanes);
|
||||
g_slist_free_full (rv->lanes, (GDestroyNotify)gitg_lane_free);
|
||||
rv->lanes = NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue