Revision: 1496
          http://geeqie.svn.sourceforge.net/geeqie/?rev=1496&view=rev
Author:   zas_
Date:     2009-03-08 15:30:15 +0000 (Sun, 08 Mar 2009)

Log Message:
-----------
Add helper macros EDITOR_ERRORS() and EDITOR_ERRORS_BUT_SKIPPED() to clean up 
the code a bit. Minor tidy up.

Modified Paths:
--------------
    trunk/src/editors.c
    trunk/src/editors.h
    trunk/src/menu.c
    trunk/src/preferences.c
    trunk/src/utilops.c

Modified: trunk/src/editors.c
===================================================================
--- trunk/src/editors.c 2009-03-08 15:02:18 UTC (rev 1495)
+++ trunk/src/editors.c 2009-03-08 15:30:15 UTC (rev 1496)
@@ -830,7 +830,7 @@
        ed->pid = -1;
        ed->flags = editor->flags | editor_command_parse(editor, list, 
&command);
 
-       ok = !(ed->flags & EDITOR_ERROR_MASK);
+       ok = !EDITOR_ERRORS(ed->flags);
 
        if (ok)
                {
@@ -924,7 +924,7 @@
 
        g_free(command);
 
-       return ed->flags & EDITOR_ERROR_MASK;
+       return EDITOR_ERRORS(ed->flags);
 }
 
 static gint editor_command_next_start(EditorData *ed)
@@ -995,12 +995,15 @@
                ed->list = NULL;
                }
 
-       if (cont == EDITOR_CB_SUSPEND)
-               return ed->flags & EDITOR_ERROR_MASK;
-       else if (cont == EDITOR_CB_SKIP)
-               return editor_command_done(ed);
-       else
-               return editor_command_next_start(ed);
+       switch (cont)
+               {
+               case EDITOR_CB_SUSPEND:
+                       return EDITOR_ERRORS(ed->flags);
+               case EDITOR_CB_SKIP:
+                       return editor_command_done(ed);
+               }
+       
+       return editor_command_next_start(ed);
 }
 
 static gint editor_command_done(EditorData *ed)
@@ -1034,7 +1037,7 @@
 
        ed->count = 0;
 
-       flags = ed->flags & EDITOR_ERROR_MASK;
+       flags = EDITOR_ERRORS(ed->flags);
 
        if (!ed->vd) editor_data_free(ed);
 
@@ -1056,7 +1059,7 @@
        EditorData *ed;
        gint flags = editor->flags;
 
-       if (flags & EDITOR_ERROR_MASK) return flags & EDITOR_ERROR_MASK;
+       if (EDITOR_ERRORS(flags)) return EDITOR_ERRORS(flags);
 
        ed = g_new0(EditorData, 1);
        ed->list = filelist_copy(list);
@@ -1074,7 +1077,7 @@
 
        editor_command_next_start(ed);
        /* errors from editor_command_next_start will be handled via callback */
-       return flags & EDITOR_ERROR_MASK;
+       return EDITOR_ERRORS(flags);
 }
 
 gboolean is_valid_editor_command(const gchar *key)
@@ -1096,7 +1099,7 @@
 
        error = editor_command_start(editor, editor->name, list, cb, data);
 
-       if (error & EDITOR_ERROR_MASK)
+       if (EDITOR_ERRORS(error))
                {
                gchar *text = g_strdup_printf(_("%s\n\"%s\""), 
editor_get_error_str(error), editor->file);
                

Modified: trunk/src/editors.h
===================================================================
--- trunk/src/editors.h 2009-03-08 15:02:18 UTC (rev 1495)
+++ trunk/src/editors.h 2009-03-08 15:30:15 UTC (rev 1496)
@@ -34,6 +34,8 @@
 
 #define        EDITOR_ERROR_MASK         0xffff0000
 
+#define EDITOR_ERRORS(flags) ((flags) & EDITOR_ERROR_MASK)
+#define EDITOR_ERRORS_BUT_SKIPPED(flags) (((flags) & EDITOR_ERROR_MASK) && 
!((flags) & EDITOR_ERROR_SKIPPED))
 
 /* return values from callback function */
 enum {

Modified: trunk/src/menu.c
===================================================================
--- trunk/src/menu.c    2009-03-08 15:02:18 UTC (rev 1495)
+++ trunk/src/menu.c    2009-03-08 15:30:15 UTC (rev 1496)
@@ -76,12 +76,8 @@
                work = work->next;
                gboolean active = TRUE;
 
-               if (fd_list)
-                       {
-                       gint flags = editor_command_parse(editor, fd_list, 
NULL);
-                       if ((flags & EDITOR_ERROR_MASK) != 0)
-                               active = FALSE;
-                       }
+               if (fd_list && EDITOR_ERRORS(editor_command_parse(editor, 
fd_list, NULL)))
+                       active = FALSE;
 
                if (active)
                        {

Modified: trunk/src/preferences.c
===================================================================
--- trunk/src/preferences.c     2009-03-08 15:02:18 UTC (rev 1495)
+++ trunk/src/preferences.c     2009-03-08 15:30:15 UTC (rev 1496)
@@ -201,7 +201,7 @@
                        {
                        gint flags = editor_command_parse(buf, NULL, NULL);
                
-                       if (flags & EDITOR_ERROR_MASK)
+                       if (EDITOR_ERRORS(flags))
                                {
                                if (errmsg->str[0]) g_string_append(errmsg, 
"\n\n");
                                g_string_append_printf(errmsg, _("%s\n#%d 
\"%s\":\n%s"), editor_get_error_str(flags),

Modified: trunk/src/utilops.c
===================================================================
--- trunk/src/utilops.c 2009-03-08 15:02:18 UTC (rev 1495)
+++ trunk/src/utilops.c 2009-03-08 15:30:15 UTC (rev 1496)
@@ -503,10 +503,11 @@
 static gint file_util_perform_ci_cb(gpointer resume_data, gint flags, GList 
*list, gpointer data)
 {
        UtilityData *ud = data;
+       gint ret = EDITOR_CB_CONTINUE;
+
        ud->resume_data = resume_data;
        
-       gint ret = EDITOR_CB_CONTINUE;
-       if ((flags & EDITOR_ERROR_MASK) && !(flags & EDITOR_ERROR_SKIPPED))
+       if (EDITOR_ERRORS_BUT_SKIPPED(flags))
                {
                GString *msg = g_string_new(editor_get_error_str(flags));
                GenericDialog *d;
@@ -548,7 +549,7 @@
                FileData *fd = list->data;
                list = list->next;
 
-               if (!(flags & EDITOR_ERROR_MASK)) /* files were successfully 
deleted, call the maint functions */
+               if (!EDITOR_ERRORS(flags)) /* files were successfully deleted, 
call the maint functions */
                        {
                        if (ud->with_sidecars) 
                                file_data_sc_apply_ci(fd);
@@ -792,7 +793,7 @@
 static gint file_util_perform_ci_dir_cb(gpointer resume_data, gint flags, 
GList *list, gpointer data)
 {
        UtilityData *ud = data;
-       file_util_perform_ci_dir(ud, FALSE, !((flags & EDITOR_ERROR_MASK) && 
!(flags & EDITOR_ERROR_SKIPPED)));
+       file_util_perform_ci_dir(ud, FALSE, !EDITOR_ERRORS_BUT_SKIPPED(flags));
        return EDITOR_CB_CONTINUE; /* does not matter, there was just single 
directory */
 }
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn

Reply via email to