[gnome-bluetooth] Add MuxBanner, copied from carrick



commit da80cc9413dd0826a4f492dd74c1e2ff697a873f
Author: Ross Burton <ross linux intel com>
Date:   Thu Apr 1 22:33:23 2010 +0100

    Add MuxBanner, copied from carrick

 moblin/moblin-copy-n-paste/Makefile.am  |    4 +-
 moblin/moblin-copy-n-paste/mux-banner.c |  106 +++++++++++++++++++++++++++++++
 moblin/moblin-copy-n-paste/mux-banner.h |   70 ++++++++++++++++++++
 3 files changed, 179 insertions(+), 1 deletions(-)
---
diff --git a/moblin/moblin-copy-n-paste/Makefile.am b/moblin/moblin-copy-n-paste/Makefile.am
index 3c9d2f1..d751af8 100644
--- a/moblin/moblin-copy-n-paste/Makefile.am
+++ b/moblin/moblin-copy-n-paste/Makefile.am
@@ -5,4 +5,6 @@ libmoblin_la_LIBADD = $(MOBLIN_LIBS)
 libmoblin_la_SOURCES = koto-cell-renderer-pixbuf.c \
 		       koto-cell-renderer-pixbuf.h \
 		       mux-cell-renderer-text.c \
-		       mux-cell-renderer-text.h
+		       mux-cell-renderer-text.h \
+		       mux-banner.c \
+		       mux-banner.h
diff --git a/moblin/moblin-copy-n-paste/mux-banner.c b/moblin/moblin-copy-n-paste/mux-banner.c
new file mode 100644
index 0000000..483fe5e
--- /dev/null
+++ b/moblin/moblin-copy-n-paste/mux-banner.c
@@ -0,0 +1,106 @@
+/*
+ * Mux - a connection panel for the Moblin Netbook
+ * Copyright (C) 2010 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * 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 - Ross Burton <ross linux intel com>
+ */
+
+#include <gtk/gtk.h>
+#include "mux-banner.h"
+
+struct _MuxBannerPrivate {
+  GdkColor colour;
+  GtkWidget *label;
+};
+
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MUX_TYPE_BANNER, MuxBannerPrivate))
+G_DEFINE_TYPE (MuxBanner, mux_banner, GTK_TYPE_HBOX);
+
+static void
+mux_banner_realize (GtkWidget *widget)
+{
+  MuxBanner *banner = MUX_BANNER (widget);
+
+  GTK_WIDGET_CLASS (mux_banner_parent_class)->realize (widget);
+
+  gdk_color_parse ("#d7d9d6", &banner->priv->colour);
+  gdk_colormap_alloc_color (gtk_widget_get_colormap (widget),
+                            &banner->priv->colour,
+                            FALSE, TRUE);
+}
+
+static gboolean
+mux_banner_expose (GtkWidget *widget, GdkEventExpose *event)
+{
+  MuxBanner *banner = MUX_BANNER (widget);
+  GdkGC *gc;
+
+  gc = gdk_gc_new (widget->window);
+  gdk_gc_set_foreground (gc, &banner->priv->colour);
+
+  gdk_draw_rectangle (widget->window, gc, TRUE,
+                      event->area.x, event->area.y,
+                      event->area.width, event->area.height);
+
+
+  return GTK_WIDGET_CLASS (mux_banner_parent_class)->expose_event (widget, event);
+}
+
+static void
+mux_banner_class_init (MuxBannerClass *klass)
+{
+    GtkWidgetClass *w_class = (GtkWidgetClass *)klass;
+
+    w_class->realize = mux_banner_realize;
+    w_class->expose_event = mux_banner_expose;
+
+    g_type_class_add_private (klass, sizeof (MuxBannerPrivate));
+}
+
+static void
+mux_banner_init (MuxBanner *self)
+{
+  self->priv = GET_PRIVATE (self);
+
+  gtk_container_set_border_width (GTK_CONTAINER (self), 8);
+
+  self->priv->label = gtk_label_new ("");
+  gtk_misc_set_alignment (GTK_MISC (self->priv->label), 0.0f, 0.5f);
+  gtk_widget_show (self->priv->label);
+  gtk_box_pack_start (GTK_BOX (self), self->priv->label, FALSE, FALSE, 8);
+}
+
+GtkWidget *
+mux_banner_new (const char *text)
+{
+  GtkWidget *widget;
+
+  widget = g_object_new (MUX_TYPE_BANNER, NULL);
+  if (text)
+    mux_banner_set_text ((MuxBanner *)widget, text);
+  return widget;
+}
+
+void
+mux_banner_set_text (MuxBanner *banner, const char *text)
+{
+  char *s;
+
+  s = g_strconcat ("<big><b>", text, "</b></big>", NULL);
+  gtk_label_set_markup (GTK_LABEL (banner->priv->label), s);
+  g_free (s);
+}
diff --git a/moblin/moblin-copy-n-paste/mux-banner.h b/moblin/moblin-copy-n-paste/mux-banner.h
new file mode 100644
index 0000000..034a1ac
--- /dev/null
+++ b/moblin/moblin-copy-n-paste/mux-banner.h
@@ -0,0 +1,70 @@
+/*
+ * Mux - a connection panel for the Moblin Netbook
+ * Copyright (C) 2010 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * 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 - Ross Burton <ross linux intel com>
+ */
+
+#ifndef __MUX_BANNER_H__
+#define __MUX_BANNER_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define MUX_TYPE_BANNER (mux_banner_get_type())
+#define MUX_BANNER(obj)                                             \
+   (G_TYPE_CHECK_INSTANCE_CAST ((obj),                                  \
+                                MUX_TYPE_BANNER,                    \
+                                MuxBanner))
+#define MUX_BANNER_CLASS(klass)                                     \
+   (G_TYPE_CHECK_CLASS_CAST ((klass),                                   \
+                             MUX_TYPE_BANNER,                       \
+                             MuxBannerClass))
+#define IS_MUX_BANNER(obj)                                          \
+   (G_TYPE_CHECK_INSTANCE_TYPE ((obj),                                  \
+                                MUX_TYPE_BANNER))
+#define IS_MUX_BANNER_CLASS(klass)                                  \
+   (G_TYPE_CHECK_CLASS_TYPE ((klass),                                   \
+                             MUX_TYPE_BANNER))
+#define MUX_BANNER_GET_CLASS(obj)                                   \
+   (G_TYPE_INSTANCE_GET_CLASS ((obj),                                   \
+                               MUX_TYPE_BANNER,                     \
+                               MuxBannerClass))
+
+typedef struct _MuxBannerPrivate MuxBannerPrivate;
+typedef struct _MuxBanner      MuxBanner;
+typedef struct _MuxBannerClass MuxBannerClass;
+
+struct _MuxBanner {
+  GtkHBox parent;
+  MuxBannerPrivate *priv;
+};
+
+struct _MuxBannerClass {
+  GtkHBoxClass parent_class;
+};
+
+GType mux_banner_get_type (void) G_GNUC_CONST;
+
+GtkWidget *mux_banner_new (const char *text);
+
+void mux_banner_set_text (MuxBanner *banner, const char *text);
+
+G_END_DECLS
+
+#endif /* __MUX_BANNER_H__ */



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