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

Re: [E-devel] Lock dialog and ibar patch



On 06/07/22 at 13:26 +0200, Morten Nilsen wrote:
> Osei Poku wrote:
> >  	cfdata->border->lock_client_maximize = 1;
> >  	cfdata->border->lock_client_fullscreen = 1;
> >       }
> > +   else
> > +     {
> > +	cfdata->border->lock_client_location = 0;
> > +	cfdata->border->lock_client_size = 0;
> > +	cfdata->border->lock_client_stacking = 0;
> > +	cfdata->border->lock_client_iconify = 0;
> > +	cfdata->border->lock_client_desk = 0;
> > +	cfdata->border->lock_client_sticky = 0;
> > +	cfdata->border->lock_client_shade = 0;
> > +	cfdata->border->lock_client_maximize = 0;
> > +	cfdata->border->lock_client_fullscreen = 0;
> > +     }
> 
> don't know about you, but I like to eliminate duplicate code..
> 
> so, to me, it seems it would be better to use an intermittent variable..
> 
> val = (foo) ? 1 : 0;
> 
> .... = val;
> .... = val;
> ......
> 
> val = (bar) ? 1 : 0;
> 
> etc..
> 
> -- 
> Cheers,
> Morten
> :wq

Good call. Changes made.  The lock_client_desk field doesnt seem to be
used and so I leave it unchanged.

Osei
Index: e_int_border_locks.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_int_border_locks.c,v
retrieving revision 1.12
diff -u -3 -r1.12 e_int_border_locks.c
--- e_int_border_locks.c	18 Feb 2006 04:35:27 -0000	1.12
+++ e_int_border_locks.c	22 Jul 2006 17:12:25 -0000
@@ -148,40 +148,40 @@
 _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
 {
    /* Actually take our cfdata settings and apply them in real life */
-   
-   if (cfdata->do_what_i_say)
-     {
-	cfdata->border->lock_client_location = 1;
-	cfdata->border->lock_client_size = 1;
-	cfdata->border->lock_client_stacking = 1;
-	cfdata->border->lock_client_iconify = 1;
-	cfdata->border->lock_client_desk = 0;
-	cfdata->border->lock_client_sticky = 1;
-	cfdata->border->lock_client_shade = 1;
-	cfdata->border->lock_client_maximize = 1;
-	cfdata->border->lock_client_fullscreen = 1;
-     }
-   if (cfdata->protect_from_me)
-     {
-	cfdata->border->lock_user_location = 1;
-	cfdata->border->lock_user_size = 1;
-	cfdata->border->lock_user_stacking = 1;
-	cfdata->border->lock_user_iconify = 1;
-	cfdata->border->lock_user_desk = 0;
-	cfdata->border->lock_user_sticky = 1;
-	cfdata->border->lock_user_shade = 1;
-	cfdata->border->lock_user_maximize = 1;
-	cfdata->border->lock_user_fullscreen = 1;
-     }
-   if (cfdata->important_window)
-     {
-	cfdata->border->lock_close = 1;
-	cfdata->border->lock_life = 1;
-     }
-   if (cfdata->keep_my_border)
-     {
-	cfdata->border->lock_border = 1;
-     }
+   int tmp;
+
+   /* cfdata->do_what_i_say options */
+   tmp = (cfdata->do_what_i_say) ? 1 : 0;
+   cfdata->border->lock_client_location = tmp;
+   cfdata->border->lock_client_size = tmp;
+   cfdata->border->lock_client_stacking = tmp;
+   cfdata->border->lock_client_iconify = tmp;
+   cfdata->border->lock_client_desk = 0;
+   cfdata->border->lock_client_sticky = tmp;
+   cfdata->border->lock_client_shade = tmp;
+   cfdata->border->lock_client_maximize = tmp;
+   cfdata->border->lock_client_fullscreen = tmp;
+
+   /* cfdata->protect_from_me options */
+   tmp = (cfdata->protect_from_me) ? 1 : 0;
+   cfdata->border->lock_user_location = tmp;
+   cfdata->border->lock_user_size = tmp;
+   cfdata->border->lock_user_stacking = tmp;
+   cfdata->border->lock_user_iconify = tmp;
+   cfdata->border->lock_user_desk = 0;
+   cfdata->border->lock_user_sticky = tmp;
+   cfdata->border->lock_user_shade = tmp;
+   cfdata->border->lock_user_maximize = tmp;
+   cfdata->border->lock_user_fullscreen = tmp;
+   
+   /* important_window options */
+   tmp = (cfdata->important_window) ? 1 : 0;
+   cfdata->border->lock_close = tmp;
+   cfdata->border->lock_life = tmp;
+
+   /* keep_my_border obtions */
+   cfdata->border->lock_border = (cfdata->keep_my_border) ? 1 : 0;
+
    /* FIXME: need to check if the remember stuff will actually work or not
     * (see e_int_border_remember.c where it checks and warns) */
    if (cfdata->remember_locks)