]> git.0d.be Git - empathy.git/commitdiff
forgot to add those files
authorXavier Claessens <xclaesse@src.gnome.org>
Sat, 8 Sep 2007 21:38:21 +0000 (21:38 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Sat, 8 Sep 2007 21:38:21 +0000 (21:38 +0000)
svn path=/trunk/; revision=293

ChangeLog
libempathy-gtk/empathy-cell-renderer-activatable.c [new file with mode: 0644]
libempathy-gtk/empathy-cell-renderer-activatable.h [new file with mode: 0644]

index 8215a0b452f3f580b8c4c9babbae16d00da44776..6f38aa62539da7b9c8a4c1e73ec1e2017b90f7ea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
 
        * libempathy-gtk/empathy-images.h:
        * libempathy-gtk/empathy-chat.glade:
+       * libempathy-gtk/empathy-cell-renderer-activatable.c:
+       * libempathy-gtk/empathy-cell-renderer-activatable.h:
        * libempathy-gtk/empathy-contact-list-view.c:
        * libempathy-gtk/empathy-contact-list-store.c:
        * libempathy-gtk/empathy-contact-list-store.h:
diff --git a/libempathy-gtk/empathy-cell-renderer-activatable.c b/libempathy-gtk/empathy-cell-renderer-activatable.c
new file mode 100644 (file)
index 0000000..926b8cf
--- /dev/null
@@ -0,0 +1,122 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 Raphael Slinckx <raphael@slinckx.net>
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * 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.
+ *
+ * Authors: Raphael Slinckx <raphael@slinckx.net>
+ */
+
+#include <gtk/gtktreeview.h>
+
+#include <libempathy/empathy-debug.h>
+
+#include "empathy-cell-renderer-activatable.h"
+
+#define DEBUG_DOMAIN "CellRendererActivatable"
+
+static void     empathy_cell_renderer_activatable_init       (EmpathyCellRendererActivatable      *cell);
+static void     empathy_cell_renderer_activatable_class_init (EmpathyCellRendererActivatableClass *klass);
+static gboolean cell_renderer_activatable_activate           (GtkCellRenderer                     *cell,
+                                                             GdkEvent                            *event,
+                                                             GtkWidget                           *widget,
+                                                             const gchar                         *path,
+                                                             GdkRectangle                        *background_area,
+                                                             GdkRectangle                        *cell_area,
+                                                             GtkCellRendererState                 flags);
+
+enum {
+       PATH_ACTIVATED,
+       LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
+G_DEFINE_TYPE (EmpathyCellRendererActivatable, empathy_cell_renderer_activatable, GTK_TYPE_CELL_RENDERER_PIXBUF)
+
+static void
+empathy_cell_renderer_activatable_init (EmpathyCellRendererActivatable *cell)
+{
+       g_object_set (cell,
+                     "xpad", 0,
+                     "ypad", 0,
+                     "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
+                     "follow-state", TRUE,
+                     NULL);
+}
+
+static void
+empathy_cell_renderer_activatable_class_init (EmpathyCellRendererActivatableClass *klass)
+{
+       GtkCellRendererClass *cell_class;
+
+       cell_class = GTK_CELL_RENDERER_CLASS (klass);
+       cell_class->activate = cell_renderer_activatable_activate;
+
+       signals[PATH_ACTIVATED] =
+               g_signal_new ("path-activated",
+                             G_TYPE_FROM_CLASS (klass),
+                             G_SIGNAL_RUN_LAST,
+                             0,
+                             NULL, NULL,
+                             g_cclosure_marshal_VOID__STRING,
+                             G_TYPE_NONE,
+                             1, G_TYPE_STRING);
+}
+
+GtkCellRenderer *
+empathy_cell_renderer_activatable_new (void)
+{
+       return g_object_new (EMPATHY_TYPE_CELL_RENDERER_ACTIVATABLE, NULL);
+}
+
+static gboolean
+cell_renderer_activatable_activate (GtkCellRenderer      *cell,
+                                   GdkEvent             *event,
+                                   GtkWidget            *widget,
+                                   const gchar          *path_string,
+                                   GdkRectangle         *background_area,
+                                   GdkRectangle         *cell_area,
+                                   GtkCellRendererState  flags)
+{
+       EmpathyCellRendererActivatable *activatable;
+       gint                            ex, ey, bx, by, bw, bh;
+
+       activatable = EMPATHY_CELL_RENDERER_ACTIVATABLE (cell);
+
+       if (!GTK_IS_TREE_VIEW (widget) ||
+           event->type != GDK_BUTTON_PRESS) {
+               return FALSE;
+       }
+
+       ex  = (gint) ((GdkEventButton *) event)->x;
+       ey  = (gint) ((GdkEventButton *) event)->y;
+       bx = background_area->x;
+       by = background_area->y;
+       bw = background_area->width;
+       bh = background_area->height;
+
+       if (ex < bx || ex > (bx+bw) || ey < by || ey > (by+bh)){
+               /* Click wasn't on the icon */
+               return FALSE;
+       }
+
+       g_signal_emit (activatable, signals[PATH_ACTIVATED], 0, path_string);
+
+       return TRUE;
+}
+
diff --git a/libempathy-gtk/empathy-cell-renderer-activatable.h b/libempathy-gtk/empathy-cell-renderer-activatable.h
new file mode 100644 (file)
index 0000000..6b17b8f
--- /dev/null
@@ -0,0 +1,55 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 Raphael Slinckx <raphael@slinckx.net>
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * 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.
+ *
+ * Authors: Raphael Slinckx <raphael@slinckx.net>
+ */
+
+#ifndef __EMPATHY_CELL_RENDERER_ACTIVATABLE_H__
+#define __EMPATHY_CELL_RENDERER_ACTIVATABLE_H__
+
+#include <gtk/gtkcellrendererpixbuf.h>
+
+G_BEGIN_DECLS
+
+#define EMPATHY_TYPE_CELL_RENDERER_ACTIVATABLE            (empathy_cell_renderer_activatable_get_type ())
+#define EMPATHY_CELL_RENDERER_ACTIVATABLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_CELL_RENDERER_ACTIVATABLE, EmpathyCellRendererActivatable))
+#define EMPATHY_CELL_RENDERER_ACTIVATABLE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_CELL_RENDERER_ACTIVATABLE, EmpathyCellRendererActivatableClass))
+#define EMPATHY_IS_CELL_RENDERER_ACTIVATABLE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_CELL_RENDERER_ACTIVATABLE))
+#define EMPATHY_IS_CELL_RENDERER_ACTIVATABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMPATHY_TYPE_CELL_RENDERER_ACTIVATABLE))
+#define EMPATHY_CELL_RENDERER_ACTIVATABLE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_CELL_RENDERER_ACTIVATABLE, EmpathyCellRendererActivatableClass))
+
+typedef struct _EmpathyCellRendererActivatable      EmpathyCellRendererActivatable;
+typedef struct _EmpathyCellRendererActivatableClass EmpathyCellRendererActivatableClass;
+
+struct _EmpathyCellRendererActivatable {
+  GtkCellRendererPixbuf parent;
+};
+
+struct _EmpathyCellRendererActivatableClass {
+  GtkCellRendererPixbufClass parent_class;
+};
+
+GType            empathy_cell_renderer_activatable_get_type (void) G_GNUC_CONST;
+GtkCellRenderer *empathy_cell_renderer_activatable_new      (void);
+
+G_END_DECLS
+
+#endif /* __EMPATHY_CELL_RENDERER_ACTIVATABLE_H__ */
+