On Sat, 2009-04-11 at 15:29 +1000, Carsten Haitzler wrote:
> On Fri, 10 Apr 2009 19:59:57 +0200 Viktor Kojouharov <vkojouha...@gmail.com>
> said:
> 
> you'll be wanting to regenerate patches as they fail... :)
> 
Aargg, here be them updated patches you be wanting

> > On Fri, 2009-04-10 at 23:56 +1000, Carsten Haitzler wrote:
> > > On Wed, 08 Apr 2009 11:12:36 +0200 Viktor Kojouharov 
> > > <vkojouha...@gmail.com>
> > > said:
> > > 
> > > > This little patch adds 'tabs' to the fileman module window. The tabs are
> > > > implemented using the toolbar widget. Currently you can add tabs and
> > > > switch between them. The only problem right now is that when adding more
> > > > than two tabs, the toolbar/scrollbar area is moved off the canvas for
> > > > some reason, until the user resizes the window - raster though it might
> > > > be a problem with the toolbar widget itself, but he didn't see the
> > > > patch, so it might as well be something on my side.
> > > 
> > > ummmm... what does it actually do? other than seeimingly addd a toolbar..
> > > that toolbar doesnt show - nothing there.
> > > 
> > > 
> > 
> > Right, I forgot that. Hit ctrl+t and a new 'tab' opens with the same
> > path as the previous one. The toolbar is not visible when only one 'tab'
> > is present in order to reduce the taken real-estate. The tabs themselves
> > don't switch between different 'pages', but just change the path of the
> > fm object. I tried having a different toolbar/fm object per tab on a
> > previous iteration, but it wasn't worth the hassle.
> > 
> > I've attached an updated patch which I previously sent to Gustavo as
> > well. It adds some cleanups.
> > 
> > On the testing side, I've been with it for a some time now, with no
> > drawbacks.
> > 
> 
> 
Index: src/bin/e_widget_toolbar.c
===================================================================
--- src/bin/e_widget_toolbar.c	(revision 39976)
+++ src/bin/e_widget_toolbar.c	(working copy)
@@ -11,6 +11,7 @@
    int icon_w, icon_h;
    Eina_List *items;
    Evas_Bool scrollable : 1;
+   Evas_Bool focus_steal : 1;
 };
 
 struct _Item
@@ -49,6 +50,7 @@
    e_widget_data_set(obj, wd);
    wd->icon_w = icon_w;
    wd->icon_h = icon_h;
+   wd->focus_steal = 1;
    
    o = e_scrollframe_add(evas);
    wd->o_base = o;
@@ -168,6 +170,30 @@
 }
 
 EAPI void
+e_widget_toolbar_item_label_set(Evas_Object *obj, int num, const char *label)
+{
+   E_Widget_Data *wd;
+   Item *it;
+
+   wd = e_widget_data_get(obj);
+   it = eina_list_nth(wd->items, num);
+   if (it)
+     {
+	int mw, mh;
+
+	edje_object_part_text_set(it->o_base, "e.text.label", label);
+	edje_object_size_min_calc(it->o_base, &mw, &mh);
+	e_box_pack_options_set(it->o_base,
+			       1, 1, /* fill */
+			       0, 0, /* expand */
+			       0.5, 0.5, /* align */
+			       mw, mh, /* min */
+			       9999, 9999 /* max */
+			       );
+     }
+}
+
+EAPI void
 e_widget_toolbar_scrollable_set(Evas_Object *obj, Evas_Bool scrollable)
 {
    E_Widget_Data *wd;
@@ -185,6 +211,29 @@
      e_widget_min_size_set(obj, mw + (500 - vw), mh + (500 - vh));
 }
 
+EAPI void
+e_widget_toolbar_focus_steal_set(Evas_Object *obj, Evas_Bool steal)
+{
+   E_Widget_Data *wd;
+
+   wd = e_widget_data_get(obj);
+   if (wd->focus_steal == steal) return;
+   if (steal)
+     {
+	evas_object_event_callback_add(e_scrollframe_edje_object_get(wd->o_base), 
+				       EVAS_CALLBACK_MOUSE_DOWN,
+				       _e_wid_focus_steal, obj);
+	wd->focus_steal = 1;
+     }
+   else
+     {
+	evas_object_event_callback_del(e_scrollframe_edje_object_get(wd->o_base), 
+				       EVAS_CALLBACK_MOUSE_DOWN,
+				       _e_wid_focus_steal);
+	wd->focus_steal = 0;
+     }
+}
+
 static void
 _e_wid_del_hook(Evas_Object *obj)
 {
Index: src/bin/e_widget_toolbar.h
===================================================================
--- src/bin/e_widget_toolbar.h	(revision 39976)
+++ src/bin/e_widget_toolbar.h	(working copy)
@@ -9,7 +9,9 @@
 EAPI Evas_Object *e_widget_toolbar_add(Evas *evas, int icon_w, int icon_h);
 EAPI void e_widget_toolbar_item_append(Evas_Object *obj, Evas_Object *icon, const char *label, void (*func) (void *data1, void *data2), const void *data1, const void *data2);
 EAPI void e_widget_toolbar_item_select(Evas_Object *obj, int num);
+EAPI void e_widget_toolbar_item_label_set(Evas_Object *obj, int num, const char *label);
 EAPI void e_widget_toolbar_scrollable_set(Evas_Object *obj, Evas_Bool scrollable);
+EAPI void e_widget_toolbar_focus_steal_set(Evas_Object *obj, Evas_Bool steal);
 
 #endif
 #endif
Index: src/modules/fileman/e_fwin.c
===================================================================
--- src/modules/fileman/e_fwin.c	(revision 39976)
+++ src/modules/fileman/e_fwin.c	(working copy)
@@ -15,6 +15,7 @@
  */
 
 typedef struct _E_Fwin E_Fwin;
+typedef struct _E_Fwin_Page_Info E_Fwin_Page_Info;
 typedef struct _E_Fwin_Apps_Dialog E_Fwin_Apps_Dialog;
 
 #define E_FWIN_TYPE 0xE0b0101f
@@ -26,10 +27,14 @@
    E_Win               *win;
    E_Zone              *zone;
    Evas_Object         *scrollframe_obj;
+   Evas_Object	       *tb_obj;
    Evas_Object         *fm_obj;
    Evas_Object         *bg_obj;
    E_Fwin_Apps_Dialog  *fad;
 
+   Eina_List	       *page_info;
+   int			page_index;
+
    Evas_Object         *under_obj;
    Evas_Object         *over_obj;
    struct {
@@ -49,6 +54,18 @@
    unsigned char        geom_save_ready : 1;
 };
 
+struct _E_Fwin_Page_Info
+{
+   const char *dev;
+   const char *path;
+
+   struct {
+	Evas_Coord x, y;
+   } scroll;
+
+   int index;
+};
+
 struct _E_Fwin_Apps_Dialog
 {
    E_Dialog    *dia;
@@ -72,6 +89,9 @@
 /* local subsystem prototypes */
 static E_Fwin *_e_fwin_new(E_Container *con, const char *dev, const char *path);
 static void _e_fwin_free(E_Fwin *fwin);
+static void _e_fwin_page_new(E_Fwin *fwin);
+static E_Fwin_Page_Info *_e_fwin_page_info_new(E_Fwin *fwin);
+static void _e_fwin_cb_page_change(void *data1, void *data2);
 static void _e_fwin_cb_delete(E_Win *win);
 static void _e_fwin_cb_move(E_Win *win);
 static void _e_fwin_cb_resize(E_Win *win);
@@ -490,6 +510,8 @@
 static void
 _e_fwin_free(E_Fwin *fwin)
 {
+   E_Fwin_Page_Info *info;
+
    if (!fwin) return; //safety
 
    if (fwin->fm_obj) evas_object_del(fwin->fm_obj);
@@ -502,6 +524,13 @@
 				       _e_fwin_zone_cb_mouse_down);
      }
 
+
+   EINA_LIST_FREE(fwin->page_info, info)
+     {
+	eina_stringshare_del(info->dev);
+	eina_stringshare_del(info->path);
+	E_FREE(info);
+     }
    if (fwin->zone_handler) 
      ecore_event_handler_del(fwin->zone_handler);
    if (fwin->zone_del_handler) 
@@ -862,36 +891,61 @@
 static void 
 _e_fwin_toolbar_resize(E_Fwin *fwin) 
 {
+   int tx, ty, tw, th, offset = 0;
    int x, y, w, h;
 
-   e_toolbar_position_calc(fwin->tbar);
+   if (fwin->tb_obj)
+     evas_object_geometry_get(fwin->tb_obj, NULL, NULL, NULL, &offset);
    w = fwin->win->w;
    h = fwin->win->h;
    switch (fwin->tbar->gadcon->orient) 
      {
+      case E_GADCON_ORIENT_HORIZ:
       case E_GADCON_ORIENT_TOP:
-	x = 0;
-	y = fwin->tbar->h;
-	h = (h - fwin->tbar->h);
-	break;
+	 tx = 0;
+	 ty = offset;
+	 th = 32;
+	 tw = w;
+
+	 x = 0;
+	 y = offset + th;
+	 h = (h - offset - th);
+	 break;
       case E_GADCON_ORIENT_BOTTOM:
-	x = 0;
-	y = 0;
-	h = (h - fwin->tbar->h);
-	break;
+	 tx = 0;
+	 th = 32;
+	 tw = w;
+	 ty = h - th;
+
+	 x = 0;
+	 y = offset;
+	 h = (h - offset - th);
+	 break;
+      case E_GADCON_ORIENT_VERT:
       case E_GADCON_ORIENT_LEFT:
-	x = (fwin->tbar->x + fwin->tbar->w);
-	y = 0;
-	w = (w - fwin->tbar->w);
-	break;
+	 tx = 0;
+	 tw = 32;
+	 th = h - offset;
+	 ty = offset;
+
+	 x = (tx + tw);
+	 y = offset;
+	 w = (w - tw);
+	 break;
       case E_GADCON_ORIENT_RIGHT:
-	x = 0;
-	y = 0;
-	w = (fwin->win->w - fwin->tbar->w);
-	break;
+	 ty = offset;
+	 tw = 32;
+	 tx = w - tw;
+	 th = h - offset;
+
+	 x = 0;
+	 y = offset;
+	 w = (w - tw);
+	 break;
       default:
-	return;
+	 return;
      }
+   e_toolbar_move_resize(fwin->tbar, tx, ty, tw, th);
    evas_object_move(fwin->scrollframe_obj, x, y);
    evas_object_resize(fwin->scrollframe_obj, w, h);
 }
@@ -899,6 +953,71 @@
 
 /* fwin callbacks */
 static void
+_e_fwin_page_new(E_Fwin *fwin)
+{
+   E_Fwin_Page_Info *info;
+   const char *real;
+
+   if (!fwin->tb_obj)
+     {
+	/* There is no toolbar yet */
+	fwin->tb_obj = e_widget_toolbar_add(evas_object_evas_get(fwin->fm_obj),
+	      48 * e_scale, 48 * e_scale);
+
+	e_widget_toolbar_focus_steal_set(fwin->tb_obj, 0);
+	info = _e_fwin_page_info_new(fwin);
+	real = ecore_file_file_get(e_fm2_real_path_get(fwin->fm_obj));
+	e_widget_toolbar_item_append(fwin->tb_obj, NULL, real,
+	      _e_fwin_cb_page_change, fwin, info);
+
+	evas_object_move(fwin->tb_obj, 0, 0);
+	evas_object_show(fwin->tb_obj);
+     }
+
+   info = _e_fwin_page_info_new(fwin);
+   real = ecore_file_file_get(e_fm2_real_path_get(fwin->fm_obj));
+   e_widget_toolbar_item_append(fwin->tb_obj, NULL, real,
+	 _e_fwin_cb_page_change, fwin, info);
+   e_widget_toolbar_item_select(fwin->tb_obj, info->index);
+
+   _e_fwin_cb_resize(fwin->win);
+}
+
+static E_Fwin_Page_Info *
+_e_fwin_page_info_new(E_Fwin *fwin)
+{
+   E_Fwin_Page_Info *info;
+   const char *dev, *path;
+
+   e_fm2_path_get(fwin->fm_obj, &dev, &path);
+   info = E_NEW(E_Fwin_Page_Info, 1);
+   info->dev = eina_stringshare_add(dev);
+   info->path = eina_stringshare_add(path);
+   info->index = eina_list_count(fwin->page_info);
+
+   fwin->page_info = eina_list_append(fwin->page_info, info);
+
+   return info;
+}
+
+static void
+_e_fwin_cb_page_change(void *data1, void *data2)
+{
+   E_Fwin *fwin = data1;
+   E_Fwin_Page_Info *info = data2, *prev;
+   Evas_Coord x, y;
+
+   if (!fwin || !info) return;
+   prev = eina_list_nth(fwin->page_info, fwin->page_index);
+   e_scrollframe_child_pos_get(fwin->scrollframe_obj, &x, &y);
+   prev->scroll.x = x;
+   prev->scroll.y = y;
+   fwin->page_index = info->index;
+   e_fm2_path_set(fwin->fm_obj, info->dev, info->path);
+   e_scrollframe_child_pos_set(fwin->scrollframe_obj, x, y);
+}
+
+static void
 _e_fwin_cb_delete(E_Win *win)
 {
    E_Fwin *fwin;
@@ -956,10 +1075,24 @@
      }
    if (fwin->win) 
      {
+	if (fwin->tb_obj)
+	  {
+	     int height;
+
+	     e_widget_min_size_get(fwin->tb_obj, NULL, &height);
+	     evas_object_resize(fwin->tb_obj, fwin->win->w, height);
+	  }
 	if (fwin->tbar)
 	  _e_fwin_toolbar_resize(fwin);
 	else 
-	  evas_object_resize(fwin->scrollframe_obj, fwin->win->w, fwin->win->h);
+	  {
+	     int offset = 0;
+
+	     if (fwin->tb_obj)
+	       evas_object_geometry_get(fwin->tb_obj, NULL, NULL, NULL, &offset);
+	     evas_object_move(fwin->scrollframe_obj, 0, offset);
+	     evas_object_resize(fwin->scrollframe_obj, fwin->win->w, fwin->win->h - offset);
+	  }
      }
    else if (fwin->zone)
      evas_object_resize(fwin->scrollframe_obj, fwin->zone->w, fwin->zone->h);
@@ -1036,6 +1169,21 @@
 	  }
 	e_scrollframe_child_pos_set(fwin->scrollframe_obj, 0, 0);
      }
+   if (fwin->tb_obj)
+     {
+	E_Fwin_Page_Info *info;
+	const char *file, *dev, *path;
+
+	e_fm2_path_get(fwin->fm_obj, &dev, &path);
+	info = eina_list_nth(fwin->page_info, fwin->page_index);
+	eina_stringshare_del(info->dev);
+	eina_stringshare_del(info->path);
+	info->dev = eina_stringshare_add(dev);
+	info->path = eina_stringshare_add(path);
+
+	file = ecore_file_file_get(e_fm2_real_path_get(fwin->fm_obj));
+	e_widget_toolbar_item_label_set(fwin->tb_obj, fwin->page_index, file);
+     }
    if ((fwin->theme_file) && (ecore_file_exists(fwin->theme_file)))
      e_fm2_custom_theme_set(obj, fwin->theme_file);
    else
@@ -1115,6 +1263,11 @@
 	     e_fm2_all_sel(fwin->fm_obj);
 	     return;
 	  }
+	if (!strcmp(ev->key, "t"))
+	  {
+	     _e_fwin_page_new(fwin);
+	     return;
+	  }
      }
 }
 
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to