Exemplo n.º 1
0
/**
 * @param p: the popup to initialize
 * @return Returns TRUE on success, FALSE on failure.
 * @brief Initialize the popup and inherited fields
 *
 * Clears the contents of the popup and stores the
 * default values.
 */
int
ewl_popup_init(Ewl_Popup *p)
{
        Ewl_Widget *w;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(p, FALSE);

        w = EWL_WIDGET(p);
        if (!ewl_window_init(EWL_WINDOW(w)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_inherit(w, EWL_POPUP_TYPE);
        ewl_widget_appearance_set(w, EWL_POPUP_TYPE);
        ewl_object_fill_policy_set(EWL_OBJECT(p), EWL_FLAG_FILL_NONE);

        ewl_window_override_set(EWL_WINDOW(p), TRUE);

        ewl_container_show_notify_set(EWL_CONTAINER(p),
                                        ewl_popup_cb_child_show);
        ewl_container_resize_notify_set(EWL_CONTAINER(p),
                                        ewl_popup_cb_child_resize);

        /*
         * add the callbacks
         */
        ewl_callback_append(w, EWL_CALLBACK_SHOW, ewl_popup_cb_show, NULL);
        ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, ewl_popup_cb_show, NULL);
        ewl_callback_append(w, EWL_CALLBACK_MOUSE_MOVE, ewl_popup_cb_mouse_move,
                                                                        NULL);
        ewl_callback_prepend(w, EWL_CALLBACK_DESTROY, ewl_popup_cb_destroy,
                                                                        NULL);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 2
0
/**
 * @param t: the toolbar to initialize
 * @return Returns TRUE on success, FALSE on failure.
 * @brief Initialize the toolbar and inherited fields
 *
 * Clears the contents of the toolbar and stores the
 * default values.
 */
int
ewl_toolbar_init(Ewl_Toolbar *t)
{
        Ewl_Widget *w;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(t, FALSE);

        w = EWL_WIDGET(t);
        if (!ewl_menubar_init(EWL_MENUBAR(t)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_inherit(w, EWL_TOOLBAR_TYPE);
        ewl_widget_appearance_set(w, "htoolbar");

        ewl_object_fill_policy_set(EWL_OBJECT(t), EWL_FLAG_FILL_HFILL |
                                                  EWL_FLAG_FILL_SHRINKABLE);
        ewl_object_alignment_set(EWL_OBJECT(t), EWL_FLAG_ALIGN_LEFT |
                                                        EWL_FLAG_ALIGN_TOP);

        ewl_container_add_notify_set(EWL_CONTAINER(EWL_MENUBAR(t)->inner_box),
                                        ewl_toolbar_cb_child_add);
        t->hidden = EWL_ICON_PART_NONE;

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 3
0
/**
 * @param w: the overlay to be initialized to default values and callbacks
 * @return Returns TRUE or FALSE depending on if initialization succeeds.
 * @brief initialize a overlay to default values and callbacks
 *
 * Sets the values and callbacks of a overlay @a w to their defaults.
 */
int
ewl_overlay_init(Ewl_Overlay *w)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(w, FALSE);

        /*
         * Initialize the fields of the inherited container class
         */
        if (!ewl_container_init(EWL_CONTAINER(w)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_appearance_set(EWL_WIDGET(w), EWL_OVERLAY_TYPE);
        ewl_widget_inherit(EWL_WIDGET(w), EWL_OVERLAY_TYPE);

        ewl_container_show_notify_set(EWL_CONTAINER(w),
                                        ewl_overlay_cb_child_show);
        ewl_container_resize_notify_set(EWL_CONTAINER(w),
                                        ewl_overlay_cb_child_resize);

        ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_NONE);

        /*
         * Override the default configure callbacks since the overlay
         * has special needs for placement.
         */
        ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_CONFIGURE,
                             ewl_overlay_cb_configure, NULL);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 4
0
/**
 * @param b: the border container to initialize
 * @return Returns TRUE on success, FALSE on failure.
 * @brief Initialize a border container to default values
 */
int
ewl_border_init(Ewl_Border *b)
{
        Ewl_Widget *w;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(b, FALSE);

        w = EWL_WIDGET(b);

        if (!ewl_box_init(EWL_BOX(w))) {
                DRETURN_INT(FALSE, DLEVEL_STABLE);
        }
        ewl_box_orientation_set(EWL_BOX(w), EWL_ORIENTATION_VERTICAL);
        ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_FILL);

        ewl_widget_appearance_set(EWL_WIDGET(b), EWL_BORDER_TYPE);
        ewl_widget_inherit(EWL_WIDGET(b), EWL_BORDER_TYPE);

        b->label = ewl_label_new();
        ewl_widget_internal_set(b->label, TRUE);
        ewl_container_child_append(EWL_CONTAINER(b), b->label);
        ewl_widget_show(b->label);

        b->body = ewl_vbox_new();
        ewl_widget_internal_set(b->body, TRUE);
        ewl_container_child_append(EWL_CONTAINER(b), b->body);
        ewl_widget_show(b->body);

        b->label_position = EWL_POSITION_TOP;

        ewl_container_redirect_set(EWL_CONTAINER(b), EWL_CONTAINER(b->body));

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 5
0
/**
 * @param s: the separator to initialize
 * @return Returns TRUE on success, FALSE on failure.
 * @brief Initialize the separator and inherited fields
 *
 * Clears the contents of the separator and stores the
 * default values.
 */
int
ewl_separator_init(Ewl_Separator *s)
{
        Ewl_Widget *w;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(s, FALSE);

        w = EWL_WIDGET(s);
        if (!ewl_widget_init(w))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_inherit(w, EWL_SEPARATOR_TYPE);
        ewl_widget_appearance_set(EWL_WIDGET(s), "hseparator");
        ewl_object_fill_policy_set(EWL_OBJECT(s), EWL_FLAG_FILL_HFILL |
                                                  EWL_FLAG_FILL_SHRINKABLE);

        ewl_object_alignment_set(EWL_OBJECT(s), EWL_FLAG_ALIGN_LEFT);

        s->orientation = EWL_ORIENTATION_HORIZONTAL;

        ewl_widget_focusable_set(w, FALSE);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 6
0
/**
 * @param sp: The Ewl_Spectrum to init
 * @return Returns TRUE on success or FALSE on failure
 * @brief Initializes an Ewl_Specturm widget to default values
 */
int
ewl_spectrum_init(Ewl_Spectrum *sp)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(sp, FALSE);

        if (!ewl_container_init(EWL_CONTAINER(sp)))
        {
                DRETURN_INT(FALSE, DLEVEL_STABLE);
        }

        ewl_widget_appearance_set(EWL_WIDGET(sp), EWL_SPECTRUM_TYPE);
        ewl_widget_inherit(EWL_WIDGET(sp), EWL_SPECTRUM_TYPE);
        ewl_object_fill_policy_set(EWL_OBJECT(sp), EWL_FLAG_FILL_FILL);
        ewl_container_callback_intercept(EWL_CONTAINER(sp),
                                        EWL_CALLBACK_MOUSE_MOVE);
        ewl_container_callback_intercept(EWL_CONTAINER(sp),
                                        EWL_CALLBACK_MOUSE_DOWN);
        ewl_container_callback_intercept(EWL_CONTAINER(sp),
                                        EWL_CALLBACK_MOUSE_UP);

        ewl_callback_append(EWL_WIDGET(sp), EWL_CALLBACK_MOUSE_DOWN,
                                ewl_spectrum_cb_mouse_down, NULL);
        ewl_callback_append(EWL_WIDGET(sp), EWL_CALLBACK_MOUSE_UP,
                                ewl_spectrum_cb_mouse_up, NULL);

        sp->type = EWL_SPECTRUM_TYPE_SQUARE;

        /* create the canvas */
        sp->canvas = ewl_image_new();
        ewl_container_child_append(EWL_CONTAINER(sp), sp->canvas);
        ewl_object_fill_policy_set(EWL_OBJECT(sp->canvas), EWL_FLAG_FILL_FILL);
        ewl_widget_internal_set(sp->canvas, TRUE);
        ewl_callback_append(EWL_WIDGET(sp->canvas), EWL_CALLBACK_REVEAL,
                                ewl_spectrum_canvas_cb_reveal, sp);
        ewl_widget_show(sp->canvas);

        /* create the cross hairs to draw on the spectrum */
        sp->cross_hairs.horizontal = ewl_hseparator_new();
        ewl_container_child_append(EWL_CONTAINER(sp), sp->cross_hairs.horizontal);
        ewl_widget_internal_set(sp->cross_hairs.horizontal, TRUE);
        ewl_widget_layer_priority_set(sp->cross_hairs.horizontal, 1);

        sp->cross_hairs.vertical = ewl_vseparator_new();
        ewl_container_child_append(EWL_CONTAINER(sp), sp->cross_hairs.vertical);
        ewl_widget_internal_set(sp->cross_hairs.vertical, TRUE);
        ewl_widget_layer_priority_set(sp->cross_hairs.vertical, 1);

        ewl_callback_append(EWL_WIDGET(sp), EWL_CALLBACK_CONFIGURE,
                        ewl_spectrum_cb_configure, NULL);

        ewl_spectrum_rgb_set(sp, 255, 255, 255);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 7
0
/**
 * @param pdf the pdf widget to initialize
 * @return Returns no value.
 * @brief Initialize an pdf widget to default values and callbacks
 *
 * Sets the fields and callbacks of @a pdf to their default values.
 */
int
ewl_pdf_init(Ewl_Pdf *pdf)
{
        Ewl_Widget *w;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(pdf, FALSE);

        if (!epdf_init()) 
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        w = EWL_WIDGET(pdf);

        if (!ewl_widget_init(w))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_appearance_set(w, EWL_PDF_TYPE);
        ewl_widget_inherit(w, EWL_PDF_TYPE);

        ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_NONE);

        /*
         * Append necessary callbacks.
         */
        ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, ewl_pdf_configure_cb,
                            NULL);
        ewl_callback_append(w, EWL_CALLBACK_REVEAL, ewl_pdf_reveal_cb,
                            NULL);
        ewl_callback_append(w, EWL_CALLBACK_OBSCURE, ewl_pdf_obscure_cb,
                            NULL);
        ewl_callback_prepend(w, EWL_CALLBACK_DESTROY, ewl_pdf_destroy_cb,
                            NULL);

        pdf->filename = NULL;

        pdf->pdf_document = NULL;
        pdf->pdf_page = NULL;
        pdf->pdf_index = NULL;

        pdf->dirty = 1;

        pdf->search.o = NULL;
        pdf->search.text = NULL;
        pdf->search.list = NULL;
        pdf->search.page = -1;
        pdf->search.is_case_sensitive = FALSE;
        pdf->search.is_circular = FALSE;

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 8
0
/**
 * @param n: The Ewl_Notebook widget to initialize
 * @return Returns TRUE on success or NULL on failure.
 * @brief Initialize a notebook to default values and callbacks
 */
int
ewl_notebook_init(Ewl_Notebook *n)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(n, FALSE);

        if (!ewl_box_init(EWL_BOX(n)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_box_orientation_set(EWL_BOX(n), EWL_ORIENTATION_VERTICAL);

        ewl_widget_appearance_set(EWL_WIDGET(n), EWL_NOTEBOOK_TYPE);
        ewl_widget_inherit(EWL_WIDGET(n), EWL_NOTEBOOK_TYPE);

        n->tabbar_position = EWL_POSITION_TOP;

        n->body.tabbar = ewl_hbox_new();
        ewl_container_child_append(EWL_CONTAINER(n), n->body.tabbar);
        ewl_object_fill_policy_set(EWL_OBJECT(n->body.tabbar),
                                EWL_FLAG_FILL_NONE);
        ewl_object_alignment_set(EWL_OBJECT(n->body.tabbar),
                                                EWL_FLAG_ALIGN_CENTER);
        ewl_widget_internal_set(n->body.tabbar, TRUE);
        ewl_widget_appearance_set(n->body.tabbar, "top/tabbar");
        ewl_widget_show(n->body.tabbar);

        n->body.pages = ewl_vbox_new();
        ewl_object_fill_policy_set(EWL_OBJECT(n->body.pages),
                                   EWL_FLAG_FILL_ALL);
        ewl_container_child_append(EWL_CONTAINER(n), n->body.pages);
        ewl_widget_internal_set(n->body.pages, TRUE);
        ewl_widget_layer_priority_set(n->body.pages, -1);
        ewl_widget_appearance_set(n->body.pages, "pages");
        ewl_widget_show(n->body.pages);

        ewl_container_redirect_set(EWL_CONTAINER(n),
                                        EWL_CONTAINER(n->body.pages));

        ewl_container_show_notify_set(EWL_CONTAINER(n->body.pages),
                                        ewl_notebook_cb_child_show);
        ewl_container_hide_notify_set(EWL_CONTAINER(n->body.pages),
                                        ewl_notebook_cb_child_hide);
        ewl_container_add_notify_set(EWL_CONTAINER(n->body.pages),
                                        ewl_notebook_cb_child_add);
        ewl_container_remove_notify_set(EWL_CONTAINER(n->body.pages),
                                        ewl_notebook_cb_child_remove);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 9
0
/**
 * @param menu: the menu to initialize
 * @return Returns no value.
 * @brief Initialize an internal menu to starting values
 */
int
ewl_menu_init(Ewl_Menu *menu)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(menu, FALSE);

        /*
         * Initialize the defaults of the inherited fields.
         */
        if (!ewl_menu_item_init(EWL_MENU_ITEM(menu)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_appearance_set(EWL_WIDGET(menu), "menu_container");
        ewl_widget_inherit(EWL_WIDGET(menu), EWL_MENU_TYPE);

        /*
         * add the callbacks
         */
        ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_MOUSE_MOVE,
                            ewl_menu_cb_mouse_move, NULL);
        ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_FOCUS_IN,
                            ewl_menu_cb_expand, NULL);
        ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_CLICKED,
                            ewl_menu_cb_expand, NULL);
        ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_CONFIGURE,
                            ewl_menu_cb_configure, NULL);
        ewl_callback_prepend(EWL_WIDGET(menu), EWL_CALLBACK_DESTROY,
                                ewl_menu_cb_destroy, NULL);

        /*
         * Create the popup menu portion of the widget.
         */
        menu->popup = ewl_context_menu_new();
        ewl_popup_follow_set(EWL_POPUP(menu->popup), EWL_WIDGET(menu));
        ewl_popup_type_set(EWL_POPUP(menu->popup),
                                        EWL_POPUP_TYPE_MENU_VERTICAL);
        ewl_widget_internal_set(menu->popup, TRUE);
        ewl_widget_appearance_set(EWL_WIDGET(menu->popup), EWL_MENU_TYPE);

        /* redirect the menu container to the popup menu */
        ewl_container_redirect_set(EWL_CONTAINER(menu),
                                        EWL_CONTAINER(menu->popup));
        ewl_callback_prepend(menu->popup, EWL_CALLBACK_DESTROY,
                                ewl_menu_cb_popup_destroy, menu);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 10
0
/**
 * @param w: the window to be initialized to default values and callbacks
 * @return Returns TRUE or FALSE depending on if initialization succeeds.
 * @brief Initialize a window to default values and callbacks
 *
 * Sets the values and callbacks of a window @a w to their defaults.
 */
int
ewl_window_init(Ewl_Window *w)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(w, FALSE);

        /*
         * Initialize the fields of the inherited container class
         */
        if (!ewl_embed_init(EWL_EMBED(w)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_appearance_set(EWL_WIDGET(w), EWL_WINDOW_TYPE);
        ewl_widget_inherit(EWL_WIDGET(w), EWL_WINDOW_TYPE);
        ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_FILL);
        ewl_embed_render_set(EWL_EMBED(w), TRUE);

        ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_REALIZE,
                             ewl_window_cb_realize, NULL);
        ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_REALIZE,
                             ewl_window_cb_postrealize, NULL);
        ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_UNREALIZE,
                             ewl_window_cb_unrealize, NULL);
        ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_SHOW,
                            ewl_window_cb_show, NULL);
        ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_EXPOSE,
                            ewl_window_cb_expose, NULL);
        ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_HIDE,
                            ewl_window_cb_hide, NULL);
        ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_DESTROY,
                             ewl_window_cb_destroy, NULL);
        /*
         * Override the default configure callbacks since the window
         * has special needs for placement.
         */
        ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_CONFIGURE,
                             ewl_window_cb_configure, NULL);

        ecore_list_append(ewl_window_list, w);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 11
0
/**
 * @param dialog: the icondialog to initialize.
 * @return Return TRUE on success, FALSE otherwise.
 * @brief Initialize an internal icondialog to starting values
 */
int
ewl_icondialog_init(Ewl_Icondialog *dialog)
{
        Ewl_Widget *w;
        Ewl_Widget *box;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(dialog, FALSE);

        w = EWL_WIDGET(dialog);

        if (!ewl_dialog_init(EWL_DIALOG(dialog))) {
                DRETURN_INT(FALSE, DLEVEL_STABLE);
        }

        ewl_widget_appearance_set(w, EWL_ICONDIALOG_TYPE);
        ewl_widget_inherit(w, EWL_ICONDIALOG_TYPE);

        /* get the parent vbox */
        box = dialog->dialog.vbox;
        /* we need a hbox */
        ewl_box_orientation_set(EWL_BOX(box), EWL_ORIENTATION_HORIZONTAL);

        /*
         * Setup a vertical box for the displayed window contents.
         */
        dialog->vbox = ewl_vbox_new();
        if (!dialog->vbox) {
                DRETURN_INT(FALSE, DLEVEL_STABLE);
        }

        ewl_container_child_append(EWL_CONTAINER(box), dialog->vbox);
        ewl_widget_internal_set(dialog->vbox, TRUE);
        ewl_object_fill_policy_set(EWL_OBJECT(dialog->vbox), EWL_FLAG_FILL_ALL);
        ewl_widget_show(dialog->vbox);

        ewl_container_redirect_set(EWL_CONTAINER(box), 
                                        EWL_CONTAINER(dialog->vbox));

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 12
0
Arquivo: ewl_dvi.c Projeto: Limsik/e17
/**
 * @param dvi: the dvi widget to initialize
 * @return Returns no value.
 * @brief Initialize an dvi widget to default values and callbacks
 *
 * Sets the fields and callbacks of @a dvi to their default
 * values. The property EDVI_PROPERTY_DELAYED_FONT_OPEN is set by
 * default.
 */
int
ewl_dvi_init(Ewl_Dvi *dvi)
{
        Ewl_Widget *w;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(dvi, FALSE);

        w = EWL_WIDGET(dvi);

        if (!ewl_widget_init(w))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_appearance_set(w, EWL_DVI_TYPE);
        ewl_widget_inherit(w, EWL_DVI_TYPE);

        /*
         * Append necessary callbacks.
         */
        ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, ewl_dvi_configure_cb,
                            NULL);
        ewl_callback_append(w, EWL_CALLBACK_REVEAL, ewl_dvi_reveal_cb,
                            NULL);
        ewl_callback_append(w, EWL_CALLBACK_OBSCURE, ewl_dvi_obscure_cb,
                            NULL);
        ewl_callback_prepend(w, EWL_CALLBACK_DESTROY, ewl_dvi_destroy_cb,
                            NULL);

        dvi->filename = NULL;

        dvi->dvi_device = edvi_device_new (edvi_dpi_get(), edvi_dpi_get());
        dvi->dvi_property = edvi_property_new();
        edvi_property_property_set (dvi->dvi_property, EDVI_PROPERTY_DELAYED_FONT_OPEN);
        dvi->dvi_document = NULL;
        dvi->dvi_page = NULL;

        dvi->dirty = 1;

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 13
0
Arquivo: ewl_ps.c Projeto: Limsik/e17
/**
 * @param ps: the ps widget to initialize
 * @return Returns no value.
 * @brief Initialize an ps widget to default values and callbacks
 *
 * Sets the fields and callbacks of @a ps to their default
 * values.
 */
int
ewl_ps_init(Ewl_Ps *ps)
{
        Ewl_Widget *w;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(ps, FALSE);

        w = EWL_WIDGET(ps);

        if (!ewl_widget_init(w))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_appearance_set(w, EWL_PS_TYPE);
        ewl_widget_inherit(w, EWL_PS_TYPE);

        /*
         * Append necessary callbacks.
         */
        ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, ewl_ps_configure_cb,
                            NULL);
        ewl_callback_append(w, EWL_CALLBACK_REVEAL, ewl_ps_reveal_cb,
                            NULL);
        ewl_callback_append(w, EWL_CALLBACK_OBSCURE, ewl_ps_obscure_cb,
                            NULL);
        ewl_callback_prepend(w, EWL_CALLBACK_DESTROY, ewl_ps_destroy_cb,
                            NULL);

        ps->filename = NULL;

        ps->ps_document = NULL;
        ps->ps_page = NULL;

        ps->dirty = 1;

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 14
0
/**
 * @param e: The Ewl_Entry to initialize
 * @return Returns TRUE on success or FALSE on failure
 * @brief Initializes an Ewl_Entry widget to default values
 */
int
ewl_entry_init(Ewl_Entry *e)
{
        const char *text_types[] = { "UTF8_STRING", "text/plain", NULL };
        Ewl_Widget *w;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(e, FALSE);

        w = EWL_WIDGET(e);

        if (!ewl_text_init(EWL_TEXT(e)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_inherit(w, EWL_ENTRY_TYPE);
        ewl_widget_appearance_set(w, EWL_ENTRY_TYPE);
        ewl_widget_focusable_set(EWL_WIDGET(e), TRUE);

        ewl_object_fill_policy_set(EWL_OBJECT(e), EWL_FLAG_FILL_HSHRINK |
                                                  EWL_FLAG_FILL_HFILL);

        ewl_container_callback_intercept(EWL_CONTAINER(w), EWL_CALLBACK_FOCUS_IN);
        ewl_container_callback_intercept(EWL_CONTAINER(w), EWL_CALLBACK_FOCUS_OUT);
        ewl_container_callback_intercept(EWL_CONTAINER(w), EWL_CALLBACK_DND_POSITION);
        ewl_container_callback_intercept(EWL_CONTAINER(w), EWL_CALLBACK_DND_DATA_RECEIVED);

        /* setup the cursor */
        e->cursor = ewl_entry_cursor_new(e);
        ewl_container_child_append(EWL_CONTAINER(e), e->cursor);
        ewl_widget_internal_set(e->cursor, TRUE);
        ewl_object_fill_policy_set(EWL_OBJECT(e->cursor), EWL_FLAG_FILL_VFILL);

        /* Set the pointer */
        ewl_attach_mouse_cursor_set(EWL_WIDGET(e), EWL_MOUSE_CURSOR_XTERM);

        /* this has to be called after the cursor is created as it will try
         * to show the cursor */
        ewl_entry_multiline_set(e, FALSE);
        ewl_entry_editable_set(e, TRUE);
        ewl_text_selectable_set(EWL_TEXT(e), TRUE);
        ewl_dnd_accepted_types_set(EWL_WIDGET(e), text_types);

        /* setup callbacks */
        ewl_callback_append(w, EWL_CALLBACK_FOCUS_IN,
                                ewl_entry_cb_focus_in, NULL);
        ewl_callback_append(w, EWL_CALLBACK_FOCUS_OUT,
                                ewl_entry_cb_focus_out, NULL);
        ewl_callback_prepend(w, EWL_CALLBACK_CONFIGURE,
                                ewl_entry_cb_configure, NULL);
        ewl_callback_append(w, EWL_CALLBACK_MOUSE_DOWN,
                                ewl_entry_cb_mouse_down, NULL);
        ewl_callback_append(w, EWL_CALLBACK_MOUSE_UP,
                                ewl_entry_cb_mouse_up, NULL);
        ewl_callback_append(w, EWL_CALLBACK_WIDGET_DISABLE,
                                ewl_entry_cb_disable, NULL);
        ewl_callback_append(w, EWL_CALLBACK_WIDGET_ENABLE,
                                ewl_entry_cb_enable, NULL);
        ewl_callback_append(w, EWL_CALLBACK_DND_POSITION,
                                ewl_entry_cb_dnd_position, NULL);
        ewl_callback_append(w, EWL_CALLBACK_DND_DATA_RECEIVED,
                                ewl_entry_cb_dnd_data, NULL);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}