[gnome-control-center/wifi-refinements: 1/20] network: Add a separator before the arrow when needed
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wifi-refinements: 1/20] network: Add a separator before the arrow when needed
- Date: Sun, 9 Sep 2012 01:09:26 +0000 (UTC)
commit 50b642c8e583b56d1e697edfc0630500b8d0f0da
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Sep 8 14:22:17 2012 -0400
network: Add a separator before the arrow when needed
The separator is giving a hint that there are two clickable
areas in the row.
https://bugzilla.gnome.org/show_bug.cgi?id=682270
panels/network/Makefile.am | 2 +
panels/network/net-device-wifi.c | 57 ++++++++++-
panels/network/panel-cell-renderer-separator.c | 130 ++++++++++++++++++++++++
panels/network/panel-cell-renderer-separator.h | 62 +++++++++++
4 files changed, 250 insertions(+), 1 deletions(-)
---
diff --git a/panels/network/Makefile.am b/panels/network/Makefile.am
index b16e249..9613a1d 100644
--- a/panels/network/Makefile.am
+++ b/panels/network/Makefile.am
@@ -36,6 +36,8 @@ libnetwork_la_SOURCES = \
panel-cell-renderer-security.h \
panel-cell-renderer-signal.c \
panel-cell-renderer-signal.h \
+ panel-cell-renderer-separator.c \
+ panel-cell-renderer-separator.h \
network-dialogs.c \
network-dialogs.h \
cc-network-panel.c \
diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c
index 6286784..fdccc0a 100644
--- a/panels/network/net-device-wifi.c
+++ b/panels/network/net-device-wifi.c
@@ -41,6 +41,7 @@
#include "panel-cell-renderer-mode.h"
#include "panel-cell-renderer-signal.h"
#include "panel-cell-renderer-security.h"
+#include "panel-cell-renderer-separator.h"
#include "net-device-wifi.h"
@@ -1667,12 +1668,13 @@ arrow_visible (GtkTreeModel *model,
COLUMN_SORT, &sort,
-1);
- if (active || ap_is_saved || strcmp ("ap:hidden", sort) == 0)
+ if (active || ap_is_saved)
ret = TRUE;
else
ret = FALSE;
g_free (sort);
+
return ret;
}
@@ -1772,6 +1774,48 @@ remote_settings_read_cb (NMRemoteSettings *remote_settings,
}
}
+static gboolean
+separator_visible (GtkTreeModel *model,
+ GtkTreeIter *iter)
+{
+ gboolean active;
+ gboolean ap_is_saved;
+ gboolean ap_in_range;
+ gchar *sort;
+ gboolean ret;
+
+ gtk_tree_model_get (model, iter,
+ COLUMN_ACTIVE, &active,
+ COLUMN_AP_IS_SAVED, &ap_is_saved,
+ COLUMN_AP_IN_RANGE, &ap_in_range,
+ COLUMN_SORT, &sort,
+ -1);
+
+ if (!active && ap_is_saved && ap_in_range)
+ ret = TRUE;
+ else
+ ret = FALSE;
+
+ g_free (sort);
+
+ return ret;
+
+}
+
+static void
+set_draw_separator (GtkCellLayout *layout,
+ GtkCellRenderer *cell,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ gboolean draw;
+
+ draw = separator_visible (model, iter);
+
+ g_object_set (cell, "draw", draw, NULL);
+}
+
static void
net_device_wifi_constructed (GObject *object)
{
@@ -1956,6 +2000,17 @@ net_device_wifi_init (NetDeviceWifi *device_wifi)
"visible", COLUMN_AP_IN_RANGE,
NULL);
+ renderer = panel_cell_renderer_separator_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), renderer, FALSE);
+ g_object_set (renderer,
+ "visible", TRUE,
+ "sensitive", FALSE,
+ "draw", TRUE,
+ NULL);
+ gtk_cell_renderer_set_fixed_size (renderer, 1, -1);
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), renderer,
+ set_draw_separator, device_wifi, NULL);
+
renderer = gtk_cell_renderer_pixbuf_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), renderer, FALSE);
g_object_set (renderer,
diff --git a/panels/network/panel-cell-renderer-separator.c b/panels/network/panel-cell-renderer-separator.c
new file mode 100644
index 0000000..ae4d5d2
--- /dev/null
+++ b/panels/network/panel-cell-renderer-separator.c
@@ -0,0 +1,130 @@
+/* -*- Separator: C; tab-width: 8; indent-tabs-separator: 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-separator.h"
+
+enum {
+ PROP_0,
+ PROP_DRAW,
+ PROP_LAST
+};
+
+G_DEFINE_TYPE (PanelCellRendererSeparator, panel_cell_renderer_separator, GTK_TYPE_CELL_RENDERER)
+
+static void
+panel_cell_renderer_separator_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ PanelCellRendererSeparator *renderer = PANEL_CELL_RENDERER_SEPARATOR (object);
+
+ switch (param_id) {
+ case PROP_DRAW:
+ g_value_set_boolean (value, renderer->draw);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+panel_cell_renderer_separator_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ PanelCellRendererSeparator *renderer = PANEL_CELL_RENDERER_SEPARATOR (object);
+
+ switch (param_id) {
+ case PROP_DRAW:
+ renderer->draw = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+render (GtkCellRenderer *cell,
+ cairo_t *cr,
+ GtkWidget *widget,
+ const GdkRectangle *background_area,
+ const GdkRectangle *cell_area,
+ GtkCellRendererState flags)
+{
+ PanelCellRendererSeparator *renderer = PANEL_CELL_RENDERER_SEPARATOR (cell);
+ GtkStyleContext *context;
+ gint x, y, w, h, xpad, ypad;
+
+ if (!renderer->draw)
+ return;
+
+ context = gtk_widget_get_style_context (widget);
+
+ gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
+
+ x = cell_area->x + xpad;
+ y = cell_area->y + ypad;
+ w = cell_area->width - xpad * 2;
+ h = cell_area->height - ypad * 2;
+
+ gtk_render_line (context, cr, x + w / 2, y, x + w / 2, y + h - 1);
+}
+
+static void
+panel_cell_renderer_separator_class_init (PanelCellRendererSeparatorClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkCellRendererClass *cell_renderer_class = GTK_CELL_RENDERER_CLASS (class);
+
+ object_class->get_property = panel_cell_renderer_separator_get_property;
+ object_class->set_property = panel_cell_renderer_separator_set_property;
+
+ cell_renderer_class->render = render;
+
+ g_object_class_install_property (object_class, PROP_DRAW,
+ g_param_spec_boolean ("draw", "draw", "draw",
+ TRUE,
+ G_PARAM_READWRITE));
+}
+
+static void
+panel_cell_renderer_separator_init (PanelCellRendererSeparator *renderer)
+{
+ renderer->draw = TRUE;
+}
+
+GtkCellRenderer *
+panel_cell_renderer_separator_new (void)
+{
+ return g_object_new (PANEL_TYPE_CELL_RENDERER_SEPARATOR, NULL);
+}
diff --git a/panels/network/panel-cell-renderer-separator.h b/panels/network/panel-cell-renderer-separator.h
new file mode 100644
index 0000000..29dfa1d
--- /dev/null
+++ b/panels/network/panel-cell-renderer-separator.h
@@ -0,0 +1,62 @@
+/* -*- Separator: C; tab-width: 8; indent-tabs-separator: 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_SEPARATOR_H
+#define PANEL_CELL_RENDERER_SEPARATOR_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include "nm-device.h"
+#include "nm-access-point.h"
+
+#define PANEL_TYPE_CELL_RENDERER_SEPARATOR (panel_cell_renderer_separator_get_type())
+#define PANEL_CELL_RENDERER_SEPARATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PANEL_TYPE_CELL_RENDERER_SEPARATOR, PanelCellRendererSeparator))
+#define PANEL_CELL_RENDERER_SEPARATOR_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST((cls), PANEL_TYPE_CELL_RENDERER_SEPARATOR, PanelCellRendererSeparatorClass))
+#define PANEL_IS_CELL_RENDERER_SEPARATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PANEL_TYPE_CELL_RENDERER_SEPARATOR))
+#define PANEL_IS_CELL_RENDERER_SEPARATOR_CLASS(cls) (G_TYPE_CHECK_CLASS_TYPE((cls), PANEL_TYPE_CELL_RENDERER_SEPARATOR))
+#define PANEL_CELL_RENDERER_SEPARATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PANEL_TYPE_CELL_RENDERER_SEPARATOR, PanelCellRendererSeparatorClass))
+
+G_BEGIN_DECLS
+
+typedef struct _PanelCellRendererSeparator PanelCellRendererSeparator;
+typedef struct _PanelCellRendererSeparatorClass PanelCellRendererSeparatorClass;
+
+struct _PanelCellRendererSeparator
+{
+ GtkCellRenderer parent;
+ gboolean draw;
+};
+
+struct _PanelCellRendererSeparatorClass
+{
+ GtkCellRendererClass parent_class;
+};
+
+GType panel_cell_renderer_separator_get_type (void);
+GtkCellRenderer *panel_cell_renderer_separator_new (void);
+
+G_END_DECLS
+
+#endif /* PANEL_CELL_RENDERER_SEPARATOR_H */
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]