Enlightenment CVS committal Author : balony Project : e17 Module : proto
Dir : e17/proto/exhibit/src/bin Modified Files: exhibit.h exhibit_image.c exhibit_image.h exhibit_main.c exhibit_menus.c exhibit_menus.h exhibit_options.c Log Message: - run in menu is not generated and usable from options. - rename function implemented =================================================================== RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit.h,v retrieving revision 1.29 retrieving revision 1.30 diff -u -3 -r1.29 -r1.30 --- exhibit.h 13 Aug 2006 16:51:13 -0000 1.29 +++ exhibit.h 13 Aug 2006 20:04:43 -0000 1.30 @@ -191,7 +191,12 @@ Etk_Widget *resbar; Etk_Widget *zoombar; Etk_Widget *menu; - Etk_Widget *win; + Etk_Widget *win; + Etk_Widget *app1_menu; + Etk_Widget *app2_menu; + Etk_Widget *app3_menu; + Etk_Widget *app4_menu; + Etk_Widget *submenu; int zoom; int brightness; =================================================================== RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_image.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -3 -r1.30 -r1.31 --- exhibit_image.c 11 Aug 2006 02:30:57 -0000 1.30 +++ exhibit_image.c 13 Aug 2006 20:04:43 -0000 1.31 @@ -739,13 +739,94 @@ */ } + +static void +_ex_image_rename_dialog_response(Etk_Object *obj, int response_id, void *data) +{ + const char *string; + char *newpath; + char *oldpath; + int ret; + Ex_Tab *tab = e->cur_tab; + + switch(response_id) + { + case ETK_RESPONSE_OK: + string = etk_entry_text_get(ETK_ENTRY(data)); + newpath = malloc(PATH_MAX); + oldpath = malloc(PATH_MAX); + sprintf(newpath, "%s%s", tab->set_img_path, string); + sprintf(oldpath, "%s%s", tab->set_img_path, tab->cur_file); + D(("Renaming from %s -> %s\n", oldpath, newpath)); + + ret = rename(oldpath, newpath); + if (ret == -1) + _ex_main_dialog_show("Error renaming file!", ETK_MESSAGE_DIALOG_ERROR); + else + { + _ex_main_image_unset(); + etk_tree_clear(ETK_TREE(tab->itree)); + etk_tree_clear(ETK_TREE(tab->dtree)); + _ex_main_populate_files(e, NULL); + } + + E_FREE(newpath); + E_FREE(oldpath); + break; + default: + break; + } + + etk_object_destroy(ETK_OBJECT(obj)); +} + +void +_ex_image_rename() +{ + Ex_Tab *tab = e->cur_tab; + Etk_Widget *dialog; + Etk_Widget *entry; + Etk_Widget *label; + char string[PATH_MAX]; + char labeltext[PATH_MAX + 100]; + + sprintf(string, "%s%s", tab->set_img_path, tab->cur_file); + dialog = etk_dialog_new(); + + sprintf(labeltext, "Rename file '%s'", string); + + label = etk_label_new(labeltext); + + etk_dialog_pack_in_main_area(ETK_DIALOG(dialog), ETK_WIDGET(label), + ETK_FALSE, ETK_FALSE, 5, ETK_FALSE); + + label = etk_label_new("New filename"); + etk_dialog_pack_in_main_area(ETK_DIALOG(dialog), ETK_WIDGET(label), + ETK_FALSE, ETK_FALSE, 2, ETK_FALSE); + + entry = etk_entry_new(); + + etk_dialog_pack_in_main_area(ETK_DIALOG(dialog), ETK_WIDGET(entry), + ETK_FALSE, ETK_FALSE, 0, ETK_FALSE); + + etk_dialog_button_add_from_stock(ETK_DIALOG(dialog), ETK_STOCK_DIALOG_OK, ETK_RESPONSE_OK); + etk_dialog_button_add_from_stock(ETK_DIALOG(dialog), ETK_STOCK_DIALOG_CANCEL, ETK_RESPONSE_CANCEL); + etk_signal_connect("response", ETK_OBJECT(dialog), + ETK_CALLBACK(_ex_image_rename_dialog_response), entry); + + etk_container_border_width_set(ETK_CONTAINER(dialog), 15); + etk_window_title_set(ETK_WINDOW(dialog), + _("Exhibit - rename")); + + etk_widget_show_all(dialog); +} + void _ex_image_run(const char *app) { Ecore_Exe *exe = NULL; char *tmp = NULL; - - D(("Application from menu: %s\n", app)); + char str[PATH_MAX]; tmp = malloc(PATH_MAX + 10); memset(tmp, 0, PATH_MAX + 10); @@ -753,12 +834,8 @@ if (!tmp) return; - if (!strcasecmp(app, "The Gimp")) - sprintf(tmp, "gimp %s%s", e->cur_tab->set_img_path, e->cur_tab->cur_file); - else if (!strcasecmp(app, "XV")) - sprintf(tmp, "xv %s%s", e->cur_tab->set_img_path, e->cur_tab->cur_file); - else if (!strcasecmp(app, "Xpaint")) - sprintf(tmp, "xpaint %s%s", e->cur_tab->set_img_path, e->cur_tab->cur_file); + sprintf(str, "%s%s", e->cur_tab->set_img_path, e->cur_tab->cur_file); + sprintf(tmp, app, str); if (strlen(tmp) <= 0) return; =================================================================== RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_image.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- exhibit_image.h 3 Aug 2006 13:12:17 -0000 1.10 +++ exhibit_image.h 13 Aug 2006 20:04:43 -0000 1.11 @@ -19,6 +19,7 @@ void _ex_image_save_as_cb(void *data); void _ex_image_save_as(Exhibit *e); void _ex_image_delete(Exhibit *e); +void _ex_image_rename(); void _ex_image_run(const char *app); void _ex_image_zoom(Etk_Image *im, int zoom); void _ex_image_brightness(Etk_Image *im, int brightness); =================================================================== RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_main.c,v retrieving revision 1.63 retrieving revision 1.64 diff -u -3 -r1.63 -r1.64 --- exhibit_main.c 11 Aug 2006 02:30:57 -0000 1.63 +++ exhibit_main.c 13 Aug 2006 20:04:43 -0000 1.64 @@ -718,13 +718,11 @@ /* Run in submenu */ menu_item = _ex_menu_item_new(EX_MENU_ITEM_NORMAL, _("Run in ..."), ETK_STOCK_APPLICATION_X_EXECUTABLE, ETK_MENU_SHELL(menu), ETK_CALLBACK(_ex_menu_run_in_cb), e); - submenu = etk_menu_new(); - etk_menu_item_submenu_set(ETK_MENU_ITEM(menu_item), ETK_MENU(submenu)); + e->submenu = etk_menu_new(); + etk_menu_item_submenu_set(ETK_MENU_ITEM(menu_item), ETK_MENU(e->submenu)); + + _ex_menu_build_run_menu(); - _ex_menu_item_new(EX_MENU_ITEM_NORMAL, _("The Gimp"), ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(submenu), ETK_CALLBACK(_ex_menu_run_in_cb), NULL); - _ex_menu_item_new(EX_MENU_ITEM_NORMAL, _("XV"), ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(submenu), ETK_CALLBACK(_ex_menu_run_in_cb), NULL); - _ex_menu_item_new(EX_MENU_ITEM_NORMAL, _("Xpaint"), ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(submenu), ETK_CALLBACK(_ex_menu_run_in_cb), NULL); - /* Continue "Edit" menu */ _ex_menu_item_new(EX_MENU_ITEM_SEPERATOR, NULL, ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(menu), NULL, NULL); _ex_menu_item_new(EX_MENU_ITEM_NORMAL, _("Rotate clockwise"), ETK_STOCK_GO_NEXT, ETK_MENU_SHELL(menu), ETK_CALLBACK(_ex_menu_rot_clockwise_cb), e); =================================================================== RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_menus.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -3 -r1.26 -r1.27 --- exhibit_menus.c 10 Aug 2006 17:05:48 -0000 1.26 +++ exhibit_menus.c 13 Aug 2006 20:04:43 -0000 1.27 @@ -18,6 +18,21 @@ "zoom_out" }; +void +_ex_menu_build_run_menu() +{ + + if (e->options->app1 && e->options->app1_cmd) + e->app1_menu = _ex_menu_item_new(EX_MENU_ITEM_NORMAL, _(e->options->app1), ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(e->submenu), ETK_CALLBACK(_ex_menu_run_in_cb), e->options->app1_cmd); + if (e->options->app2 && e->options->app2_cmd) + e->app2_menu = _ex_menu_item_new(EX_MENU_ITEM_NORMAL, _(e->options->app2), ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(e->submenu), ETK_CALLBACK(_ex_menu_run_in_cb), e->options->app2_cmd); + if (e->options->app3 && e->options->app3_cmd) + e->app3_menu = _ex_menu_item_new(EX_MENU_ITEM_NORMAL, _(e->options->app3), ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(e->submenu), ETK_CALLBACK(_ex_menu_run_in_cb), e->options->app3_cmd); + if (e->options->app4 && e->options->app4_cmd) + e->app4_menu = _ex_menu_item_new(EX_MENU_ITEM_NORMAL, _(e->options->app4), ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(e->submenu), ETK_CALLBACK(_ex_menu_run_in_cb), e->options->app4_cmd); + +} + Etk_Widget * _ex_menu_item_new(Ex_Menu_Item_Type item_type, const char *label, int stock_id, Etk_Menu_Shell *menu_shell, @@ -138,8 +153,13 @@ void _ex_menu_rename_cb(Etk_Object *obj, void *data) { + Exhibit *e = data; EX_MENU_ITEM_GET_RETURN(obj); - D(("rename\n")); + + if (!e->cur_tab->image_loaded) + return; + + _ex_image_rename(); } void @@ -187,14 +207,13 @@ void _ex_menu_run_in_cb(Etk_Object *obj, void *data) { - const char *app; + const char *cmd = data; EX_MENU_ITEM_GET_RETURN(obj); if (!e->cur_tab->image_loaded) return; - app = etk_menu_item_label_get(ETK_MENU_ITEM(obj)); - _ex_image_run(app); + _ex_image_run(cmd); } void =================================================================== RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_menus.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- exhibit_menus.h 3 Aug 2006 13:12:17 -0000 1.8 +++ exhibit_menus.h 13 Aug 2006 20:04:43 -0000 1.9 @@ -11,6 +11,8 @@ } Ex_Menu_Item_Type; Etk_Widget *_ex_menu_item_new(Ex_Menu_Item_Type item_type, const char *label, int stock_id, Etk_Menu_Shell *menu_shell, Etk_Signal_Callback_Function callback, void *data); + +void _ex_menu_build_run_menu(); void _ex_menu_new_window_cb(Etk_Object *obj, void *data); void _ex_menu_new_tab_cb(Etk_Object *obj, void *data); void _ex_menu_delete_tab_cb(Etk_Object *obj, void *data); =================================================================== RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_options.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -3 -r1.11 -r1.12 --- exhibit_options.c 13 Aug 2006 16:51:13 -0000 1.11 +++ exhibit_options.c 13 Aug 2006 20:04:43 -0000 1.12 @@ -485,8 +485,12 @@ APP_NEW(dialog->app4, e->options->app4); APP_NEW(dialog->app4_cmd, e->options->app4_cmd); - /* - Rebuild menus with settings */ - + /* Rebuild the possible new menu */ + etk_menu_shell_remove(ETK_MENU_SHELL(e->submenu), ETK_MENU_ITEM(e->app1_menu)); + etk_menu_shell_remove(ETK_MENU_SHELL(e->submenu), ETK_MENU_ITEM(e->app2_menu)); + etk_menu_shell_remove(ETK_MENU_SHELL(e->submenu), ETK_MENU_ITEM(e->app3_menu)); + etk_menu_shell_remove(ETK_MENU_SHELL(e->submenu), ETK_MENU_ITEM(e->app4_menu)); + _ex_menu_build_run_menu(); } static Etk_Widget * ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs