1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 12:00:31 +01:00

WINGs: Added 'const' attribute to functions in wapplication, wappresource, wcolor, wfont, wpixmap

This makes both the API and local function const-correct on their
input parameters.
This commit is contained in:
Christophe CURIS
2013-05-09 17:34:01 +02:00
committed by Carlos R. Mafra
parent af403073f0
commit e7c8ac76ea
6 changed files with 37 additions and 37 deletions

View File

@@ -608,15 +608,15 @@ WMRect wmkrect(int x, int y, unsigned int width, unsigned int height);
void WMInitializeApplication(char *applicationName, int *argc, char **argv); void WMInitializeApplication(const char *applicationName, int *argc, char **argv);
void WMSetResourcePath(char *path); void WMSetResourcePath(const char *path);
/* don't free the returned string */ /* don't free the returned string */
char* WMGetApplicationName(void); char* WMGetApplicationName(void);
/* Try to locate resource file. ext may be NULL */ /* Try to locate resource file. ext may be NULL */
char* WMPathForResourceOfType(char *resource, char *ext); char* WMPathForResourceOfType(const char *resource, const char *ext);
/* ---[ WINGs/widgets.c ]------------------------------------------------- */ /* ---[ WINGs/widgets.c ]------------------------------------------------- */
@@ -654,7 +654,7 @@ void WMSetApplicationIconPixmap(WMScreen *app, WMPixmap *icon);
WMPixmap* WMGetApplicationIconPixmap(WMScreen *app); WMPixmap* WMGetApplicationIconPixmap(WMScreen *app);
/* If color==NULL it will use the default color for panels: ae/aa/ae */ /* If color==NULL it will use the default color for panels: ae/aa/ae */
WMPixmap* WMCreateApplicationIconBlendedPixmap(WMScreen *scr, RColor *color); WMPixmap* WMCreateApplicationIconBlendedPixmap(WMScreen *scr, const RColor *color);
void WMSetApplicationIconWindow(WMScreen *scr, Window window); void WMSetApplicationIconWindow(WMScreen *scr, Window window);
@@ -745,7 +745,7 @@ void WMSetViewDragDestinationProcs(WMView *view, WMDragDestinationProcs *procs);
Bool WMIsAntialiasingEnabled(WMScreen *scrPtr); Bool WMIsAntialiasingEnabled(WMScreen *scrPtr);
WMFont* WMCreateFont(WMScreen *scrPtr, char *fontName); WMFont* WMCreateFont(WMScreen *scrPtr, const char *fontName);
WMFont* WMCopyFontWithStyle(WMScreen *scrPtr, WMFont *font, WMFontStyle style); WMFont* WMCopyFontWithStyle(WMScreen *scrPtr, WMFont *font, WMFontStyle style);
@@ -770,13 +770,13 @@ WMFont* WMSystemFontOfSize(WMScreen *scrPtr, int size);
WMFont* WMBoldSystemFontOfSize(WMScreen *scrPtr, int size); WMFont* WMBoldSystemFontOfSize(WMScreen *scrPtr, int size);
void WMDrawString(WMScreen *scr, Drawable d, WMColor *color, WMFont *font, void WMDrawString(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
int x, int y, char *text, int length); int x, int y, const char *text, int length);
void WMDrawImageString(WMScreen *scr, Drawable d, WMColor *color, void WMDrawImageString(WMScreen *scr, Drawable d, WMColor *color,
WMColor *background, WMFont *font, int x, int y, WMColor *background, WMFont *font, int x, int y,
char *text, int length); const char *text, int length);
int WMWidthOfString(WMFont *font, char *text, int length); int WMWidthOfString(WMFont *font, const char *text, int length);
/* ---[ WINGs/wpixmap.c ]------------------------------------------------- */ /* ---[ WINGs/wpixmap.c ]------------------------------------------------- */
@@ -798,13 +798,13 @@ WMPixmap* WMCreatePixmapFromXPMData(WMScreen *scrPtr, char **data);
WMSize WMGetPixmapSize(WMPixmap *pixmap); WMSize WMGetPixmapSize(WMPixmap *pixmap);
WMPixmap* WMCreatePixmapFromFile(WMScreen *scrPtr, char *fileName); WMPixmap* WMCreatePixmapFromFile(WMScreen *scrPtr, const char *fileName);
WMPixmap* WMCreateBlendedPixmapFromRImage(WMScreen *scrPtr, RImage *image, WMPixmap* WMCreateBlendedPixmapFromRImage(WMScreen *scrPtr, RImage *image,
RColor *color); const RColor *color);
WMPixmap* WMCreateBlendedPixmapFromFile(WMScreen *scrPtr, char *fileName, WMPixmap* WMCreateBlendedPixmapFromFile(WMScreen *scrPtr, const char *fileName,
RColor *color); const RColor *color);
void WMDrawPixmap(WMPixmap *pixmap, Drawable d, int x, int y); void WMDrawPixmap(WMPixmap *pixmap, Drawable d, int x, int y);
@@ -846,7 +846,7 @@ WMColor* WMCreateRGBAColor(WMScreen *scr, unsigned short red,
unsigned short green, unsigned short blue, unsigned short green, unsigned short blue,
unsigned short alpha, Bool exact); unsigned short alpha, Bool exact);
WMColor* WMCreateNamedColor(WMScreen *scr, char *name, Bool exact); WMColor* WMCreateNamedColor(WMScreen *scr, const char *name, Bool exact);
RColor WMGetRColorFromColor(WMColor *color); RColor WMGetRColorFromColor(WMColor *color);

View File

@@ -16,7 +16,7 @@ Bool W_ApplicationInitialized(void)
return _WINGS_progname != NULL; return _WINGS_progname != NULL;
} }
void WMInitializeApplication(char *applicationName, int *argc, char **argv) void WMInitializeApplication(const char *applicationName, int *argc, char **argv)
{ {
int i; int i;
@@ -49,7 +49,7 @@ void WMInitializeApplication(char *applicationName, int *argc, char **argv)
W_InitNotificationCenter(); W_InitNotificationCenter();
} }
void WMSetResourcePath(char *path) void WMSetResourcePath(const char *path)
{ {
if (WMApplication.resourcePath) if (WMApplication.resourcePath)
wfree(WMApplication.resourcePath); wfree(WMApplication.resourcePath);
@@ -102,7 +102,7 @@ error:
return NULL; return NULL;
} }
char *WMPathForResourceOfType(char *resource, char *ext) char *WMPathForResourceOfType(const char *resource, const char *ext)
{ {
char *path, *tmp, *appdir; char *path, *tmp, *appdir;
int i; int i;

View File

@@ -77,17 +77,17 @@ WMPixmap *WMGetApplicationIconPixmap(WMScreen * scr)
return scr->applicationIconPixmap; return scr->applicationIconPixmap;
} }
WMPixmap *WMCreateApplicationIconBlendedPixmap(WMScreen * scr, RColor * color) WMPixmap *WMCreateApplicationIconBlendedPixmap(WMScreen * scr, const RColor * color)
{ {
WMPixmap *pix; WMPixmap *pix;
if (scr->applicationIconImage) { if (scr->applicationIconImage) {
RColor gray; static const RColor gray = {
/* red */ 0xAE,
gray.red = 0xae; /* green */ 0xAA,
gray.green = 0xaa; /* blue */ 0xAE,
gray.blue = 0xae; /* alpha */ 0xFF
gray.alpha = 0xff; };
if (!color) if (!color)
color = &gray; color = &gray;

View File

@@ -122,7 +122,7 @@ WMColor *WMCreateRGBAColor(WMScreen * scr, unsigned short red, unsigned short gr
return color; return color;
} }
WMColor *WMCreateNamedColor(WMScreen * scr, char *name, Bool exact) WMColor *WMCreateNamedColor(WMScreen * scr, const char *name, Bool exact)
{ {
WMColor *color; WMColor *color;
XColor xcolor; XColor xcolor;

View File

@@ -16,7 +16,7 @@
#define DEFAULT_SIZE WINGsConfiguration.defaultFontSize #define DEFAULT_SIZE WINGsConfiguration.defaultFontSize
static FcPattern *xlfdToFcPattern(char *xlfd) static FcPattern *xlfdToFcPattern(const char *xlfd)
{ {
FcPattern *pattern; FcPattern *pattern;
char *fname, *ptr; char *fname, *ptr;
@@ -41,7 +41,7 @@ static FcPattern *xlfdToFcPattern(char *xlfd)
return pattern; return pattern;
} }
static char *xlfdToFcName(char *xlfd) static char *xlfdToFcName(const char *xlfd)
{ {
FcPattern *pattern; FcPattern *pattern;
char *fname; char *fname;
@@ -64,7 +64,7 @@ static Bool hasProperty(FcPattern * pattern, const char *property)
return False; return False;
} }
static Bool hasPropertyWithStringValue(FcPattern * pattern, const char *object, char *value) static Bool hasPropertyWithStringValue(FcPattern * pattern, const char *object, const char *value)
{ {
FcChar8 *str; FcChar8 *str;
int id; int id;
@@ -83,7 +83,7 @@ static Bool hasPropertyWithStringValue(FcPattern * pattern, const char *object,
return False; return False;
} }
static char *makeFontOfSize(char *font, int size, char *fallback) static char *makeFontOfSize(const char *font, int size, const char *fallback)
{ {
FcPattern *pattern; FcPattern *pattern;
char *result; char *result;
@@ -91,7 +91,7 @@ static char *makeFontOfSize(char *font, int size, char *fallback)
if (font[0] == '-') { if (font[0] == '-') {
pattern = xlfdToFcPattern(font); pattern = xlfdToFcPattern(font);
} else { } else {
pattern = FcNameParse((FcChar8 *) font); pattern = FcNameParse((const FcChar8 *) font);
} }
/*FcPatternPrint(pattern); */ /*FcPatternPrint(pattern); */
@@ -104,7 +104,7 @@ static char *makeFontOfSize(char *font, int size, char *fallback)
} }
if (fallback && !hasPropertyWithStringValue(pattern, FC_FAMILY, fallback)) { if (fallback && !hasPropertyWithStringValue(pattern, FC_FAMILY, fallback)) {
FcPatternAddString(pattern, FC_FAMILY, (FcChar8 *) fallback); FcPatternAddString(pattern, FC_FAMILY, (const FcChar8 *) fallback);
} }
/*FcPatternPrint(pattern); */ /*FcPatternPrint(pattern); */
@@ -115,7 +115,7 @@ static char *makeFontOfSize(char *font, int size, char *fallback)
return result; return result;
} }
WMFont *WMCreateFont(WMScreen * scrPtr, char *fontName) WMFont *WMCreateFont(WMScreen * scrPtr, const char *fontName)
{ {
Display *display = scrPtr->display; Display *display = scrPtr->display;
WMFont *font; WMFont *font;
@@ -250,7 +250,7 @@ WMFont *WMBoldSystemFontOfSize(WMScreen * scrPtr, int size)
return font; return font;
} }
int WMWidthOfString(WMFont * font, char *text, int length) int WMWidthOfString(WMFont * font, const char *text, int length)
{ {
XGlyphInfo extents; XGlyphInfo extents;
@@ -261,7 +261,7 @@ int WMWidthOfString(WMFont * font, char *text, int length)
return extents.xOff; /* don't ask :P */ return extents.xOff; /* don't ask :P */
} }
void WMDrawString(WMScreen * scr, Drawable d, WMColor * color, WMFont * font, int x, int y, char *text, int length) void WMDrawString(WMScreen * scr, Drawable d, WMColor * color, WMFont * font, int x, int y, const char *text, int length)
{ {
XftColor xftcolor; XftColor xftcolor;
@@ -280,7 +280,7 @@ void WMDrawString(WMScreen * scr, Drawable d, WMColor * color, WMFont * font, in
void void
WMDrawImageString(WMScreen * scr, Drawable d, WMColor * color, WMColor * background, WMDrawImageString(WMScreen * scr, Drawable d, WMColor * color, WMColor * background,
WMFont * font, int x, int y, char *text, int length) WMFont * font, int x, int y, const char *text, int length)
{ {
XftColor textColor; XftColor textColor;
XftColor bgColor; XftColor bgColor;

View File

@@ -64,7 +64,7 @@ WMPixmap *WMCreatePixmapFromXPixmaps(WMScreen * scrPtr, Pixmap pixmap, Pixmap ma
return pixPtr; return pixPtr;
} }
WMPixmap *WMCreatePixmapFromFile(WMScreen * scrPtr, char *fileName) WMPixmap *WMCreatePixmapFromFile(WMScreen * scrPtr, const char *fileName)
{ {
WMPixmap *pixPtr; WMPixmap *pixPtr;
RImage *image; RImage *image;
@@ -101,7 +101,7 @@ WMPixmap *WMCreatePixmapFromRImage(WMScreen * scrPtr, RImage * image, int thresh
return pixPtr; return pixPtr;
} }
WMPixmap *WMCreateBlendedPixmapFromRImage(WMScreen * scrPtr, RImage * image, RColor * color) WMPixmap *WMCreateBlendedPixmapFromRImage(WMScreen * scrPtr, RImage * image, const RColor * color)
{ {
WMPixmap *pixPtr; WMPixmap *pixPtr;
RImage *copy; RImage *copy;
@@ -117,7 +117,7 @@ WMPixmap *WMCreateBlendedPixmapFromRImage(WMScreen * scrPtr, RImage * image, RCo
return pixPtr; return pixPtr;
} }
WMPixmap *WMCreateBlendedPixmapFromFile(WMScreen * scrPtr, char *fileName, RColor * color) WMPixmap *WMCreateBlendedPixmapFromFile(WMScreen * scrPtr, const char *fileName, const RColor * color)
{ {
WMPixmap *pixPtr; WMPixmap *pixPtr;
RImage *image; RImage *image;