[Goodies-commits] r3929 - xfmpc/trunk/src

Mike Massonnet mmassonnet at xfce.org
Fri Feb 8 12:34:50 CET 2008


Author: mmassonnet
Date: 2008-02-08 11:34:49 +0000 (Fri, 08 Feb 2008)
New Revision: 3929

Added:
   xfmpc/trunk/src/extended-interface.c
   xfmpc/trunk/src/extended-interface.h
Modified:
   xfmpc/trunk/src/Makefile.am
   xfmpc/trunk/src/interface.c
Log:
Add the extended interface widget
* src/Makefile.am:
  - Add compilation for new files
* src/extended-interface.c,
  src/extended-interface.h:
  - New files
* src/interface.c:
  - Add a new XfmpcExtendedInterface


Modified: xfmpc/trunk/src/Makefile.am
===================================================================
--- xfmpc/trunk/src/Makefile.am	2008-02-08 11:34:43 UTC (rev 3928)
+++ xfmpc/trunk/src/Makefile.am	2008-02-08 11:34:49 UTC (rev 3929)
@@ -6,6 +6,8 @@
 	interface.h							\
 	interface-ui.h							\
 	interface-ui.xml						\
+	extended-interface.c						\
+	extended-interface.h						\
 	preferences.c							\
 	preferences.h							\
 	mpdclient.c							\

Added: xfmpc/trunk/src/extended-interface.c
===================================================================
--- xfmpc/trunk/src/extended-interface.c	                        (rev 0)
+++ xfmpc/trunk/src/extended-interface.c	2008-02-08 11:34:49 UTC (rev 3929)
@@ -0,0 +1,214 @@
+/*
+ *  Copyright (c) 2008 Mike Massonnet <mmassonnet at xfce.org>
+ *
+ *  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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+
+#include "extended-interface.h"
+
+#define BORDER 4
+
+
+
+/* List store identifiers */
+enum
+{
+  COLUMN_STRING,
+  COLUMN_POINTER,
+  N_COLUMNS,
+};
+
+
+
+static void             xfmpc_extended_interface_class_init (XfmpcExtendedInterfaceClass *klass);
+static void             xfmpc_extended_interface_init       (XfmpcExtendedInterface *extended_interface);
+static void             xfmpc_extended_interface_dispose    (GObject *object);
+static void             xfmpc_extended_interface_finalize   (GObject *object);
+
+static void             cb_xfmpc_extended_interface_combobox_changed (GtkComboBox *widget,
+                                                             XfmpcExtendedInterface *extended_interface);
+
+
+
+struct _XfmpcExtendedInterfaceClass
+{
+  GtkVBoxClass                  parent_class;
+};
+
+struct _XfmpcExtendedInterface
+{
+  GtkVBox                       parent;
+  XfmpcExtendedInterfacePriv   *priv;
+};
+
+struct _XfmpcExtendedInterfacePriv
+{
+  GtkListStore                 *list_store;
+  GtkWidget                    *combobox;
+  GtkWidget                    *notebook;
+};
+
+
+
+static GObjectClass *parent_class = NULL;
+
+
+
+GType
+xfmpc_extended_interface_get_type ()
+{
+  static GType xfmpc_extended_interface_type = G_TYPE_INVALID;
+
+  if (G_UNLIKELY (xfmpc_extended_interface_type == G_TYPE_INVALID))
+    {
+      static const GTypeInfo xfmpc_extended_interface_info =
+        {
+          sizeof (XfmpcExtendedInterfaceClass),
+          (GBaseInitFunc) NULL,
+          (GBaseFinalizeFunc) NULL,
+          (GClassInitFunc) xfmpc_extended_interface_class_init,
+          (GClassFinalizeFunc) NULL,
+          NULL,
+          sizeof (XfmpcExtendedInterface),
+          0,
+          (GInstanceInitFunc) xfmpc_extended_interface_init,
+          NULL
+        };
+      xfmpc_extended_interface_type = g_type_register_static (GTK_TYPE_VBOX, "XfmpcExtendedInterface", &xfmpc_extended_interface_info, 0);
+    }
+
+  return xfmpc_extended_interface_type;
+}
+
+
+
+static void
+xfmpc_extended_interface_class_init (XfmpcExtendedInterfaceClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  parent_class = g_type_class_peek_parent (klass);
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->dispose = xfmpc_extended_interface_dispose;
+  gobject_class->finalize = xfmpc_extended_interface_finalize;
+}
+
+static void
+xfmpc_extended_interface_init (XfmpcExtendedInterface *extended_interface)
+{
+  extended_interface->priv = g_slice_new0 (XfmpcExtendedInterfacePriv);
+
+  /* Combo box */
+  GtkListStore *list_store = extended_interface->priv->list_store =
+    gtk_list_store_new (N_COLUMNS,
+                        G_TYPE_STRING,
+                        G_TYPE_POINTER);
+
+  GtkWidget *combobox = extended_interface->priv->combobox =
+    gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store));
+
+  GtkCellRenderer *cell = gtk_cell_renderer_text_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), cell, TRUE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox),
+                                  cell, "text", COLUMN_STRING,
+                                  NULL);
+
+  /* Notebook */
+  GtkWidget *notebook = extended_interface->priv->notebook = gtk_notebook_new ();
+  gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
+
+  /* Extended interface widgets */
+  GtkWidget *child = gtk_label_new ("Hello world!");
+  xfmpc_extended_interface_append_child (extended_interface, child, "Hello world!");
+
+  child = gtk_label_new ("Good bye world!");
+  xfmpc_extended_interface_append_child (extended_interface, child, "Good bye world!");
+
+  /* Containers */
+  gtk_box_pack_start (GTK_BOX (extended_interface), combobox, FALSE, FALSE, BORDER);
+  gtk_box_pack_start (GTK_BOX (extended_interface), notebook, TRUE, TRUE, 0);
+
+  /* Signals */
+  g_signal_connect (combobox, "changed",
+                    G_CALLBACK (cb_xfmpc_extended_interface_combobox_changed), extended_interface);
+}
+
+static void
+xfmpc_extended_interface_dispose (GObject *object)
+{
+  (*G_OBJECT_CLASS (parent_class)->dispose) (object);
+}
+
+static void
+xfmpc_extended_interface_finalize (GObject *object)
+{
+  (*G_OBJECT_CLASS (parent_class)->finalize) (object);
+}
+
+
+
+GtkWidget*
+xfmpc_extended_interface_new ()
+{
+  return g_object_new (XFMPC_TYPE_EXTENDED_INTERFACE, NULL);
+}
+
+void
+xfmpc_extended_interface_append_child (XfmpcExtendedInterface *extended_interface,
+                                       GtkWidget *child,
+                                       const gchar *title)
+{
+  GtkTreeIter iter;
+
+  gtk_list_store_append (extended_interface->priv->list_store, &iter);
+  gtk_list_store_set (extended_interface->priv->list_store, &iter,
+                      COLUMN_STRING, title,
+                      COLUMN_POINTER, child,
+                      -1);
+
+  if (gtk_combo_box_get_active(GTK_COMBO_BOX (extended_interface->priv->combobox)) == -1)
+    gtk_combo_box_set_active (GTK_COMBO_BOX (extended_interface->priv->combobox), 0);
+
+  gtk_notebook_append_page (GTK_NOTEBOOK (extended_interface->priv->notebook), child, NULL);
+  gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (extended_interface->priv->notebook), child, TRUE, TRUE, GTK_PACK_START);
+}
+
+static void
+cb_xfmpc_extended_interface_combobox_changed (GtkComboBox *widget,
+                                              XfmpcExtendedInterface *extended_interface)
+{
+  GtkWidget            *child;
+  GtkTreeIter           iter;
+  gint                  i;
+
+  if (gtk_combo_box_get_active_iter (widget, &iter) == FALSE)
+    return;
+
+  gtk_tree_model_get (GTK_TREE_MODEL (extended_interface->priv->list_store), &iter,
+                      COLUMN_POINTER, &child,
+                      -1);
+  g_return_if_fail (G_LIKELY (GTK_IS_WIDGET (child)));
+
+  i = gtk_notebook_page_num (GTK_NOTEBOOK (extended_interface->priv->notebook), child);
+  gtk_notebook_set_current_page (GTK_NOTEBOOK (extended_interface->priv->notebook), i);
+}
+

Added: xfmpc/trunk/src/extended-interface.h
===================================================================
--- xfmpc/trunk/src/extended-interface.h	                        (rev 0)
+++ xfmpc/trunk/src/extended-interface.h	2008-02-08 11:34:49 UTC (rev 3929)
@@ -0,0 +1,48 @@
+/*
+ *  Copyright (c) 2008 Mike Massonnet <mmassonnet at xfce.org>
+ *
+ *  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 Library 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.
+ */
+
+#ifndef __XFMPC_EXTENDED_INTERFACE_H__
+#define __XFMPC_EXTENDED_INTERFACE_H__
+
+G_BEGIN_DECLS
+
+#define XFMPC_TYPE_EXTENDED_INTERFACE               (xfmpc_extended_interface_get_type())
+
+#define XFMPC_EXTENDED_INTERFACE(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_EXTENDED_INTERFACE, XfmpcExtendedInterface))
+#define XFMPC_EXTENDED_INTERFACE_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_EXTENDED_INTERFACE, XfmpcExtendedInterfaceClass))
+
+#define XFMPC_IS_EXTENDED_INTERFACE(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_EXTENDED_INTERFACE))
+#define XFMPC_IS_EXTENDED_INTERFACE_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_EXTENDED_INTERFACE))
+
+#define XFMPC_EXTENDED_INTERFACE_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_EXTENDED_INTERFACE, XfmpcExtendedInterfaceClass))
+
+typedef struct _XfmpcExtendedInterfaceClass         XfmpcExtendedInterfaceClass;
+typedef struct _XfmpcExtendedInterface              XfmpcExtendedInterface;
+typedef struct _XfmpcExtendedInterfacePriv          XfmpcExtendedInterfacePriv;
+
+GType                   xfmpc_extended_interface_get_type       () G_GNUC_CONST;
+
+GtkWidget *             xfmpc_extended_interface_new            ();
+
+void                    xfmpc_extended_interface_append_child   (XfmpcExtendedInterface *extended_interface,
+                                                                 GtkWidget *child,
+                                                                 const gchar *title);
+G_END_DECLS
+
+#endif
+

Modified: xfmpc/trunk/src/interface.c
===================================================================
--- xfmpc/trunk/src/interface.c	2008-02-08 11:34:43 UTC (rev 3928)
+++ xfmpc/trunk/src/interface.c	2008-02-08 11:34:49 UTC (rev 3929)
@@ -26,6 +26,7 @@
 
 #include "interface.h"
 #include "interface-ui.h"
+#include "extended-interface.h"
 #include "preferences.h"
 #include "mpdclient.h"
 
@@ -68,6 +69,7 @@
 {
   GtkWindow             parent;
   XfmpcInterfacePriv   *priv;
+  GtkWidget            *extended_interface;
   XfmpcPreferences     *preferences;
   XfmpcMpdclient       *mpdclient;
 };
@@ -192,6 +194,8 @@
   gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (control), 1.0);
   gtk_container_add (GTK_CONTAINER (progress_box), control);
 
+  interface->extended_interface = xfmpc_extended_interface_new ();
+
   /* Title */
   PangoAttrList* attrs = pango_attr_list_new ();
   PangoAttribute* attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
@@ -240,6 +244,8 @@
   gtk_container_add (GTK_CONTAINER (box), interface->priv->title);
   gtk_container_add (GTK_CONTAINER (box), interface->priv->subtitle);
 
+  gtk_box_pack_start (GTK_BOX (vbox), interface->extended_interface, TRUE, TRUE, 0);
+
   /* === Accelerators === */
   GtkActionGroup *action_group = gtk_action_group_new ("XfmpcInterface");
   gtk_action_group_add_actions (action_group, action_entries, G_N_ELEMENTS (action_entries), GTK_WINDOW (interface));




More information about the Goodies-commits mailing list