[gitg] Make parent label click work again



commit ac53bfd312a6f0078909baece00979260479bfc2
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Sun Jun 6 23:32:03 2010 +0200

    Make parent label click work again

 gitg/gitg-revision-details-panel.c |   25 ++++++++++++++++++-------
 gitg/gitg-revision-panel.c         |   20 ++++++++++++++++++++
 gitg/gitg-revision-panel.h         |   19 +++++++++++++------
 gitg/gitg-window.c                 |    1 +
 4 files changed, 52 insertions(+), 13 deletions(-)
---
diff --git a/gitg/gitg-revision-details-panel.c b/gitg/gitg-revision-details-panel.c
index 0d0eb5f..b3655b4 100644
--- a/gitg/gitg-revision-details-panel.c
+++ b/gitg/gitg-revision-details-panel.c
@@ -58,6 +58,7 @@ struct _GitgRevisionDetailsPanelPrivate
 	gboolean in_stat;
 
 	GSList *stats;
+	GitgWindow *window;
 };
 
 static void gitg_revision_panel_iface_init (GitgRevisionPanelInterface *iface);
@@ -166,8 +167,16 @@ gitg_revision_panel_get_panel_impl (GitgRevisionPanel *panel)
 }
 
 static void
+gitg_revision_panel_initialize_impl (GitgRevisionPanel *panel,
+                                     GitgWindow        *window)
+{
+	GITG_REVISION_DETAILS_PANEL (panel)->priv->window = window;
+}
+
+static void
 gitg_revision_panel_iface_init (GitgRevisionPanelInterface *iface)
 {
+	iface->initialize = gitg_revision_panel_initialize_impl;
 	iface->get_id = gitg_revision_panel_get_id_impl;
 	iface->update = gitg_revision_panel_update_impl;
 	iface->get_label = gitg_revision_panel_get_label_impl;
@@ -492,28 +501,30 @@ on_parent_clicked (GtkWidget      *ev,
                    GdkEventButton *event,
                    gpointer        userdata)
 {
+	GitgRevisionDetailsPanel *panel;
+	gchar *hash;
+
 	if (event->button != 1)
 	{
 		return FALSE;
 	}
 
-	//GitgRevisionDetailsPanel *panel = GITG_REVISION_DETAILS_PANEL (userdata);
-	//gchar *hash = (gchar *)g_object_get_data (G_OBJECT(ev), HASH_KEY);
-
-	// TODO: do something
+	panel = GITG_REVISION_DETAILS_PANEL (userdata);
+	hash = (gchar *)g_object_get_data (G_OBJECT (ev), HASH_KEY);
 
+	gitg_window_select (panel->priv->window, hash);
 	return FALSE;
 }
 
 static GtkWidget *
 make_parent_label (GitgRevisionDetailsPanel *self,
-                   gchar const              *hash)
+                   gchar const              *sha1)
 {
 	GtkWidget *ev = gtk_event_box_new ();
 	GtkWidget *lbl = gtk_label_new (NULL);
 
 	gchar *markup = g_strconcat ("<span underline='single' foreground='#00f'>",
-	                             hash,
+	                             sha1,
 	                             "</span>",
 	                             NULL);
 
@@ -528,7 +539,7 @@ make_parent_label (GitgRevisionDetailsPanel *self,
 
 	g_object_set_data_full (G_OBJECT(ev),
 	                        HASH_KEY,
-	                        (gpointer)gitg_hash_sha1_to_hash_new (hash),
+	                        g_strdup (sha1),
 	                        (GDestroyNotify)g_free);
 
 	g_signal_connect (ev,
diff --git a/gitg/gitg-revision-panel.c b/gitg/gitg-revision-panel.c
index 4a0a5a2..2812a8d 100644
--- a/gitg/gitg-revision-panel.c
+++ b/gitg/gitg-revision-panel.c
@@ -3,6 +3,13 @@
 G_DEFINE_INTERFACE (GitgRevisionPanel, gitg_revision_panel, G_TYPE_INVALID)
 
 /* Default implementation */
+static void
+gitg_revision_panel_initialize_default (GitgRevisionPanel *panel,
+                                        GitgWindow        *window)
+{
+	/* No default implementation */
+}
+
 static gchar *
 gitg_revision_panel_get_id_default (GitgRevisionPanel *panel)
 {
@@ -34,6 +41,7 @@ gitg_revision_panel_default_init (GitgRevisionPanelInterface *iface)
 {
 	static gboolean initialized = FALSE;
 
+	iface->initialize = gitg_revision_panel_initialize_default;
 	iface->get_id = gitg_revision_panel_get_id_default;
 	iface->get_label = gitg_revision_panel_get_label_default;
 	iface->get_panel = gitg_revision_panel_get_panel_default;
@@ -80,3 +88,15 @@ gitg_revision_panel_update (GitgRevisionPanel *panel,
 	                                                  repository,
 	                                                  revision);
 }
+
+void
+gitg_revision_panel_initialize (GitgRevisionPanel *panel,
+                                GitgWindow        *window)
+{
+	g_return_if_fail (GITG_IS_REVISION_PANEL (panel));
+	g_return_if_fail (GITG_IS_WINDOW (window));
+
+	GITG_REVISION_PANEL_GET_INTERFACE (panel)->initialize (panel,
+	                                                       window);
+}
+
diff --git a/gitg/gitg-revision-panel.h b/gitg/gitg-revision-panel.h
index 5a100a2..2bab4a0 100644
--- a/gitg/gitg-revision-panel.h
+++ b/gitg/gitg-revision-panel.h
@@ -3,6 +3,7 @@
 
 #include <gtk/gtk.h>
 #include <libgitg/gitg-repository.h>
+#include "gitg-window.h"
 
 G_BEGIN_DECLS
 
@@ -18,17 +19,23 @@ struct _GitgRevisionPanelInterface
 {
 	GTypeInterface parent;
 
-	void       (*update)   ( GitgRevisionPanel *panel,
-	                         GitgRepository    *repository,
-	                         GitgRevision      *revision);
+	void       (*initialize) (GitgRevisionPanel *panel,
+	                          GitgWindow        *window);
 
-	gchar     *(*get_label) (GitgRevisionPanel *panel);
-	gchar     *(*get_id)    (GitgRevisionPanel *panel);
-	GtkWidget *(*get_panel) (GitgRevisionPanel *panel);
+	void       (*update)     (GitgRevisionPanel *panel,
+	                          GitgRepository    *repository,
+	                          GitgRevision      *revision);
+
+	gchar     *(*get_label)  (GitgRevisionPanel *panel);
+	gchar     *(*get_id)     (GitgRevisionPanel *panel);
+	GtkWidget *(*get_panel)  (GitgRevisionPanel *panel);
 };
 
 GType gitg_revision_panel_get_type (void) G_GNUC_CONST;
 
+void       gitg_revision_panel_initialize (GitgRevisionPanel *panel,
+                                           GitgWindow        *window);
+
 GtkWidget *gitg_revision_panel_get_panel (GitgRevisionPanel *panel);
 gchar     *gitg_revision_panel_get_id    (GitgRevisionPanel *panel);
 gchar     *gitg_revision_panel_get_label (GitgRevisionPanel *panel);
diff --git a/gitg/gitg-window.c b/gitg/gitg-window.c
index 1ac3b19..25eed6b 100644
--- a/gitg/gitg-window.c
+++ b/gitg/gitg-window.c
@@ -250,6 +250,7 @@ add_revision_panel (GitgWindow *window,
 	g_return_if_fail (g_type_is_a (panel_type, GITG_TYPE_REVISION_PANEL));
 
 	panel = g_object_new (panel_type, NULL);
+	gitg_revision_panel_initialize (panel, window);
 
 	window->priv->revision_panels = g_slist_append (window->priv->revision_panels,
 	                                                panel);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]