[gnome-control-center/wifi-refinements] network: Add cell renderers
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wifi-refinements] network: Add cell renderers
- Date: Sun, 9 Sep 2012 03:37:49 +0000 (UTC)
commit 3e21c78b10e88cd53cff5fa9a5c37b2700ffbba8
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Sep 8 23:28:10 2012 -0400
network: Add cell renderers
These are activatable variants of text and pixbuf cell
renderers. They emit an 'activate' signal when clicked
or activated by keyboard.
panels/network/Makefile.am | 4 +
panels/network/panel-cell-renderer-pixbuf.c | 82 +++++++++++++++++++++++++++
panels/network/panel-cell-renderer-pixbuf.h | 61 ++++++++++++++++++++
panels/network/panel-cell-renderer-text.c | 82 +++++++++++++++++++++++++++
panels/network/panel-cell-renderer-text.h | 61 ++++++++++++++++++++
5 files changed, 290 insertions(+), 0 deletions(-)
---
diff --git a/panels/network/Makefile.am b/panels/network/Makefile.am
index 9613a1d..c4fab22 100644
--- a/panels/network/Makefile.am
+++ b/panels/network/Makefile.am
@@ -38,6 +38,10 @@ libnetwork_la_SOURCES = \
panel-cell-renderer-signal.h \
panel-cell-renderer-separator.c \
panel-cell-renderer-separator.h \
+ panel-cell-renderer-text.c \
+ panel-cell-renderer-text.h \
+ panel-cell-renderer-pixbuf.c \
+ panel-cell-renderer-pixbuf.h \
network-dialogs.c \
network-dialogs.h \
cc-network-panel.c \
diff --git a/panels/network/panel-cell-renderer-pixbuf.c b/panels/network/panel-cell-renderer-pixbuf.c
new file mode 100644
index 0000000..72650c9
--- /dev/null
+++ b/panels/network/panel-cell-renderer-pixbuf.c
@@ -0,0 +1,82 @@
+/* -*- Pixbuf: C; tab-width: 8; indent-tabs-pixbuf: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Written by Matthias Clasen
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "panel-cell-renderer-pixbuf.h"
+
+enum {
+ ACTIVATE,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (PanelCellRendererPixbuf, panel_cell_renderer_pixbuf, GTK_TYPE_CELL_RENDERER_PIXBUF)
+
+static gint
+activate (GtkCellRenderer *cell,
+ GdkEvent *event,
+ GtkWidget *widget,
+ const gchar *path,
+ const GdkRectangle *background_area,
+ const GdkRectangle *cell_area,
+ GtkCellRendererState flags)
+{
+ g_signal_emit (cell, signals[ACTIVATE], 0, path);
+
+ return TRUE;
+}
+
+static void
+panel_cell_renderer_pixbuf_class_init (PanelCellRendererPixbufClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkCellRendererClass *cell_renderer_class = GTK_CELL_RENDERER_CLASS (class);
+
+ cell_renderer_class->activate = activate;
+
+ signals[ACTIVATE] =
+ g_signal_new ("activate",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PanelCellRendererPixbufClass, activate),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+}
+
+static void
+panel_cell_renderer_pixbuf_init (PanelCellRendererPixbuf *renderer)
+{
+}
+
+GtkCellRenderer *
+panel_cell_renderer_pixbuf_new (void)
+{
+ return g_object_new (PANEL_TYPE_CELL_RENDERER_PIXBUF, NULL);
+}
diff --git a/panels/network/panel-cell-renderer-pixbuf.h b/panels/network/panel-cell-renderer-pixbuf.h
new file mode 100644
index 0000000..839af92
--- /dev/null
+++ b/panels/network/panel-cell-renderer-pixbuf.h
@@ -0,0 +1,61 @@
+/* -*- Pixbuf: C; tab-width: 8; indent-tabs-pixbuf: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Written by Matthias Clasen
+ */
+
+#ifndef PANEL_CELL_RENDERER_PIXBUF_H
+#define PANEL_CELL_RENDERER_PIXBUF_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#define PANEL_TYPE_CELL_RENDERER_PIXBUF (panel_cell_renderer_pixbuf_get_type())
+#define PANEL_CELL_RENDERER_PIXBUF(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PANEL_TYPE_CELL_RENDERER_PIXBUF, PanelCellRendererPixbuf))
+#define PANEL_CELL_RENDERER_PIXBUF_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST((cls), PANEL_TYPE_CELL_RENDERER_PIXBUF, PanelCellRendererPixbufClass))
+#define PANEL_IS_CELL_RENDERER_PIXBUF(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PANEL_TYPE_CELL_RENDERER_PIXBUF))
+#define PANEL_IS_CELL_RENDERER_PIXBUF_CLASS(cls) (G_TYPE_CHECK_CLASS_TYPE((cls), PANEL_TYPE_CELL_RENDERER_PIXBUF))
+#define PANEL_CELL_RENDERER_PIXBUF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PANEL_TYPE_CELL_RENDERER_PIXBUF, PanelCellRendererPixbufClass))
+
+G_BEGIN_DECLS
+
+typedef struct _PanelCellRendererPixbuf PanelCellRendererPixbuf;
+typedef struct _PanelCellRendererPixbufClass PanelCellRendererPixbufClass;
+
+struct _PanelCellRendererPixbuf
+{
+ GtkCellRendererPixbuf parent;
+};
+
+struct _PanelCellRendererPixbufClass
+{
+ GtkCellRendererPixbufClass parent_class;
+
+ void (*activate) (PanelCellRendererPixbuf *pixbuf,
+ const gchar *path);
+};
+
+GType panel_cell_renderer_pixbuf_get_type (void);
+GtkCellRenderer *panel_cell_renderer_pixbuf_new (void);
+
+G_END_DECLS
+
+#endif /* PANEL_CELL_RENDERER_PIXBUF_H */
+
diff --git a/panels/network/panel-cell-renderer-text.c b/panels/network/panel-cell-renderer-text.c
new file mode 100644
index 0000000..5731da6
--- /dev/null
+++ b/panels/network/panel-cell-renderer-text.c
@@ -0,0 +1,82 @@
+/* -*- Text: C; tab-width: 8; indent-tabs-text: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Written by Matthias Clasen
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "panel-cell-renderer-text.h"
+
+enum {
+ ACTIVATE,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (PanelCellRendererText, panel_cell_renderer_text, GTK_TYPE_CELL_RENDERER_TEXT)
+
+static gint
+activate (GtkCellRenderer *cell,
+ GdkEvent *event,
+ GtkWidget *widget,
+ const gchar *path,
+ const GdkRectangle *background_area,
+ const GdkRectangle *cell_area,
+ GtkCellRendererState flags)
+{
+ g_signal_emit (cell, signals[ACTIVATE], 0, path);
+
+ return TRUE;
+}
+
+static void
+panel_cell_renderer_text_class_init (PanelCellRendererTextClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkCellRendererClass *cell_renderer_class = GTK_CELL_RENDERER_CLASS (class);
+
+ cell_renderer_class->activate = activate;
+
+ signals[ACTIVATE] =
+ g_signal_new ("activate",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PanelCellRendererTextClass, activate),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+}
+
+static void
+panel_cell_renderer_text_init (PanelCellRendererText *renderer)
+{
+}
+
+GtkCellRenderer *
+panel_cell_renderer_text_new (void)
+{
+ return g_object_new (PANEL_TYPE_CELL_RENDERER_TEXT, NULL);
+}
diff --git a/panels/network/panel-cell-renderer-text.h b/panels/network/panel-cell-renderer-text.h
new file mode 100644
index 0000000..c4c2e45
--- /dev/null
+++ b/panels/network/panel-cell-renderer-text.h
@@ -0,0 +1,61 @@
+/* -*- Text: C; tab-width: 8; indent-tabs-text: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Written by Matthias Clasen
+ */
+
+#ifndef PANEL_CELL_RENDERER_TEXT_H
+#define PANEL_CELL_RENDERER_TEXT_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#define PANEL_TYPE_CELL_RENDERER_TEXT (panel_cell_renderer_text_get_type())
+#define PANEL_CELL_RENDERER_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PANEL_TYPE_CELL_RENDERER_TEXT, PanelCellRendererText))
+#define PANEL_CELL_RENDERER_TEXT_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST((cls), PANEL_TYPE_CELL_RENDERER_TEXT, PanelCellRendererTextClass))
+#define PANEL_IS_CELL_RENDERER_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PANEL_TYPE_CELL_RENDERER_TEXT))
+#define PANEL_IS_CELL_RENDERER_TEXT_CLASS(cls) (G_TYPE_CHECK_CLASS_TYPE((cls), PANEL_TYPE_CELL_RENDERER_TEXT))
+#define PANEL_CELL_RENDERER_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PANEL_TYPE_CELL_RENDERER_TEXT, PanelCellRendererTextClass))
+
+G_BEGIN_DECLS
+
+typedef struct _PanelCellRendererText PanelCellRendererText;
+typedef struct _PanelCellRendererTextClass PanelCellRendererTextClass;
+
+struct _PanelCellRendererText
+{
+ GtkCellRendererText parent;
+};
+
+struct _PanelCellRendererTextClass
+{
+ GtkCellRendererTextClass parent_class;
+
+ void (*activate) (PanelCellRendererText *text,
+ const gchar *path);
+};
+
+GType panel_cell_renderer_text_get_type (void);
+GtkCellRenderer *panel_cell_renderer_text_new (void);
+
+G_END_DECLS
+
+#endif /* PANEL_CELL_RENDERER_TEXT_H */
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]