[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [E-devel] taskbar patch -- indent and cleanup



Sthithaprajna Garapaty wrote:
Thanks for the patch.
Updated taskbar and added the module.eap so it'll show up in the config
list.

Here's another :) contains the _gc_init prototype changes amd removes e_modapi_init like I said in my last (as of yet undelivered) post..

this patch also contains more cleanup that I did after creating the last patch I sent, basically shaving off some pointers

it does not contain the whitespace strip I mentioned, so you should (still) do :%s/\s*// in vim

--
Cheers,
Morten
:wq
diff -ur taskbar-0.0.4.org/e_mod_main.c taskbar-0.0.3/e_mod_main.c
--- taskbar-0.0.4.org/e_mod_main.c	2006-06-04 18:54:15.000000000 +0200
+++ taskbar-0.0.3/e_mod_main.c	2006-06-06 06:25:16.217464658 +0200
@@ -7,7 +7,7 @@
 /***************************************************************************/
 /**/
 /* gadcon requirements */
-static E_Gadcon_Client *_gc_init(E_Gadcon *gc, char *name, char *id, char *style);
+static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
 static void _gc_shutdown(E_Gadcon_Client *gcc);
 static void _gc_orient(E_Gadcon_Client *gcc);
 static char *_gc_label(void);
@@ -118,53 +118,46 @@
 Config *taskbar_config = NULL;
 
 static E_Gadcon_Client *
-_gc_init(E_Gadcon *gc, char *name, char *id, char *style)
+_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
 {
-   Taskbar *b;
-   Evas_Object *o;
-   E_Gadcon_Client *gcc;
    Instance *inst;
    Evas_Coord x, y, w, h;
    int cx, cy, cw, ch;
    const char *drop[] = { "enlightenment/border" };
 
    inst = E_NEW(Instance, 1);
 
-   b = _taskbar_new(gc->evas, gc->zone);
-   b->show_label = 1;
-   b->inst = inst;
-   inst->taskbar = b;
-   o = b->o_box;
-   gcc = e_gadcon_client_new(gc, name, id, style, o);
-   gcc->data = inst;
-   
-   inst->gcc = gcc;
-   inst->o_taskbar = o;
-   
+   inst->taskbar = _taskbar_new(gc->evas, gc->zone);
+   inst->taskbar->show_label = 1;
+   inst->taskbar->inst = inst;
+   inst->o_taskbar = inst->taskbar->o_box;
+   inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->o_taskbar);
+   inst->gcc->data = inst;
+
    e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy, &cw, &ch);
-   evas_object_geometry_get(o, &x, &y, &w, &h);
+   evas_object_geometry_get(inst->o_taskbar, &x, &y, &w, &h);
    inst->drop_handler =
      e_drop_handler_add(inst,
 			_taskbar_inst_cb_enter, _taskbar_inst_cb_move,
 			_taskbar_inst_cb_leave, _taskbar_inst_cb_drop,
 			drop, 1, cx + x, cy + y, w, h);
-   evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE,
+   evas_object_event_callback_add(inst->o_taskbar, EVAS_CALLBACK_MOVE,
 				  _taskbar_cb_obj_moveresize, inst);
-   evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE,
+   evas_object_event_callback_add(inst->o_taskbar, EVAS_CALLBACK_RESIZE,
 				  _taskbar_cb_obj_moveresize, inst);
    taskbar_config->instances = evas_list_append(taskbar_config->instances, inst);
    /* FIXME: HACK!!!! */
    inst->drop_recalc_timer = ecore_timer_add(1.0, _taskbar_cb_timer_drop_recalc,
 					     inst);
-   return gcc;
+   return inst->gcc;
 }
 
 static void
 _gc_shutdown(E_Gadcon_Client *gcc)
 {
    Instance *inst;
-   
-   inst = gcc->data;
+   inst = (Instance *)(gcc->data);
+
    ecore_timer_del(inst->drop_recalc_timer);
    taskbar_config->instances = evas_list_remove(taskbar_config->instances, inst);
    e_drop_handler_del(inst->drop_handler);
@@ -176,8 +169,8 @@
 _gc_orient(E_Gadcon_Client *gcc)
 {
    Instance *inst;
-   
-   inst = gcc->data;
+   inst = (Instance *)(gcc->data);
+
    switch (gcc->gadcon->orient)
      {
 	case E_GADCON_ORIENT_FLOAT:
@@ -200,9 +193,6 @@
 	case E_GADCON_ORIENT_CORNER_RB:
 	   _taskbar_orient_set(inst->taskbar, 0);
 	   e_gadcon_client_aspect_set(gcc, 16, evas_list_count(inst->taskbar->icons) * 16);
-	   break;
-	default:
-	   break;
      }
    if (evas_list_count(inst->taskbar->icons) < 1)
      e_gadcon_client_aspect_set(gcc, 16, 16);
@@ -256,9 +246,9 @@
 {
    _taskbar_empty(b);
    evas_object_del(b->o_box);
-   if (b->o_drop) evas_object_del(b->o_drop);
+   if (b->o_drop)      evas_object_del(b->o_drop);
    if (b->o_drop_over) evas_object_del(b->o_drop_over);
-   if (b->o_empty) evas_object_del(b->o_empty);
+   if (b->o_empty)     evas_object_del(b->o_empty);
    free(b);
 }
 
@@ -485,7 +474,6 @@
 static void
 _taskbar_icon_free(Taskbar_Icon *ic)
 {
-
    if (taskbar_config->menu)
      {
 	e_menu_post_deactivate_callback_set(taskbar_config->menu, NULL, NULL);
@@ -566,8 +554,8 @@
 _taskbar_cb_obj_moveresize(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
    Instance *inst;
-
    inst = (Instance *)data;
+
    _taskbar_resize_handle(inst->taskbar);
    _taskbar_instance_drop_zone_recalc(inst);
 }
@@ -583,11 +571,9 @@
 static void
 _taskbar_cb_icon_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
-   Evas_Event_Mouse_In *ev;
    Taskbar_Icon *ic;
-   
-   ev = event_info;
-   ic = data;
+   ic = (Taskbar_Icon *)data;
+
    _taskbar_icon_signal_emit(ic, "active", "");
    if (ic->taskbar->show_label)
      _taskbar_icon_signal_emit(ic, "label_active", "");
@@ -596,11 +582,9 @@
 static void
 _taskbar_cb_icon_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
-   Evas_Event_Mouse_Out *ev;
    Taskbar_Icon *ic;
-
-   ev = event_info;
    ic = data;
+
    _taskbar_icon_signal_emit(ic, "passive", "");
    if (ic->taskbar->show_label)
      _taskbar_icon_signal_emit(ic, "label_passive", "");
@@ -609,18 +593,16 @@
 static void
 _taskbar_cb_icon_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
-
    Evas_Event_Mouse_Down *ev;
    Taskbar_Icon *ic;
 
    ic = data;
    ev = event_info;
 
    if ((ev->button == 3) && (!taskbar_config->menu))
      {
-
 	int cx, cy, cw, ch;
 	e_gadcon_canvas_zone_geometry_get(ic->taskbar->inst->gcc->gadcon,
 				    &cx, &cy, &cw, &ch);
 	if (evas_key_modifier_is_set(ev->modifiers, "Alt"))
 	   {
@@ -786,11 +768,8 @@
 static void
 _taskbar_cb_drag_finished(E_Drag *drag, int dropped)
 {
-   E_Border *bd;
-   
-   bd = drag->data;
-   if (!dropped) e_border_uniconify(bd);
-   e_object_unref(E_OBJECT(bd));
+   if (!dropped) e_border_uniconify((E_Border *)(drag->data));
+   e_object_unref(E_OBJECT(drag->data));
 }
 
 static void
@@ -823,9 +802,10 @@
    Evas_Object *o, *o2;
    Taskbar_Icon *ic;
    int cx, cy, cw, ch;
-   
-   ev = event_info;
-   inst = data;
+
+   ev = (E_Event_Dnd_Enter *)event_info;
+   inst = (Instance *)data;
+
    o = edje_object_add(evas_object_evas_get(inst->taskbar->o_box));
    inst->taskbar->o_drop = o;
    o2 = edje_object_add(evas_object_evas_get(inst->taskbar->o_box));
@@ -925,11 +905,9 @@
 static void
 _taskbar_inst_cb_leave(void *data, const char *type, void *event_info)
 {
-   E_Event_Dnd_Leave *ev;
    Instance *inst;
-   
-   ev = event_info;
-   inst = data;
+   inst = (Instance *)data;
+
    inst->taskbar->ic_drop_before = NULL;
    evas_object_del(inst->taskbar->o_drop);
    inst->taskbar->o_drop = NULL;
@@ -948,17 +926,17 @@
    Taskbar *b;
    Taskbar_Icon *ic, *ic2;
    Evas_List *l;
 
    ev = event_info;
    inst = data;
    if (!strcmp(type, "enlightenment/border"))
      {
 	bd = ev->data;
+	if (!bd) return;
      }
-   if (!bd) return;
 
    if (!bd->iconic) e_border_iconify(bd);
 
    ic2 = inst->taskbar->ic_drop_before;
 
    /* Add new eapp before this icon */
@@ -1007,23 +985,22 @@
    E_Event_Border_Add *ev;
    Taskbar *b;
    Taskbar_Icon *ic;
 
    ev = event;
-   if (ev->border->client.netwm.state.skip_taskbar) return 1;
-   if (ev->border->user_skip_winlist) return 1;
    b = _taskbar_zone_find(ev->border->zone);
    if (!b) return 1;
    if (_taskbar_icon_find(b, ev->border)) return 1;
    ic = _taskbar_icon_new(b, ev->border);
    if (!ic) return 1;
-   if ((ev->border->desk == e_desk_current_get(ev->border->zone)) || (ev->border->sticky))
-     {
-	b->icons = evas_list_append(b->icons, ic);
-	e_box_pack_end(b->o_box, ic->o_holder);
-	_taskbar_empty_handle(b);
-	_taskbar_resize_handle(b);
-	_gc_orient(b->inst->gcc);
-     }
+   if (ev->border->client.netwm.state.skip_taskbar) return 1;
+   if (ev->border->user_skip_winlist) return 1;
+   if ((ev->border->desk == e_desk_current_get(ev->border->zone))||(ev->border->sticky)) {
+      b->icons = evas_list_append(b->icons, ic);
+      e_box_pack_end(b->o_box, ic->o_holder);
+      _taskbar_empty_handle(b);
+      _taskbar_resize_handle(b);
+      _gc_orient(b->inst->gcc);
+   }
    return 1;
 }
 
@@ -1124,12 +1101,12 @@
 		   if (!ic)
 		     {
 			if (ev->border->user_skip_winlist) continue;
-	        	if (ev->border->client.netwm.state.skip_taskbar) continue;	 
+	        	if (ev->border->client.netwm.state.skip_taskbar) continue;
 	        	ic = _taskbar_icon_new(inst->taskbar, ev->border);
 	        	inst->taskbar->icons = evas_list_append(inst->taskbar->icons, ic);
 	        	e_box_pack_end(inst->taskbar->o_box, ic->o_holder);
 	        	_taskbar_empty_handle(inst->taskbar);
-   	        	_taskbar_resize_handle(inst->taskbar);
+			_taskbar_resize_handle(inst->taskbar);
 	        	_gc_orient(inst->taskbar->inst->gcc);
 		     }
 		}
@@ -1198,10 +1175,8 @@
 {
    Ecore_X_Event_Window_Focus_In *ev;
    E_Border *bd;
-   Taskbar *b;
-   Taskbar_Icon *ic;
    Evas_List *l;
 
    ev = event;
    bd = e_border_find_by_client_window(ev->win);
    if (!bd) return 1;
@@ -1209,23 +1184,23 @@
    for (l = taskbar_config->instances; l; l = l->next)
      {
 	Instance *inst;
+	Taskbar_Icon *ic;
 
 	inst = l->data;
 	ic = _taskbar_icon_find(inst->taskbar, bd);
 	if (ic)
 	   _taskbar_icon_signal_emit(ic, "focused", "");
      }
-   return 1;	
+   return 1;
 }
+
 static int
 _taskbar_cb_window_focus_out(void *data, int type, void *event)
 {
    Ecore_X_Event_Window_Focus_Out *ev;
    E_Border *bd;
-   Taskbar *b;
-   Taskbar_Icon *ic;
    Evas_List *l;
 
    ev = event;
    bd = e_border_find_by_client_window(ev->win);
    if (!bd) return 1;
@@ -1233,6 +1208,7 @@
    for (l = taskbar_config->instances; l; l = l->next)
      {
 	Instance *inst;
+	Taskbar_Icon *ic;
 
 	inst = l->data;
 	ic = _taskbar_icon_find(inst->taskbar, bd);
@@ -1328,13 +1304,15 @@
       (E_EVENT_BORDER_STICK, _taskbar_cb_event_border_zone_set, NULL));
  */
    e_gadcon_provider_register(&_gadcon_class);
+
+   return taskbar_config;
 }
 
 EAPI int
 e_modapi_shutdown(E_Module *m)
 {
    e_gadcon_provider_unregister(&_gadcon_class);
 
    while (taskbar_config->handlers)
      {
 	ecore_event_handler_del(taskbar_config->handlers->data);