Make dialog-like windows centered. Work on implementing missing ede-desktop functions

This commit is contained in:
Sanel Zukan 2012-05-07 08:53:13 +00:00
parent 27b8bd888a
commit dd496f4780
12 changed files with 91 additions and 49 deletions

View File

@ -2,8 +2,8 @@
Version=1.0
Type=Application
Encoding=UTF-8
Exec=xterm -fn 9x15
Exec=ede-launch --launch terminal
Icon=utilities-terminal
Categories=Utility;
Name=Terminal
Comment=Standard X11 terminal
Comment=X11 terminal

View File

@ -3,7 +3,7 @@
*
* Eabout, display version and authors
* Part of Equinox Desktop Environment (EDE).
* Copyright (c) 2008-2011 EDE Authors.
* Copyright (c) 2008-2012 EDE Authors.
*
* This program is licensed under terms of the
* GNU General Public License version 2 or newer.
@ -26,8 +26,11 @@
#include <FL/Fl_Pixmap.H>
#include <edelib/Ede.h>
#include <edelib/WindowUtils.h>
#include "icons/ede.xpm"
EDELIB_NS_USING(window_center_on_screen)
static Fl_Pixmap image_ede((const char**)ede_xpm);
Fl_Window* win;
@ -39,9 +42,9 @@ Fl_Text_Display::Style_Table_Entry style_table[] = {
};
const char* content = "\n\
Heads:\n\n\
Sanel Zukan (karijes@equinox-project.org)\n\
Vedran Ljubovic (vljubovic@equinox-project.org)\n\
Developers:\n\n\
Sanel Zukan (karijes@users.sf.net)\n\
Vedran Ljubovic (vljubovic@users.sf.net)\n\
\n\
Contributors:\n\n\
(to be added)\n\
@ -87,7 +90,7 @@ const char* content = "\n\
Cambridge, MA 02139, USA";
const char* bold_keywords[] = {
"Heads:",
"Developers:",
"Contributors:",
"Past developers:",
"Patches in 1.x series by:",
@ -138,7 +141,7 @@ int main(int argc, char **argv) {
ede_label_box->labelfont(1);
ede_label_box->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
Fl_Box* ede_copy_box = new Fl_Box(70, 35, 300, 25, "Copyright (c) by EDE Authors 2000-2011");
Fl_Box* ede_copy_box = new Fl_Box(70, 35, 300, 25, "Copyright (c) by EDE Authors 2000-2012");
ede_copy_box->labelsize(11);
ede_copy_box->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_TOP);
@ -175,6 +178,7 @@ int main(int argc, char **argv) {
Fl_Group::current()->resizable(rbox2);
win->end();
window_center_on_screen(win);
win->show(argc, argv);
return Fl::run();
}

View File

@ -23,9 +23,11 @@
#include <FL/Fl_Value_Slider.H>
#include <edelib/Window.h>
#include <edelib/WindowUtils.h>
#include <edelib/XSettingsClient.h>
#include <edelib/Ede.h>
EDELIB_NS_USING(window_center_on_screen)
EDELIB_NS_USING(XSettingsClient)
EDELIB_NS_USING(XSettingsAction)
EDELIB_NS_USING(XSettingsSetting)
@ -165,6 +167,7 @@ static void window_create(int argc, char** argv) {
Fl_Button* test = new Fl_Button(10, 175, 90, 25, _("&Test"));
test->callback(test_cb);
win->end();
window_center_on_screen(win);
win->show(argc, argv);
}

View File

@ -35,6 +35,7 @@
#include <edelib/Color.h>
#include <edelib/Window.h>
#include <edelib/WindowUtils.h>
#include <edelib/Resource.h>
#include <edelib/Debug.h>
#include <edelib/Util.h>
@ -475,6 +476,7 @@ int main(int argc, char** argv) {
cancel->callback(close_cb, win);
win->end();
load_settings();
edelib::window_center_on_screen(win);
win->show(argc, argv);
return Fl::run();
}

View File

@ -30,7 +30,6 @@
#include "ede-desktop.h"
#include "DesktopIcon.h"
#include "MovableIcon.h"
#include "IconProperties.h"
#include "Utils.h"
/* minimal icon sizes */
@ -51,15 +50,18 @@ EDELIB_NS_USING(MenuButton)
EDELIB_NS_USING(ICON_SIZE_HUGE)
EDELIB_NS_USING(ICON_SIZE_TINY)
EDELIB_NS_USING(input)
EDELIB_NS_USING(ask)
EDELIB_NS_USING(run_async)
static void open_cb(Fl_Widget*, void* d);
static void rename_cb(Fl_Widget*, void* d);
static void delete_cb(Fl_Widget*, void* d);
static void props_cb(Fl_Widget*, void* d);
static MenuItem icon_menu[] = {
{_("&Open"), 0, open_cb, 0},
{_("&Rename"), 0, rename_cb, 0},
{_("&Delete"), 0, delete_cb, 0, FL_MENU_DIVIDER},
{_("&Properties"), 0, props_cb, 0},
{0}
};
@ -85,9 +87,15 @@ static void rename_cb(Fl_Widget*, void* d) {
di->rename(new_name);
}
static void delete_cb(Fl_Widget*, void* d) {
DesktopIcon* di = (DesktopIcon*)d;
if(ask(_("This icon will be permanently deleted. Proceed?")))
Desktop::instance()->remove_icon(di, true);
}
static void props_cb(Fl_Widget*, void* d) {
DesktopIcon* di = (DesktopIcon*)d;
show_icon_properties_dialog(di);
}
DesktopIcon::DesktopIcon(GlobalIconSettings* gs, IconSettings* is, int bg) :

View File

@ -17,6 +17,7 @@
#include <FL/Fl_Button.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Choice.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/Fl_Shared_Image.H>
#include <edelib/Nls.h>
@ -44,6 +45,12 @@ static Fl_Input *name, *comment, *execute;
static Fl_Choice *icon_type;
static String img_path;
/* the only supported type for now is application */
static Fl_Menu_Item menu_items[] = {
{_("Application"), 0, 0, 0},
{0}
};
static bool is_empty(const char *str) {
if(!str) return true;
const char *p = str;
@ -155,12 +162,14 @@ void icon_dialog_icon_create(void) {
browse = new Fl_Button(395, 70, 25, 25, "...");
icon_type = new Fl_Choice(205, 100, 215, 25, _("Type:"));
icon_type->down_box(FL_BORDER_BOX);
icon_type->menu(menu_items);
ok = new Fl_Button(235, 135, 90, 25, _("&OK"));
ok->callback(ok_cb);
cancel = new Fl_Button(330, 135, 90, 25, _("&Cancel"));
cancel->callback(cancel_cb);
win->end();
win->set_modal();
win->show();
}

View File

@ -17,8 +17,7 @@ SOURCE = ede-desktop.cpp
Wallpaper.cpp
DesktopIcon.cpp
MovableIcon.cpp
IconDialog.cpp
IconProperties.cpp ;
IconDialog.cpp ;
ObjectC++Flags $(SOURCE) : $(EDELIB_DBUS_INCLUDE) ;

View File

@ -74,6 +74,8 @@
EDELIB_NS_USING(MenuItem)
EDELIB_NS_USING(String)
EDELIB_NS_USING(DesktopFile)
EDELIB_NS_USING(DirWatch)
EDELIB_NS_USING(Resource)
EDELIB_NS_USING(run_async)
EDELIB_NS_USING(input)
EDELIB_NS_USING(alert)
@ -89,9 +91,18 @@ EDELIB_NS_USING(netwm_window_set_type)
EDELIB_NS_USING(netwm_callback_add)
EDELIB_NS_USING(netwm_callback_remove)
EDELIB_NS_USING(font_cache_find)
EDELIB_NS_USING(file_test)
EDELIB_NS_USING(dir_home)
EDELIB_NS_USING(build_filename)
EDELIB_NS_USING(FILE_TEST_IS_DIR)
EDELIB_NS_USING(FILE_TEST_IS_REGULAR)
EDELIB_NS_USING(NETWM_WINDOW_TYPE_DESKTOP)
EDELIB_NS_USING(NETWM_CHANGED_CURRENT_WORKAREA)
EDELIB_NS_USING(NETWM_CHANGED_CURRENT_WORKSPACE)
EDELIB_NS_USING(DW_CREATE)
EDELIB_NS_USING(DW_MODIFY)
EDELIB_NS_USING(DW_RENAME)
EDELIB_NS_USING(DW_DELETE)
static void background_conf_cb(Fl_Widget*, void*);
static void icons_conf_cb(Fl_Widget*, void*);
@ -148,8 +159,8 @@ static void folder_create_cb(Fl_Widget*, void*) {
const char *n = input(_("New folder with name"));
if(!n) return;
String h = edelib::dir_home();
String dp = edelib::build_filename(h.c_str(), "Desktop", n);
String h = dir_home();
String dp = build_filename(h.c_str(), "Desktop", n);
if(!dir_create(dp.c_str()))
alert(_("Unable to create directory '%s'! Please check if directory already exists or you have enough permissions to create it"), dp.c_str());
@ -210,13 +221,11 @@ Desktop::~Desktop() {
delete selbox;
delete dbus;
edelib::DirWatch::shutdown();
DirWatch::shutdown();
foreign_callback_remove(settings_changed_cb);
}
void Desktop::init_internals(void) {
String p;
update_workarea();
/*
@ -242,25 +251,22 @@ void Desktop::init_internals(void) {
/* read main config */
read_config();
/* location of Desktop folder */
desktop_dir_path = build_filename(dir_home().c_str(), "Desktop");
/* now try to load icons from "Desktop" directory */
p = edelib::dir_home();
String desktop_path = edelib::build_filename(p.c_str(), "Desktop");
if(file_test(desktop_dir_path.c_str(), FILE_TEST_IS_DIR)) {
/* now try load icons from "Desktop" directory */
load_icons(desktop_dir_path.c_str());
/* setup watcher used for Desktop directory */
edelib::DirWatch::init();
/* setup watcher used for Desktop directory */
DirWatch::init();
if(edelib::file_test(desktop_path.c_str(), edelib::FILE_TEST_IS_DIR)) {
load_icons(desktop_path.c_str());
if(!edelib::DirWatch::add(desktop_path.c_str(),
edelib::DW_CREATE | edelib::DW_MODIFY | edelib::DW_RENAME | edelib::DW_DELETE))
{
E_WARNING(E_STRLOC ": Unable to watch %s\n", desktop_path.c_str());
}
if(!DirWatch::add(desktop_dir_path.c_str(), DW_CREATE | DW_MODIFY | DW_RENAME | DW_DELETE))
E_WARNING(E_STRLOC ": Unable to watch %s\n", desktop_dir_path.c_str());
else
DirWatch::callback(dir_watch_cb);
}
edelib::DirWatch::callback(dir_watch_cb);
running = true;
}
@ -309,7 +315,7 @@ void Desktop::update_workarea(void) {
}
void Desktop::read_config(void) {
edelib::Resource conf;
Resource conf;
if(!conf.load(CONFIG_NAME)) {
E_WARNING(E_STRLOC ": Can't load %s, using default values\n", CONFIG_NAME);
@ -372,7 +378,7 @@ void Desktop::read_config(void) {
void Desktop::load_icons(const char* path) {
E_ASSERT(path != NULL);
edelib::Resource conf, *conf_ptr = NULL;
Resource conf, *conf_ptr = NULL;
if(!conf.load(ICONS_CONFIG_NAME))
E_WARNING(E_STRLOC ": Can't load icons positions; arranging them somehow...\n");
@ -397,7 +403,7 @@ void Desktop::load_icons(const char* path) {
}
void Desktop::save_icons_positions(void) {
edelib::Resource conf;
Resource conf;
char* icon_base;
DesktopIconListIter it = icons.begin(), it_end = icons.end();
@ -472,7 +478,7 @@ IconSettings* Desktop::read_desktop_file(const char* path) {
return is;
}
bool Desktop::add_icon_by_path(const char* path, edelib::Resource* conf) {
bool Desktop::add_icon_by_path(const char* path, Resource* conf) {
E_ASSERT(path != NULL);
IconSettings* is = NULL;
@ -561,12 +567,17 @@ DesktopIcon* Desktop::find_icon_by_path(const char* path, DesktopIconListIter* r
return NULL;
}
bool Desktop::remove_icon(DesktopIcon *d, bool real_delete) {
bool ret = remove_icon_by_path(d->path().c_str());
return ret;
}
bool Desktop::remove_icon_by_path(const char* path) {
DesktopIconListIter pos;
DesktopIcon* ic = find_icon_by_path(path, &pos);
if(!ic) {
E_DEBUG(">>> Didn't find %s\n", path);
E_DEBUG(E_STRLOC ": Didn't find '%s' as path marked for removal\n", path);
return false;
}
@ -752,13 +763,13 @@ void Desktop::select_in_area(void) {
if(intersects(ax, ay, ax+aw, ay+ah, ic->x(), ic->y(), ic->w()+ic->x(), ic->h()+ic->y())) {
if(!ic->is_focused()) {
ic->do_focus();
// updated from Desktop::draw()
/* updated from Desktop::draw() */
ic->damage(EDAMAGE_CHILD_LABEL);
}
} else {
if(ic->is_focused()) {
ic->do_unfocus();
// updated from Desktop::draw()
/* updated from Desktop::draw() */
ic->fast_redraw();
//ic->damage(EDAMAGE_CHILD_LABEL);
//ic->redraw();
@ -794,6 +805,8 @@ void Desktop::notify_desktop_changed(void) {
XFreeStringList(names);
}
/* leaving for the future */
#if 0
void Desktop::dnd_drop_source(const char* src, int src_len, int x, int y) {
if(!src)
return;
@ -831,7 +844,7 @@ void Desktop::dnd_drop_source(const char* src, int src_len, int x, int y) {
else
sptr = src_copy;
if(!edelib::file_test(sptr, edelib::FILE_TEST_IS_REGULAR) || !edelib::file_test(sptr, edelib::FILE_TEST_IS_DIR)) {
if(!file_test(sptr, FILE_TEST_IS_REGULAR) || !file_test(sptr, FILE_TEST_IS_DIR)) {
edelib::message("Droping file content is not implemented yet ;)");
delete [] src_copy;
return;
@ -900,6 +913,7 @@ void Desktop::dnd_drop_source(const char* src, int src_len, int x, int y) {
redraw();
}
#endif
void Desktop::draw(void) {
if(!damage())
@ -1124,7 +1138,7 @@ int Desktop::handle(int event) {
if(di)
return di->handle(event);
dnd_drop_source(Fl::event_text(), Fl::event_length(), Fl::event_x(), Fl::event_y());
//dnd_drop_source(Fl::event_text(), Fl::event_length(), Fl::event_x(), Fl::event_y());
return 1;
}

View File

@ -101,6 +101,8 @@ private:
bool moving;
bool do_dirwatch;
edelib::String desktop_dir_path;
SelectionOverlay* selbox;
GlobalIconSettings* gisett;
@ -134,7 +136,7 @@ private:
void select_in_area(void);
void dnd_drop_source(const char* src, int src_len, int x, int y);
//void dnd_drop_source(const char* src, int src_len, int x, int y);
DesktopIcon* below_mouse(int px, int py);
@ -154,6 +156,7 @@ public:
void read_config(void);
bool add_icon_by_path(const char* path, edelib::Resource* conf);
bool remove_icon(DesktopIcon *d, bool real_delete);
void update_workarea(void);
void area(int& X, int& Y, int& W, int& H) { X = x(); Y = y(); W = w(); H = h(); }

View File

@ -34,6 +34,7 @@ EDELIB_NS_USING(alert)
#include <X11/extensions/XKBrules.h>
#include <edelib/Window.h>
#include <edelib/WindowUtils.h>
#include <edelib/Debug.h>
#include <edelib/String.h>
#include <edelib/Resource.h>
@ -52,6 +53,7 @@ EDELIB_NS_USING(Resource)
EDELIB_NS_USING(file_path)
EDELIB_NS_USING(run_sync)
EDELIB_NS_USING(foreign_callback_call)
EDELIB_NS_USING(window_center_on_screen)
static AppWindow *win;
static Fl_Hold_Browser *layout_browser;
@ -299,6 +301,7 @@ int main(int argc, char **argv) {
/* read all XKB layouts */
XkbRF_RulesPtr xkb_rules = fetch_all_layouts(cl);
window_center_on_screen(win);
win->show(argc, argv);
Fl::run();

View File

@ -71,10 +71,6 @@ Taskbar::Taskbar() : Fl_Group(0, 0, 40, 25), curr_active(NULL), prev_active(NULL
end();
panel = EDE_PANEL_GET_PANEL_OBJECT(this);
/* assure display is openned */
fl_open_display();
create_task_buttons();
netwm_callback_add(net_event_cb, this);
}
@ -128,10 +124,7 @@ void Taskbar::create_task_buttons(void) {
b->update_title_from_xid();
b->update_image_from_xid();
/*
* catch the name changes
* TODO: put this in Netwm.{h,cpp}
*/
/* catch the name changes */
XSelectInput(fl_display, wins[i], PropertyChangeMask | StructureNotifyMask);
b->callback((Fl_Callback*)button_cb, this);

View File

@ -26,11 +26,14 @@
#include <FL/x.H>
#include <edelib/Debug.h>
#include <edelib/WindowUtils.h>
#include <edelib/Ede.h>
#include "XScreenSaver.h"
#include "icons/energy.xpm"
EDELIB_NS_USING(window_center_on_screen)
static Fl_Pixmap image_energy((const char**)energy_star_xpm);
static Fl_Spinner* standby_val;
@ -245,6 +248,7 @@ int main(int argc, char **argv) {
close_button->callback(close_cb);
main_win->end();
window_center_on_screen(main_win);
main_win->show(argc, argv);
/* run preview immediately */
saver_list->do_callback();