Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        E.h actions.c config.c fx.c ipc.c settings.c 


Log Message:
Don't show dialog at startup when effects (ripples/waves) are enabled,
move control of the effects to the FX settings dialog.

===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -3 -r1.137 -r1.138
--- E.h 28 Sep 2003 19:21:34 -0000      1.137
+++ E.h 28 Sep 2003 19:36:08 -0000      1.138
@@ -2856,13 +2856,14 @@
 void                SC_Kill(void);
 
 /* fx.c exportable functions */
-void                FX_Start(char *name);
+#define FX_OP_START  1
+#define FX_OP_STOP   2
+#define FX_OP_TOGGLE 3
+void                FX_Op(const char *name, int fx_op);
 void                FX_DeskChange(void);
 void                FX_Pause(void);
 char              **FX_Active(int *num);
 int                 FX_IsOn(char *effect);
-void                FX_Deactivate(char *effect);
-void                FX_Activate(char *effect);
 
 /* ipc.c functions */
 int                 HandleIPC(char *params, Client * c);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/actions.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -3 -r1.108 -r1.109
--- actions.c   28 Sep 2003 19:21:34 -0000      1.108
+++ actions.c   28 Sep 2003 19:36:09 -0000      1.109
@@ -3313,7 +3313,7 @@
    if (InZoom())
       EDBUG_RETURN(0);
    if (params)
-      FX_Start((char *)params);
+      FX_Op((const char *)params, FX_OP_TOGGLE);
    autosave();
    EDBUG_RETURN(0);
 }
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/config.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -3 -r1.66 -r1.67
--- config.c    28 Sep 2003 19:08:27 -0000      1.66
+++ config.c    28 Sep 2003 19:36:09 -0000      1.67
@@ -2925,7 +2925,7 @@
        if (fields < 1)
          {
             word(s, 1, s2);
-            FX_Start(s2);
+            FX_Op(s2, FX_OP_START);
          }
        else if (i1 == CONFIG_CLOSE)
          {
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/fx.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -3 -r1.28 -r1.29
--- fx.c        12 Jul 2003 15:04:31 -0000      1.28
+++ fx.c        28 Sep 2003 19:36:10 -0000      1.29
@@ -22,6 +22,9 @@
  */
 #include "E.h"
 
+/* Someone may do this right one day, but for now - kill'em */
+#define ENABLE_FX_INFO 0
+
 #ifndef M_PI_2
 #define M_PI_2 (3.141592654 / 2)
 #endif
@@ -55,7 +58,6 @@
 void                FX_ImageSpinner_Quit(void);
 void                FX_ImageSpinner_Pause(void);
 
-static int          num_fx_handlers = 4;
 static FXHandler    fx_handlers[] = {
    {"ripples",
     FX_Ripple_Init, FX_Ripple_Desk, FX_Ripple_Quit, FX_Ripple_Pause,
@@ -72,31 +74,77 @@
     FX_ImageSpinner_Pause,
     0, 0}
 };
+#define N_FX_HANDLERS (sizeof(fx_handlers)/sizeof(FXHandler))
 
 /****************************** Effect handlers *****************************/
 
+static FXHandler   *
+FX_Find(const char *name)
+{
+   int                 i;
+
+   for (i = 0; i < N_FX_HANDLERS; i++)
+      if (!strcmp(fx_handlers[i].name, name))
+        return &fx_handlers[i];
+
+   return NULL;
+}
+
+void
+FX_Op(const char *name, int fx_op)
+{
+   FXHandler          *fxh;
+
+   fxh = FX_Find(name);
+   if (fxh == NULL)
+      return;
+
+   switch (fx_op)
+     {
+     case FX_OP_START:
+       if (fxh->in_use)
+          break;
+      do_start:
+       if (fxh->init_func)
+          (*(fxh->init_func)) (name);
+       fxh->in_use = 1;
+       break;
+
+     case FX_OP_STOP:
+       if (!fxh->in_use)
+          break;
+      do_stop:
+       if (fxh->quit_func)
+          fxh->quit_func();
+       fxh->in_use = 0;
+       break;
+
+     case FX_OP_TOGGLE:
+       if (fxh->in_use)
+          goto do_stop;
+       else
+          goto do_start;
+       break;
+     }
+}
+
 void
-FX_Start(char *name)
+FX_Activate(char *effect)
 {
    int                 i;
 
-   for (i = 0; i < num_fx_handlers; i++)
+   for (i = 0; i < N_FX_HANDLERS; i++)
      {
-       if (!strcmp(fx_handlers[i].name, name))
+       if (!strcmp(fx_handlers[i].name, effect))
          {
-            if ((fx_handlers[i].in_use) && (fx_handlers[i].quit_func))
-              {
-                 (*(fx_handlers[i].quit_func)) ();
-                 fx_handlers[i].in_use = 0;
-              }
-            else
+            if (!fx_handlers[i].in_use)
               {
-                 if (fx_handlers[i].init_func)
-                    (*(fx_handlers[i].init_func)) (name);
                  fx_handlers[i].in_use = 1;
+                 (*(fx_handlers[i].init_func)) (effect);
               }
          }
      }
+   return;
 }
 
 void
@@ -104,12 +152,12 @@
 {
    int                 i;
 
-   for (i = 0; i < num_fx_handlers; i++)
+   for (i = 0; i < N_FX_HANDLERS; i++)
      {
        if (fx_handlers[i].in_use)
          {
             if (fx_handlers[i].desk_func)
-               (*(fx_handlers[i].desk_func)) ();
+               fx_handlers[i].desk_func();
          }
      }
 }
@@ -119,7 +167,7 @@
 {
    int                 i;
 
-   for (i = 0; i < num_fx_handlers; i++)
+   for (i = 0; i < N_FX_HANDLERS; i++)
      {
        if (fx_handlers[i].in_use)
          {
@@ -146,7 +194,7 @@
    char              **list = NULL;
 
    *num = 0;
-   for (i = 0; i < num_fx_handlers; i++)
+   for (i = 0; i < N_FX_HANDLERS; i++)
      {
        if (fx_handlers[i].in_use)
          {
@@ -164,57 +212,17 @@
 {
    int                 i;
 
-   for (i = 0; i < num_fx_handlers; i++)
+   for (i = 0; i < N_FX_HANDLERS; i++)
      {
        if (!strcmp(fx_handlers[i].name, effect))
          {
-            if (fx_handlers[i].in_use)
-               return 1;
-            return 0;
+            return fx_handlers[i].in_use;
          }
      }
    return 0;
 
 }
 
-void
-FX_Deactivate(char *effect)
-{
-   int                 i;
-
-   for (i = 0; i < num_fx_handlers; i++)
-     {
-       if (!strcmp(fx_handlers[i].name, effect))
-         {
-            if (fx_handlers[i].in_use)
-              {
-                 fx_handlers[i].in_use = 0;
-                 (*(fx_handlers[i].quit_func)) ();
-              }
-         }
-     }
-   return;
-}
-
-void
-FX_Activate(char *effect)
-{
-   int                 i;
-
-   for (i = 0; i < num_fx_handlers; i++)
-     {
-       if (!strcmp(fx_handlers[i].name, effect))
-         {
-            if (!fx_handlers[i].in_use)
-              {
-                 fx_handlers[i].in_use = 1;
-                 (*(fx_handlers[i].init_func)) (effect);
-              }
-         }
-     }
-   return;
-}
-
 /****************************** RIPPLES *************************************/
 
 #define fx_ripple_waterh 64
@@ -222,12 +230,29 @@
 static Window       fx_ripple_win = 0;
 static int          fx_ripple_count = 0;
 
-void                FX_ripple_timeout(int val, void *data);
+static void
+FX_ripple_info(void)
+{
+#if ENABLE_FX_INFO
+   static char         before = 0;
+
+   if (!before)
+      DIALOG_OK(_("Starting up Ripples FX..."),
+               _("\n" "You have just started the Ripples Effect.\n" "\n"
+                 "If you look closely on your desktop background, and if it\n"
+                 "doesn't have a solid colour (i.e. has a background texture or\n"
+                 "image), you will see a pool of water at the bottom of your\n"
+                 "screen that reflects everything above it and \"ripples\".\n"
+                 "\n"
+                 "To disable this effect just select this option again to toggle\n"
+                 "it off.\n"));
+   before = 1;
+#endif
+}
 
-void
+static void
 FX_ripple_timeout(int val, void *data)
 {
-   static char         before = 0;
    static double       incv = 0, inch = 0;
    static GC           gc1 = 0, gc = 0;
    int                 y;
@@ -252,17 +277,8 @@
        gcv.subwindow_mode = IncludeInferiors;
        gc = XCreateGC(disp, fx_ripple_win, GCSubwindowMode, &gcv);
        gc1 = XCreateGC(disp, fx_ripple_win, 0L, &gcv);
-       if (!before)
-          DIALOG_OK(_("Starting up Ripples FX..."),
-                    _("\n" "You have just started the Ripples Effect.\n" "\n"
-                      "If you look closely on your desktop background, and if it\n"
-                      "doesn't have a solid colour (i.e. has a background texture 
or\n"
-                      "image), you will see a pool of water at the bottom of your\n"
-                      "screen that reflects everything above it and \"ripples\".\n"
-                      "\n"
-                      "To disable this effect just select this option again to 
toggle\n"
-                      "it off.\n"));
-       before = 1;
+
+       FX_ripple_info();
      }
    if (fx_ripple_count == 0)
       XCopyArea(disp, fx_ripple_win, fx_ripple_above, gc, 0,
@@ -355,8 +371,6 @@
 static int          fx_raindrops_number = 4;
 static PixImg      *fx_raindrops_draw = NULL;
 
-void                FX_raindrops_timeout(int val, void *data);
-
 typedef struct _drop_context
 {
    int                 x, y;
@@ -367,10 +381,30 @@
 
 static DropContext  fx_raindrops[4];
 
-void
-FX_raindrops_timeout(int val, void *data)
+static void
+FX_raindrops_info(void)
 {
+#if ENABLE_FX_INFO
    static char         before = 0;
+
+   if (!before)
+      DIALOG_OK(_("Starting up Raindrops FX..."),
+               _("\n" "You have just started the Raindrops Effect.\n"
+                 "\n"
+                 "If you look closely on your desktop background, and if it\n"
+                 "doesn't have a solid colour (i.e. has a background texture or\n"
+                 "image), you will see \"raindrops\" hit the background and\n"
+                 "make little splashes. This Effect can be VERY CPU intensive.\n"
+                 "\n"
+                 "To disable this effect just select this option again to toggle\n"
+                 "it off.\n"));
+   before = 1;
+#endif
+}
+
+static void
+FX_raindrops_timeout(int val, void *data)
+{
    static GC           gc1 = 0, gc = 0;
    int                 i, x, y, xx, yy;
    int                 percent_done;
@@ -413,18 +447,9 @@
                         "and editing it, enabling shared pixmaps.\n" "\n"));
             return;
          }
-       if (!before)
-          DIALOG_OK(_("Starting up Raindrops FX..."),
-                    _("\n" "You have just started the Raindrops Effect.\n"
-                      "\n"
-                      "If you look closely on your desktop background, and if it\n"
-                      "doesn't have a solid colour (i.e. has a background texture 
or\n"
-                      "image), you will see \"raindrops\" hit the background and\n"
-                      "make little splashes. This Effect can be VERY CPU intensive.\n"
-                      "\n"
-                      "To disable this effect just select this option again to 
toggle\n"
-                      "it off.\n"));
-       before = 1;
+
+       FX_raindrops_info();
+
        if (first)
          {
             int                 j;
@@ -674,13 +699,30 @@
 static Window       fx_wave_win = 0;
 static int          fx_wave_count = 0;
 
-void                FX_Wave_timeout(int val, void *data);
+static void
+FX_Wave_info(void)
+{
+#if ENABLE_FX_INFO
+   static char         before = 0;
 
-void
+   if (!before)
+      DIALOG_OK(_("Starting up Waves FX..."),
+               _("\n" "You have just started the Waves Effect.\n" "\n"
+                 "If you look closely on your desktop background, and if it\n"
+                 "doesn't have a solid colour (i.e. has a background texture or\n"
+                 "image), you will see a pool of water at the bottom of your\n"
+                 "screen that reflects everything above it and \"waves\".\n"
+                 "\n"
+                 "To disable this effect just select this option again to toggle\n"
+                 "it off.\n"));
+   before = 1;
+#endif
+}
+
+static void
 FX_Wave_timeout(int val, void *data)
 {
    /* Variables */
-   static char         before = 0;
    static double       incv = 0, inch = 0;
    static double       incx = 0;
    double              incx2;
@@ -708,17 +750,8 @@
        gcv.subwindow_mode = IncludeInferiors;
        gc = XCreateGC(disp, fx_wave_win, GCSubwindowMode, &gcv);
        gc1 = XCreateGC(disp, fx_wave_win, 0L, &gcv);
-       if (!before)
-          DIALOG_OK(_("Starting up Waves FX..."),
-                    _("\n" "You have just started the Waves Effect.\n" "\n"
-                      "If you look closely on your desktop background, and if it\n"
-                      "doesn't have a solid colour (i.e. has a background texture 
or\n"
-                      "image), you will see a pool of water at the bottom of your\n"
-                      "screen that reflects everything above it and \"waves\".\n"
-                      "\n"
-                      "To disable this effect just select this option again to 
toggle\n"
-                      "it off.\n"));
-       before = 1;
+
+       FX_Wave_info();
      }
 
    /* On the zero, grab the desktop again. */
@@ -857,12 +890,26 @@
 static int          fx_imagespinner_count = 3;
 static ImlibData   *fx_imagespinner_imd = NULL;
 static char        *fx_imagespinner_params = NULL;
-static void         FX_imagespinner_timeout(int val, void *data);
 
-void
-FX_imagespinner_timeout(int val, void *data)
+static void
+FX_imagespinner_info(void)
 {
+#if ENABLE_FX_INFO
    static char         before = 0;
+
+   if (!before)
+      DIALOG_OK(_("Starting up imagespinners FX..."),
+               _("\n" "You have just started the imagespinners Effect.\n"
+                 "\n"
+                 "To disable this effect just select this option again to toggle\n"
+                 "it off.\n"));
+   before = 1;
+#endif
+}
+
+static void
+FX_imagespinner_timeout(int val, void *data)
+{
    char               *string = NULL;
 
    if (!fx_imagespinner_win)
@@ -872,13 +919,8 @@
           fx_imagespinner_imd = prImlibData;
        else
           fx_imagespinner_imd = pImlibData;
-       if (!before)
-          DIALOG_OK(_("Starting up imagespinners FX..."),
-                    _("\n" "You have just started the imagespinners Effect.\n"
-                      "\n"
-                      "To disable this effect just select this option again to 
toggle\n"
-                      "it off.\n"));
-       before = 1;
+
+       FX_imagespinner_info();
      }
 /* do stuff here */
    string = getword(fx_imagespinner_params, fx_imagespinner_count);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/ipc.c,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -3 -r1.111 -r1.112
--- ipc.c       17 Aug 2003 10:09:07 -0000      1.111
+++ ipc.c       28 Sep 2003 19:36:10 -0000      1.112
@@ -3180,31 +3180,26 @@
        char                word1[FILEPATH_LEN_MAX];
        char                word2[FILEPATH_LEN_MAX];
 
+       word1[0] = '\0';
+       word2[0] = '\0';
+
        word(params, 1, word1);
-       if (!strcmp(word1, "ripples"))
+
+       if (!strcmp(word1, "raindrops") || !strcmp(word1, "ripples") ||
+           !strcmp(word1, "waves"))
          {
             word(params, 2, word2);
-            if (!strcmp(word2, "on"))
-              {
-                 if (!FX_IsOn("ripples"))
-                    FX_Activate("ripples");
-              }
+            if (!strcmp(word2, ""))
+               FX_Op(word1, FX_OP_TOGGLE);
+            else if (!strcmp(word2, "on"))
+               FX_Op(word1, FX_OP_START);
             else if (!strcmp(word2, "off"))
-              {
-                 if (FX_IsOn("ripples"))
-                    FX_Deactivate("ripples");
-              }
+               FX_Op(word1, FX_OP_STOP);
             else if (!strcmp(word2, "?"))
-              {
-                 if (FX_IsOn("ripples"))
-                    Esnprintf(buf, sizeof(buf), "ripples: on");
-                 else
-                    Esnprintf(buf, sizeof(buf), "ripples: off");
-              }
+               Esnprintf(buf, sizeof(buf), "%s: %s", word1,
+                         FX_IsOn(word1) ? "on" : "off");
             else
-              {
-                 Esnprintf(buf, sizeof(buf), "Error: unknown mode specified");
-              }
+               Esnprintf(buf, sizeof(buf), "Error: unknown mode specified");
          }
        else if (!strcmp(word1, "deskslide"))
          {
@@ -3252,31 +3247,6 @@
                  Esnprintf(buf, sizeof(buf), "Error: unknown mode specified");
               }
          }
-       else if (!strcmp(word1, "raindrops"))
-         {
-            word(params, 2, word2);
-            if (!strcmp(word2, "on"))
-              {
-                 if (!FX_IsOn("raindrops"))
-                    FX_Activate("raindrops");
-              }
-            else if (!strcmp(word2, "off"))
-              {
-                 if (FX_IsOn("raindrops"))
-                    FX_Deactivate("raindrops");
-              }
-            else if (!strcmp(word2, "?"))
-              {
-                 if (FX_IsOn("raindrops"))
-                    Esnprintf(buf, sizeof(buf), "raindrops: on");
-                 else
-                    Esnprintf(buf, sizeof(buf), "raindrops: off");
-              }
-            else
-              {
-                 Esnprintf(buf, sizeof(buf), "Error: unknown mode specified");
-              }
-         }
        else if (!strcmp(word1, "menu_animate"))
          {
             word(params, 2, word2);
@@ -3294,31 +3264,6 @@
                     Esnprintf(buf, sizeof(buf), "menu_animate: on");
                  else
                     Esnprintf(buf, sizeof(buf), "menu_animate: off");
-              }
-            else
-              {
-                 Esnprintf(buf, sizeof(buf), "Error: unknown mode specified");
-              }
-         }
-       else if (!strcmp(word1, "waves"))
-         {
-            word(params, 2, word2);
-            if (!strcmp(word2, "on"))
-              {
-                 if (!FX_IsOn("waves"))
-                    FX_Activate("waves");
-              }
-            else if (!strcmp(word2, "off"))
-              {
-                 if (FX_IsOn("waves"))
-                    FX_Deactivate("waves");
-              }
-            else if (!strcmp(word2, "?"))
-              {
-                 if (FX_IsOn("waves"))
-                    Esnprintf(buf, sizeof(buf), "waves: on");
-                 else
-                    Esnprintf(buf, sizeof(buf), "waves: off");
               }
             else
               {
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/settings.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -3 -r1.73 -r1.74
--- settings.c  10 Aug 2003 15:44:47 -0000      1.73
+++ settings.c  28 Sep 2003 19:36:10 -0000      1.74
@@ -2051,6 +2051,9 @@
 static int          tmp_cleanup_slide_speed;
 static int          tmp_desktop_slide_speed;
 static int          tmp_shade_speed;
+static char         tmp_effect_raindrops;
+static char         tmp_effect_ripples;
+static char         tmp_effect_waves;
 
 static void         CB_ConfigureFX(int val, void *data);
 static void
@@ -2071,12 +2074,14 @@
        mode.slidespeedmap = tmp_map_slide_speed;
        mode.slidespeedcleanup = tmp_cleanup_slide_speed;
        desks.slidespeed = tmp_desktop_slide_speed;
-       if ((desks.dragdir != tmp_dragdir)
-           || ((tmp_dragbar) && (desks.dragbar_width < 1)) || ((!tmp_dragbar)
-                                                               &&
-                                                               (desks.
-                                                                dragbar_width >
-                                                                0)))
+
+       FX_Op("raindrops", tmp_effect_raindrops ? FX_OP_START : FX_OP_STOP);
+       FX_Op("ripples", tmp_effect_ripples ? FX_OP_START : FX_OP_STOP);
+       FX_Op("waves", tmp_effect_waves ? FX_OP_START : FX_OP_STOP);
+
+       if ((desks.dragdir != tmp_dragdir) ||
+           ((tmp_dragbar) && (desks.dragbar_width < 1)) ||
+           ((!tmp_dragbar) && (desks.dragbar_width > 0)))
          {
             Button             *b;
 
@@ -2130,6 +2135,10 @@
    tmp_cleanup_slide_speed = mode.slidespeedcleanup;
    tmp_desktop_slide_speed = desks.slidespeed;
 
+   tmp_effect_raindrops = FX_IsOn("raindrops");
+   tmp_effect_ripples = FX_IsOn("ripples");
+   tmp_effect_waves = FX_IsOn("waves");
+
    d = CreateDialog("CONFIGURE_FX");
    DialogSetTitle(d, _("Special FX Settings"));
 
@@ -2437,12 +2446,49 @@
    DialogItemSetFill(di, 1, 0);
    DialogItemSeparatorSetOrientation(di, 0);
 
+   /* Effects */
+   di = DialogAddItem(table, DITEM_TEXT);
+   DialogItemSetPadding(di, 2, 2, 2, 2);
+   DialogItemSetFill(di, 1, 0);
+   DialogItemSetColSpan(di, 4);
+   DialogItemTextSetText(di, _("Effects"));
+#if 0
+   di = DialogAddItem(table, DITEM_CHECKBUTTON);
+   DialogItemSetPadding(di, 2, 2, 2, 2);
+   DialogItemSetFill(di, 1, 0);
+   DialogItemSetColSpan(di, 4);
+   DialogItemCheckButtonSetText(di, _("Enable Effect: Raindrops"));
+   DialogItemCheckButtonSetState(di, tmp_effect_raindrops);
+   DialogItemCheckButtonSetPtr(di, &tmp_effect_raindrops);
+#endif
+   di = DialogAddItem(table, DITEM_CHECKBUTTON);
+   DialogItemSetPadding(di, 2, 2, 2, 2);
+   DialogItemSetFill(di, 1, 0);
+   DialogItemCheckButtonSetText(di, _("Ripples"));
+   DialogItemCheckButtonSetState(di, tmp_effect_ripples);
+   DialogItemCheckButtonSetPtr(di, &tmp_effect_ripples);
+
+   di = DialogAddItem(table, DITEM_CHECKBUTTON);
+   DialogItemSetPadding(di, 2, 2, 2, 2);
+   DialogItemSetFill(di, 1, 0);
+   DialogItemSetColSpan(di, 3);
+   DialogItemCheckButtonSetText(di, _("Waves"));
+   DialogItemCheckButtonSetState(di, tmp_effect_waves);
+   DialogItemCheckButtonSetPtr(di, &tmp_effect_waves);
+
+   di = DialogAddItem(table, DITEM_SEPARATOR);
+   DialogItemSetColSpan(di, 4);
+   DialogItemSetPadding(di, 2, 2, 2, 2);
+   DialogItemSetFill(di, 1, 0);
+   DialogItemSeparatorSetOrientation(di, 0);
+
    DialogAddButton(d, _("OK"), CB_ConfigureFX, 1);
    DialogAddButton(d, _("Apply"), CB_ConfigureFX, 0);
    DialogAddButton(d, _("Close"), CB_ConfigureFX, 1);
    DialogSetExitFunction(d, CB_ConfigureFX, 2, d);
    DialogBindKey(d, "Escape", CB_SettingsEscape, 0, d);
    DialogBindKey(d, "Return", CB_ConfigureFX, 0, d);
+
    ShowDialog(d);
 }
 




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to