[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright gtkshell/ptk-app-menu.c rootcat/Makef...
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright gtkshell/ptk-app-menu.c rootcat/Makef... |
Date: |
Sun, 15 Aug 2010 22:23:29 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 10/08/15 22:23:29
Modified files:
gtkshell : ptk-app-menu.c
rootcat : Makefile rootcat.c
Added files:
rootcat : StringRenderer.c StringRenderer.h rootcat.h
Log message:
End of night commit.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/ptk-app-menu.c?cvsroot=antiright&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/antiright/rootcat/Makefile?cvsroot=antiright&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/antiright/rootcat/rootcat.c?cvsroot=antiright&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/antiright/rootcat/StringRenderer.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/rootcat/StringRenderer.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/rootcat/rootcat.h?cvsroot=antiright&rev=1.1
Patches:
Index: gtkshell/ptk-app-menu.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/ptk-app-menu.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- gtkshell/ptk-app-menu.c 15 Aug 2010 18:44:18 -0000 1.4
+++ gtkshell/ptk-app-menu.c 15 Aug 2010 22:23:29 -0000 1.5
@@ -617,10 +617,6 @@
data, (GDestroyNotify) ptk_app_menu_item_free );
setup_menu_item_signals(menu_item, data);
-/* g_signal_connect( menu_item, "expose-event",
- G_CALLBACK(on_menu_item_expose), data );
- g_signal_connect( menu_item, "size-request",
- G_CALLBACK(on_menu_item_size_request), data );*/
on_menu_item_expose( menu_item, NULL, data );
gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu_item),
GTK_WIDGET(sub_menu) );
@@ -665,7 +661,6 @@
path = g_build_filename( sys_dirs[len], app_dir_name, NULL );
if( stat( path, &dir_stat) == 0 )
{
- //times[len] = dir_stat.st_mtime;
func( path, user_data );
}
g_free( path );
Index: rootcat/Makefile
===================================================================
RCS file: /sources/antiright/antiright/rootcat/Makefile,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- rootcat/Makefile 22 Jul 2010 19:50:36 -0000 1.4
+++ rootcat/Makefile 15 Aug 2010 22:23:29 -0000 1.5
@@ -35,7 +35,7 @@
LDFLAGS=-L/usr/pkg/lib -L/usr/X11R6/lib -lX11 -lXft -lXext
CFLAGS+=$(INCLUDES)
CFLAGS+=-g3
-objs=rootcat.o
+objs=rootcat.o StringRenderer.o
all: $(PROG)
Index: rootcat/rootcat.c
===================================================================
RCS file: /sources/antiright/antiright/rootcat/rootcat.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- rootcat/rootcat.c 22 Jul 2010 19:50:36 -0000 1.5
+++ rootcat/rootcat.c 15 Aug 2010 22:23:29 -0000 1.6
@@ -1,6 +1,6 @@
/*
AntiRight
- (c) 2008 Jeffrey Bedard
+ (c) 2008-2010 Jeffrey Bedard
address@hidden
This file is part of AntiRight.
@@ -20,153 +20,9 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
*/
-#include <X11/X.h>
-#include <X11/Xutil.h>
-#include <X11/Xlib.h>
-#include <X11/Xft/Xft.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#define SR_DEFAULT_FONT "Mono 12"
-#define SR_DEFAULT_COLOR "white"
-
-#ifndef $
-#define $(class, method, ...) class->method(class, ##__VA_ARGS__)
-#endif /* ! $ */
-typedef struct _StringRenderer
-{
- Display * dpy;
- Window window;
- XftDraw * __draw;
- XftColor color;
- XftFont * font;
-
- void (*delete)(struct _StringRenderer *);
- unsigned int (*draw)(struct _StringRenderer *,
- const int, const int, const char *);
- void (*clear)(struct _StringRenderer *);
- unsigned int (*get_line_height)(struct _StringRenderer *,
- const char *);
-} StringRenderer;
-
-void
-StringRenderer_clear(StringRenderer * rc)
-{
- XClearWindow(rc->dpy, rc->window);
-}
+#include "rootcat.h"
-unsigned int
-StringRenderer_get_line_height(StringRenderer * rc, const char * string)
-{
- XGlyphInfo extents;
-
- assert(string);
- assert(rc);
- assert(rc->dpy);
- assert(rc->font);
-
- XftTextExtentsUtf8(rc->dpy, rc->font,
- (FcChar8 *)string, strlen(string),
- &extents);
-
- return extents.height;
-}
-
-/* Returns the number of lines printed. */
-static unsigned int
-StringRenderer_draw(StringRenderer * rc,
- const int x, const int y, const char * string)
-{
- char * iter = (char*)string;
- const int max_length=strlen(string);
- int total_length;
- int length;
- int lines=0;
-
- for(total_length=0; total_length<=max_length; total_length+=length)
- {
- for(length=0;iter[length] != '\0'
- && iter[length] !='\n';length++);
- length++;
- XftDrawStringUtf8(rc->__draw, &(rc->color), rc->font,
- x, y+lines*1.5*($(rc, get_line_height, iter)),
- (FcChar8 *)iter, length-1);
- iter+=length;
- lines++;
- }
-
- return lines;
-}
-
-static void
-delete_StringRenderer(StringRenderer * rc)
-{
- Display * dpy = rc->dpy;
- const int screen = DefaultScreen(dpy);
-
- XftColorFree(dpy, DefaultVisual(dpy, screen),
- DefaultColormap(dpy, screen), &(rc->color));
- XftFontClose(dpy, rc->font);
- XftDrawDestroy(rc->__draw);
- XCloseDisplay(dpy);
- free(rc);
-}
-
-static void
-error_opening_display(void)
-{
- fprintf(stderr, "Error: cannot open DISPLAY\n");
- exit(1);
-}
-
-static StringRenderer *
-new_StringRenderer(Display * dpy, Window w,
- const char * font, const char * color)
-{
- int screen;
- Visual * visual;
- Colormap cmap;
-
- /* Validate inputs. */
- if(!dpy)
- error_opening_display();
- if(!font)
- font=SR_DEFAULT_FONT;
- if(!color)
- color=SR_DEFAULT_COLOR;
-
- /* Allocate class. */
- StringRenderer * rc = malloc(sizeof(StringRenderer));
- assert(rc);
-
- rc->delete=&delete_StringRenderer;
- rc->draw=&StringRenderer_draw;
- rc->get_line_height=&StringRenderer_get_line_height;
- rc->clear = &StringRenderer_clear;
-
- rc->dpy=dpy;
- rc->window=w;
- screen=DefaultScreen(dpy);
- visual=DefaultVisual(dpy, screen);
- cmap=DefaultColormap(dpy, screen);
- rc->__draw=XftDrawCreate(dpy, w, visual, cmap);
- XftColorAllocName(dpy, visual, cmap, color, &(rc->color));
- rc->font=XftFontOpenName(dpy, screen, font);
-
- return rc;
-}
-
-static StringRenderer *
-new_StringRenderer_root(const char * font, const char * color)
-{
- Display * dpy = XOpenDisplay(getenv("DISPLAY"));
- if(!dpy)
- error_opening_display();
- return new_StringRenderer(dpy, DefaultRootWindow(dpy), font, color);
-}
static inline void
rootcat_end(StringRenderer * rc, int exit_code)
@@ -192,16 +48,15 @@
exit(exit_code);
}
-static char * rootcat_color=NULL;
-static char * rootcat_font=NULL;
-
int main(int argc, char ** argv)
{
StringRenderer *rc=NULL;
- int counter;
+ int counter=0;
int line=0;
+ char * color=NULL;
+ char * font=NULL;
- for(counter=1; counter<argc; counter++)
+ while(++counter<argc)
{
const char * string = argv[counter];
@@ -212,7 +67,7 @@
case 'C': /* Set color */
counter++;
if(argv[counter])
- rootcat_color=argv[counter];
+ color=argv[counter];
else
print_usage(argv[0], 1);
break;
@@ -222,7 +77,7 @@
case 'F': /* Set font */
counter++;
if(argv[counter])
- rootcat_font=argv[counter];
+ font=argv[counter];
else
print_usage(argv[0], 1);
break;
@@ -234,10 +89,10 @@
}
else
{
- if(rc==NULL)
+ if(!rc)
{
rc=new_StringRenderer_root(
- rootcat_font, rootcat_color);
+ font, color);
$(rc, clear);
}
{
@@ -245,12 +100,12 @@
=$(rc, get_line_height, string);
$(rc, draw, (height/2),
- ((++line)*1.5*height), string);
+ ((++line)*LINE_SPACING*height),
+ string);
}
}
}
- if(rc!=NULL)
- $(rc, delete);
+ if(rc) $(rc, delete);
return 0;
}
Index: rootcat/StringRenderer.c
===================================================================
RCS file: rootcat/StringRenderer.c
diff -N rootcat/StringRenderer.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ rootcat/StringRenderer.c 15 Aug 2010 22:23:29 -0000 1.1
@@ -0,0 +1,131 @@
+/*
+ AntiRight
+ (c) 2008-2010 Jeffrey Bedard
+ address@hidden
+
+ This file is part of AntiRight.
+
+ AntiRight is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ AntiRight is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with AntiRight; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+*/
+
+#include "rootcat.h"
+
+static void
+StringRenderer_clear(StringRenderer * rc)
+{
+ XClearWindow(rc->dpy, rc->window);
+}
+
+static unsigned int
+StringRenderer_get_line_height(StringRenderer * rc, const char * string)
+{
+ XGlyphInfo extents;
+
+ XftTextExtentsUtf8(rc->dpy, rc->font,
+ (FcChar8 *)string, strlen(string),
+ &extents);
+
+ return extents.height;
+}
+
+/* Returns the number of lines printed. */
+static unsigned int
+StringRenderer_draw(StringRenderer * rc,
+ const int x, const int y, const char * string)
+{
+ char * iter = (char*)string;
+ const int max_length=strlen(string);
+ int total_length=0;
+ register int length=0;
+ int lines=0;
+
+ for(total_length=0; total_length<=max_length; total_length+=length)
+ {
+ for(length=0;iter[length] != '\0'
+ && iter[length] !='\n';length++);
+ length++;
+ XftDrawStringUtf8(rc->__draw, &(rc->color), rc->font,
+ x, y+lines*LINE_SPACING*$(rc, get_line_height, iter),
+ (FcChar8*)iter, length-1);
+ iter+=length;
+ lines++;
+ }
+
+ return lines;
+}
+
+static void
+delete_StringRenderer(StringRenderer * rc)
+{
+ Display * dpy = rc->dpy;
+ const int screen = DefaultScreen(dpy);
+
+ XftColorFree(dpy, DefaultVisual(dpy, screen),
+ DefaultColormap(dpy, screen), &(rc->color));
+ XftFontClose(dpy, rc->font);
+ XftDrawDestroy(rc->__draw);
+ XCloseDisplay(dpy);
+ free(rc);
+}
+
+StringRenderer *
+new_StringRenderer(Display * dpy, Window w,
+ const char * font, const char * color)
+{
+ /* Validate inputs. */
+ if(!dpy)
+ {
+ dpy = XOpenDisplay(getenv("DISPLAY"));
+ if(!dpy)
+ {
+ perror("cannot open DISPLAY");
+ exit(1);
+ }
+ }
+ if(!font)
+ font=SR_DEFAULT_FONT;
+ if(!color)
+ color=SR_DEFAULT_COLOR;
+ if(w==0)
+ w=DefaultRootWindow(dpy);
+
+ /* Allocate class. */
+ StringRenderer * rc = malloc(sizeof(StringRenderer));
+ assert(rc);
+
+ rc->delete=&delete_StringRenderer;
+ rc->draw=&StringRenderer_draw;
+ rc->get_line_height=&StringRenderer_get_line_height;
+ rc->clear = &StringRenderer_clear;
+
+ rc->dpy=dpy;
+ rc->window=w;
+ {
+ const int screen=DefaultScreen(dpy);
+ {
+ const Colormap cmap=DefaultColormap(dpy, screen);
+ const Visual * visual=DefaultVisual(dpy, screen);
+
+ rc->__draw=XftDrawCreate(dpy, w,
+ (Visual*)visual, cmap);
+ XftColorAllocName(dpy, visual,
+ cmap, color, &(rc->color));
+ }
+ rc->font=XftFontOpenName(dpy, screen, font);
+ }
+
+ return rc;
+}
+
Index: rootcat/StringRenderer.h
===================================================================
RCS file: rootcat/StringRenderer.h
diff -N rootcat/StringRenderer.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ rootcat/StringRenderer.h 15 Aug 2010 22:23:29 -0000 1.1
@@ -0,0 +1,49 @@
+/*
+ AntiRight
+ (c) 2008-2010 Jeffrey Bedard
+ address@hidden
+
+ This file is part of AntiRight.
+
+ AntiRight is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ AntiRight is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with AntiRight; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+*/
+
+#ifndef __STRINGRENDERER_H__
+#define __STRINGRENDERER_H__
+
+typedef struct _StringRenderer
+{
+ Display * dpy;
+ Window window;
+ XftDraw * __draw;
+ XftColor color;
+ XftFont * font;
+
+ void (*delete)(struct _StringRenderer *);
+ unsigned int (*draw)(struct _StringRenderer *,
+ const int, const int, const char *);
+ void (*clear)(struct _StringRenderer *);
+ unsigned int (*get_line_height)(struct _StringRenderer *,
+ const char *);
+} StringRenderer;
+
+StringRenderer *
+new_StringRenderer(Display * dpy, Window w,
+ const char * font, const char * color);
+
+#define new_StringRenderer_root(f,c) new_StringRenderer(NULL, 0, f, c)
+
+#endif /* __STRINGRENDERER_H__ */
+
Index: rootcat/rootcat.h
===================================================================
RCS file: rootcat/rootcat.h
diff -N rootcat/rootcat.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ rootcat/rootcat.h 15 Aug 2010 22:23:29 -0000 1.1
@@ -0,0 +1,46 @@
+/*
+ AntiRight
+ (c) 2008-2010 Jeffrey Bedard
+ address@hidden
+
+ This file is part of AntiRight.
+
+ AntiRight is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ AntiRight is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with AntiRight; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+*/
+
+#ifndef __ROOTCAT_H__
+#define __ROOTCAT_H__
+
+#include <X11/X.h>
+#include <X11/Xutil.h>
+#include <X11/Xlib.h>
+#include <X11/Xft/Xft.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#define SR_DEFAULT_FONT "Mono 12"
+#define SR_DEFAULT_COLOR "white"
+#define LINE_SPACING 1.25
+
+#ifndef $
+#define $(class, method, ...) class->method(class, ##__VA_ARGS__)
+#endif /* ! $ */
+
+#include "StringRenderer.h"
+
+#endif /* __ROOTCAT_H__ */
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Antiright-devel] antiright gtkshell/ptk-app-menu.c rootcat/Makef...,
Jeffrey Bedard <=