Пример #1
0
/* Plugin constructor. */
static GtkWidget *space_constructor(Panel *panel, config_setting_t *settings)
{
    /* Allocate plugin context and set into Plugin private data pointer. */
    SpacePlugin * sp = g_new0(SpacePlugin, 1);
    GtkWidget * p;

    /* Load parameters from the configuration file. */
    config_setting_lookup_int(settings, "Size", &sp->size);

    /* Save construction pointers */
    sp->panel = panel;
    sp->settings = settings;

    /* Default the size parameter. */
    if (sp->size == 0)
        sp->size = 2;

    /* Allocate top level widget and set into Plugin widget pointer. */
    p = gtk_event_box_new();
    lxpanel_plugin_set_data(p, sp, g_free);
#if GTK_CHECK_VERSION(2,18,0)
    gtk_widget_set_has_window(p,FALSE);
#else
    GTK_WIDGET_SET_FLAGS(p, GTK_NO_WINDOW);
#endif
    gtk_widget_add_events(p, GDK_BUTTON_PRESS_MASK);
    gtk_container_set_border_width(GTK_CONTAINER(p), 0);

    /* Apply the configuration and show the widget. */
    space_apply_configuration(p);
    return p;
}
Пример #2
0
/* Plugin constructor. */
static int space_constructor(Plugin * p, char ** fp)
{
    /* Allocate plugin context and set into Plugin private data pointer. */
    SpacePlugin * sp = g_new0(SpacePlugin, 1);
    p->priv = sp;

    /* Load parameters from the configuration file. */
    line s;
    s.len = 256;
    if (fp != NULL)
    {
        while (lxpanel_get_line(fp, &s) != LINE_BLOCK_END)
        {
            if (s.type == LINE_NONE)
            {
                ERR( "space: illegal token %s\n", s.str);
                return 0;
            }
            if (s.type == LINE_VAR)
            {
                if (g_ascii_strcasecmp(s.t[0], "size") == 0)
                    sp->size = atoi(s.t[1]);
                else
                    ERR( "space: unknown var %s\n", s.t[0]);
            }
            else
            {
                ERR( "space: illegal in this context %s\n", s.str);
                return 0;
            }
        }
    }

    /* Default the size parameter. */
    if (sp->size == 0)
        sp->size = 2;

    /* Allocate top level widget and set into Plugin widget pointer. */
    p->pwid = gtk_event_box_new();
#if GTK_CHECK_VERSION(2,18,0)
    gtk_widget_set_has_window(p->pwid,FALSE);
#else
    GTK_WIDGET_SET_FLAGS(p->pwid, GTK_NO_WINDOW);
#endif
    gtk_widget_add_events(p->pwid, GDK_BUTTON_PRESS_MASK);
    gtk_container_set_border_width(GTK_CONTAINER(p->pwid), 0);

    /* Connect signals. */
    g_signal_connect(p->pwid, "button-press-event", G_CALLBACK(plugin_button_press_event), p);

    /* Apply the configuration and show the widget. */
    space_apply_configuration(p);
    gtk_widget_show(p->pwid);
    return 1;
}