On Thu, 16 Nov 2006 19:40:58 +0100
lok <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I've made some changement on the pager config.
> The first one let the user choose the mouse button he wants for the two
> type of drag.
> And the second disable the wheel callback on the pager. The wheel
> callback on the pager works only if the pager is in a shelf "above
> everything". By default it's disabled because scrolling above the pager
> in this case make you switch by a step of 2 desktops (one is done by
> the pager's callback and the other by the E's default mousebinding).
> 
> The pager is probably the most used module, so I prefere to not commit
> this patch directly. (just to be sure to not be hunt down if I've made
> a mistake). And the patch also fix a small warning.
> 
> Lok

ok sorry about the double posting. 
I forgot to change two values before making the patch.
This one is the good one. (No need to apply the previous)

Lok
Index: pager/e_mod_config.c
===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/pager/e_mod_config.c,v
retrieving revision 1.22
diff -u -u -r1.22 e_mod_config.c
--- pager/e_mod_config.c	3 Sep 2006 07:40:45 -0000	1.22
+++ pager/e_mod_config.c	16 Nov 2006 19:36:54 -0000
@@ -1,11 +1,37 @@
 #include "e.h"
 #include "e_mod_main.h"
 
+typedef enum _Pager_Grab_Button Pager_Grab_Button;
+enum _Pager_Grab_Button
+{
+   GRAB_BUTTON_DRAG,
+   GRAB_BUTTON_NOPLACE
+};
+
 struct _E_Config_Dialog_Data
 {
    int show_popup;
    double popup_speed;
    int drag_resist;
+   unsigned char btn_drag;
+   unsigned char btn_noplace;
+   int flip_desk;
+
+   struct
+     {
+	Ecore_X_Window bind_win;
+	E_Dialog *dia;
+	Evas_List *handlers;
+
+	unsigned char *button1;
+	unsigned char *button2;
+     } grab;
+
+   struct
+     {
+	Evas_Object *o_btn1;
+	Evas_Object *o_btn2;
+     } gui;
 };
 
 /* Protos */
@@ -15,6 +41,11 @@
 static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
 static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
 static int _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
+static void _advanced_update_button_label(E_Config_Dialog_Data *cfdata);
+static void _grab_wnd_show(void *data1, void *data2);
+static void _grab_wnd_hide(E_Config_Dialog_Data *cfdata);
+static int _grab_mouse_down_cb(void *data, int type, void *event);
+static int _grab_key_down_cb(void *data, int type, void *event);
 
 void 
 _config_pager_module(Config_Item *ci)
@@ -47,6 +78,9 @@
    cfdata->show_popup = pager_config->popup;
    cfdata->popup_speed = pager_config->popup_speed;
    cfdata->drag_resist = pager_config->drag_resist;
+   cfdata->btn_drag = pager_config->btn_drag;
+   cfdata->btn_noplace = pager_config->btn_noplace;
+   cfdata->flip_desk = pager_config->flip_desk;
 }
 
 static void *
@@ -111,6 +145,25 @@
    e_widget_framelist_object_append(of, ob);
    e_widget_list_object_append(o, of, 1, 1, 0.5);   
 
+   of = e_widget_frametable_add(evas, _("Buttons Settings"), 0);
+   ob = e_widget_label_add(evas, _("Drag and select button"));
+   e_widget_frametable_object_append(of, ob, 1, 1, 1, 1, 1, 1, 1, 1);
+   ob = e_widget_label_add(evas, _("Drag no place button"));
+   e_widget_frametable_object_append(of, ob, 1, 2, 1, 1, 1, 1, 1, 1);
+   ob = e_widget_button_add(evas, _("Click to set"), NULL, _grab_wnd_show, (void *)GRAB_BUTTON_DRAG, cfdata);
+   e_widget_frametable_object_append(of, ob, 2, 1, 1, 1, 1, 1, 0, 0);
+   cfdata->gui.o_btn1 = ob;
+   ob = e_widget_button_add(evas, _("Click to set"), NULL, _grab_wnd_show, (void *)GRAB_BUTTON_NOPLACE, cfdata);
+   e_widget_frametable_object_append(of, ob, 2, 2, 1, 1, 1, 1, 0, 0);
+   cfdata->gui.o_btn2 = ob;
+   _advanced_update_button_label(cfdata);
+   e_widget_list_object_append(o, of, 1, 1, 0.5);   
+   
+   of = e_widget_framelist_add(evas, _("Wheel callback"), 0);   
+   ob = e_widget_check_add(evas, _("Flip desktop on mouse wheel"), &(cfdata->flip_desk));
+   e_widget_framelist_object_append(of, ob);
+   e_widget_list_object_append(o, of, 1, 1, 0.5);   
+
    return o;
 }
 
@@ -120,7 +173,135 @@
    pager_config->popup = cfdata->show_popup;
    pager_config->popup_speed = cfdata->popup_speed;
    pager_config->drag_resist = cfdata->drag_resist;
+   pager_config->btn_drag = cfdata->btn_drag;
+   pager_config->btn_noplace = cfdata->btn_noplace;
+   pager_config->flip_desk = cfdata->flip_desk;
    _pager_cb_config_updated();
    e_config_save_queue();
+   return 1;
+}
+
+static void
+_advanced_update_button_label(E_Config_Dialog_Data *cfdata)
+{
+   char label[strlen(_("Click to set"))];
+   
+   if (cfdata->btn_drag)
+     snprintf(label, strlen(_("Button "))+3, "Button %d", cfdata->btn_drag);
+   else
+     snprintf(label, strlen(_("Click to set"))+1, _("Click to set"));
+   e_widget_button_label_set(cfdata->gui.o_btn1, label);
+   
+   if (cfdata->btn_noplace)
+     snprintf(label, strlen(_("Button "))+3, "Button %d", cfdata->btn_noplace);
+   else
+     snprintf(label, strlen(_("Click to set"))+1, _("Click to set"));
+   e_widget_button_label_set(cfdata->gui.o_btn2, label);
+}
+
+static void
+_grab_wnd_show(void *data1, void *data2)
+{
+   E_Manager *man;
+   E_Config_Dialog_Data *cfdata;
+
+   man = e_manager_current_get();
+   cfdata = data2;
+
+   if ((Pager_Grab_Button)data1 == GRAB_BUTTON_DRAG)
+     {
+	cfdata->grab.button1 = &(cfdata->btn_drag);
+	cfdata->grab.button2 = &(cfdata->btn_noplace);
+     }
+   else
+     {
+	cfdata->grab.button1 = &(cfdata->btn_noplace);
+	cfdata->grab.button2 = &(cfdata->btn_drag);
+     }
+
+   cfdata->grab.dia = e_dialog_new(e_container_current_get(man), "Pager", "_pager_button_grab_dialog");
+   if (!cfdata->grab.dia) return;
+   e_dialog_title_set(cfdata->grab.dia, _("Pager Button Grab"));
+   e_dialog_icon_set(cfdata->grab.dia, "enlightenment/mouse_clean", 48);
+   e_dialog_text_set(cfdata->grab.dia, _("Please press a mouse button<br>"
+					 "Press <hilight>Escape</hilight> to abort.<br>"
+					 "Or <hilight>Del</hilight> to reset the button."));
+   e_win_centered_set(cfdata->grab.dia->win, 1);
+   e_win_borderless_set(cfdata->grab.dia->win, 1);
+
+   cfdata->grab.bind_win = ecore_x_window_input_new(man->root, 0, 0, 1, 1);
+   ecore_x_window_show(cfdata->grab.bind_win);
+   e_grabinput_get(cfdata->grab.bind_win, 0, cfdata->grab.bind_win);
+
+   cfdata->grab.handlers = evas_list_append(cfdata->grab.handlers,
+			    ecore_event_handler_add(ECORE_X_EVENT_KEY_DOWN,
+				 _grab_key_down_cb, cfdata));
+   cfdata->grab.handlers = evas_list_append(cfdata->grab.handlers,
+			      ecore_event_handler_add(ECORE_X_EVENT_MOUSE_BUTTON_DOWN,
+				 _grab_mouse_down_cb, cfdata));
+
+   e_dialog_show(cfdata->grab.dia);
+}
+
+static void
+_grab_wnd_hide(E_Config_Dialog_Data *cfdata)
+{
+   while (cfdata->grab.handlers)
+     {
+	ecore_event_handler_del(cfdata->grab.handlers->data);
+	cfdata->grab.handlers = evas_list_remove_list(cfdata->grab.handlers, cfdata->grab.handlers);
+     }
+   cfdata->grab.handlers = NULL;
+   e_grabinput_release(cfdata->grab.bind_win, cfdata->grab.bind_win);
+   ecore_x_window_del(cfdata->grab.bind_win);
+   cfdata->grab.bind_win = 0;
+
+   e_object_del(E_OBJECT(cfdata->grab.dia));
+   cfdata->grab.dia = NULL;
+   _advanced_update_button_label(cfdata);
+}
+
+static int
+_grab_mouse_down_cb(void *data, int type, void *event)
+{
+   E_Config_Dialog_Data *cfdata;
+   Ecore_X_Event_Mouse_Button_Down *ev;
+   
+   ev = event;
+   cfdata = data;
+
+   if (ev->button != 3)
+     {
+	if (ev->button == *(cfdata->grab.button2))
+	  {
+	     *(cfdata->grab.button2) = *(cfdata->grab.button1);
+	     *(cfdata->grab.button1) = ev->button;
+	  }
+	else
+	  {
+	     *(cfdata->grab.button1) = ev->button;
+	  } 
+     }
+
+   _grab_wnd_hide(cfdata);
+   return 1;
+}
+
+static int
+_grab_key_down_cb(void *data, int type, void *event)
+{
+   E_Config_Dialog_Data *cfdata;
+   Ecore_X_Event_Key_Down *ev = event;
+
+   cfdata = data;
+
+   if (ev->win != cfdata->grab.bind_win) return 1;
+
+   if (!strcmp(ev->keyname, "Escape")) _grab_wnd_hide(cfdata);
+   if (!strcmp(ev->keyname, "Delete"))
+     {
+	*(cfdata->grab.button1) = 0;
+	_grab_wnd_hide(cfdata);
+     }
    return 1;
 }
Index: pager/e_mod_main.c
===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/pager/e_mod_main.c,v
retrieving revision 1.194
diff -u -u -r1.194 e_mod_main.c
--- pager/e_mod_main.c	15 Nov 2006 06:24:30 -0000	1.194
+++ pager/e_mod_main.c	16 Nov 2006 19:36:55 -0000
@@ -1318,8 +1318,8 @@
    pw = data;
    if (!pw) return;
    if (pw->border->lock_user_location) return;
-   /* FIXME: make this configurable */
-   if ((ev->button == 1) || (ev->button == 2))
+   if ((ev->button == pager_config->btn_drag) 
+	|| (ev->button == pager_config->btn_noplace))
      {
 	Evas_Coord ox, oy;
 
@@ -1332,7 +1332,8 @@
 	pw->drag.start = 1;
 	pw->drag.no_place = 0;
 	pw->drag.button = ev->button;
-	if (ev->button == 2) pw->drag.no_place = 1;
+	if (ev->button == pager_config->btn_noplace) 
+	  pw->drag.no_place = 1;
      }
 }
 
@@ -1345,8 +1346,8 @@
    ev = event_info;
    pw = data;
    if (!pw) return;
-   /* FIXME: make this configurable as above */
-   if ((ev->button == 1) || (ev->button == 2))
+   if ((ev->button == pager_config->btn_drag) 
+	|| (ev->button ==pager_config->btn_noplace))
      {  
 	if (!pw->drag.from_pager)
 	  {
@@ -1706,7 +1707,7 @@
    ev = event_info;
    pd = data;
 
-   e_zone_desk_linear_flip_by(pd->desk->zone, ev->z);
+   if (pager_config->flip_desk) e_zone_desk_linear_flip_by(pd->desk->zone, ev->z);
 }
 
 static int
@@ -1741,6 +1742,9 @@
    E_CONFIG_VAL(D, T, drag_resist, UINT);
    E_CONFIG_VAL(D, T, scale, UCHAR);
    E_CONFIG_VAL(D, T, resize, UCHAR);
+   E_CONFIG_VAL(D, T, btn_drag, UCHAR);
+   E_CONFIG_VAL(D, T, btn_noplace, UCHAR);
+   E_CONFIG_VAL(D, T, flip_desk, UINT);
 
    pager_config = e_config_domain_load("module.pager", conf_edd);
 
@@ -1752,12 +1756,19 @@
 	pager_config->drag_resist = 3;
 	pager_config->scale = 1;
 	pager_config->resize = PAGER_RESIZE_BOTH;
+	pager_config->btn_drag = 1;
+	pager_config->btn_noplace = 2;
+	pager_config->flip_desk = 0;
      }
    E_CONFIG_LIMIT(pager_config->popup_speed, 0.1, 10.0);
    E_CONFIG_LIMIT(pager_config->popup, 0, 1);
    E_CONFIG_LIMIT(pager_config->drag_resist, 0, 50);
-   E_CONFIG_LIMIT(pager_config->scale, 0, 1);
    E_CONFIG_LIMIT(pager_config->resize, PAGER_RESIZE_HORZ, PAGER_RESIZE_BOTH);
+   E_CONFIG_LIMIT(pager_config->flip_desk, 0, 1);
+
+   if (pager_config->scale > 1) pager_config->scale = 1;
+   if (pager_config->btn_drag > 10) pager_config->btn_drag = 10;
+   if (pager_config->btn_noplace > 10) pager_config->btn_noplace = 10;
 
    pager_config->handlers = evas_list_append
      (pager_config->handlers, ecore_event_handler_add
Index: pager/e_mod_main.h
===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/pager/e_mod_main.h,v
retrieving revision 1.48
diff -u -u -r1.48 e_mod_main.h
--- pager/e_mod_main.h	6 Jun 2006 15:23:44 -0000	1.48
+++ pager/e_mod_main.h	16 Nov 2006 19:36:55 -0000
@@ -33,6 +33,10 @@
    Evas_List       *instances;
    E_Menu          *menu;
    Evas_List       *handlers;
+
+   unsigned char    btn_drag;
+   unsigned char    btn_noplace;
+   unsigned int     flip_desk;
 };
 
 struct _Config_Item
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to