static void create_panel(struct wl_client * client, struct wl_resource * resource, uint32_t id, struct wl_resource * surface_resource) { struct swc_surface * surface = wl_resource_get_user_data(surface_resource); if (!panel_new(client, wl_resource_get_version(resource), id, surface)) wl_client_post_no_memory(client); }
static Widget * restore_into_right_dir_panel (int idx, Widget * from_widget) { Widget *new_widget = NULL; const char *saved_dir = panels[idx].last_saved_dir; gboolean last_was_panel = (from_widget && get_display_type (idx) != view_listing); const char *p_name = get_nth_panel_name (idx); if (last_was_panel) new_widget = (Widget *) panel_new_with_dir (p_name, saved_dir); else new_widget = (Widget *) panel_new (p_name); return new_widget; }
static Widget * restore_into_right_dir_panel (int idx, Widget * from_widget) { WPanel *new_widget; const char *saved_dir = panels[idx].last_saved_dir; gboolean last_was_panel = (from_widget && get_display_type (idx) != view_listing); const char *p_name = get_nth_panel_name (idx); if (last_was_panel) { vfs_path_t *saved_dir_vpath; saved_dir_vpath = vfs_path_from_str (saved_dir); new_widget = panel_new_with_dir (p_name, saved_dir_vpath); vfs_path_free (saved_dir_vpath); } else new_widget = panel_new (p_name); return WIDGET (new_widget); }
/** * Create new window with specified caption and position * * @param __name - name of widget * @param __caption - caption of window * @param __x, __y - coordinates of window * @param __w, __h - width and height of window * @return a pointer to window object */ w_window_t* widget_create_window (const wchar_t *__name, const wchar_t *__caption, int __x, int __y, int __w, int __h, unsigned int __style) { w_window_t *res; window_context = hotkey_create_context (L"window-class-context", HKCF_OPAQUE); if (__style & WMS_CENTERED) { __x = CENTRE_X (__w); __y = CENTRE_Y (__h); } WIDGET_INIT (res, w_window_t, WT_WINDOW, __name, 0, 0, window_context, window_destructor, window_drawer, __x, __y, 0, __w, __h); if (__caption) { res->caption.text = wcsdup (__caption); } res->panel = panel_new (res->layout); res->style = __style; /* Layout parameters */ res->font = FONT (CID_BLACK, CID_GREY); res->caption.font = FONT (CID_BLUE, CID_GREY); WIDGET_CALLBACK (res, keydown) = (widget_keydown_proc) window_keydown; WIDGET_CALLBACK (res, onresize) = (widget_action) window_onresize; return res; }
static void _start_panels_from_dir(const char *panel_dir) { GDir* dir = g_dir_open( panel_dir, 0, NULL ); const gchar* name; if( ! dir ) { return; } while((name = g_dir_read_name(dir)) != NULL) { char* panel_config = g_build_filename( panel_dir, name, NULL ); if (strchr(panel_config, '~') == NULL) /* Skip editor backup files in case user has hand edited in this directory */ { LXPanel* panel = panel_new( panel_config, name ); if( panel ) all_panels = g_slist_prepend( all_panels, panel ); } g_free( panel_config ); } g_dir_close( dir ); }
/* since a lot of routines depend on the current_panel variable */ void set_display_type (int num, int type) { int x, y, cols, lines; int the_other; /* Index to the other panel */ char *file_name = 0; /* For Quick view */ Widget *new_widget, *old_widget; WPanel *the_other_panel; x =y = cols = lines = 0; old_widget = 0; if (num >= MAX_VIEWS){ fprintf (stderr, "Could not allocate more that %d views\n", MAX_VIEWS); abort (); } /* Check that we will have a WPanel * at least */ the_other = 0; if (type != view_listing){ the_other = num == 0 ? 1 : 0; if (panels [the_other].type != view_listing) return; } /* Get rid of it */ if (panels [num].widget){ Widget *w = panels [num].widget; WPanel *panel = (WPanel *) panels [num].widget; x = w->x; y = w->y; cols = w->cols; lines = w->lines; old_widget = panels [num].widget; if (panels [num].type == view_listing){ if (panel->frame_size == frame_full && type != view_listing){ cols = COLS - first_panel_size; if (num == 1) x = first_panel_size; } } #ifdef HAVE_TK tk_evalf ("container_clean %s", panel->widget.wcontainer); #endif } new_widget = 0; switch (type){ case view_listing: new_widget = (Widget *) panel_new (get_nth_panel_name (num)); break; case view_info: new_widget = (Widget *) info_new (); break; case view_tree: new_widget = (Widget *) tree_new (1, 0, 0, 0, 0); break; case view_quick: new_widget = (Widget *) view_new (0, 0, 0, 0, 1); the_other_panel = (WPanel *) panels [the_other].widget; if (the_other_panel) file_name = the_other_panel->dir.list[the_other_panel->selected].fname; else file_name = ""; view_init ((WView *) new_widget, 0, file_name, 0); break; } panels [num].type = type; panels [num].widget = (Widget *) new_widget; /* We set the same size the old widget had */ widget_set_size ((Widget *) new_widget, y, x, lines, cols); /* We wanna the new widget at the same position */ /* XView sets wcontainer to !0 <- Not XView, but we, when we create it */ /* Ok, the XView support code does it */ if (old_widget && old_widget->wcontainer){ new_widget->wcontainer = old_widget->wcontainer; new_widget->area = old_widget->area; } /* We use replace to keep the circular list of the dialog in the */ /* same state. Maybe we could just kill it and then replace it */ if (midnight_dlg && old_widget){ dlg_replace_widget (midnight_dlg, old_widget, panels [num].widget); } if (type == view_listing){ if (num == 0) left_panel = (WPanel *) new_widget; else right_panel = (WPanel *) new_widget; } if (type == view_tree) the_tree = (WTree *) new_widget; /* Prevent current_panel's value from becoming invalid. * It's just a quick hack to prevent segfaults. Comment out and * try following: * - select left panel * - invoke menue left/tree * - as long as you stay in the left panel almost everything that uses * cpanel causes segfault, e.g. C-Enter, C-x c, ... */ if (type != view_listing) if (cpanel == (WPanel *) old_widget) current_panel = num == 0 ? right_panel : left_panel; }