Enlightenment CVS committal

Author  : lordchaos
Project : e17
Module  : proto

Dir     : e17/proto/entropy/src/plugins


Modified Files:
        layout_ewl_simple.c structure_viewer.c 


Log Message:
* Cleanup for structure viewer
* Right click for structure viewer headers to edit/delete
* Core plugin destroy notify for layouts so we can save headers on shutdown

===================================================================
RCS file: 
/cvsroot/enlightenment/e17/proto/entropy/src/plugins/layout_ewl_simple.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -3 -r1.26 -r1.27
--- layout_ewl_simple.c 30 Dec 2005 23:16:26 -0000      1.26
+++ layout_ewl_simple.c 7 Jan 2006 08:21:01 -0000       1.27
@@ -7,13 +7,21 @@
 #include "ewl_mime_dialog.h"
 #include "entropy_gui.h"
 
-static Ewl_Widget* win;
-static Ecore_List* components;
+#define HEADER_CONFIG_MAX 2048
 
+static Ewl_Widget* win;
 void layout_ewl_simple_config_create(entropy_core* core);
 void layout_ewl_simple_add_header(entropy_gui_component_instance* instance, 
char* name, char* uri);
 void layout_ewl_simple_add_config_location(entropy_gui_component_instance* 
instance, char* name, char* uri);
 
+typedef struct entropy_ewl_layout_header_uri entropy_ewl_layout_header_uri;
+struct entropy_ewl_layout_header_uri {
+       Ewl_Widget* visual;
+       entropy_gui_component_instance* layout;
+       
+       char* uri;
+       char* header;
+};
 
 typedef struct entropy_layout_gui entropy_layout_gui;
 struct entropy_layout_gui {
@@ -22,18 +30,20 @@
        Ewl_Widget* tree;
        Ewl_Widget* paned;
        Ewl_Widget* local_container;
-       
        Ewl_Widget* context_menu;
        Ewl_Widget* context_menu_floater;
-       
        Ecore_List* current_folder;
        Ecore_List* local_components;
+       Ecore_Hash* headers;
+
+       entropy_ewl_layout_header_uri* active_header;
+
+       
 
 
        /*Tmp*/
        Ewl_Widget* samba_radio;
        Ewl_Widget* posix_radio;
-
        Ewl_Widget* location_add_window;
        Ewl_Widget* location_add_name;
        Ewl_Widget* location_add_path;
@@ -121,24 +131,34 @@
 
 }
 
+
+/*Header context menu*/
+void location_menu_popup_delete_cb(Ewl_Widget *label, void *ev_data, void 
*user_data) {
+       entropy_gui_component_instance* instance = user_data;
+       entropy_layout_gui* layout = instance->data;
+
+       printf("Destroying '%s' -> %p\n", 
EWL_WIDGET(layout->active_header->visual)->inheritance, 
layout->active_header->visual);
+       
+       ewl_widget_destroy(layout->active_header->visual);
+       ecore_hash_remove(layout->headers, layout->active_header->visual);
+}
+
 void location_menu_popup_cb(Ewl_Widget *label, void *ev_data, void *user_data) 
{
        Ewl_Event_Mouse_Down *ev = ev_data;
-       entropy_layout_gui* gui = user_data;
+       entropy_ewl_layout_header_uri* header = user_data;
        
        if (ev->button == 3) {
-               printf("Click at %d:%d\n", ev->x, ev->y);
-
-               ewl_widget_show(gui->context_menu_floater);
-               
ewl_floater_position_set(EWL_FLOATER(gui->context_menu_floater), ev->x, ev->y);
-
-               ewl_callback_call(EWL_WIDGET(gui->context_menu), 
EWL_CALLBACK_FOCUS_IN);
-       }
-
+               printf("Click at %d:%d for header %p and visual %p\n", ev->x, 
ev->y,header,header->visual);
        
+               ((entropy_layout_gui*)header->layout->data)->active_header = 
header;
 
-
-
+               ewl_widget_show( 
((entropy_layout_gui*)header->layout->data)->context_menu_floater);
+               
ewl_floater_position_set(EWL_FLOATER(((entropy_layout_gui*)header->layout->data)->context_menu_floater),
 ev->x, ev->y);
+               
ewl_callback_call(EWL_WIDGET(((entropy_layout_gui*)header->layout->data)->context_menu),
 EWL_CALLBACK_FOCUS_IN);
+       }
 }
+/*----------------*/
+
 
 
 void location_add_cb(Ewl_Widget *main_win, void *ev_data, void *user_data) {
@@ -298,9 +318,9 @@
 
 void layout_ewl_simple_add_config_location(entropy_gui_component_instance* 
instance, char* name, char* uri) {
        char* current_uri = entropy_config_str_get("layout_ewl_simple", 
"structure_bar");
-       char new_uri[2048];
+       char new_uri[HEADER_CONFIG_MAX];
 
-       snprintf(new_uri, 2048, "%s|%s;%s", current_uri, name, uri);
+       snprintf(new_uri, HEADER_CONFIG_MAX, "%s|%s;%s", current_uri, name, 
uri);
        entropy_config_str_set("layout_ewl_simple", "structure_bar", new_uri);
 
        entropy_free(current_uri);
@@ -308,11 +328,9 @@
 
 
 void layout_ewl_simple_config_create(entropy_core* core) {
-       char* eg = calloc(2048, sizeof(char)) ;
-
-       //printf("Setting config..\n");
+       char* eg = calloc(HEADER_CONFIG_MAX, sizeof(char)) ;
 
-       sprintf(eg, "Computer;posix:///|Home;posix://%s|Samba Example (Don't 
use!);smb://username:password@/test/machine/folder", 
+       snprintf(eg, HEADER_CONFIG_MAX, 
"Computer;posix:///|Home;posix://%s|Samba Example (Don't 
use!);smb://username:password@/test/machine/folder", 
                entropy_core_home_dir_get(core));
 
        //printf("Setting default config string..\n");
@@ -326,22 +344,25 @@
 
        Ewl_Widget* hbox;
        entropy_plugin* structure;
+       entropy_ewl_layout_header_uri* header = calloc(1, 
sizeof(entropy_ewl_layout_header_uri));
        void* (*structure_plugin_init)(entropy_core* core, 
entropy_gui_component_instance*, void* data);
-
        entropy_layout_gui* gui = ((entropy_layout_gui*)instance->data);
        Ewl_Widget* tree= gui->tree;
 
 
-       //printf("Add URI: %s\n", uri);
+
        hbox = ewl_border_new();
        ewl_border_text_set(EWL_BORDER(hbox), name);
-
-
-
-
-       
        ewl_container_child_append(EWL_CONTAINER(tree), hbox);
        ewl_widget_show(hbox);
+
+       header->header = strdup(name);
+       header->uri = strdup(uri);
+       header->visual = hbox;
+       header->layout = instance;
+       ecore_hash_set(gui->headers, hbox, header);
+       printf("Adding %p to header hash with visual %p\n", header, 
header->visual);
+
        
        
        /*Now attach an object to it*/
@@ -349,20 +370,12 @@
 
        if (structure) {
                Ewl_Widget* visual;
-
                entropy_generic_file* file = entropy_core_parse_uri(uri);
 
                /*Add the callback for the popup*/
-               ewl_callback_append(EWL_BORDER(hbox)->label, 
EWL_CALLBACK_MOUSE_DOWN, location_menu_popup_cb, gui);
-               
-
-               
-
-               /*Mark this file as a 'folder' - more of a bootstrap.  Should 
we really do this? FIXME*/
+               ewl_callback_append(EWL_BORDER(hbox)->label, 
EWL_CALLBACK_MOUSE_DOWN, location_menu_popup_cb, header);
                strcpy(file->mime_type, "file/folder");
 
-               //printf("***** Adding structure viewer\n");
-
                /*Main drive viewer*/
                {
                        structure_plugin_init = dlsym(structure->dl_ref, 
"entropy_plugin_init");
@@ -467,9 +480,7 @@
                        entropy_gui_component_instance_disable(iter);
 
                        if (EWL_WIDGET(iter->gui_object)->parent && 
EWL_WIDGET(iter->gui_object)->parent == layout->local_container) {
-                               
//ewl_container_child_remove(EWL_CONTAINER(layout->paned), 
EWL_WIDGET(iter->gui_object));
                                printf("Removed a local view..\n");
-
                                ewl_widget_hide(EWL_WIDGET(iter->gui_object));
                        }
                }
@@ -483,10 +494,6 @@
                
ewl_container_child_append(EWL_CONTAINER(layout->local_container), 
EWL_WIDGET(instance->gui_object));
 
        ewl_widget_show(EWL_WIDGET(instance->gui_object));
-
-
-
-               
 }
 
 
@@ -499,7 +506,30 @@
 
 
 void entropy_plugin_destroy(entropy_gui_component_instance* comp) {
-       //printf("Destroying layout...\n");
+       entropy_layout_gui* gui = comp->data;
+       Ecore_List* keys;
+       void* key;
+       char write_str[HEADER_CONFIG_MAX];
+
+       keys = ecore_hash_keys(gui->headers);
+       ecore_list_goto_first(keys);
+
+       bzero(write_str, HEADER_CONFIG_MAX);
+       while ( (key = ecore_list_remove_first(keys))) {
+               entropy_ewl_layout_header_uri* header = 
ecore_hash_get(gui->headers, key);
+               printf("Saving header '%s' with '%s'\n", header->header, 
header->uri);
+               strcat(write_str, header->header);
+               strcat(write_str, ";");
+               strcat(write_str, header->uri);
+               strcat(write_str, "|");
+       }
+
+       printf("Write string: '%s'\n", write_str);
+
+       entropy_config_str_set("layout_ewl_simple", "structure_bar", write_str);
+
+       
+       printf("Destroying layout...\n");
 }
 
 
@@ -507,7 +537,6 @@
        int i =0;
        char **c = NULL;
        /*Init ewl*/
-       components = ecore_list_new();
        ewl_init(&i, c);
 }
 
@@ -548,6 +577,7 @@
        layout->data = gui;
        layout->core = core;
        gui->local_components = ecore_list_new();
+       gui->headers = ecore_hash_new(ecore_direct_hash, ecore_direct_compare);
 
        /*Register this layout container with the core, so our children can get 
events*/
        entropy_core_layout_register(core, layout);
@@ -557,8 +587,6 @@
        local_plugins = entropy_plugins_type_get(ENTROPY_PLUGIN_GUI_COMPONENT, 
ENTROPY_PLUGIN_GUI_COMPONENT_LOCAL_VIEW);
        
        if (local_plugins) {
-               //printf("Plugin: %s\n", plugin->filename);
-               //
                while ((plugin = ecore_list_remove_first(local_plugins))) {
                        entropy_gui_component_instance* instance;
                        char* name = NULL;
@@ -581,9 +609,6 @@
                                
entropy_gui_component_instance_disable(instance);
                        }
 
-
-                       
-
                        /*Add this plugin to the local viewers list*/
                        ecore_list_append(gui->local_components, instance);
                }
@@ -592,8 +617,6 @@
                return NULL;
        }
 
-       //printf("Initialising simple EWL layout manager...\n");
-
        /*EWL Setup*/
        win= ewl_window_new();
        ewl_window_dnd_aware_set(EWL_WINDOW(win));
@@ -714,16 +737,13 @@
        item = ewl_menu_item_new();
        ewl_menu_item_text_set(EWL_MENU_ITEM(item), "Delete");
        ewl_container_child_append(EWL_CONTAINER(gui->context_menu), item);
+       ewl_callback_append(item, EWL_CALLBACK_CLICKED, 
location_menu_popup_delete_cb, layout);
        ewl_widget_show(item);
 
        ewl_widget_show(gui->context_menu);
 
        /*--------------------------*/
        
-       
-       
-
-
 
        ewl_container_child_append(EWL_CONTAINER(hbox), expand_button);
        ewl_container_child_append(EWL_CONTAINER(hbox), contract_button);
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/proto/entropy/src/plugins/structure_viewer.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -3 -r1.26 -r1.27
--- structure_viewer.c  3 Jan 2006 11:41:36 -0000       1.26
+++ structure_viewer.c  7 Jan 2006 08:21:01 -0000       1.27
@@ -32,11 +32,8 @@
        void* data;
 };
 
-void structure_viewer_add_row(entropy_gui_component_instance* instance, 
entropy_generic_file* file, Ewl_Row* prow);
-
-
-/*void entropy_gui_component_instance_destroy(entropy_gui_component* comp) {
-}*/
+void structure_viewer_add_row(entropy_gui_component_instance* instance, 
+       entropy_generic_file* file, Ewl_Row* prow);
 
 int entropy_plugin_type_get() {
         return ENTROPY_PLUGIN_GUI_COMPONENT;
@@ -54,16 +51,19 @@
        return itree;
 }*/
 
-void gui_event_callback(entropy_notify_event* eevent, void* requestor, void* 
el, entropy_gui_component_instance* comp) {
-   entropy_file_structure_viewer* viewer = 
(entropy_file_structure_viewer*)comp->data;
+void gui_event_callback(entropy_notify_event* eevent, void* requestor, 
+       void* el, entropy_gui_component_instance* comp) {
+       
+   entropy_file_structure_viewer* viewer = 
+       (entropy_file_structure_viewer*)comp->data;
 
    switch (eevent->event_type) {
        case ENTROPY_NOTIFY_FILE_REMOVE_DIRECTORY: {
                entropy_generic_file* event_file = (entropy_generic_file*)el;
        
-               printf("Received a remove directory notify at structure 
viewer\n");
-               
-               Ewl_Row* row = ecore_hash_get(viewer->row_folder_hash, 
event_file);
+               Ewl_Row* row = ecore_hash_get(viewer->row_folder_hash, 
+                       event_file);
+
                if (row) {
                        ewl_tree_row_destroy(EWL_TREE(viewer->tree), row);
                }
@@ -74,41 +74,40 @@
       case ENTROPY_NOTIFY_FILELIST_REQUEST: {
                                                          
        entropy_generic_file* file;
-       
-
-       /*We only want folder events from outselves, so leave otherwise..*/
-       //if (requestor != comp) {
-       //      return;
-       //}
-
-
-       entropy_generic_file* event_file = 
((entropy_file_request*)eevent->data)->file;
-       //printf("Looking for row for file %p (%s)\n", event_file, 
event_file->filename);
+       entropy_generic_file* event_file = 
+               ((entropy_file_request*)eevent->data)->file;
        
        Ewl_Row* row = ecore_hash_get(viewer->row_folder_hash, event_file);
-       /*printf ("   Got %p\n", row);*/
-
-       /*If we don't own this row, forget about doing something - we don't 
know about this*/
        
+       /*If we don't own this row, forget about doing something 
+        * - we don't know about this*/
        if (row && !ecore_hash_get(viewer->loaded_dirs, row)) {
 
 
                        ecore_list_goto_first(el);
                        while ( (file = ecore_list_next(el)) ) {
 
-                               /*We need the file's mime type, so get it here 
if it's not here already...*/
+                               /*We need the file's mime type, 
+                                * so get it here if it's not here already...*/
                                if (!strlen(file->mime_type)) {
-                                       
entropy_mime_file_identify(comp->core->mime_plugins, file);
+                                       entropy_mime_file_identify(
+                                       comp->core->mime_plugins, file);
                                }
                                
-                               if (file->filetype == FILE_FOLDER || 
entropy_core_descent_for_mime_get(comp->core, file->mime_type)  ) {
+                               if (file->filetype == FILE_FOLDER || 
+                                 entropy_core_descent_for_mime_get(comp->core, 
+                                 file->mime_type)  ) {
                                        char *c = entropy_malloc(sizeof(char));
                                        *c = 1;
 
-                                       /*Tell the core we're watching this 
file*/
-                                       
entropy_core_file_cache_add_reference(file->md5);
-                                       structure_viewer_add_row(comp, file, 
row);
-                                       ecore_hash_set(viewer->loaded_dirs, 
row, c);
+                                       /*Tell the core we're watching 
+                                        * this file*/
+                                       entropy_core_file_cache_add_reference(
+                                               file->md5);
+                                       structure_viewer_add_row(comp, file, 
+                                               row);
+                                       ecore_hash_set(viewer->loaded_dirs, 
+                                               row, c);
                                }
                        }
                /*ecore_list_destroy(el);*/
@@ -119,14 +118,10 @@
 
 
                /*Highlight this row*/
-               /*TODO Find some way to cleanly find the text member of the 
row*/
-               /*ewl_text_cursor_position_set(EWL_TEXT(row->data), 0);
-               ewl_text_color_apply(EWL_TEXT(event->data), 0, 0, 255, 255, 
ewl_text_length_get(EWL_TEXT(event->data)));
-               viewer->last_selected_label = event->data;*/
-
-               
+               /*TODO Find some way to cleanly find the 
+                * text member of the row*/
        } else {
-               /*printf("---------------------------------------------> This 
row already has children!!\n");*/
+               /*printf("-> This row already has children!!\n");*/
        }
       }
       break;
@@ -188,18 +183,30 @@
                                }
                        }
 
-                       //printf("Copy to folder '%s/%s'\n", event->file->path, 
event->file->filename);
                } else if (ewl_widget_type_is(widget, "row")) {
-                       entropy_generic_file* file = 
entropy_core_object_file_association_get(widget);
+                       entropy_generic_file* file = 
+                        entropy_core_object_file_association_get(widget);
+
                        entropy_plugin* plugin = 
-                               
entropy_plugins_type_get_first(ENTROPY_PLUGIN_BACKEND_FILE 
,ENTROPY_PLUGIN_SUB_TYPE_ALL);
-                       void (*copy_func)(entropy_generic_file* source, char* 
dest_uri, entropy_gui_component_instance* requester);
-                       copy_func = dlsym(plugin->dl_ref, 
"entropy_filesystem_file_copy");
+                               entropy_plugins_type_get_first(
+                               ENTROPY_PLUGIN_BACKEND_FILE ,
+                               ENTROPY_PLUGIN_SUB_TYPE_ALL);
+                       
+                       void (*copy_func)(entropy_generic_file* source, 
+                       char* dest_uri, 
+                       entropy_gui_component_instance* requester);
+
+                       copy_func = dlsym(plugin->dl_ref, 
+                               "entropy_filesystem_file_copy");
+                       
                        char* folder;
                        
                        if (file) {
-                               printf("Detected row drop.. 
(%s/%s)\n",file->path, file->filename);
-                               folder = 
entropy_core_generic_file_uri_create(event->file, 0);
+                               printf("Detected row drop.. (%s/%s)\n",
+                                       file->path, file->filename);
+                               
+                               folder = entropy_core_generic_file_uri_create(
+                                       event->file, 0);
 
                                (*copy_func)(file, folder, event->instance);
 
@@ -274,14 +281,16 @@
                row = ewl_tree_row_add(EWL_TREE(viewer->tree), prow, children);
 
                ewl_object_fill_policy_set(EWL_OBJECT(row), 
EWL_FLAG_FILL_VSHRINK | EWL_FLAG_FILL_HFILL);
+               ewl_object_custom_h_set(EWL_OBJECT(row), 15);
                ewl_widget_show(row);
 
                event = entropy_malloc(sizeof(event_file_core)); 
                event->file = file; /*Create a clone of this file, and add it 
to the event */
                event->instance = instance;
                event->data = label; /*So we can highlight the current 
directory*/
-               
-               ecore_list_append(viewer->files, event->file); /*Save this file 
in this list of files we're responsible for */
+       
+                /*Save this file in this list of files we're responsible for */
+               ecore_list_append(viewer->files, event->file);
                
 
                ewl_callback_append(label, EWL_CALLBACK_MOUSE_DOWN, 
row_clicked_callback, event);
@@ -320,9 +329,12 @@
        instance->layout_parent = layout;
 
        /*Register out interest in receiving folder notifications*/
-       entropy_core_component_event_register(instance, 
entropy_core_gui_event_get(ENTROPY_GUI_EVENT_FOLDER_CHANGE_CONTENTS));
-       entropy_core_component_event_register(instance, 
entropy_core_gui_event_get(ENTROPY_GUI_EVENT_FOLDER_CHANGE_CONTENTS_EXTERNAL));
-       entropy_core_component_event_register(instance, 
entropy_core_gui_event_get(ENTROPY_GUI_EVENT_FILE_REMOVE_DIRECTORY));
+       entropy_core_component_event_register(instance, 
+               
entropy_core_gui_event_get(ENTROPY_GUI_EVENT_FOLDER_CHANGE_CONTENTS));
+       entropy_core_component_event_register(instance, 
+               
entropy_core_gui_event_get(ENTROPY_GUI_EVENT_FOLDER_CHANGE_CONTENTS_EXTERNAL));
+       entropy_core_component_event_register(instance, 
+               
entropy_core_gui_event_get(ENTROPY_GUI_EVENT_FILE_REMOVE_DIRECTORY));
 
 
 
@@ -336,7 +348,8 @@
        viewer->loaded_dirs = ecore_hash_new(ecore_direct_hash, 
ecore_direct_compare);
        viewer->row_folder_hash = ecore_hash_new(ecore_direct_hash, 
ecore_direct_compare);
        
-       
ewl_object_fill_policy_set(EWL_OBJECT(EWL_TREE(viewer->tree)->scrollarea), 
EWL_FLAG_FILL_HFILL);
+       
ewl_object_fill_policy_set(EWL_OBJECT(EWL_TREE(viewer->tree)->scrollarea),
+               EWL_FLAG_FILL_HFILL);
        
        instance->gui_object = viewer->tree;
 




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to