This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project wmaker-crm.git.

The branch, next has been updated
       via  39fa6d9e2cc75861d71fe9d7387c7e26d7d02a99 (commit)
       via  76e8a8f963946311ba054f69350fc77c2ed7799b (commit)
      from  f5d845cfadeedce4a848189de01a6c4c95cd7db7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://repo.or.cz/w/wmaker-crm.git/commit/39fa6d9e2cc75861d71fe9d7387c7e26d7d02a99

commit 39fa6d9e2cc75861d71fe9d7387c7e26d7d02a99
Author: Rodolfo García Peñas (kix) <[email protected]>
Date:   Tue Jul 3 12:43:02 2012 +0200

    Remove dup code from getWindowMakerIconImage()
    
    The code to find the icon in the function getWindowMakerIconImage()
    is duplicated, because it is the same code as in get_default_icon_filename()
    
    This patch includes the prototypes of get_default_icon_filename()
    and get_default_icon_rimage() in defaults.h, so these functions
    can be used in other files.

diff --git a/src/defaults.h b/src/defaults.h
index 9b5ea95..e96128a 100644
--- a/src/defaults.h
+++ b/src/defaults.h
@@ -48,4 +48,7 @@ RImage * wDefaultGetImage(WScreen *scr, char *winstance, char 
*wclass, int max_s
 
 int wDefaultGetStartWorkspace(WScreen *scr, char *instance, char *class);
 void wDefaultChangeIcon(WScreen *scr, char *instance, char* class, char *file);
+char *get_default_icon_filename(WScreen *scr, char *winstance, char *wclass, 
char *command,
+                               Bool noDefault);
+RImage *get_default_icon_rimage(WScreen *scr, char *file_name, int max_size);
 #endif /* WMDEFAULTS_H_ */
diff --git a/src/dialog.c b/src/dialog.c
index f2ec900..3f9e536 100644
--- a/src/dialog.c
+++ b/src/dialog.c
@@ -1461,45 +1461,23 @@ static void setCrashAction(void *self, void *clientData)
 }
 
 /* Make this read the logo from a compiled in pixmap -Dan */
-static WMPixmap *getWindowMakerIconImage(WMScreen * scr)
+static WMPixmap *getWindowMakerIconImage(WMScreen *scr)
 {
-       WMPropList *dict, *key, *option, *value = NULL;
        WMPixmap *pix = NULL;
-       char *path;
-
-       if (!WDWindowAttributes || !WDWindowAttributes->dictionary)
-               return NULL;
-
-       WMPLSetCaseSensitive(True);
-
-       key = WMCreatePLString("Logo.WMPanel");
-       option = WMCreatePLString("Icon");
-
-       dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key);
-
-       if (dict) {
-               value = WMGetFromPLDictionary(dict, option);
-       }
-
-       WMReleasePropList(key);
-       WMReleasePropList(option);
-
-       WMPLSetCaseSensitive(False);
+       char *path = NULL;
 
-       if (value && WMIsPLString(value)) {
-               path = FindImage(wPreferences.icon_path, 
WMGetFromPLString(value));
+       path = get_default_icon_filename(NULL, "Logo", "WMPanel", NULL, True);
 
-               if (path) {
-                       RColor gray;
+       if (path) {
+               RColor gray;
 
-                       gray.red = 0xae;
-                       gray.green = 0xaa;
-                       gray.blue = 0xae;
-                       gray.alpha = 0;
+               gray.red = 0xae;
+               gray.green = 0xaa;
+               gray.blue = 0xae;
+               gray.alpha = 0;
 
-                       pix = WMCreateBlendedPixmapFromFile(scr, path, &gray);
-                       wfree(path);
-               }
+               pix = WMCreateBlendedPixmapFromFile(scr, path, &gray);
+               wfree(path);
        }
 
        return pix;

http://repo.or.cz/w/wmaker-crm.git/commit/76e8a8f963946311ba054f69350fc77c2ed7799b

commit 76e8a8f963946311ba054f69350fc77c2ed7799b
Author: Rodolfo García Peñas (kix) <[email protected]>
Date:   Tue Jul 3 12:00:47 2012 +0200

    wDefaultGetImage splitted
    
    The function wDefaultGetImage() is splitted in two:
    
    1. get_default_icon_filename(): This function returns the full
       path of an icon. The function searches the icon in the database
       using instance and class.
    2. get_default_icon_rimage(): This function returns the RImage for
       a given image path (full path). This function validates the icon
       size, so the icon is fully usable.
    
    The function get_default_icon_filename() now adds the .app icons in the
    search (using wApplicationExtractDirPackIcon()). To do it, the command
    should be included, because this function searches '"command".app' icons.
    Setting the command to NULL, this case is not used.
    
    To do it we need the function wApplicationExtractDirPackIcon() defined
    at appicon.c, so we need set the function as non-static and provide their
    prototype in appicon.h.
    
    This patch also includes an extra pointer check at wDefaultGetStartWorkspace
    to make sure that WDWindowAttributes exists.

diff --git a/src/appicon.c b/src/appicon.c
index 25f88ce..795b020 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -74,7 +74,7 @@ static void remove_from_appicon_list(WScreen *scr, WAppIcon 
*appicon);
 /* This function is used if the application is a .app. It checks if it has an 
icon in it
  * like for example /usr/local/GNUstep/Applications/WPrefs.app/WPrefs.tiff
  */
-static void wApplicationExtractDirPackIcon(WScreen * scr, char *path, char 
*wm_instance, char *wm_class)
+void wApplicationExtractDirPackIcon(WScreen * scr, char *path, char 
*wm_instance, char *wm_class)
 {
        char *iconPath = NULL;
        char *tmp = NULL;
diff --git a/src/appicon.h b/src/appicon.h
index 1fbd976..280843c 100644
--- a/src/appicon.h
+++ b/src/appicon.h
@@ -80,4 +80,6 @@ void makeAppIconFor(WApplication * wapp);
 void removeAppIconFor(WApplication * wapp);
 void save_appicon(WAppIcon *aicon, Bool dock);
 void paint_app_icon(WApplication *wapp);
+void wApplicationExtractDirPackIcon(WScreen * scr, char *path, char 
*wm_instance,
+                                   char *wm_class);
 #endif
diff --git a/src/wdefaults.c b/src/wdefaults.c
index a34d86e..1f52d7d 100644
--- a/src/wdefaults.c
+++ b/src/wdefaults.c
@@ -36,6 +36,7 @@
 
 #include "WindowMaker.h"
 #include "window.h"
+#include "appicon.h"
 #include "screen.h"
 #include "funcs.h"
 #include "workspace.h"
@@ -374,36 +375,80 @@ static WMPropList *get_generic_value(char *instance, char 
*class,
        return value;
 }
 
-RImage *wDefaultGetImage(WScreen * scr, char *winstance, char *wclass, int 
max_size)
+/* Get the file name of the image, using instance and class */
+char *get_default_icon_filename(WScreen *scr, char *winstance, char *wclass, 
char *command,
+                               Bool noDefault)
 {
-       char *file_name;
-       char *path;
-       RImage *image;
+       char *file_name = NULL;
+       char *file_path = NULL;
 
        /* Get the file name of the image, using instance and class */
-       file_name = wDefaultGetIconFile(winstance, wclass, False);
-       if (!file_name)
-               return NULL;
+       file_name = wDefaultGetIconFile(winstance, wclass, noDefault);
+
+       /* If the specific (or generic if noDefault is False) icon filename
+        * is not found, and command is specified, then include the .app icons
+        * and re-do the search, but now always including the default icon
+        * so the icon is found always. The .app is selected before default */
+       if (!file_name && scr && command) {
+               wApplicationExtractDirPackIcon(scr, command, winstance, wclass);
+               file_name = wDefaultGetIconFile(winstance, wclass, False);
+       }
 
-       /* Search the file image in the icon paths */
-       path = FindImage(wPreferences.icon_path, file_name);
+       /* Get the full path for the image file */
+       if (file_name) {
+               file_path = FindImage(wPreferences.icon_path, file_name);
+
+               if (!file_path)
+                       wwarning(_("could not find icon file "%s""), file_name);
+
+               /* FIXME: Here, if file_path don't exists, then the icon is in 
the
+                * "icon database" (WDWindowAttributes->dictionary), but the 
icon
+                * is not en disk. Therefore, we should remove it from the icon
+                * database.
+                * OTOH, probably the correct message should be "could not find 
the
+                * icon file %s, please, check your configuration files", 
because
+                * the icons are loaded in the icon database from the 
configuration
+                * files
+                */
+
+               /* Don't wfree(file_name) here, because is a pointer to the icon
+                * dictionary (WDWindowAttributes->dictionary) value.
+                */
+       }
 
-       if (!path) {
-               wwarning(_("could not find icon file "%s""), file_name);
+       return file_path;
+}
+
+/* This function returns the image picture for the file_name file */
+RImage *get_default_icon_rimage(WScreen *scr, char *file_name, int max_size)
+{
+       RImage *image = NULL;
+
+       if (!file_name)
                return NULL;
-       }
 
-       image = RLoadImage(scr->rcontext, path, 0);
+       image = RLoadImage(scr->rcontext, file_name, 0);
        if (!image)
-               wwarning(_("error loading image file "%s": %s"), path, 
RMessageForError(RErrorCode));
-
-       wfree(path);
+               wwarning(_("error loading image file "%s": %s"), file_name,
+                        RMessageForError(RErrorCode));
 
        image = wIconValidateIconSize(scr, image, max_size);
 
        return image;
 }
 
+RImage *wDefaultGetImage(WScreen * scr, char *winstance, char *wclass, int 
max_size)
+{
+       char *file_name = NULL;
+
+       /* Get the file name of the image, using instance and class */
+       file_name = get_default_icon_filename(scr, winstance, wclass, NULL, 
False);
+       if (!file_name)
+               return NULL;
+
+       return get_default_icon_rimage(scr, file_name, max_size);
+}
+
 int wDefaultGetStartWorkspace(WScreen * scr, char *instance, char *class)
 {
        WMPropList *value;
@@ -441,7 +486,7 @@ char *wDefaultGetIconFile(char *instance, char *class, Bool 
noDefault)
        if (!ANoTitlebar)
                init_wdefaults();
 
-       if (!WDWindowAttributes->dictionary)
+       if (!WDWindowAttributes || !WDWindowAttributes->dictionary)
                return NULL;
 
        value = get_generic_value(instance, class, AIcon, noDefault);

-----------------------------------------------------------------------

Summary of changes:
 src/appicon.c   |    2 +-
 src/appicon.h   |    2 +
 src/defaults.h  |    3 ++
 src/dialog.c    |   44 +++++++-----------------------
 src/wdefaults.c |   79 +++++++++++++++++++++++++++++++++++++++++++------------
 5 files changed, 79 insertions(+), 51 deletions(-)


repo.or.cz automatic notification. Contact project admin [email protected]
if you want to unsubscribe, or site admin [email protected] if you receive
no reply.
-- 
wmaker-crm.git ("The Window Maker window manager")


-- 
To unsubscribe, send mail to [email protected].

Reply via email to