[ekiga/ds-gtk-application] GtkInfoBar: Added Gm version of a GtkInfoBar.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-gtk-application] GtkInfoBar: Added Gm version of a GtkInfoBar.
- Date: Thu, 6 Nov 2014 18:51:11 +0000 (UTC)
commit 17826d921fc8ad70c5c48421083663cd87f34b19
Author: Damien Sandras <dsandras seconix com>
Date: Thu Nov 6 19:48:32 2014 +0100
GtkInfoBar: Added Gm version of a GtkInfoBar.
It is a convenience GObject so that "Information" messages are displayed
for a few seconds, then are automatically hidden. Other message types
have an explicit close action.
lib/Makefile.am | 2 +
lib/gui/gm-info-bar.c | 159 +++++++++++++++++++++++++++++++++++++++++++++++++
lib/gui/gm-info-bar.h | 104 ++++++++++++++++++++++++++++++++
3 files changed, 265 insertions(+), 0 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 7679b11..a13bd0f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -123,6 +123,8 @@ libekiga_la_SOURCES += \
gui/gm-smileys.c \
gui/gm-entry.h \
gui/gm-entry.c \
+ gui/gm-info-bar.h \
+ gui/gm-info-bar.c \
gui/gmwindow.c \
gui/gmwindow.h \
gui/gmmenuaddon.c \
diff --git a/lib/gui/gm-info-bar.c b/lib/gui/gm-info-bar.c
new file mode 100644
index 0000000..5583e0f
--- /dev/null
+++ b/lib/gui/gm-info-bar.c
@@ -0,0 +1,159 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2014 Damien Sandras <dsandras seconix com>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ * gm-info-bar.h - description
+ * -----------------------------
+ * begin : Sat Nov 1 2014
+ * copyright : (C) 2014 by Damien Sandras
+ * description : Contains a GmInfoBary implementation handling
+ * GtkInfoBar info and error messages.
+ *
+ */
+
+
+#include "gm-info-bar.h"
+
+
+struct _GmInfoBarPrivate {
+
+ GtkWidget *label;
+ guint timeout;
+};
+
+G_DEFINE_TYPE (GmInfoBar, gm_info_bar, GTK_TYPE_INFO_BAR);
+
+
+/* Callbacks */
+static gboolean on_info_bar_delayed_hide (gpointer self);
+
+static void on_info_bar_response (GmInfoBar *self,
+ gint response_id,
+ gpointer data);
+
+
+/* Static GObject functions and declarations */
+static void gm_info_bar_dispose (GObject* obj);
+
+static void gm_info_bar_class_init (GmInfoBarClass *);
+
+static void gm_info_bar_init (GmInfoBar *);
+
+
+/* Callbacks */
+static gboolean
+on_info_bar_delayed_hide (gpointer self)
+{
+ gtk_widget_hide (GTK_WIDGET (self));
+
+ return FALSE;
+}
+
+static void
+on_info_bar_response (GmInfoBar *self,
+ gint response_id,
+ G_GNUC_UNUSED gpointer data)
+{
+ g_return_if_fail (GM_IS_INFO_BAR (self));
+
+ if (response_id == GTK_RESPONSE_CLOSE)
+ gtk_widget_hide (GTK_WIDGET (self));
+}
+
+
+/* Implementation of GObject stuff */
+static void
+gm_info_bar_dispose (GObject* obj)
+{
+ GmInfoBarPrivate *priv = GM_INFO_BAR (obj)->priv;
+
+ if (priv->timeout > 0) {
+ g_source_remove (priv->timeout);
+ priv->timeout = 0;
+ }
+
+ G_OBJECT_CLASS (gm_info_bar_parent_class)->dispose (obj);
+}
+
+
+static void
+gm_info_bar_class_init (GmInfoBarClass *klass)
+{
+ g_type_class_add_private (klass, sizeof (GmInfoBarPrivate));
+
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->dispose = gm_info_bar_dispose;
+}
+
+
+static void
+gm_info_bar_init (GmInfoBar* self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GM_TYPE_INFO_BAR,
+ GmInfoBarPrivate);
+
+ self->priv->timeout = 0;
+ self->priv->label = gtk_label_new (NULL);
+ gtk_label_set_line_wrap (GTK_LABEL (self->priv->label), TRUE);
+
+ gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (self))),
+ self->priv->label, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (self), "response",
+ G_CALLBACK (on_info_bar_response), NULL);
+}
+
+
+/* public api */
+GtkWidget *
+gm_info_bar_new ()
+{
+ return GTK_WIDGET (g_object_new (GM_TYPE_INFO_BAR, NULL));
+}
+
+
+void
+gm_info_bar_set_message (GmInfoBar *self,
+ GtkMessageType type,
+ const char *message)
+{
+ g_return_if_fail (GM_IS_INFO_BAR (self) || !message || !g_strcmp0 (message, ""));
+
+ gtk_info_bar_set_message_type (GTK_INFO_BAR (self), type);
+ gtk_label_set_text (GTK_LABEL (self->priv->label), message);
+ gtk_info_bar_set_show_close_button (GTK_INFO_BAR (self), (type != GTK_MESSAGE_INFO));
+ gtk_widget_show_all (GTK_WIDGET (self));
+
+ /* Flash the information message. Please don't abuse this.
+ */
+ if (type == GTK_MESSAGE_INFO) {
+ self->priv->timeout = g_timeout_add_seconds (4, on_info_bar_delayed_hide, self);
+ }
+}
diff --git a/lib/gui/gm-info-bar.h b/lib/gui/gm-info-bar.h
new file mode 100644
index 0000000..b980786
--- /dev/null
+++ b/lib/gui/gm-info-bar.h
@@ -0,0 +1,104 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2014 Damien Sandras <dsandras seconix com>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ * gm-info-bar.h - description
+ * -----------------------------
+ * begin : Sat Nov 1 2014
+ * copyright : (C) 2014 by Damien Sandras
+ * description : Contains a GmInfoBary implementation handling
+ * GtkInfoBar info and error messages.
+ *
+ */
+
+
+#ifndef __GM_INFO_BAR_H__
+#define __GM_INFO_BAR_H__
+
+#include <gtk/gtk.h>
+
+
+G_BEGIN_DECLS
+
+typedef struct _GmInfoBar GmInfoBar;
+typedef struct _GmInfoBarPrivate GmInfoBarPrivate;
+typedef struct _GmInfoBarClass GmInfoBarClass;
+
+/*
+ * Public API
+ *
+ */
+
+/** Create a new GmInfoBar.
+ * @return A GmInfoBar.
+ */
+GtkWidget *gm_info_bar_new ();
+
+
+/** Update the GmInfoBar content.
+ * @param self: A GmInfoBar
+ * @param type: The message type.
+ * @param message: The non empty information message to display.
+ */
+void gm_info_bar_set_message (GmInfoBar *self,
+ GtkMessageType type,
+ const char *message);
+
+
+/* GObject thingies */
+struct _GmInfoBar
+{
+ GtkInfoBar parent;
+
+ GmInfoBarPrivate *priv;
+};
+
+struct _GmInfoBarClass
+{
+ GtkInfoBarClass parent;
+
+ void (*valid) (GmInfoBar* self);
+};
+
+#define GM_TYPE_INFO_BAR (gm_info_bar_get_type ())
+
+#define GM_INFO_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GM_TYPE_INFO_BAR, GmInfoBar))
+
+#define GM_IS_INFO_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GM_TYPE_INFO_BAR))
+
+#define GM_INFO_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GM_TYPE_INFO_BAR, GmInfoBarClass))
+
+#define GM_IS_INFO_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GM_TYPE_INFO_BAR))
+
+#define GM_INFO_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GM_TYPE_INFO_BAR, GmInfoBarClass))
+
+GType gm_info_bar_get_type ();
+
+G_END_DECLS
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]