Exemplo n.º 1
0
mcview_t *
mcview_new (int y, int x, int lines, int cols, gboolean is_panel)
{
    mcview_t *view;

    view = g_new0 (mcview_t, 1);
    init_widget (WIDGET (view), y, x, lines, cols, mcview_callback, mcview_event);

    view->hex_mode = FALSE;
    view->hexedit_mode = FALSE;
    view->locked = FALSE;
    view->hexview_in_text = FALSE;
    view->text_nroff_mode = FALSE;
    view->text_wrap_mode = FALSE;
    view->magic_mode = FALSE;

    view->dpy_frame_size = is_panel ? 1 : 0;
    view->converter = str_cnv_from_term;

    mcview_init (view);

    if (mcview_default_hex_mode)
        mcview_toggle_hex_mode (view);
    if (mcview_default_nroff_flag)
        mcview_toggle_nroff_mode (view);
    if (mcview_global_wrap_mode)
        mcview_toggle_wrap_mode (view);
    if (mcview_default_magic_flag)
        mcview_toggle_magic_mode (view);

    return view;
}
Exemplo n.º 2
0
/* we need this callback to catch
   blist construction and install
   widget when we may do so */
static void cb_blist_created(GtkWidget *widget, gpointer data)
{
  /* create widget and
     load preferences */
  create_widget();
  init_widget();
}
Exemplo n.º 3
0
/*---------------------------------------------------------------------*/
void init_console( void )
{
    struct gra_info _gra_info;
    get_info( &_gra_info );
    __key_ptr = __key1;

#if 0
    cons = create_widget( eWIDGET_BASE );
    textbox = (struct text_box*)create_widget( eWIDGET_TEXT_BOX );
#endif

    init_widget( &cons );
    init_widget( &textbox.base );
    add_widget( &cons, &textbox.base );

    cons.data.rect.posx = _gra_info.screen_width>>1;
    cons.data.rect.posy = 0;
    cons.data.rect.width = 40 * DEBUG_FONT_SIZE_X;//200;
    cons.data.rect.height = 30 * DEBUG_FONT_SIZE_Y;//200;

    textbox.base.data.rect.posx = _gra_info.screen_width>>1;
    textbox.base.data.rect.posy = 0;
    textbox.base.data.rect.width = cons.data.rect.width ;
    textbox.base.data.rect.height = cons.data.rect.height;
    textbox.col = textbox.base.data.rect.width / DEBUG_FONT_SIZE_X;//col;
    textbox.row = textbox.base.data.rect.height/ DEBUG_FONT_SIZE_Y;//row:
    textbox.now_col = 0;
    textbox.now_row = 0;

    t_state.pos.x = 0;
    t_state.pos.y = 0;
    t_state.is_touch = false;

    init_cons = true;
    cmd_mode = false;

    // command queue initialize
    init_squeue( cmd_queue, cmd_stack, 0, 0, sizeof(cmd_stack) );

    _init_cmd_args( &_cmd_args );

    puts("console initialize", 0, DEBUG_FONT_SIZE_Y*1);
}
Exemplo n.º 4
0
int
edit_file (const char *_file, int line)
{
    static gboolean made_directory = FALSE;
    Dlg_head *edit_dlg;
    WEdit *wedit;
    WMenuBar *menubar;

    if (!made_directory)
    {
        char *dir = concat_dir_and_file (mc_config_get_cache_path (), EDIT_DIR);
        made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
        g_free (dir);

        dir = concat_dir_and_file (mc_config_get_path (), EDIT_DIR);
        made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
        g_free (dir);

        dir = concat_dir_and_file (mc_config_get_data_path (), EDIT_DIR);
        made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
        g_free (dir);
    }

    wedit = edit_init (NULL, 1, 0, LINES - 2, COLS, _file, line);

    if (wedit == NULL)
        return 0;

    /* Create a new dialog and add it widgets to it */
    edit_dlg =
        create_dlg (FALSE, 0, 0, LINES, COLS, NULL, edit_dialog_callback,
                    "[Internal File Editor]", NULL, DLG_WANT_TAB);

    edit_dlg->get_shortcut = edit_get_shortcut;
    edit_dlg->get_title = edit_get_title;

    menubar = menubar_new (0, 0, COLS, NULL);
    add_widget (edit_dlg, menubar);
    edit_init_menu (menubar);

    init_widget (&wedit->widget, wedit->widget.y, wedit->widget.x,
                 wedit->widget.lines, wedit->widget.cols, edit_callback, edit_event);
    widget_want_cursor (wedit->widget, TRUE);

    add_widget (edit_dlg, wedit);

    add_widget (edit_dlg, buttonbar_new (TRUE));

    run_dlg (edit_dlg);

    if (edit_dlg->state == DLG_CLOSED)
        destroy_dlg (edit_dlg);

    return 1;
}
Exemplo n.º 5
0
WWidget::WWidget(QWidget *parent) :
	QWidget(parent)
{
    init_widget();  /* 初始化界面的控件 */
    init_connection();  /* 初始化控件之间的消息响应 */

    /* 设置默认的文件路径 */
    QString fir_str("../test/file1.txt");
    QString sec_str("../test/file2.txt");
    fir_file_le.setText(fir_str);
    sec_file_le.setText(sec_str);
}
Exemplo n.º 6
0
Arquivo: menu.c Projeto: ryanlee/mc
WMenuBar *
menubar_new (int y, int x, int cols, GList * menu)
{
    WMenuBar *menubar;

    menubar = g_new0 (WMenuBar, 1);
    init_widget (&menubar->widget, y, x, 1, cols, menubar_callback, menubar_event);
    widget_want_cursor (menubar->widget, FALSE);
    menubar->is_visible = TRUE; /* by default */
    menubar_set_menu (menubar, menu);

    return menubar;
}
Exemplo n.º 7
0
Arquivo: check.c Projeto: BrEacK/mc
WCheck *
check_new (int y, int x, int state, const char *text)
{
    WCheck *c;

    c = g_new (WCheck, 1);
    c->text = parse_hotkey (text);
    init_widget (&c->widget, y, x, 1, 4 + hotkey_width (c->text), check_callback, check_event);
    /* 4 is width of "[X] " */
    c->state = state ? C_BOOL : 0;
    widget_want_hotkey (c->widget, TRUE);

    return c;
}
Exemplo n.º 8
0
Arquivo: hline.c Projeto: artzub/mc
WHLine *
hline_new (int y, int x, int width)
{
    WHLine *l;
    int lines = 1;

    l = g_new (WHLine, 1);
    init_widget (&l->widget, y, x, lines, width, hline_callback, NULL);
    l->auto_adjust_cols = (width < 0);
    l->transparent = FALSE;
    widget_want_cursor (l->widget, FALSE);
    widget_want_hotkey (l->widget, FALSE);

    return l;
}
Exemplo n.º 9
0
WButtonBar *
buttonbar_new (gboolean visible)
{
    WButtonBar *bb;

    bb = g_new0 (WButtonBar, 1);

    init_widget (&bb->widget, LINES - 1, 0, 1, COLS, buttonbar_callback, buttonbar_event);
    bb->widget.pos_flags = WPOS_KEEP_HORZ | WPOS_KEEP_BOTTOM;
    bb->visible = visible;
    widget_want_hotkey (bb->widget, 1);
    widget_want_cursor (bb->widget, 0);

    return bb;
}
Exemplo n.º 10
0
Arquivo: button.c Projeto: artzub/mc
WButton *
button_new (int y, int x, int action, button_flags_t flags, const char *text, bcback_fn callback)
{
    WButton *b;

    b = g_new (WButton, 1);
    b->action = action;
    b->flags = flags;
    b->text = parse_hotkey (text);

    init_widget (&b->widget, y, x, 1, button_get_len (b), button_callback, button_event);

    b->selected = FALSE;
    b->callback = callback;
    widget_want_hotkey (b->widget, TRUE);
    b->hotpos = (b->text.hotkey != NULL) ? str_term_width1 (b->text.start) : -1;

    return b;
}
Exemplo n.º 11
0
Arquivo: gauge.c Projeto: artzub/mc
WGauge *
gauge_new (int y, int x, gboolean shown, int max, int current)
{
    WGauge *g;

    g = g_new (WGauge, 1);
    init_widget (&g->widget, y, x, 1, gauge_len, gauge_callback, NULL);

    g->shown = shown;
    if (max == 0)
        max = 1;                /* I do not like division by zero :) */
    g->max = max;
    g->current = current;
    g->from_left_to_right = TRUE;

    widget_want_cursor (g->widget, FALSE);
    widget_want_hotkey (g->widget, FALSE);

    return g;
}
Exemplo n.º 12
0
Arquivo: label.c Projeto: artzub/mc
WLabel *
label_new (int y, int x, const char *text)
{
    WLabel *l;
    int cols = 1;
    int lines = 1;

    if (text != NULL)
        str_msg_term_size (text, &lines, &cols);

    l = g_new (WLabel, 1);
    init_widget (&l->widget, y, x, lines, cols, label_callback, NULL);
    l->text = g_strdup (text);
    l->auto_adjust_cols = TRUE;
    l->transparent = FALSE;
    widget_want_cursor (l->widget, FALSE);
    widget_want_hotkey (l->widget, FALSE);

    return l;
}
Exemplo n.º 13
0
int
xdiff_view (const char *file1, const char *file2)
{
    int error;
    WDiff *view;
    WButtonBar *bar;
    Dlg_head *view_dlg;

    /* Create dialog and widgets, put them on the dialog */
    view_dlg =
	create_dlg(0, 0, LINES, COLS, NULL, view_dialog_callback,
		   "[Binary Diff Viewer]", NULL, DLG_WANT_TAB);

    view = g_new0(WDiff, 1);

    init_widget(&view->widget, 0, 0, LINES - 1, COLS,
		(callback_fn)view_callback,
		(mouse_h)view_event);

    widget_want_cursor(view->widget, 0);

    bar = buttonbar_new(1);

    add_widget(view_dlg, bar);
    add_widget(view_dlg, view);

    error = view_init(view, file1, file2);

    /* Please note that if you add another widget,
     * you have to modify view_adjust_size to
     * be aware of it
     */
    if (!error) {
	run_dlg(view_dlg);
	view_search(view, -1);
	view_fini(view, 1);
    }
    destroy_dlg(view_dlg);

    return error;
}
Exemplo n.º 14
0
Arquivo: tree.c Projeto: ryanlee/mc
WTree *
tree_new (int y, int x, int lines, int cols, gboolean is_panel)
{
    WTree *tree = g_new (WTree, 1);

    init_widget (&tree->widget, y, x, lines, cols, tree_callback, tree_event);
    tree->is_panel = is_panel;
    tree->selected_ptr = 0;

    tree->store = tree_store_get ();
    tree_store_add_entry_remove_hook (remove_callback, tree);
    tree->tree_shown = 0;
    tree->search_buffer[0] = 0;
    tree->topdiff = tree->widget.lines / 2;
    tree->searching = 0;
    tree->active = 0;

    /* We do not want to keep the cursor */
    widget_want_cursor (tree->widget, 0);
    load_tree (tree);
    return tree;
}
Exemplo n.º 15
0
Arquivo: groupbox.c Projeto: artzub/mc
WGroupbox *
groupbox_new (int y, int x, int height, int width, const char *title)
{
    WGroupbox *g;

    g = g_new (WGroupbox, 1);
    init_widget (&g->widget, y, x, height, width, groupbox_callback, NULL);

    widget_want_cursor (g->widget, FALSE);
    widget_want_hotkey (g->widget, FALSE);

    /* Strip existing spaces, add one space before and after the title */
    if (title != NULL)
    {
        char *t;

        t = g_strstrip (g_strdup (title));
        g->title = g_strconcat (" ", t, " ", (char *) NULL);
        g_free (t);
    }

    return g;
}
Exemplo n.º 16
0
static gboolean plugin_load(PurplePlugin *plugin)
{
  /* connect construction signal only when needed
     as when installing the plugin after launching
     pidgin there is no need to wait for blist
     creation */
  if(is_gtk_blist_created()) {
    /* create widget and
       load preferences */
    create_widget();
    init_widget();
  }
  else
    /* connect construction signal */
    purple_signal_connect(pidgin_blist_get_handle(),
                          "gtkblist-created",
                          plugin,
                          PURPLE_CALLBACK(cb_blist_created),
                          NULL);

  purple_debug_info(NAME,"plugin initialized...\n");

  return TRUE;
}