[gitg] Remove use of deprecated API
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Remove use of deprecated API
- Date: Thu, 24 Mar 2011 10:43:55 +0000 (UTC)
commit c9e2556af11d0ef63c67ca2fde357dbce3d48883
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Thu Mar 24 11:43:42 2011 +0100
Remove use of deprecated API
gitg/gitg-commit-view.c | 4 ++-
gitg/gitg-revision-details-panel.c | 56 ++++++++++++++++++++++++++++++++++++
gitg/gitg-window.c | 28 ------------------
gitg/gitg.c | 56 ------------------------------------
4 files changed, 59 insertions(+), 85 deletions(-)
---
diff --git a/gitg/gitg-commit-view.c b/gitg/gitg-commit-view.c
index ee82ce0..ccd64c6 100644
--- a/gitg/gitg-commit-view.c
+++ b/gitg/gitg-commit-view.c
@@ -970,7 +970,9 @@ get_info_at_pointer (GitgCommitView *view,
GdkWindow *win = gtk_text_view_get_window (textview, GTK_TEXT_WINDOW_TEXT);
gdk_window_get_pointer (win, &x, &y, NULL);
- gdk_drawable_get_size (GDK_DRAWABLE (win), &width, &height);
+
+ width = gdk_window_get_width (win);
+ height = gdk_window_get_height (win);
if (x < 0 || y < 0 || x > width || y > height)
{
diff --git a/gitg/gitg-revision-details-panel.c b/gitg/gitg-revision-details-panel.c
index 91413f6..e4f5d75 100644
--- a/gitg/gitg-revision-details-panel.c
+++ b/gitg/gitg-revision-details-panel.c
@@ -25,6 +25,7 @@
#include "gitg-utils.h"
#include "gitg-revision-panel.h"
#include "gitg-stat-view.h"
+#include "gitg-uri.h"
#include <glib/gi18n.h>
#include <stdlib.h>
@@ -238,6 +239,57 @@ on_shell_begin (GitgShell *shell,
gdk_cursor_unref (cursor);
}
+static gboolean
+link_button_activate_link_cb (GtkLinkButton *button,
+ GitgWindow *window)
+{
+ const gchar *uri;
+ GFile *file;
+ GitgRepository *repository;
+ gchar *work_tree_path;
+ gchar *selection;
+ gchar *activatable;
+ gchar *action;
+
+ uri = gtk_link_button_get_uri (button);
+ file = g_file_new_for_uri (uri);
+ repository = gitg_window_get_repository (window);
+
+ if (g_file_has_uri_scheme (file, "gitg") &&
+ gitg_uri_parse (uri, &work_tree_path, &selection,
+ &activatable, &action))
+ {
+ GFile *wt;
+ GFile *work_tree;
+ gboolean equal;
+
+ wt = gitg_repository_get_work_tree (repository);
+ work_tree = g_file_new_for_path (work_tree_path);
+ equal = g_file_equal (wt, work_tree);
+
+ g_object_unref (wt);
+ g_object_unref (work_tree);
+
+ if (equal)
+ {
+ gitg_window_select (window, selection);
+ gitg_window_activate (window, activatable, action);
+ }
+
+ g_free (work_tree_path);
+ g_free (selection);
+ g_free (activatable);
+ g_free (action);
+ g_object_unref (file);
+
+ return TRUE;
+ }
+
+ g_object_unref (file);
+
+ return FALSE;
+}
+
static void
make_stats_table (GitgRevisionDetailsPanel *panel)
{
@@ -316,6 +368,10 @@ make_stats_table (GitgRevisionDetailsPanel *panel)
gtk_button_set_alignment (GTK_BUTTON (file),
0,
0.5);
+ g_signal_connect (file,
+ "clicked",
+ G_CALLBACK (link_button_activate_link_cb),
+ panel->priv->window);
total_str = g_strdup_printf ("%d", info->added + info->removed);
total = gtk_label_new (total_str);
diff --git a/gitg/gitg-window.c b/gitg/gitg-window.c
index 8bd4e6b..585084a 100644
--- a/gitg/gitg-window.c
+++ b/gitg/gitg-window.c
@@ -2208,31 +2208,6 @@ on_recent_open (GtkRecentChooser *chooser,
g_object_unref (work_tree);
}
-static void
-url_activate_hook (GtkAboutDialog *dialog,
- gchar const *link,
- gpointer data)
-{
- gtk_show_uri (NULL, link, GDK_CURRENT_TIME, NULL);
-}
-
-static void
-email_activate_hook (GtkAboutDialog *dialog,
- gchar const *link,
- gpointer data)
-{
- gchar *uri;
- gchar *escaped;
-
- escaped = g_uri_escape_string (link, NULL, FALSE);
- uri = g_strdup_printf ("mailto:%s", escaped);
-
- gtk_show_uri (NULL, uri, GDK_CURRENT_TIME, NULL);
-
- g_free (uri);
- g_free (escaped);
-}
-
void
on_help_about (GtkAction *action,
GitgWindow *window)
@@ -2255,9 +2230,6 @@ on_help_about (GtkAction *action,
"Foundation, Inc., 59 Temple Place, Suite 330,\n"
"Boston, MA 02111-1307, USA.");
- gtk_about_dialog_set_url_hook (url_activate_hook, NULL, NULL);
- gtk_about_dialog_set_email_hook (email_activate_hook, NULL, NULL);
-
gchar *path = gitg_dirs_get_data_filename ("icons", "gitg.svg", NULL);
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (path, NULL);
g_free (path);
diff --git a/gitg/gitg.c b/gitg/gitg.c
index e2676f4..2372a10 100644
--- a/gitg/gitg.c
+++ b/gitg/gitg.c
@@ -37,7 +37,6 @@
static gboolean commit_mode = FALSE;
static gchar *select_sha1 = NULL;
-static GtkLinkButtonUriFunc original_link_button_hook;
static void
show_version_and_quit (void)
@@ -167,57 +166,6 @@ set_icons ()
g_list_free (icons);
}
-static void
-link_button_uri_hook (GtkLinkButton *button,
- gchar const *link_,
- GitgWindow *window)
-{
- GFile *file;
- GitgRepository *repository;
-
- file = g_file_new_for_uri (link_);
- repository = gitg_window_get_repository (window);
-
- if (!g_file_has_uri_scheme (file, "gitg"))
- {
- original_link_button_hook (button, link_, NULL);
- }
- else if (repository)
- {
- gchar *work_tree_path;
- gchar *selection;
- gchar *activatable;
- gchar *action;
-
- if (gitg_uri_parse (link_, &work_tree_path, &selection, &activatable, &action))
- {
- GFile *wt;
- GFile *work_tree;
- gboolean equal;
-
- wt = gitg_repository_get_work_tree (repository);
- work_tree = g_file_new_for_path (work_tree_path);
- equal = g_file_equal (wt, work_tree);
-
- g_object_unref (wt);
- g_object_unref (work_tree);
-
- if (equal)
- {
- gitg_window_select (window, selection);
- gitg_window_activate (window, activatable, action);
- }
-
- g_free (work_tree_path);
- g_free (selection);
- g_free (activatable);
- g_free (action);
- }
- }
-
- g_object_unref (file);
-}
-
int
main (int argc, char **argv)
{
@@ -256,10 +204,6 @@ main (int argc, char **argv)
gitg_window_show_commit (window);
}
- original_link_button_hook = gtk_link_button_set_uri_hook ((GtkLinkButtonUriFunc)link_button_uri_hook,
- window,
- NULL);
-
gtk_main ();
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]