MplPanelGtk

MplPanelGtk — Class for panels using Gtk

Synopsis

                    MplPanelGtk;
                    MplPanelGtkClass;
#define             MPL_PANEL_GTK_INIT
MplPanelClient *    mpl_panel_gtk_new                   (const gchar *name,
                                                         const gchar *tooltip,
                                                         const gchar *stylesheet,
                                                         const gchar *button_style,
                                                         gboolean with_toolbar_service);
GtkWidget *         mpl_panel_gtk_get_window            (MplPanelGtk *panel);
void                mpl_panel_gtk_set_child             (MplPanelGtk *panel,
                                                         GtkWidget *child);

Object Hierarchy

  GObject
   +----MplPanelClient
         +----MplPanelGtk

Description

MplPanelGtk is a class for all Panels that implement their UI using Gtk+. A minimal Panel implementation using MplPanelGtk would look as follows:

  #include <meego-panel/mpl-panel-gtk.h>

  int
  main (int argc, char **argv)
  {
    MplPanelClient *client;
    GtkWidget      *contents;

    gtk_init (&argc, &argv);

    client = mpl_panel_gtk_new ("mypanel",
                                "this is mypanel",
                                "somewhere/mypanel-button.css",
                                "mypanel-button",
                                FALSE);

    / * create the content actor for your panel * /
    contents = make_my_panel_conents ();

    mpl_panel_gtk_set_child (MPL_PANEL_GTK (client), contents);

    gtk_main ();

    return 0;
  }

*/

G_DEFINE_TYPE (MplPanelGtk, mpl_panel_gtk, MPL_TYPE_PANEL_CLIENT)

#define MPL_PANEL_GTK_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), MPL_TYPE_PANEL_GTK, MplPanelGtkPrivate))

static void mpl_panel_gtk_constructed (GObject *self);

enum { PROP_0, };

struct _MplPanelGtkPrivate { GtkWidget *window; GtkWidget *child; };

static void mpl_panel_gtk_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { switch (property_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }

static void mpl_panel_gtk_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { switch (property_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }

static void mpl_panel_gtk_dispose (GObject *self) { G_OBJECT_CLASS (mpl_panel_gtk_parent_class)->dispose (self); }

static void mpl_panel_gtk_finalize (GObject *object) { G_OBJECT_CLASS (mpl_panel_gtk_parent_class)->finalize (object); }

static void mpl_panel_gtk_set_size (MplPanelClient *self, guint width, guint height) { MplPanelGtkPrivate *priv = MPL_PANEL_GTK (self)->priv; MplPanelClientClass *p_class;

p_class = MPL_PANEL_CLIENT_CLASS (mpl_panel_gtk_parent_class);

gtk_widget_set_size_request (priv->window, width, height); gtk_window_resize (GTK_WINDOW (priv->window), width, height);

if (p_class->set_size) p_class->set_size (self, width, height); }

static void mpl_panel_gtk_set_position (MplPanelClient *self, gint x, gint y) { MplPanelGtkPrivate *priv = MPL_PANEL_GTK (self)->priv; MplPanelClientClass *p_class;

p_class = MPL_PANEL_CLIENT_CLASS (mpl_panel_gtk_parent_class);

gtk_window_move (GTK_WINDOW (priv->window), x, y);

if (p_class->set_position) p_class->set_position (self, x, y); }

static void mpl_panel_gtk_show (MplPanelClient *self) { MplPanelGtkPrivate *priv = MPL_PANEL_GTK (self)->priv;

gtk_widget_show (priv->window); }

static void mpl_panel_gtk_hide (MplPanelClient *self) { MplPanelGtkPrivate *priv = MPL_PANEL_GTK (self)->priv;

gtk_widget_hide (priv->window); }

static void mpl_panel_gtk_unload (MplPanelClient *panel) { gtk_main_quit(); }

static void mpl_panel_gtk_class_init (MplPanelGtkClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); MplPanelClientClass *client_class = MPL_PANEL_CLIENT_CLASS (klass);

g_type_class_add_private (klass, sizeof (MplPanelGtkPrivate));

object_class->get_property = mpl_panel_gtk_get_property; object_class->set_property = mpl_panel_gtk_set_property; object_class->dispose = mpl_panel_gtk_dispose; object_class->finalize = mpl_panel_gtk_finalize; object_class->constructed = mpl_panel_gtk_constructed;

client_class->set_position = mpl_panel_gtk_set_position; client_class->set_size = mpl_panel_gtk_set_size; client_class->show = mpl_panel_gtk_show; client_class->hide = mpl_panel_gtk_hide; client_class->unload = mpl_panel_gtk_unload; }

static void mpl_panel_gtk_init (MplPanelGtk *self) { MplPanelGtkPrivate *priv;

priv = self->priv = MPL_PANEL_GTK_GET_PRIVATE (self); }

static void mpl_panel_gtk_constructed (GObject *self) { MplPanelGtkPrivate *priv = MPL_PANEL_GTK (self)->priv; GtkWidget *window;

if (G_OBJECT_CLASS (mpl_panel_gtk_parent_class)->constructed) G_OBJECT_CLASS (mpl_panel_gtk_parent_class)->constructed (self);

priv->window = window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_name (priv->window, "MplPanelGtk"); gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DOCK); gtk_window_stick (GTK_WINDOW (window));

/* Realize the window so we can get the xid.

Details

MplPanelGtk

typedef struct _MplPanelGtk MplPanelGtk;

Panel object for Gtk+-based panels.


MplPanelGtkClass

typedef struct {
} MplPanelGtkClass;

Panel object for Gtk+-based panels.


MPL_PANEL_GTK_INIT

#define MPL_PANEL_GTK_INIT MPL_PANEL_GTK_INIT__is_replaced_with__gtk_init


mpl_panel_gtk_new ()

MplPanelClient *    mpl_panel_gtk_new                   (const gchar *name,
                                                         const gchar *tooltip,
                                                         const gchar *stylesheet,
                                                         const gchar *button_style,
                                                         gboolean with_toolbar_service);

Constructs a new MplPanelGtk object.

name :

canonical name of the panel

tooltip :

tooltip for the associated Toolbar button

stylesheet :

stylesheet for the associated Toolbar button

button_style :

css style id for the button style

with_toolbar_service :

whether the panel will be using any Toolbar services (e.g., the launching API)

Returns :

new MplPanelClient object.

mpl_panel_gtk_get_window ()

GtkWidget *         mpl_panel_gtk_get_window            (MplPanelGtk *panel);

Returns the top level window of the panel.

panel :

MplPanelGtk

Returns :

top level GtkWidget

mpl_panel_gtk_set_child ()

void                mpl_panel_gtk_set_child             (MplPanelGtk *panel,
                                                         GtkWidget *child);

Set's the content widget of the panel to be the provided child widget.

panel :

MplPanelGtk

child :

GtkWidget.