From dd496f4780ee58859da06a7679ea35714e498100 Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Mon, 7 May 2012 08:53:13 +0000 Subject: [PATCH] Make dialog-like windows centered. Work on implementing missing ede-desktop functions --- data/desktop-links/ede-xterm.desktop | 4 +- ede-about/ede-about.cpp | 16 +++-- ede-bell-conf/ede-bell-conf.cpp | 3 + ede-desktop-conf/ede-desktop-conf.cpp | 2 + ede-desktop/DesktopIcon.cpp | 12 +++- ede-desktop/IconDialog.cpp | 9 +++ ede-desktop/Jamfile | 3 +- ede-desktop/ede-desktop.cpp | 70 +++++++++++-------- ede-desktop/ede-desktop.h | 5 +- ede-keyboard-conf/ede-keyboard-conf.cpp | 3 + ede-panel/applets/taskbar/Taskbar.cpp | 9 +-- ede-screensaver-conf/ede-screensaver-conf.cpp | 4 ++ 12 files changed, 91 insertions(+), 49 deletions(-) diff --git a/data/desktop-links/ede-xterm.desktop b/data/desktop-links/ede-xterm.desktop index a322681..b9a1e8a 100644 --- a/data/desktop-links/ede-xterm.desktop +++ b/data/desktop-links/ede-xterm.desktop @@ -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 diff --git a/ede-about/ede-about.cpp b/ede-about/ede-about.cpp index 7636900..4872304 100644 --- a/ede-about/ede-about.cpp +++ b/ede-about/ede-about.cpp @@ -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 #include +#include #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(); } diff --git a/ede-bell-conf/ede-bell-conf.cpp b/ede-bell-conf/ede-bell-conf.cpp index 6534e45..4ca9dc4 100644 --- a/ede-bell-conf/ede-bell-conf.cpp +++ b/ede-bell-conf/ede-bell-conf.cpp @@ -23,9 +23,11 @@ #include #include +#include #include #include +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); } diff --git a/ede-desktop-conf/ede-desktop-conf.cpp b/ede-desktop-conf/ede-desktop-conf.cpp index e06e9c3..61d8097 100644 --- a/ede-desktop-conf/ede-desktop-conf.cpp +++ b/ede-desktop-conf/ede-desktop-conf.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -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(); } diff --git a/ede-desktop/DesktopIcon.cpp b/ede-desktop/DesktopIcon.cpp index f1d3399..1a02958 100644 --- a/ede-desktop/DesktopIcon.cpp +++ b/ede-desktop/DesktopIcon.cpp @@ -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) : diff --git a/ede-desktop/IconDialog.cpp b/ede-desktop/IconDialog.cpp index 006a586..8f02e81 100644 --- a/ede-desktop/IconDialog.cpp +++ b/ede-desktop/IconDialog.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -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(); } diff --git a/ede-desktop/Jamfile b/ede-desktop/Jamfile index 6dac854..9db6184 100644 --- a/ede-desktop/Jamfile +++ b/ede-desktop/Jamfile @@ -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) ; diff --git a/ede-desktop/ede-desktop.cpp b/ede-desktop/ede-desktop.cpp index bd49193..0aecb83 100644 --- a/ede-desktop/ede-desktop.cpp +++ b/ede-desktop/ede-desktop.cpp @@ -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; } diff --git a/ede-desktop/ede-desktop.h b/ede-desktop/ede-desktop.h index bdcfec9..25adeee 100644 --- a/ede-desktop/ede-desktop.h +++ b/ede-desktop/ede-desktop.h @@ -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(); } diff --git a/ede-keyboard-conf/ede-keyboard-conf.cpp b/ede-keyboard-conf/ede-keyboard-conf.cpp index 663e8d9..1276288 100644 --- a/ede-keyboard-conf/ede-keyboard-conf.cpp +++ b/ede-keyboard-conf/ede-keyboard-conf.cpp @@ -34,6 +34,7 @@ EDELIB_NS_USING(alert) #include #include +#include #include #include #include @@ -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(); diff --git a/ede-panel/applets/taskbar/Taskbar.cpp b/ede-panel/applets/taskbar/Taskbar.cpp index df23050..d8067ca 100644 --- a/ede-panel/applets/taskbar/Taskbar.cpp +++ b/ede-panel/applets/taskbar/Taskbar.cpp @@ -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); diff --git a/ede-screensaver-conf/ede-screensaver-conf.cpp b/ede-screensaver-conf/ede-screensaver-conf.cpp index eae061a..814542f 100644 --- a/ede-screensaver-conf/ede-screensaver-conf.cpp +++ b/ede-screensaver-conf/ede-screensaver-conf.cpp @@ -26,11 +26,14 @@ #include #include +#include #include #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();