From: Dana Jansens Date: Mon, 5 Mar 2007 15:44:17 +0000 (+0000) Subject: scary commit..but here goes. X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=ec304c9e433e4b1cedf924ca64d783f05db7d42d;p=chaz%2Fopenbox scary commit..but here goes. YOUR THEMES ARE NOW OFFICIALLY BROKEN. Openbox has just moved it's theme format to an XML based one. The details of this format can be found in data/themerc.xsd (and http://openbox.org/themerc.xsd ALSO! This is very good and important and stuff! In the tools directory you will find THEMETOXML ! This tool takes a themerc on stdin, and spits out the same theme in theme.xml format. So this is all you need to do to update your themes. PLEASE NOTE: This themetoxml does _not_ install itself anywhere. It simply builds and then lives out in its tools/themetoxml directory, and that's it. So if you want to use it, that is where to find it. In moving to the new XML format, a number of additions/changes to the theme engine have been made. Themetoxml takes these into account and will set all the new things appropriately to make your theme look the same as it always has. New additions include.. * padding now has an horizontal and vertical component, instead of being one number * menus can have different borders than windows (color and size) * menu offset can now be negative. it's a little weird, but someone will want it no doubt * fonts are no longer controled by the theme at all, however font shadowing is, and on that note.. * font shadows are now any color you want, not just black and white * you can now set the shadow anywhere you can set the text's color, so you have more control, i.e. you can set shadow on active menu items but not inactive, or disabled, etc. * every color now has an alpha channel. at the moment they don't do anything, besides the font shadow one, but it leaves room for future explorations. it is REALLY HIGHLY RECOMMENDED that you set the alpha to 255 all the time, until such time as it could be useful. otherwise one day your theme may turn awful for people. * font colors are in the range 0-255, in case you were wondering, and they have to be specified in decimal * if you'd like to change you font's you can do so in your configuration file. this is how it is going to stay. changing the font in the theme assumes too much about peoples eye sight and locality and stuff. it doesn't belong there, sorry. the system-wide default rc.xml includes the new font settings for your viewing pleasure, and ill drop an example of it below. * shadows can now be positioned in any direction, they have both an x and a y offset which can be negative and positive. and offset of 0,0 will disable the shadow This isn't a release or anything. If someone had some good ideas about the xml theme format, I'd like to hear them. But I don't think it will be changing much right now beyond where it is. I don't even know how the new functionality will play out for themers, so we'll see. Whew.. I guess that's it. I'm not sure if I mentioned every little change or not, but oh well. Mileage may vary.. Please send any feedback. Here's the font configuration example. Hopefully ObConf will let you set this real soon. ... arial,sans 7 bold normal arial,sans 7 bold normal arial,sans 8 bold normal arial,sans 8 bold normal --- diff --git a/Makefile.am b/Makefile.am index be621a07..f1b1b9f8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,9 +28,11 @@ lib_LTLIBRARIES = \ bin_PROGRAMS = \ openbox/openbox \ - tools/themetoxml/themetoxml \ tools/gnome-panel-control/gnome-panel-control +noinst_PROGRAMS = \ + tools/themetoxml/themetoxml + ## render ## render_rendertest_CPPFLAGS = \ @@ -237,7 +239,7 @@ dist_mikachu_theme_DATA= \ themes/Mikachu/openbox-3/desk.xbm \ themes/Mikachu/openbox-3/iconify.xbm \ themes/Mikachu/openbox-3/max.xbm \ - themes/Mikachu/openbox-3/themerc + themes/Mikachu/openbox-3/themerc.xml natura_themedir = $(themedir)/Natura/openbox-3 @@ -254,7 +256,7 @@ dist_natura_theme_DATA= \ themes/Natura/openbox-3/max_toggled.xbm \ themes/Natura/openbox-3/max.xbm \ themes/Natura/openbox-3/shade.xbm \ - themes/Natura/openbox-3/themerc + themes/Natura/openbox-3/themerc.xml artwizboxed_themedir = $(themedir)/artwiz-boxed/openbox-3 dist_artwizboxed_theme_DATA= \ @@ -265,7 +267,7 @@ dist_artwizboxed_theme_DATA= \ themes/artwiz-boxed/openbox-3/iconify.xbm \ themes/artwiz-boxed/openbox-3/max_toggled.xbm \ themes/artwiz-boxed/openbox-3/max.xbm \ - themes/artwiz-boxed/openbox-3/themerc + themes/artwiz-boxed/openbox-3/themerc.xml bear2_themedir = $(themedir)/bear2/openbox-3 dist_bear2_theme_DATA= \ @@ -282,11 +284,11 @@ dist_bear2_theme_DATA= \ themes/bear2/openbox-3/max.xbm \ themes/bear2/openbox-3/shade_pressed.xbm \ themes/bear2/openbox-3/shade.xbm \ - themes/bear2/openbox-3/themerc + themes/bear2/openbox-3/themerc.xml orang_themedir = $(themedir)/orang/openbox-3 dist_orang_theme_DATA= \ - themes/orang/openbox-3/themerc + themes/orang/openbox-3/themerc.xml syscrash_themedir = $(themedir)/syscrash/openbox-3 dist_syscrash_theme_DATA= \ @@ -301,7 +303,7 @@ dist_syscrash_theme_DATA= \ themes/syscrash/openbox-3/max_toggled.xbm \ themes/syscrash/openbox-3/max.xbm \ themes/syscrash/openbox-3/shade.xbm \ - themes/syscrash/openbox-3/themerc + themes/syscrash/openbox-3/themerc.xml ## public headers ## diff --git a/data/themerc.xsd b/data/themerc.xsd new file mode 100755 index 00000000..7b9573d9 --- /dev/null +++ b/data/themerc.xsd @@ -0,0 +1,169 @@ + + + + + + + Openbox theme definition + Version 1 + Copyright 2007 Dana Jansens + + + + + + + The root node + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/m4/openbox.m4 b/m4/openbox.m4 index 32162353..663f91db 100644 --- a/m4/openbox.m4 +++ b/m4/openbox.m4 @@ -64,7 +64,7 @@ AC_DEFUN([OB_COMPILER_FLAGS], if test "$GCC" = "yes"; then AC_MSG_RESULT([yes]) if test "$DEBUG" = "yes"; then - FLAGS="$FLAGS -g -fno-inline -fno-strict-aliasing" + FLAGS="$FLAGS -O0 -g -fno-inline" FLAGS="$FLAGS -Wall -Wsign-compare -Waggregate-return" FLAGS="$FLAGS -Wcast-qual -Wbad-function-cast -Wpointer-arith" # for Python.h @@ -73,6 +73,7 @@ AC_DEFUN([OB_COMPILER_FLAGS], if test "$STRICT" = "yes"; then FLAGS="$FLAGS -ansi -pedantic -D_XOPEN_SOURCE" fi + FLAGS="$FLAGS -fno-strict-aliasing" fi AC_MSG_CHECKING([for compiler specific flags]) AC_MSG_RESULT([$FLAGS]) diff --git a/openbox/dock.c b/openbox/dock.c index eceb3b99..53c79139 100644 --- a/openbox/dock.c +++ b/openbox/dock.c @@ -57,8 +57,8 @@ void dock_startup(gboolean reconfig) GList *it; XSetWindowBorder(ob_display, dock->frame, - RrColorPixel(ob_rr_theme->b_color)); - XSetWindowBorderWidth(ob_display, dock->frame, ob_rr_theme->bwidth); + RrColorPixel(ob_rr_theme->frame_b_color)); + XSetWindowBorderWidth(ob_display, dock->frame, ob_rr_theme->fbwidth); RrAppearanceFree(dock->a_frame); dock->a_frame = RrAppearanceCopy(ob_rr_theme->a_focused_title); @@ -91,8 +91,8 @@ void dock_startup(gboolean reconfig) &attrib); dock->a_frame = RrAppearanceCopy(ob_rr_theme->a_focused_title); XSetWindowBorder(ob_display, dock->frame, - RrColorPixel(ob_rr_theme->b_color)); - XSetWindowBorderWidth(ob_display, dock->frame, ob_rr_theme->bwidth); + RrColorPixel(ob_rr_theme->frame_b_color)); + XSetWindowBorderWidth(ob_display, dock->frame, ob_rr_theme->fbwidth); g_hash_table_insert(window_map, &dock->frame, dock); stacking_add(DOCK_AS_WINDOW(dock)); @@ -261,8 +261,8 @@ void dock_configure() } /* used for calculating offsets */ - dock->w += ob_rr_theme->bwidth * 2; - dock->h += ob_rr_theme->bwidth * 2; + dock->w += ob_rr_theme->fbwidth * 2; + dock->h += ob_rr_theme->fbwidth * 2; a = screen_physical_area(); @@ -349,51 +349,51 @@ void dock_configure() case OB_DIRECTION_NORTHWEST: switch (config_dock_orient) { case OB_ORIENTATION_HORZ: - dock->y -= dock->h - ob_rr_theme->bwidth; + dock->y -= dock->h - ob_rr_theme->fbwidth; break; case OB_ORIENTATION_VERT: - dock->x -= dock->w - ob_rr_theme->bwidth; + dock->x -= dock->w - ob_rr_theme->fbwidth; break; } break; case OB_DIRECTION_NORTH: - dock->y -= dock->h - ob_rr_theme->bwidth; + dock->y -= dock->h - ob_rr_theme->fbwidth; break; case OB_DIRECTION_NORTHEAST: switch (config_dock_orient) { case OB_ORIENTATION_HORZ: - dock->y -= dock->h - ob_rr_theme->bwidth; + dock->y -= dock->h - ob_rr_theme->fbwidth; break; case OB_ORIENTATION_VERT: - dock->x += dock->w - ob_rr_theme->bwidth; + dock->x += dock->w - ob_rr_theme->fbwidth; break; } break; case OB_DIRECTION_WEST: - dock->x -= dock->w - ob_rr_theme->bwidth; + dock->x -= dock->w - ob_rr_theme->fbwidth; break; case OB_DIRECTION_EAST: - dock->x += dock->w - ob_rr_theme->bwidth; + dock->x += dock->w - ob_rr_theme->fbwidth; break; case OB_DIRECTION_SOUTHWEST: switch (config_dock_orient) { case OB_ORIENTATION_HORZ: - dock->y += dock->h - ob_rr_theme->bwidth; + dock->y += dock->h - ob_rr_theme->fbwidth; break; case OB_ORIENTATION_VERT: - dock->x -= dock->w - ob_rr_theme->bwidth; + dock->x -= dock->w - ob_rr_theme->fbwidth; break; } break; case OB_DIRECTION_SOUTH: - dock->y += dock->h - ob_rr_theme->bwidth; + dock->y += dock->h - ob_rr_theme->fbwidth; break; case OB_DIRECTION_SOUTHEAST: switch (config_dock_orient) { case OB_ORIENTATION_HORZ: - dock->y += dock->h - ob_rr_theme->bwidth; + dock->y += dock->h - ob_rr_theme->fbwidth; break; case OB_ORIENTATION_VERT: - dock->x += dock->w - ob_rr_theme->bwidth; + dock->x += dock->w - ob_rr_theme->fbwidth; break; } break; @@ -402,8 +402,8 @@ void dock_configure() } if (!config_dock_floating && config_dock_hide) { - strw = ob_rr_theme->bwidth; - strh = ob_rr_theme->bwidth; + strw = ob_rr_theme->fbwidth; + strh = ob_rr_theme->fbwidth; } else { strw = dock->w; strh = dock->h; @@ -501,8 +501,8 @@ void dock_configure() dock->h += minh; /* not used for actually sizing shit */ - dock->w -= ob_rr_theme->bwidth * 2; - dock->h -= ob_rr_theme->bwidth * 2; + dock->w -= ob_rr_theme->fbwidth * 2; + dock->h -= ob_rr_theme->fbwidth * 2; if (dock->dock_apps) { g_assert(dock->w > 0); @@ -517,8 +517,8 @@ void dock_configure() XUnmapWindow(ob_display, dock->frame); /* but they are useful outside of this function! */ - dock->w += ob_rr_theme->bwidth * 2; - dock->h += ob_rr_theme->bwidth * 2; + dock->w += ob_rr_theme->fbwidth * 2; + dock->h += ob_rr_theme->fbwidth * 2; screen_update_areas(); } diff --git a/openbox/event.c b/openbox/event.c index b978f563..6314c9f7 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -597,9 +597,9 @@ static void event_handle_root(XEvent *e) } else if (msgtype == prop_atoms.net_showing_desktop) { screen_show_desktop(e->xclient.data.l[0] != 0); } else if (msgtype == prop_atoms.ob_control) { - if ((Atom)e->xclient.data.l[0] == 1) + if (e->xclient.data.l[0] == 1) ob_reconfigure(); - else if ((Atom)e->xclient.data.l[0] == 2) + else if (e->xclient.data.l[0] == 2) ob_restart(); } break; diff --git a/openbox/focus.c b/openbox/focus.c index edd26b69..f867ff16 100644 --- a/openbox/focus.c +++ b/openbox/focus.c @@ -392,7 +392,7 @@ void focus_cycle_draw_indicator() wt = wl = wr = wb = MAX(3, ob_rr_theme->handle_height + - ob_rr_theme->bwidth * 2); + ob_rr_theme->fbwidth * 2); x = focus_cycle_target->frame->area.x; y = focus_cycle_target->frame->area.y; diff --git a/openbox/frame.c b/openbox/frame.c index 57a1b8ab..b92c3f12 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -159,15 +159,15 @@ static void set_theme_statics(ObFrame *self) { /* set colors/appearance/sizes for stuff that doesn't change */ XSetWindowBorder(ob_display, self->window, - RrColorPixel(ob_rr_theme->b_color)); + RrColorPixel(ob_rr_theme->frame_b_color)); XSetWindowBorder(ob_display, self->title, - RrColorPixel(ob_rr_theme->b_color)); + RrColorPixel(ob_rr_theme->frame_b_color)); XSetWindowBorder(ob_display, self->handle, - RrColorPixel(ob_rr_theme->b_color)); + RrColorPixel(ob_rr_theme->frame_b_color)); XSetWindowBorder(ob_display, self->rgrip, - RrColorPixel(ob_rr_theme->b_color)); + RrColorPixel(ob_rr_theme->frame_b_color)); XSetWindowBorder(ob_display, self->lgrip, - RrColorPixel(ob_rr_theme->b_color)); + RrColorPixel(ob_rr_theme->frame_b_color)); XResizeWindow(ob_display, self->max, ob_rr_theme->button_size, ob_rr_theme->button_size); @@ -181,14 +181,16 @@ static void set_theme_statics(ObFrame *self) ob_rr_theme->button_size, ob_rr_theme->button_size); XResizeWindow(ob_display, self->shade, ob_rr_theme->button_size, ob_rr_theme->button_size); - XResizeWindow(ob_display, self->lgrip, - ob_rr_theme->grip_width, ob_rr_theme->handle_height); - XResizeWindow(ob_display, self->rgrip, - ob_rr_theme->grip_width, ob_rr_theme->handle_height); + if (ob_rr_theme->handle_height > 0) { + XResizeWindow(ob_display, self->lgrip, + ob_rr_theme->grip_width, ob_rr_theme->handle_height); + XResizeWindow(ob_display, self->rgrip, + ob_rr_theme->grip_width, ob_rr_theme->handle_height); + } XResizeWindow(ob_display, self->tlresize, - ob_rr_theme->grip_width, ob_rr_theme->handle_height); + ob_rr_theme->grip_width, ob_rr_theme->top_grip_height); XResizeWindow(ob_display, self->trresize, - ob_rr_theme->grip_width, ob_rr_theme->handle_height); + ob_rr_theme->grip_width, ob_rr_theme->top_grip_height); /* set up the dynamic appearances */ self->a_unfocused_title = RrAppearanceCopy(ob_rr_theme->a_unfocused_title); @@ -272,8 +274,8 @@ void frame_adjust_shape(ObFrame *self) num = 0; if (self->decorations & OB_FRAME_DECOR_TITLEBAR) { - xrect[0].x = -ob_rr_theme->bwidth; - xrect[0].y = -ob_rr_theme->bwidth; + xrect[0].x = -ob_rr_theme->fbwidth; + xrect[0].y = -ob_rr_theme->fbwidth; xrect[0].width = self->width + self->rbwidth * 2; xrect[0].height = ob_rr_theme->title_height + self->bwidth * 2; @@ -281,7 +283,7 @@ void frame_adjust_shape(ObFrame *self) } if (self->decorations & OB_FRAME_DECOR_HANDLE) { - xrect[1].x = -ob_rr_theme->bwidth; + xrect[1].x = -ob_rr_theme->fbwidth; xrect[1].y = FRAME_HANDLE_Y(self); xrect[1].width = self->width + self->rbwidth * 2; xrect[1].height = ob_rr_theme->handle_height + @@ -308,8 +310,9 @@ void frame_adjust_area(ObFrame *self, gboolean moved, self->max_horz = self->client->max_horz; if (self->decorations & OB_FRAME_DECOR_BORDER) { - self->bwidth = ob_rr_theme->bwidth; - self->cbwidth_x = self->cbwidth_y = ob_rr_theme->cbwidth; + self->bwidth = ob_rr_theme->fbwidth; + self->cbwidth_x = ob_rr_theme->cbwidthx; + self->cbwidth_y = ob_rr_theme->cbwidthy; } else { self->bwidth = self->cbwidth_x = self->cbwidth_y = 0; } @@ -340,7 +343,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved, self->innersize.top += ob_rr_theme->title_height + self->rbwidth + (self->rbwidth - self->bwidth); if (self->decorations & OB_FRAME_DECOR_HANDLE && - ob_rr_theme->show_handle) + ob_rr_theme->handle_height > 0) self->innersize.bottom += ob_rr_theme->handle_height + self->rbwidth + (self->rbwidth - self->bwidth); @@ -382,7 +385,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved, if (!fake) { if (self->decorations & OB_FRAME_DECOR_HANDLE && - ob_rr_theme->show_handle) + ob_rr_theme->handle_height > 0) { XMoveResizeWindow(ob_display, self->handle, -self->bwidth, FRAME_HANDLE_Y(self), @@ -401,12 +404,6 @@ void frame_adjust_area(ObFrame *self, gboolean moved, XUnmapWindow(ob_display, self->lgrip); XUnmapWindow(ob_display, self->rgrip); } - - /* XXX make a subwindow with these dimentions? - ob_rr_theme->grip_width + self->bwidth, 0, - self->width - (ob_rr_theme->grip_width + self->bwidth) * 2, - ob_rr_theme->handle_height); - */ } else XUnmapWindow(ob_display, self->handle); @@ -608,14 +605,14 @@ static void layout_title(ObFrame *self) n = d = i = l = m = c = s = FALSE; /* figure out whats being shown, and the width of the label */ - self->label_width = self->width - (ob_rr_theme->padding + 1) * 2; + self->label_width = self->width - (ob_rr_theme->paddingx + 1) * 2; for (lc = config_title_layout; *lc != '\0'; ++lc) { switch (*lc) { case 'N': if (n) { *lc = ' '; break; } /* rm duplicates */ n = TRUE; self->label_width -= (ob_rr_theme->button_size + 2 + - ob_rr_theme->padding + 1); + ob_rr_theme->paddingx + 1); break; case 'D': if (d) { *lc = ' '; break; } @@ -624,7 +621,7 @@ static void layout_title(ObFrame *self) break; d = TRUE; self->label_width -= (ob_rr_theme->button_size + - ob_rr_theme->padding + 1); + ob_rr_theme->paddingx + 1); break; case 'S': if (s) { *lc = ' '; break; } @@ -633,7 +630,7 @@ static void layout_title(ObFrame *self) break; s = TRUE; self->label_width -= (ob_rr_theme->button_size + - ob_rr_theme->padding + 1); + ob_rr_theme->paddingx + 1); break; case 'I': if (i) { *lc = ' '; break; } @@ -642,7 +639,7 @@ static void layout_title(ObFrame *self) break; i = TRUE; self->label_width -= (ob_rr_theme->button_size + - ob_rr_theme->padding + 1); + ob_rr_theme->paddingx + 1); break; case 'L': if (l) { *lc = ' '; break; } @@ -655,7 +652,7 @@ static void layout_title(ObFrame *self) break; m = TRUE; self->label_width -= (ob_rr_theme->button_size + - ob_rr_theme->padding + 1); + ob_rr_theme->paddingx + 1); break; case 'C': if (c) { *lc = ' '; break; } @@ -664,7 +661,7 @@ static void layout_title(ObFrame *self) break; c = TRUE; self->label_width -= (ob_rr_theme->button_size + - ob_rr_theme->padding + 1); + ob_rr_theme->paddingx + 1); break; } } @@ -678,57 +675,57 @@ static void layout_title(ObFrame *self) if (!m) XUnmapWindow(ob_display, self->max); if (!c) XUnmapWindow(ob_display, self->close); - x = ob_rr_theme->padding + 1; + x = ob_rr_theme->paddingx + 1; for (lc = config_title_layout; *lc != '\0'; ++lc) { switch (*lc) { case 'N': if (!n) break; self->icon_x = x; XMapWindow(ob_display, self->icon); - XMoveWindow(ob_display, self->icon, x, ob_rr_theme->padding); - x += ob_rr_theme->button_size + 2 + ob_rr_theme->padding + 1; + XMoveWindow(ob_display, self->icon, x, ob_rr_theme->paddingx); + x += ob_rr_theme->button_size + 2 + ob_rr_theme->paddingx + 1; break; case 'D': if (!d) break; self->desk_x = x; XMapWindow(ob_display, self->desk); - XMoveWindow(ob_display, self->desk, x, ob_rr_theme->padding + 1); - x += ob_rr_theme->button_size + ob_rr_theme->padding + 1; + XMoveWindow(ob_display, self->desk, x, ob_rr_theme->paddingx + 1); + x += ob_rr_theme->button_size + ob_rr_theme->paddingx + 1; break; case 'S': if (!s) break; self->shade_x = x; XMapWindow(ob_display, self->shade); - XMoveWindow(ob_display, self->shade, x, ob_rr_theme->padding + 1); - x += ob_rr_theme->button_size + ob_rr_theme->padding + 1; + XMoveWindow(ob_display, self->shade, x, ob_rr_theme->paddingx + 1); + x += ob_rr_theme->button_size + ob_rr_theme->paddingx + 1; break; case 'I': if (!i) break; self->iconify_x = x; XMapWindow(ob_display, self->iconify); - XMoveWindow(ob_display,self->iconify, x, ob_rr_theme->padding + 1); - x += ob_rr_theme->button_size + ob_rr_theme->padding + 1; + XMoveWindow(ob_display,self->iconify, x, ob_rr_theme->paddingx + 1); + x += ob_rr_theme->button_size + ob_rr_theme->paddingx + 1; break; case 'L': if (!l) break; self->label_x = x; XMapWindow(ob_display, self->label); - XMoveWindow(ob_display, self->label, x, ob_rr_theme->padding); - x += self->label_width + ob_rr_theme->padding + 1; + XMoveWindow(ob_display, self->label, x, ob_rr_theme->paddingx); + x += self->label_width + ob_rr_theme->paddingx + 1; break; case 'M': if (!m) break; self->max_x = x; XMapWindow(ob_display, self->max); - XMoveWindow(ob_display, self->max, x, ob_rr_theme->padding + 1); - x += ob_rr_theme->button_size + ob_rr_theme->padding + 1; + XMoveWindow(ob_display, self->max, x, ob_rr_theme->paddingx + 1); + x += ob_rr_theme->button_size + ob_rr_theme->paddingx + 1; break; case 'C': if (!c) break; self->close_x = x; XMapWindow(ob_display, self->close); - XMoveWindow(ob_display, self->close, x, ob_rr_theme->padding + 1); - x += ob_rr_theme->button_size + ob_rr_theme->padding + 1; + XMoveWindow(ob_display, self->close, x, ob_rr_theme->paddingx + 1); + x += ob_rr_theme->button_size + ob_rr_theme->paddingx + 1; break; } } diff --git a/openbox/framerender.c b/openbox/framerender.c index 464e1c6b..2195ff74 100644 --- a/openbox/framerender.c +++ b/openbox/framerender.c @@ -147,43 +147,42 @@ void framerender_frame(ObFrame *self) ob_rr_theme->a_clear->surface.parenty = 0; RrPaint(ob_rr_theme->a_clear, self->tlresize, - ob_rr_theme->grip_width, ob_rr_theme->handle_height); + ob_rr_theme->grip_width, ob_rr_theme->top_grip_height); ob_rr_theme->a_clear->surface.parentx = self->width - ob_rr_theme->grip_width; RrPaint(ob_rr_theme->a_clear, self->trresize, - ob_rr_theme->grip_width, ob_rr_theme->handle_height); - + ob_rr_theme->grip_width, ob_rr_theme->top_grip_height); /* set parents for any parent relative guys */ l->surface.parent = t; l->surface.parentx = self->label_x; - l->surface.parenty = ob_rr_theme->padding; + l->surface.parenty = ob_rr_theme->paddingy; m->surface.parent = t; m->surface.parentx = self->max_x; - m->surface.parenty = ob_rr_theme->padding + 1; + m->surface.parenty = ob_rr_theme->paddingy + 1; n->surface.parent = t; n->surface.parentx = self->icon_x; - n->surface.parenty = ob_rr_theme->padding; + n->surface.parenty = ob_rr_theme->paddingy; i->surface.parent = t; i->surface.parentx = self->iconify_x; - i->surface.parenty = ob_rr_theme->padding + 1; + i->surface.parenty = ob_rr_theme->paddingy + 1; d->surface.parent = t; d->surface.parentx = self->desk_x; - d->surface.parenty = ob_rr_theme->padding + 1; + d->surface.parenty = ob_rr_theme->paddingy + 1; s->surface.parent = t; s->surface.parentx = self->shade_x; - s->surface.parenty = ob_rr_theme->padding + 1; + s->surface.parenty = ob_rr_theme->paddingy + 1; c->surface.parent = t; c->surface.parentx = self->close_x; - c->surface.parenty = ob_rr_theme->padding + 1; + c->surface.parenty = ob_rr_theme->paddingy + 1; framerender_label(self, l); framerender_max(self, m); @@ -194,7 +193,9 @@ void framerender_frame(ObFrame *self) framerender_close(self, c); } - if (self->decorations & OB_FRAME_DECOR_HANDLE) { + if (self->decorations & OB_FRAME_DECOR_HANDLE && + ob_rr_theme->handle_height > 0) + { RrAppearance *h, *g; h = (self->focused ? diff --git a/openbox/menu.c b/openbox/menu.c index 243fc55b..868293c6 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -313,7 +313,7 @@ void menu_show(gchar *name, gint x, gint y, ObClient *client) menu_frame_move(frame, x, y); } else menu_frame_move(frame, - x - ob_rr_theme->bwidth, y - ob_rr_theme->bwidth); + x - ob_rr_theme->mbwidth, y - ob_rr_theme->mbwidth); for (i = 0; i < screen_num_monitors; ++i) { Rect *a = screen_physical_area_monitor(i); if (RECT_CONTAINS(*a, x, y)) { diff --git a/openbox/menuframe.c b/openbox/menuframe.c index e9fc32da..743f4204 100644 --- a/openbox/menuframe.c +++ b/openbox/menuframe.c @@ -412,25 +412,25 @@ static void menu_frame_render(ObMenuFrame *self) gboolean has_icon = FALSE; ObMenu *sub; - XSetWindowBorderWidth(ob_display, self->window, ob_rr_theme->bwidth); + XSetWindowBorderWidth(ob_display, self->window, ob_rr_theme->mbwidth); XSetWindowBorder(ob_display, self->window, - RrColorPixel(ob_rr_theme->b_color)); + RrColorPixel(ob_rr_theme->menu_b_color)); if (!self->parent && self->show_title) { XMoveWindow(ob_display, self->title, - -ob_rr_theme->bwidth, h - ob_rr_theme->bwidth); + -ob_rr_theme->mbwidth, h - ob_rr_theme->mbwidth); self->a_title->texture[0].data.text.string = self->menu->title; RrMinsize(self->a_title, &tw, &th); - tw = MIN(tw, MAX_MENU_WIDTH) + ob_rr_theme->padding * 2; + tw = MIN(tw, MAX_MENU_WIDTH) + ob_rr_theme->paddingx * 2; w = MAX(w, tw); th = ob_rr_theme->menu_title_height; - h += (self->title_h = th + ob_rr_theme->bwidth); + h += (self->title_h = th + ob_rr_theme->mbwidth); - XSetWindowBorderWidth(ob_display, self->title, ob_rr_theme->bwidth); + XSetWindowBorderWidth(ob_display, self->title, ob_rr_theme->mbwidth); XSetWindowBorder(ob_display, self->title, - RrColorPixel(ob_rr_theme->b_color)); + RrColorPixel(ob_rr_theme->menu_b_color)); } XMoveWindow(ob_display, self->items, 0, h); @@ -538,9 +538,9 @@ static void menu_frame_render(ObMenuFrame *self) if (!self->parent && self->show_title) { XResizeWindow(ob_display, self->title, - w, self->title_h - ob_rr_theme->bwidth); + w, self->title_h - ob_rr_theme->mbwidth); RrPaint(self->a_title, self->title, - w, self->title_h - ob_rr_theme->bwidth); + w, self->title_h - ob_rr_theme->mbwidth); XMapWindow(ob_display, self->title); } else XUnmapWindow(ob_display, self->title); @@ -550,8 +550,8 @@ static void menu_frame_render(ObMenuFrame *self) for (it = self->entries; it; it = g_list_next(it)) menu_entry_frame_render(it->data); - w += ob_rr_theme->bwidth * 2; - h += ob_rr_theme->bwidth * 2; + w += ob_rr_theme->mbwidth * 2; + h += ob_rr_theme->mbwidth * 2; RECT_SET_SIZE(self->area, w, h); @@ -721,8 +721,8 @@ ObMenuEntryFrame* menu_entry_frame_under(gint x, gint y) GList *it; if ((frame = menu_frame_under(x, y))) { - x -= ob_rr_theme->bwidth + frame->area.x; - y -= frame->title_h + ob_rr_theme->bwidth + frame->area.y; + x -= ob_rr_theme->mbwidth + frame->area.x; + y -= frame->title_h + ob_rr_theme->mbwidth + frame->area.y; for (it = frame->entries; it; it = g_list_next(it)) { ObMenuEntryFrame *e = it->data; @@ -795,7 +795,7 @@ void menu_entry_frame_show_submenu(ObMenuEntryFrame *self) self->frame->area.x + self->frame->area.width - ob_rr_theme->menu_overlap - - ob_rr_theme->bwidth, + - ob_rr_theme->mbwidth, self->frame->area.y + self->frame->title_h + self->area.y diff --git a/openbox/popup.c b/openbox/popup.c index 4a0ae890..6b118792 100644 --- a/openbox/popup.c +++ b/openbox/popup.c @@ -36,8 +36,8 @@ ObPopup *popup_new(gboolean hasicon) self->hasicon = hasicon; self->gravity = NorthWestGravity; self->x = self->y = self->w = self->h = 0; - self->a_bg = RrAppearanceCopy(ob_rr_theme->app_hilite_bg); - self->a_text = RrAppearanceCopy(ob_rr_theme->app_hilite_label); + self->a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg); + self->a_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label); attrib.override_redirect = True; self->bg = XCreateWindow(ob_display, RootWindow(ob_display, ob_screen), @@ -88,11 +88,11 @@ void popup_size_to_string(ObPopup *self, gchar *text) self->a_text->texture[0].data.text.string = text; RrMinsize(self->a_text, &textw, &texth); /*XXX textw += ob_rr_theme->bevel * 2;*/ - texth += ob_rr_theme->padding * 2; + texth += ob_rr_theme->paddingy * 2; - self->h = texth + ob_rr_theme->padding * 2; + self->h = texth + ob_rr_theme->paddingy * 2; iconw = (self->hasicon ? texth : 0); - self->w = textw + iconw + ob_rr_theme->padding * (self->hasicon ? 3 : 2); + self->w = textw + iconw + ob_rr_theme->paddingx * (self->hasicon ? 3 : 2); } void popup_set_text_align(ObPopup *self, RrJustify align) @@ -115,8 +115,8 @@ void popup_show(ObPopup *self, gchar *text) RrMargins(self->a_bg, &l, &t, &r, &b); - XSetWindowBorderWidth(ob_display, self->bg, ob_rr_theme->bwidth); - XSetWindowBorder(ob_display, self->bg, ob_rr_theme->b_color->pixel); + XSetWindowBorderWidth(ob_display, self->bg, ob_rr_theme->fbwidth); + XSetWindowBorder(ob_display, self->bg, ob_rr_theme->frame_b_color->pixel); /* set up the textures */ self->a_text->texture[0].data.text.string = text; @@ -124,22 +124,22 @@ void popup_show(ObPopup *self, gchar *text) /* measure the shit out */ RrMinsize(self->a_text, &textw, &texth); /*XXX textw += ob_rr_theme->padding * 2;*/ - texth += ob_rr_theme->padding * 2; + texth += ob_rr_theme->paddingy * 2; /* set the sizes up and reget the text sizes from the calculated outer sizes */ if (self->h) { h = self->h; - texth = h - (t+b + ob_rr_theme->padding * 2); + texth = h - (t+b + ob_rr_theme->paddingy * 2); } else - h = t+b + texth + ob_rr_theme->padding * 2; + h = t+b + texth + ob_rr_theme->paddingy * 2; iconw = (self->hasicon ? texth : 0); if (self->w) { w = self->w; - textw = w - (l+r + iconw + ob_rr_theme->padding * + textw = w - (l+r + iconw + ob_rr_theme->paddingx * (self->hasicon ? 3 : 2)); } else - w = l+r + textw + iconw + ob_rr_theme->padding * + w = l+r + textw + iconw + ob_rr_theme->paddingx * (self->hasicon ? 3 : 2); /* sanity checks to avoid crashes! */ if (w < 1) w = 1; @@ -185,12 +185,12 @@ void popup_show(ObPopup *self, gchar *text) self->a_text->surface.parent = self->a_bg; self->a_text->surface.parentx = l + iconw + - ob_rr_theme->padding * (self->hasicon ? 2 : 1); - self->a_text->surface.parenty = t + ob_rr_theme->padding; + ob_rr_theme->paddingx * (self->hasicon ? 2 : 1); + self->a_text->surface.parenty = t + ob_rr_theme->paddingy; XMoveResizeWindow(ob_display, self->text, - l + iconw + ob_rr_theme->padding * + l + iconw + ob_rr_theme->paddingx * (self->hasicon ? 2 : 1), - t + ob_rr_theme->padding, textw, texth); + t + ob_rr_theme->paddingy, textw, texth); RrPaint(self->a_bg, self->bg, w, h); RrPaint(self->a_text, self->text, textw, texth); @@ -198,7 +198,8 @@ void popup_show(ObPopup *self, gchar *text) if (self->hasicon) { if (iconw < 1) iconw = 1; /* sanity check for crashes */ if (self->draw_icon) - self->draw_icon(l + ob_rr_theme->padding, t + ob_rr_theme->padding, + self->draw_icon(l + ob_rr_theme->paddingx, + t + ob_rr_theme->paddingy, iconw, texth, self->draw_icon_data); } @@ -282,20 +283,20 @@ static void pager_popup_draw_icon(gint px, gint py, gint w, gint h, guint r, c; gint eachw, eachh; - eachw = (w - ob_rr_theme->bwidth - - (screen_desktop_layout.columns * ob_rr_theme->bwidth)) + eachw = (w - ob_rr_theme->fbwidth - + (screen_desktop_layout.columns * ob_rr_theme->fbwidth)) / screen_desktop_layout.columns; - eachh = (h - ob_rr_theme->bwidth - - (screen_desktop_layout.rows * ob_rr_theme->bwidth)) + eachh = (h - ob_rr_theme->fbwidth - + (screen_desktop_layout.rows * ob_rr_theme->fbwidth)) / screen_desktop_layout.rows; /* make them squares */ eachw = eachh = MIN(eachw, eachh); /* center */ - px += (w - (screen_desktop_layout.columns * (eachw + ob_rr_theme->bwidth) + - ob_rr_theme->bwidth)) / 2; - py += (h - (screen_desktop_layout.rows * (eachh + ob_rr_theme->bwidth) + - ob_rr_theme->bwidth)) / 2; + px += (w - (screen_desktop_layout.columns * (eachw + ob_rr_theme->fbwidth) + + ob_rr_theme->fbwidth)) / 2; + py += (h - (screen_desktop_layout.rows * (eachh + ob_rr_theme->fbwidth) + + ob_rr_theme->fbwidth)) / 2; if (eachw <= 0 || eachh <= 0) return; @@ -361,10 +362,10 @@ static void pager_popup_draw_icon(gint px, gint py, gint w, gint h, rown = n; for (r = 0, y = 0; r < screen_desktop_layout.rows; - ++r, y += eachh + ob_rr_theme->bwidth) + ++r, y += eachh + ob_rr_theme->fbwidth) { for (c = 0, x = 0; c < screen_desktop_layout.columns; - ++c, x += eachw + ob_rr_theme->bwidth) + ++c, x += eachw + ob_rr_theme->fbwidth) { RrAppearance *a; @@ -393,8 +394,8 @@ ObPagerPopup *pager_popup_new() self->desks = 0; self->wins = g_new(Window, self->desks); - self->hilight = RrAppearanceCopy(ob_rr_theme->app_hilite_fg); - self->unhilight = RrAppearanceCopy(ob_rr_theme->app_unhilite_fg); + self->hilight = RrAppearanceCopy(ob_rr_theme->osd_hilite_fg); + self->unhilight = RrAppearanceCopy(ob_rr_theme->osd_unhilite_fg); self->popup->draw_icon = pager_popup_draw_icon; self->popup->draw_icon_data = self; @@ -432,9 +433,9 @@ void pager_popup_show(ObPagerPopup *self, gchar *text, guint desk) for (i = self->desks; i < screen_num_desktops; ++i) { XSetWindowAttributes attr; - attr.border_pixel = RrColorPixel(ob_rr_theme->b_color); + attr.border_pixel = RrColorPixel(ob_rr_theme->frame_b_color); self->wins[i] = XCreateWindow(ob_display, self->popup->bg, - 0, 0, 1, 1, ob_rr_theme->bwidth, + 0, 0, 1, 1, ob_rr_theme->fbwidth, RrDepth(ob_rr_inst), InputOutput, RrVisual(ob_rr_inst), CWBorderPixel, &attr); diff --git a/parser/parse.c b/parser/parse.c index 6df24725..9db02fb0 100644 --- a/parser/parse.c +++ b/parser/parse.c @@ -1,7 +1,7 @@ /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- parse.c for the Openbox window manager - Copyright (c) 2003 Ben Jansens + Copyright (c) 2003-2007 Dana Jansens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include #include #include +#include static gboolean xdg_start; static gchar *xdg_config_home_path; @@ -67,7 +68,7 @@ void parse_register(ObParseInst *i, const gchar *tag, struct Callback *c; if ((c = g_hash_table_lookup(i->callbacks, tag))) { - g_warning("tag '%s' already registered", tag); + g_warning("Tag '%s' already registered", tag); return; } @@ -90,7 +91,35 @@ gboolean parse_load_rc(xmlDocPtr *doc, xmlNodePtr *root) g_free(path); } if (!r) - g_warning("unable to find a valid config file, using defaults"); + g_warning("Unable to find a valid config file, using defaults"); + return r; +} + +gboolean parse_load_theme(const gchar *name, xmlDocPtr *doc, xmlNodePtr *root, + gchar **retpath) +{ + GSList *it; + gchar *path; + gboolean r = FALSE; + + /* backward compatibility.. */ + path = g_build_filename(g_get_home_dir(), ".themes", name, + "openbox-3", "themerc.xml", NULL); + if ((r = parse_load(path, "openbox_theme", doc, root))) + *retpath = g_path_get_dirname(path); + g_free(path); + + if (!r) { + for (it = xdg_data_dir_paths; !r && it; it = g_slist_next(it)) { + path = g_build_filename(it->data, "themes", name, "openbox-3", + "themerc.xml", NULL); + if ((r = parse_load(path, "openbox_theme", doc, root))) + *retpath = g_path_get_dirname(path); + g_free(path); + } + } + if (!r) + g_warning("Unable to load the theme %s", name); return r; } @@ -110,14 +139,20 @@ gboolean parse_load_menu(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root) } } if (!r) - g_warning("unable to find a valid menu file '%s'", file); + g_warning("Unable to find a valid menu file '%s'", file); return r; } gboolean parse_load(const gchar *path, const gchar *rootname, xmlDocPtr *doc, xmlNodePtr *root) { - if ((*doc = xmlParseFile(path))) { + struct stat s; + if (stat(path, &s) < 0) + return FALSE; + + /* XML_PARSE_BLANKS is needed apparently. When it loads a theme file, + without this option, the tree is weird and has extra nodes in it. */ + if ((*doc = xmlReadFile(path, NULL, XML_PARSE_NOBLANKS))) { *root = xmlDocGetRootElement(*doc); if (!*root) { xmlFreeDoc(*doc); @@ -127,7 +162,7 @@ gboolean parse_load(const gchar *path, const gchar *rootname, if (xmlStrcasecmp((*root)->name, (const xmlChar*)rootname)) { xmlFreeDoc(*doc); *doc = NULL; - g_warning("document %s is of wrong type. root node is " + g_warning("Document %s is of wrong type. root node is " "not '%s'", path, rootname); } } @@ -150,7 +185,7 @@ gboolean parse_load_mem(gpointer data, guint len, const gchar *rootname, if (xmlStrcasecmp((*root)->name, (const xmlChar*)rootname)) { xmlFreeDoc(*doc); *doc = NULL; - g_warning("document in given memory is of wrong type. root " + g_warning("Document in given memory is of wrong type. root " "node is not '%s'", rootname); } } @@ -395,6 +430,10 @@ void parse_paths_shutdown() g_free(it->data); g_slist_free(xdg_data_dir_paths); xdg_data_dir_paths = NULL; + g_free(xdg_config_home_path); + xdg_config_home_path = NULL; + g_free(xdg_data_home_path); + xdg_data_home_path = NULL; } gchar *parse_expand_tilde(const gchar *f) diff --git a/parser/parse.h b/parser/parse.h index ac3acba2..d2a6606b 100644 --- a/parser/parse.h +++ b/parser/parse.h @@ -38,6 +38,9 @@ void parse_shutdown(ObParseInst *inst); gboolean parse_load_rc(xmlDocPtr *doc, xmlNodePtr *root); /* Loads an Openbox menu, from the normal paths */ gboolean parse_load_menu(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root); +/* Loads an Openbox menu, from the normal paths */ +gboolean parse_load_theme(const gchar *name, xmlDocPtr *doc, xmlNodePtr *root, + gchar **path); void parse_register(ObParseInst *inst, const gchar *tag, ParseCallback func, gpointer data); diff --git a/render/font.c b/render/font.c index 3c64cce9..c3353b67 100644 --- a/render/font.c +++ b/render/font.c @@ -121,29 +121,29 @@ void RrFontClose(RrFont *f) } static void font_measure_full(const RrFont *f, const gchar *str, - gint *x, gint *y, gint shadow_offset) + gint *x, gint *y, gint shadow_x, gint shadow_y) { PangoRectangle rect; pango_layout_set_text(f->layout, str, -1); pango_layout_set_width(f->layout, -1); pango_layout_get_pixel_extents(f->layout, NULL, &rect); - *x = rect.width + ABS(shadow_offset); - *y = rect.height + ABS(shadow_offset); + *x = rect.width + ABS(shadow_x); + *y = rect.height + ABS(shadow_y); } RrSize *RrFontMeasureString(const RrFont *f, const gchar *str, - gint shadow_offset) + gint shadow_x, gint shadow_y) { RrSize *size; size = g_new(RrSize, 1); - font_measure_full(f, str, &size->width, &size->height, shadow_offset); + font_measure_full(f, str, &size->width, &size->height, shadow_x, shadow_y); return size; } -gint RrFontHeight(const RrFont *f, gint shadow_offset) +gint RrFontHeight(const RrFont *f, gint shadow_y) { - return (f->ascent + f->descent) / PANGO_SCALE + ABS(shadow_offset); + return (f->ascent + f->descent) / PANGO_SCALE + ABS(shadow_y); } static inline int font_calculate_baseline(RrFont *f, gint height) @@ -207,27 +207,17 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area) break; } - if (t->shadow_offset) { - if (t->shadow_tint >= 0) { - c.color.red = 0; - c.color.green = 0; - c.color.blue = 0; - c.color.alpha = 0xffff * t->shadow_tint / 100; - c.pixel = BlackPixel(RrDisplay(t->font->inst), - RrScreen(t->font->inst)); - } else { - c.color.red = 0xffff; - c.color.green = 0xffff; - c.color.blue = 0xffff; - c.color.alpha = 0xffff * -t->shadow_tint / 100; - c.pixel = WhitePixel(RrDisplay(t->font->inst), - RrScreen(t->font->inst)); - } + if (t->shadow_offset_x || t->shadow_offset_y) { + c.color.red = t->shadow_color->r | t->shadow_color->r << 8; + c.color.green = t->shadow_color->g | t->shadow_color->g << 8; + c.color.blue = t->shadow_color->b | t->shadow_color->b << 8; + c.color.alpha = 0xffff * t->shadow_alpha / 255; + c.pixel = t->shadow_color->pixel; /* see below... */ pango_xft_render_layout_line (d, &c, pango_layout_get_line(t->font->layout, 0), - (x + t->shadow_offset) * PANGO_SCALE, - (y + t->shadow_offset) * PANGO_SCALE); + (x + t->shadow_offset_x) * PANGO_SCALE, + (y + t->shadow_offset_y) * PANGO_SCALE); } c.color.red = t->color->r | t->color->r << 8; diff --git a/render/render.c b/render/render.c index 962d3ec9..669761d5 100644 --- a/render/render.c +++ b/render/render.c @@ -349,10 +349,11 @@ void RrMinsize(RrAppearance *a, gint *w, gint *h) case RR_TEXTURE_TEXT: m = RrFontMeasureString(a->texture[i].data.text.font, a->texture[i].data.text.string, - a->texture[i].data.text.shadow_offset); + a->texture[i].data.text.shadow_offset_x, + a->texture[i].data.text.shadow_offset_y); *w = MAX(*w, m->width + 4); m->height = RrFontHeight(a->texture[i].data.text.font, - a->texture[i].data.text.shadow_offset); + a->texture[i].data.text.shadow_offset_y); *h += MAX(*h, m->height); g_free(m); break; diff --git a/render/render.h b/render/render.h index 65d16f22..d03db8d5 100644 --- a/render/render.h +++ b/render/render.h @@ -2,7 +2,7 @@ render.h for the Openbox window manager Copyright (c) 2006 Mikael Magnusson - Copyright (c) 2003 Ben Jansens + Copyright (c) 2003-2007 Dana Jansens Copyright (c) 2003 Derek Foreman This program is free software; you can redistribute it and/or modify @@ -121,8 +121,10 @@ struct _RrTextureText { RrJustify justify; RrColor *color; gchar *string; - gint shadow_offset; - gchar shadow_tint; + gint shadow_offset_x; + gint shadow_offset_y; + RrColor *shadow_color; + gchar shadow_alpha; }; struct _RrPixmapMask { @@ -231,8 +233,8 @@ RrFont *RrFontOpen (const RrInstance *inst, gchar *name, gint size, RrFont *RrFontOpenDefault (const RrInstance *inst); void RrFontClose (RrFont *f); RrSize *RrFontMeasureString (const RrFont *f, const gchar *str, - gint shadow_offset); -gint RrFontHeight (const RrFont *f, gint shadow_offset); + gint shadow_offset_x, gint shadow_offset_y); +gint RrFontHeight (const RrFont *f, gint shadow_offset_y); gint RrFontMaxCharWidth (const RrFont *f); void RrPaint (RrAppearance *a, Window win, gint w, gint h); diff --git a/render/theme.c b/render/theme.c index c8762181..c31ca112 100644 --- a/render/theme.c +++ b/render/theme.c @@ -2,7 +2,7 @@ theme.c for the Openbox window manager Copyright (c) 2006 Mikael Magnusson - Copyright (c) 2003 Ben Jansens + Copyright (c) 2003-2007 Dana Jansens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,44 +26,71 @@ #include "parser/parse.h" #include -#include #include #include #include -static XrmDatabase loaddb(RrTheme *theme, gchar *name); -static gboolean read_bool(XrmDatabase db, gchar *rname, gboolean *value); -static gboolean read_int(XrmDatabase db, gchar *rname, gint *value); -static gboolean read_string(XrmDatabase db, gchar *rname, gchar **value); -static gboolean read_color(XrmDatabase db, const RrInstance *inst, - gchar *rname, RrColor **value); -static gboolean read_mask(const RrInstance *inst, - gchar *maskname, RrTheme *theme, +typedef struct { + xmlDocPtr doc; + const RrInstance *inst; + gchar *path; +} ParseState; + +static void parse_style(gchar *tex, RrSurfaceColorType *grad, + RrReliefType *relief, RrBevelType *bevel, + gboolean *interlaced, gboolean *border, + gboolean allow_trans); +static gboolean read_mask(ParseState *ps, gchar *maskname, RrPixmapMask **value); -static gboolean read_appearance(XrmDatabase db, const RrInstance *inst, - gchar *rname, RrAppearance *value, - gboolean allow_trans); static RrPixel32* read_c_image(gint width, gint height, const guint8 *data); static void set_default_appearance(RrAppearance *a); +static xmlNodePtr find_node(xmlNodePtr n, gchar *names[]); +static gboolean find_int(ParseState *ps, xmlNodePtr n, gchar *names[], + gint *integer, gint lower, gint upper); +static gboolean find_string(ParseState *ps, xmlNodePtr n, gchar *names[], + gchar **string); +static gboolean find_color(ParseState *ps, xmlNodePtr n, gchar *names[], + RrColor **color, gchar *alpha); + static gboolean find_point(ParseState *ps, xmlNodePtr n, gchar *names[], + gint *x, gint *y, + gint lowx, gint lowy, gint upx, gint upy); +static gboolean find_shadow(ParseState *ps, xmlNodePtr n, gchar *names[], + RrAppearance *a); +static gboolean find_appearance(ParseState *ps, xmlNodePtr n, gchar *names[], + RrAppearance *a, gboolean allow_trans); + +/* make a null terminated array out of a list of strings */ +#define L(args...) (gchar*[]){args,NULL} +/* shortcut to the various find_* functions */ +#define FIND(type, args...) find_##type(&ps, root, args) RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, RrFont *active_window_font, RrFont *inactive_window_font, RrFont *menu_title_font, RrFont *menu_item_font) { - XrmDatabase db = NULL; + ParseState ps; + xmlNodePtr root; RrJustify winjust, mtitlejust; - gboolean b; gchar *str; RrTheme *theme; - gint offset; - gint tint; - theme = g_new0(RrTheme, 1); + if (name) { + if (!parse_load_theme(name, &ps.doc, &root, &ps.path)) { + g_warning("Falling back to the default theme: '%s'", + DEFAULT_THEME); + /* make it fall back to default theme */ + name = NULL; + } + } + if (!name) { + if (!parse_load_theme(DEFAULT_THEME, &ps.doc, &root, &ps.path)) + return NULL; + } + ps.inst = inst; + theme = g_new0(RrTheme, 1); theme->inst = inst; - theme->show_handle = TRUE; - theme->a_disabled_focused_max = RrAppearanceNew(inst, 1); theme->a_disabled_unfocused_max = RrAppearanceNew(inst, 1); theme->a_hover_focused_max = RrAppearanceNew(inst, 1); @@ -96,25 +123,8 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, theme->a_clear = RrAppearanceNew(inst, 0); theme->a_clear_tex = RrAppearanceNew(inst, 1); - if (name) { - db = loaddb(theme, name); - if (db == NULL) { - g_warning("Failed to load the theme '%s'\n" - "Falling back to the default: '%s'", - name, DEFAULT_THEME); - } else - theme->name = g_path_get_basename(name); - } - if (db == NULL) { - db = loaddb(theme, DEFAULT_THEME); - if (db == NULL) { - g_warning("Failed to load the theme '%s'.", DEFAULT_THEME); - return NULL; - } else - theme->name = g_path_get_basename(DEFAULT_THEME); - } - /* load the font stuff */ + if (active_window_font) { theme->win_font_focused = active_window_font; RrFontRef(active_window_font); @@ -128,10 +138,10 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, theme->win_font_unfocused = RrFontOpenDefault(inst); winjust = RR_JUSTIFY_LEFT; - if (read_string(db, "window.label.text.justify", &str)) { - if (!g_ascii_strcasecmp(str, "right")) + if (FIND(string, L( "window", "justify"), &str)) { + if (strcmp(str, "right") == 0) winjust = RR_JUSTIFY_RIGHT; - else if (!g_ascii_strcasecmp(str, "center")) + else if (strcmp(str, "center") == 0) winjust = RR_JUSTIFY_CENTER; } @@ -142,10 +152,10 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, theme->menu_title_font = RrFontOpenDefault(inst); mtitlejust = RR_JUSTIFY_LEFT; - if (read_string(db, "menu.title.text.justify", &str)) { - if (!g_ascii_strcasecmp(str, "right")) + if (FIND(string, L("menu", "justify"), &str)) { + if (strcmp(str, "right") == 0) mtitlejust = RR_JUSTIFY_RIGHT; - else if (!g_ascii_strcasecmp(str, "center")) + else if (strcmp(str, "center") == 0) mtitlejust = RR_JUSTIFY_CENTER; } @@ -156,143 +166,195 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, theme->menu_font = RrFontOpenDefault(inst); /* load direct dimensions */ - if (!read_int(db, "menu.overlap", &theme->menu_overlap) || - theme->menu_overlap < 0 || theme->menu_overlap > 20) + if (!FIND(int, L("menu","overlap"), + &theme->menu_overlap, -100, 100)) theme->menu_overlap = 0; - if (!read_int(db, "window.handle.width", &theme->handle_height)) - theme->handle_height = 6; - if (!theme->handle_height) - theme->show_handle = FALSE; - if (theme->handle_height <= 0 || theme->handle_height > 100) + + if (!FIND(int, L("dimensions","handle"), &theme->handle_height, 0, 100)) theme->handle_height = 6; - if (!read_int(db, "padding.width", &theme->padding) || - theme->padding < 0 || theme->padding > 100) - theme->padding = 3; - if (!read_int(db, "border.width", &theme->bwidth) || - theme->bwidth < 0 || theme->bwidth > 100) - theme->bwidth = 1; - if (!read_int(db, "window.client.padding.width", &theme->cbwidth) || - theme->cbwidth < 0 || theme->cbwidth > 100) - theme->cbwidth = theme->padding; + + if (!FIND(point, L("dimensions","padding"), + &theme->paddingx, &theme->paddingy, 0, 100, 0, 100)) + theme->paddingx = theme->paddingy = 3; + + if (!FIND(int, L("window","border","width"), + &theme->fbwidth, 0, 100)) + theme->fbwidth = 1; + + /* menu border width inherits from frame border width */ + if (!FIND(int, L("menu","border","width"), + &theme->mbwidth, 0, 100)) + theme->mbwidth = theme->fbwidth; + + if (!FIND(point, L("window","clientpadding"), &theme->cbwidthx, + &theme->cbwidthy, 0, 100, 0, 100)) + theme->cbwidthx = theme->cbwidthy = 1; /* load colors */ - if (!read_color(db, inst, - "border.color", &theme->b_color)) - theme->b_color = RrColorNew(inst, 0, 0, 0); - if (!read_color(db, inst, - "window.active.client.color", - &theme->cb_focused_color)) - theme->cb_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff); - if (!read_color(db, inst, - "window.inactive.client.color", - &theme->cb_unfocused_color)) - theme->cb_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff); - if (!read_color(db, inst, - "window.active.label.text.color", - &theme->title_focused_color)) + if (!FIND(color, L("window","border","primary"), + &theme->frame_b_color, NULL)) + theme->frame_b_color = RrColorNew(inst, 0, 0, 0); + + /* menu border color inherits from frame border color */ + if (!FIND(color, L("menu","border","primary"), + &theme->menu_b_color, NULL)) + theme->menu_b_color = RrColorNew(inst, + theme->frame_b_color->r, + theme->frame_b_color->g, + theme->frame_b_color->b); + if (!FIND(color, L("window","active","clientpadding"), + &theme->cb_focused_color, NULL)) + theme->cb_focused_color = RrColorNew(inst, 255, 255, 255); + if (!FIND(color, L("window","inactive","clientpadding"), + &theme->cb_unfocused_color, NULL)) + theme->cb_unfocused_color = RrColorNew(inst, 255, 255, 255); + if (!FIND(color, L("window","active","label","text","primary"), + &theme->title_focused_color, NULL)) theme->title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0); - if (!read_color(db, inst, - "window.inactive.label.text.color", - &theme->title_unfocused_color)) + if (!FIND(color, L("osd","text","primary"), + &theme->osd_color, NULL)) + theme->osd_color = RrColorNew(inst, + theme->title_focused_color->r, + theme->title_focused_color->g, + theme->title_focused_color->b); + if (!FIND(color, L("window","inactive","label","text","primary"), + &theme->title_unfocused_color, NULL)) theme->title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff); - if (!read_color(db, inst, - "window.active.button.unpressed.image.color", - &theme->titlebut_focused_unpressed_color)) + if (!FIND(color, L("window","active","buttons","unpressed","image"), + &theme->titlebut_focused_unpressed_color, NULL)) theme->titlebut_focused_unpressed_color = RrColorNew(inst, 0, 0, 0); - if (!read_color(db, inst, - "window.inactive.button.unpressed.image.color", - &theme->titlebut_unfocused_unpressed_color)) + if (!FIND(color, L("window","inactive","buttons", "unpressed","image"), + &theme->titlebut_unfocused_unpressed_color, NULL)) theme->titlebut_unfocused_unpressed_color = RrColorNew(inst, 0xff, 0xff, 0xff); - if (!read_color(db, inst, - "window.active.button.pressed.image.color", - &theme->titlebut_focused_pressed_color)) + if (!FIND(color, L("window","active","buttons","pressed","image"), + &theme->titlebut_focused_pressed_color, NULL)) theme->titlebut_focused_pressed_color = RrColorNew(inst, theme->titlebut_focused_unpressed_color->r, theme->titlebut_focused_unpressed_color->g, theme->titlebut_focused_unpressed_color->b); - if (!read_color(db, inst, - "window.inactive.button.pressed.image.color", - &theme->titlebut_unfocused_pressed_color)) + if (!FIND(color, L("window","inactive","buttons","pressed","image"), + &theme->titlebut_unfocused_pressed_color, NULL)) theme->titlebut_unfocused_pressed_color = RrColorNew(inst, theme->titlebut_unfocused_unpressed_color->r, theme->titlebut_unfocused_unpressed_color->g, theme->titlebut_unfocused_unpressed_color->b); - if (!read_color(db, inst, - "window.active.button.disabled.image.color", - &theme->titlebut_disabled_focused_color)) + if (!FIND(color, L("window","active","buttons","disabled","image"), + &theme->titlebut_disabled_focused_color, NULL)) theme->titlebut_disabled_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff); - if (!read_color(db, inst, - "window.inactive.button.disabled.image.color", - &theme->titlebut_disabled_unfocused_color)) + if (!FIND(color, L("window","inactive","buttons","disabled","image"), + &theme->titlebut_disabled_unfocused_color, NULL)) theme->titlebut_disabled_unfocused_color = RrColorNew(inst, 0, 0, 0); - if (!read_color(db, inst, - "window.active.button.hover.image.color", - &theme->titlebut_hover_focused_color)) + if (!FIND(color, + L("window","active","buttons","hover","image"), + &theme->titlebut_hover_focused_color, NULL)) theme->titlebut_hover_focused_color = RrColorNew(inst, theme->titlebut_focused_unpressed_color->r, theme->titlebut_focused_unpressed_color->g, theme->titlebut_focused_unpressed_color->b); - if (!read_color(db, inst, - "window.inactive.button.hover.image.color", - &theme->titlebut_hover_unfocused_color)) + if (!FIND(color, L("window","inactive","buttons","hover","image"), + &theme->titlebut_hover_unfocused_color, NULL)) theme->titlebut_hover_unfocused_color = RrColorNew(inst, theme->titlebut_unfocused_unpressed_color->r, theme->titlebut_unfocused_unpressed_color->g, theme->titlebut_unfocused_unpressed_color->b); - if (!read_color(db, inst, - "window.active.button.toggled.image.color", - &theme->titlebut_toggled_focused_color)) + if (!FIND(color, L("window","active","buttons","toggled","image"), + &theme->titlebut_toggled_focused_color, NULL)) theme->titlebut_toggled_focused_color = RrColorNew(inst, theme->titlebut_focused_pressed_color->r, theme->titlebut_focused_pressed_color->g, theme->titlebut_focused_pressed_color->b); - if (!read_color(db, inst, - "window.inactive.button.toggled.image.color", - &theme->titlebut_toggled_unfocused_color)) + if (!FIND(color, L("window","inactive","buttons","toggled","image"), + &theme->titlebut_toggled_unfocused_color, NULL)) theme->titlebut_toggled_unfocused_color = RrColorNew(inst, theme->titlebut_unfocused_pressed_color->r, theme->titlebut_unfocused_pressed_color->g, theme->titlebut_unfocused_pressed_color->b); - if (!read_color(db, inst, - "menu.title.text.color", &theme->menu_title_color)) + if (!FIND(color, L("menu","title","text","primary"), + &theme->menu_title_color, NULL)) theme->menu_title_color = RrColorNew(inst, 0, 0, 0); - if (!read_color(db, inst, - "menu.items.text.color", &theme->menu_color)) + if (!FIND(color, L("menu","inactive","primary"), &theme->menu_color, NULL)) theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff); - if (!read_color(db, inst, - "menu.items.disabled.text.color", - &theme->menu_disabled_color)) + if (!FIND(color, L("menu","disabled","primary"), + &theme->menu_disabled_color, NULL)) theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0); - if (!read_color(db, inst, - "menu.items.active.text.color", - &theme->menu_selected_color)) + if (!FIND(color, L("menu","active","text","primary"), + &theme->menu_selected_color, NULL)) theme->menu_selected_color = RrColorNew(inst, 0, 0, 0); + if (!FIND(color, L("window","active","label","text","shadow","primary"), + &theme->title_focused_shadow_color, + &theme->title_focused_shadow_alpha)) + { + theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0); + theme->title_focused_shadow_alpha = 50; + } + if (!FIND(color, L("osd","text","shadow","primary"), + &theme->osd_shadow_color, &theme->osd_shadow_alpha)) + { + theme->osd_shadow_color = + RrColorNew(inst, theme->title_focused_shadow_color->r, + theme->title_focused_shadow_color->g, + theme->title_focused_shadow_color->b); + theme->osd_shadow_alpha = theme->title_focused_shadow_alpha; + } + if (!FIND(color, L("window","inactive","label","text","shadow","primary"), + &theme->title_unfocused_shadow_color, + &theme->title_unfocused_shadow_alpha)) + { + theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0); + theme->title_unfocused_shadow_alpha = 50; + } + if (!FIND(color, L("menu","title","text","shadow","primary"), + &theme->menu_title_shadow_color, + &theme->menu_title_shadow_alpha)) + { + theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0); + theme->menu_title_shadow_alpha = 50; + } + if (!FIND(color, L("menu","inactive","shadow","primary"), + &theme->menu_text_normal_shadow_color, + &theme->menu_text_normal_shadow_alpha)) + { + theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0); + theme->menu_text_normal_shadow_alpha = 50; + } + if (!FIND(color, L("menu","active","text","shadow","primary"), + &theme->menu_text_selected_shadow_color, + &theme->menu_text_selected_shadow_alpha)) + { + theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0); + theme->menu_text_selected_shadow_alpha = 50; + } + if (!FIND(color, L("menu","disabled","shadow","primary"), + &theme->menu_text_disabled_shadow_color, + &theme->menu_text_disabled_shadow_alpha)) + { + theme->menu_text_disabled_shadow_color = + RrColorNew(inst, theme->menu_text_normal_shadow_color->r, + theme->menu_text_normal_shadow_color->g, + theme->menu_text_normal_shadow_color->b); + theme->menu_text_disabled_shadow_alpha = + theme->menu_text_normal_shadow_alpha; + } - if (read_mask(inst, "max.xbm", theme, &theme->max_mask)) { - if (!read_mask(inst, "max_pressed.xbm", theme, - &theme->max_pressed_mask)) { + /* load the image masks */ + if (read_mask(&ps, "max.xbm", &theme->max_mask)) { + if (!read_mask(&ps, "max_pressed.xbm", &theme->max_pressed_mask)) theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask); - } - if (!read_mask(inst, "max_toggled.xbm", theme, - &theme->max_toggled_mask)) { + if (!read_mask(&ps, "max_toggled.xbm", &theme->max_toggled_mask)) theme->max_toggled_mask = RrPixmapMaskCopy(theme->max_pressed_mask); - } - if (!read_mask(inst, "max_disabled.xbm", theme, - &theme->max_disabled_mask)) { + if (!read_mask(&ps, "max_disabled.xbm", &theme->max_disabled_mask)) theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask); - } - if (!read_mask(inst, "max_hover.xbm", theme, &theme->max_hover_mask)) { + if (!read_mask(&ps, "max_hover.xbm", &theme->max_hover_mask)) theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask); - } } else { { guchar data[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f }; @@ -307,21 +369,17 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask); } - if (read_mask(inst, "iconify.xbm", theme, &theme->iconify_mask)) { - if (!read_mask(inst, "iconify_pressed.xbm", theme, - &theme->iconify_pressed_mask)) { + if (read_mask(&ps, "iconify.xbm", &theme->iconify_mask)) { + if (!read_mask(&ps, "iconify_pressed.xbm", + &theme->iconify_pressed_mask)) theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask); - } - if (!read_mask(inst, "iconify_disabled.xbm", theme, - &theme->iconify_disabled_mask)) { + if (!read_mask(&ps, "iconify_disabled.xbm", + &theme->iconify_disabled_mask)) theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask); - } - if (!read_mask(inst, "iconify_hover.xbm", theme, - &theme->iconify_hover_mask)) { + if (!read_mask(&ps, "iconify_hover.xbm", &theme->iconify_hover_mask)) theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask); - } } else { { guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f }; @@ -336,24 +394,16 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, OB_DEFAULT_ICON_HEIGHT, OB_DEFAULT_ICON_pixel_data); - if (read_mask(inst, "desk.xbm", theme, &theme->desk_mask)) { - if (!read_mask(inst, "desk_pressed.xbm", theme, - &theme->desk_pressed_mask)) { + if (read_mask(&ps, "desk.xbm", &theme->desk_mask)) { + if (!read_mask(&ps, "desk_pressed.xbm", &theme->desk_pressed_mask)) theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask); - } - if (!read_mask(inst, "desk_toggled.xbm", theme, - &theme->desk_toggled_mask)) { + if (!read_mask(&ps, "desk_toggled.xbm", &theme->desk_toggled_mask)) theme->desk_toggled_mask = RrPixmapMaskCopy(theme->desk_pressed_mask); - } - if (!read_mask(inst, "desk_disabled.xbm", theme, - &theme->desk_disabled_mask)) { + if (!read_mask(&ps, "desk_disabled.xbm", &theme->desk_disabled_mask)) theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask); - } - if (!read_mask(inst, "desk_hover.xbm", theme, - &theme->desk_hover_mask)) { + if (!read_mask(&ps, "desk_hover.xbm", &theme->desk_hover_mask)) theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask); - } } else { { guchar data[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 }; @@ -369,24 +419,16 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask); } - if (read_mask(inst, "shade.xbm", theme, &theme->shade_mask)) { - if (!read_mask(inst, "shade_pressed.xbm", theme, - &theme->shade_pressed_mask)) { + if (read_mask(&ps, "shade.xbm", &theme->shade_mask)) { + if (!read_mask(&ps, "shade_pressed.xbm", &theme->shade_pressed_mask)) theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask); - } - if (!read_mask(inst, "shade_toggled.xbm", theme, - &theme->shade_toggled_mask)) { + if (!read_mask(&ps, "shade_toggled.xbm", &theme->shade_toggled_mask)) theme->shade_toggled_mask = RrPixmapMaskCopy(theme->shade_pressed_mask); - } - if (!read_mask(inst, "shade_disabled.xbm", theme, - &theme->shade_disabled_mask)) { + if (!read_mask(&ps, "shade_disabled.xbm", &theme->shade_disabled_mask)) theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask); - } - if (!read_mask(inst, "shade_hover.xbm", theme, - &theme->shade_hover_mask)) { + if (!read_mask(&ps, "shade_hover.xbm", &theme->shade_hover_mask)) theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask); - } } else { { guchar data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 }; @@ -402,19 +444,13 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask); } - if (read_mask(inst, "close.xbm", theme, &theme->close_mask)) { - if (!read_mask(inst, "close_pressed.xbm", theme, - &theme->close_pressed_mask)) { + if (read_mask(&ps, "close.xbm", &theme->close_mask)) { + if (!read_mask(&ps, "close_pressed.xbm", &theme->close_pressed_mask)) theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask); - } - if (!read_mask(inst, "close_disabled.xbm", theme, - &theme->close_disabled_mask)) { + if (!read_mask(&ps, "close_disabled.xbm", &theme->close_disabled_mask)) theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask); - } - if (!read_mask(inst, "close_hover.xbm", theme, - &theme->close_hover_mask)) { + if (!read_mask(&ps, "close_hover.xbm", &theme->close_hover_mask)) theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask); - } } else { { guchar data[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 }; @@ -425,140 +461,104 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask); } - if (!read_mask(inst, "bullet.xbm", theme, &theme->menu_bullet_mask)) { + if (!read_mask(&ps, "bullet.xbm", &theme->menu_bullet_mask)) { guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 }; theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data); } /* read the decoration textures */ - if (!read_appearance(db, inst, - "window.active.title.bg", theme->a_focused_title, - FALSE)) + if (!FIND(appearance, L("window","active","titlebar"), + theme->a_focused_title, FALSE)) set_default_appearance(theme->a_focused_title); - if (!read_appearance(db, inst, - "window.inactive.title.bg", theme->a_unfocused_title, - FALSE)) + if (!FIND(appearance, L("window","inactive","titlebar"), + theme->a_unfocused_title, FALSE)) set_default_appearance(theme->a_unfocused_title); - if (!read_appearance(db, inst, - "window.active.label.bg", theme->a_focused_label, - TRUE)) + if (!FIND(appearance, L("window","active","label"), + theme->a_focused_label, TRUE)) set_default_appearance(theme->a_focused_label); - if (!read_appearance(db, inst, - "window.inactive.label.bg", theme->a_unfocused_label, - TRUE)) + if (!FIND(appearance, L("window","inactive","label"), + theme->a_unfocused_label, TRUE)) set_default_appearance(theme->a_unfocused_label); - if (!read_appearance(db, inst, - "window.active.handle.bg", theme->a_focused_handle, - FALSE)) + if (!FIND(appearance, L("window","active","handle"), + theme->a_focused_handle, FALSE)) set_default_appearance(theme->a_focused_handle); - if (!read_appearance(db, inst, - "window.inactive.handle.bg",theme->a_unfocused_handle, - FALSE)) + if (!FIND(appearance, L("window","inactive","handle"), + theme->a_unfocused_handle, FALSE)) set_default_appearance(theme->a_unfocused_handle); - if (!read_appearance(db, inst, - "window.active.grip.bg", theme->a_focused_grip, - TRUE)) + if (!FIND(appearance, L("window","active","grip"), + theme->a_focused_grip, TRUE)) set_default_appearance(theme->a_focused_grip); - if (!read_appearance(db, inst, - "window.inactive.grip.bg", theme->a_unfocused_grip, - TRUE)) + if (!FIND(appearance, L("window","inactive","grip"), + theme->a_unfocused_grip, TRUE)) set_default_appearance(theme->a_unfocused_grip); - if (!read_appearance(db, inst, - "menu.items.bg", theme->a_menu, - FALSE)) + if (!FIND(appearance, L("menu","entries"), theme->a_menu, FALSE)) set_default_appearance(theme->a_menu); - if (!read_appearance(db, inst, - "menu.title.bg", theme->a_menu_title, - FALSE)) + if (!FIND(appearance, L("menu","title"), theme->a_menu_title, FALSE)) set_default_appearance(theme->a_menu_title); - if (!read_appearance(db, inst, - "menu.items.active.bg", theme->a_menu_selected, - TRUE)) + if (!FIND(appearance, L("menu", "active"), theme->a_menu_selected, TRUE)) set_default_appearance(theme->a_menu_selected); /* read the appearances for rendering non-decorations */ - theme->app_hilite_bg = RrAppearanceCopy(theme->a_focused_title); - theme->app_hilite_label = RrAppearanceCopy(theme->a_focused_label); + theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title); + theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label); if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL) - theme->app_hilite_fg = RrAppearanceCopy(theme->a_focused_label); + theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_label); else - theme->app_hilite_fg = RrAppearanceCopy(theme->a_focused_title); - theme->app_unhilite_bg = RrAppearanceCopy(theme->a_unfocused_title); - theme->app_unhilite_label = RrAppearanceCopy(theme->a_unfocused_label); + theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_title); if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL) - theme->app_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_label); + theme->osd_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_label); else - theme->app_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_title); + theme->osd_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_title); /* read buttons textures */ - if (!read_appearance(db, inst, - "window.active.button.disabled.bg", - theme->a_disabled_focused_max, - TRUE)) + if (!FIND(appearance, L("window","active","buttons","disabled"), + theme->a_disabled_focused_max, TRUE)) set_default_appearance(theme->a_disabled_focused_max); - if (!read_appearance(db, inst, - "window.inactive.button.disabled.bg", - theme->a_disabled_unfocused_max, - TRUE)) + if (!FIND(appearance, L("window","inactive","buttons","disabled"), + theme->a_disabled_unfocused_max, TRUE)) set_default_appearance(theme->a_disabled_unfocused_max); - if (!read_appearance(db, inst, - "window.active.button.pressed.bg", - theme->a_focused_pressed_max, - TRUE)) + if (!FIND(appearance, L("window","active","buttons","pressed"), + theme->a_focused_pressed_max, TRUE)) set_default_appearance(theme->a_focused_pressed_max); - if (!read_appearance(db, inst, - "window.inactive.button.pressed.bg", - theme->a_unfocused_pressed_max, - TRUE)) + if (!FIND(appearance, L("window","inactive","buttons","pressed"), + theme->a_unfocused_pressed_max, TRUE)) set_default_appearance(theme->a_unfocused_pressed_max); - if (!read_appearance(db, inst, - "window.active.button.toggled.bg", - theme->a_toggled_focused_max, - TRUE)) + if (!FIND(appearance, L("window","active","buttons","toggled"), + theme->a_toggled_focused_max, TRUE)) { RrAppearanceFree(theme->a_toggled_focused_max); theme->a_toggled_focused_max = RrAppearanceCopy(theme->a_focused_pressed_max); } - if (!read_appearance(db, inst, - "window.inactive.button.toggled.bg", - theme->a_toggled_unfocused_max, - TRUE)) + if (!FIND(appearance, L("window","inactive","buttons","toggled"), + theme->a_toggled_unfocused_max, TRUE)) { RrAppearanceFree(theme->a_toggled_unfocused_max); theme->a_toggled_unfocused_max = RrAppearanceCopy(theme->a_unfocused_pressed_max); } - if (!read_appearance(db, inst, - "window.active.button.unpressed.bg", - theme->a_focused_unpressed_max, - TRUE)) + if (!FIND(appearance, L("window","active","buttons","unpressed"), + theme->a_focused_unpressed_max, TRUE)) set_default_appearance(theme->a_focused_unpressed_max); - if (!read_appearance(db, inst, - "window.inactive.button.unpressed.bg", - theme->a_unfocused_unpressed_max, - TRUE)) + if (!FIND(appearance, L("window","inactive","buttons","unpressed"), + theme->a_unfocused_unpressed_max, TRUE)) set_default_appearance(theme->a_unfocused_unpressed_max); - if (!read_appearance(db, inst, - "window.active.button.hover.bg", - theme->a_hover_focused_max, - TRUE)) + if (!FIND(appearance, L("window","active","buttons","hover"), + theme->a_hover_focused_max, TRUE)) { RrAppearanceFree(theme->a_hover_focused_max); theme->a_hover_focused_max = RrAppearanceCopy(theme->a_focused_unpressed_max); } - if (!read_appearance(db, inst, - "window.inactive.button.hover.bg", - theme->a_hover_unfocused_max, - TRUE)) + if (!FIND(appearance, L("window","inactive","buttons","hover"), + theme->a_hover_unfocused_max, TRUE)) { RrAppearanceFree(theme->a_hover_unfocused_max); theme->a_hover_unfocused_max = RrAppearanceCopy(theme->a_unfocused_unpressed_max); } - theme->a_disabled_focused_close = + theme->a_disabled_focused_close = RrAppearanceCopy(theme->a_disabled_focused_max); theme->a_disabled_unfocused_close = RrAppearanceCopy(theme->a_disabled_unfocused_max); @@ -644,79 +644,68 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, /* set up the textures */ theme->a_focused_label->texture[0].type = - theme->app_hilite_label->texture[0].type = RR_TEXTURE_TEXT; + theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT; theme->a_focused_label->texture[0].data.text.justify = winjust; - theme->app_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT; + theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT; theme->a_focused_label->texture[0].data.text.font = - theme->app_hilite_label->texture[0].data.text.font = + theme->osd_hilite_label->texture[0].data.text.font = theme->win_font_focused; theme->a_focused_label->texture[0].data.text.color = - theme->app_hilite_label->texture[0].data.text.color = theme->title_focused_color; - - if (read_bool(db, "window.active.label.text.shadow", &b) && b) { - if (!read_int(db, "window.active.label.text.shadow.offset", &offset)) - offset = 1; - - if (!read_int(db, "window.active.label.text.shadow.tint", &tint)) - tint = 50; - tint = (tint > 100 ? 100 : (tint < -100 ? -100 : tint)); - } else { - offset = 0; - tint = 50; + theme->osd_hilite_label->texture[0].data.text.color = + theme->osd_color; + + if (!FIND(shadow, L("window","active","label","text","shadow","offset"), + theme->a_focused_label)) + theme->a_focused_label->texture[0].data.text.shadow_offset_x = + theme->a_focused_label->texture[0].data.text.shadow_offset_y = 0; + theme->a_focused_label->texture[0].data.text.shadow_color = + theme->title_focused_shadow_color; + theme->a_focused_label->texture[0].data.text.shadow_alpha = + theme->title_focused_shadow_alpha; + + if (!FIND(shadow, L("osd","text","shadow","offset"), + theme->osd_hilite_label)) + { + theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = + theme->a_focused_label->texture[0].data.text.shadow_offset_x; + theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = + theme->a_focused_label->texture[0].data.text.shadow_offset_y; } - theme->a_focused_label->texture[0].data.text.shadow_offset = - theme->app_hilite_label->texture[0].data.text.shadow_offset = offset; - theme->a_focused_label->texture[0].data.text.shadow_tint = - theme->app_hilite_label->texture[0].data.text.shadow_tint = tint; + theme->osd_hilite_label->texture[0].data.text.shadow_color = + theme->osd_shadow_color; + theme->osd_hilite_label->texture[0].data.text.shadow_alpha = + theme->osd_shadow_alpha; - theme->a_unfocused_label->texture[0].type = - theme->app_unhilite_label->texture[0].type = RR_TEXTURE_TEXT; + theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT; theme->a_unfocused_label->texture[0].data.text.justify = winjust; - theme->app_unhilite_label->texture[0].data.text.justify = - RR_JUSTIFY_LEFT; theme->a_unfocused_label->texture[0].data.text.font = - theme->app_unhilite_label->texture[0].data.text.font = theme->win_font_unfocused; theme->a_unfocused_label->texture[0].data.text.color = - theme->app_unhilite_label->texture[0].data.text.color = theme->title_unfocused_color; - if (read_bool(db, "window.inactive.label.text.shadow", &b) && b) { - if (!read_int(db, "window.inactive.label.text.shadow.offset", &offset)) - offset = 1; - - if (!read_int(db, "window.inactive.label.text.shadow.tint", &tint)) - tint = 50; - tint = (tint > 100 ? 100 : (tint < -100 ? -100 : tint)); - } else { - offset = 0; - tint = 50; - } - theme->a_unfocused_label->texture[0].data.text.shadow_offset = - theme->app_unhilite_label->texture[0].data.text.shadow_offset = - offset; - theme->a_unfocused_label->texture[0].data.text.shadow_tint = - theme->app_unhilite_label->texture[0].data.text.shadow_tint = tint; + if (!FIND(shadow, L("window","inactive","label","text","shadow","offset"), + theme->a_unfocused_label)) + theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = + theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = 0; + theme->a_unfocused_label->texture[0].data.text.shadow_color = + theme->title_unfocused_shadow_color; + theme->a_unfocused_label->texture[0].data.text.shadow_alpha = + theme->title_unfocused_shadow_alpha; theme->a_menu_title->texture[0].type = RR_TEXTURE_TEXT; theme->a_menu_title->texture[0].data.text.justify = mtitlejust; theme->a_menu_title->texture[0].data.text.font = theme->menu_title_font; theme->a_menu_title->texture[0].data.text.color = theme->menu_title_color; - if (read_bool(db, "menu.title.text.shadow", &b) && b) { - if (!read_int(db, "menu.title.text.shadow.offset", &offset)) - offset = 1; - - if (!read_int(db, "menu.title.text.shadow.tint", &tint)) - tint = 50; - tint = (tint > 100 ? 100 : (tint < -100 ? -100 : tint)); - } else { - offset = 0; - tint = 50; - } - theme->a_menu_title->texture[0].data.text.shadow_offset = offset; - theme->a_menu_title->texture[0].data.text.shadow_tint = tint; + if (!FIND(shadow, L("menu","title","text","shadow","offset"), + theme->a_menu_title)) + theme->a_menu_title->texture[0].data.text.shadow_offset_x = + theme->a_menu_title->texture[0].data.text.shadow_offset_y = 0; + theme->a_menu_title->texture[0].data.text.shadow_color = + theme->menu_title_shadow_color; + theme->a_menu_title->texture[0].data.text.shadow_alpha = + theme->menu_title_shadow_alpha; theme->a_menu_text_normal->texture[0].type = theme->a_menu_text_disabled->texture[0].type = @@ -735,24 +724,33 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, theme->a_menu_text_selected->texture[0].data.text.color = theme->menu_selected_color; - if (read_bool(db, "menu.items.text.shadow", &b) && b) { - if (!read_int(db, "menu.items.text.shadow.offset", &offset)) - offset = 1; - - if (!read_int(db, "menu.items.text.shadow.tint", &tint)) - tint = 50; - tint = (tint > 100 ? 100 : (tint < -100 ? -100 : tint)); - } else { - offset = 0; - tint = 50; - } - theme->a_menu_text_normal->texture[0].data.text.shadow_offset = - theme->a_menu_text_disabled->texture[0].data.text.shadow_offset = - theme->a_menu_text_selected->texture[0].data.text.shadow_offset = - offset; - theme->a_menu_text_normal->texture[0].data.text.shadow_tint = - theme->a_menu_text_disabled->texture[0].data.text.shadow_tint = - theme->a_menu_text_selected->texture[0].data.text.shadow_tint = tint; + if (!FIND(shadow, L("menu","inactive","shadow","offset"), + theme->a_menu_text_normal)) + theme->a_menu_text_normal->texture[0].data.text.shadow_offset_x = + theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y = + 0; + if (!FIND(shadow, L("menu","active","text","shadow","offset"), + theme->a_menu_text_selected)) + theme->a_menu_text_selected->texture[0].data.text.shadow_offset_x = + theme->a_menu_text_selected->texture[0].data.text.shadow_offset_y = + 0; + if (!FIND(shadow, L("menu","disabled","shadow","offset"), + theme->a_menu_text_disabled)) + theme->a_menu_text_disabled->texture[0].data.text.shadow_offset_x = + theme->a_menu_text_disabled->texture[0].data.text.shadow_offset_y = + 0; + theme->a_menu_text_normal->texture[0].data.text.shadow_color = + theme->menu_text_normal_shadow_color; + theme->a_menu_text_normal->texture[0].data.text.shadow_alpha = + theme->menu_text_normal_shadow_alpha; + theme->a_menu_text_selected->texture[0].data.text.shadow_color = + theme->menu_text_selected_shadow_color; + theme->a_menu_text_selected->texture[0].data.text.shadow_alpha = + theme->menu_text_selected_shadow_alpha; + theme->a_menu_text_disabled->texture[0].data.text.shadow_color = + theme->menu_text_disabled_shadow_color; + theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha = + theme->menu_text_disabled_shadow_alpha; theme->a_disabled_focused_max->texture[0].type = theme->a_disabled_unfocused_max->texture[0].type = @@ -802,7 +800,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, theme->a_unfocused_pressed_iconify->texture[0].type = theme->a_menu_bullet_normal->texture[0].type = theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK; - + theme->a_disabled_focused_max->texture[0].data.mask.mask = theme->a_disabled_unfocused_max->texture[0].data.mask.mask = theme->max_disabled_mask; @@ -936,27 +934,35 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, theme->a_menu_bullet_selected->texture[0].data.mask.color = theme->menu_selected_color; - XrmDestroyDatabase(db); - - /* set the font heights */ - theme->win_font_height = RrFontHeight - (theme->win_font_focused, - theme->a_focused_label->texture[0].data.text.shadow_offset); - theme->win_font_height = - MAX(theme->win_font_height, - RrFontHeight - (theme->win_font_focused, - theme->a_unfocused_label->texture[0].data.text.shadow_offset)); - theme->menu_title_font_height = RrFontHeight - (theme->menu_title_font, - theme->a_menu_title->texture[0].data.text.shadow_offset); - theme->menu_font_height = RrFontHeight - (theme->menu_font, - theme->a_menu_text_normal->texture[0].data.text.shadow_offset); - - /* calculate some last extents */ + g_free(ps.path); + parse_close(ps.doc); + { gint ft, fb, fl, fr, ut, ub, ul, ur; + RrAppearance *a, *b, *c; + + /* caluclate the font heights*/ + a = theme->a_focused_label; + theme->win_font_height = + RrFontHeight(theme->win_font_focused, + a->texture[0].data.text.shadow_offset_y); + a = theme->a_unfocused_label; + theme->win_font_height = + MAX(theme->win_font_height, + RrFontHeight(theme->win_font_unfocused, + a->texture[0].data.text.shadow_offset_y)); + a = theme->a_menu_title; + theme->menu_title_font_height = + RrFontHeight(theme->menu_title_font, + a->texture[0].data.text.shadow_offset_y); + a = theme->a_menu_text_normal; + b = theme->a_menu_text_selected; + c = theme->a_menu_text_disabled; + theme->menu_font_height = + RrFontHeight(theme->menu_font, + MAX(a->texture[0].data.text.shadow_offset_y, + MAX(b->texture[0].data.text.shadow_offset_y, + c->texture[0].data.text.shadow_offset_y))); RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb); RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub); @@ -973,14 +979,16 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, MAX(MAX(theme->padding * 2, ft + fb), MAX(theme->padding * 2, ut + ub)); */ - theme->title_height = theme->label_height + theme->padding * 2; + theme->title_height = theme->label_height + theme->paddingy * 2; /* this should match the above title_height given the same font size for both. */ theme->menu_title_height = theme->menu_title_font_height + - theme->padding * 2; + theme->paddingy * 2; } theme->button_size = theme->label_height - 2; theme->grip_width = 25; + theme->top_grip_height = MAX(theme->handle_height, + theme->title_height / 4); return theme; } @@ -988,28 +996,34 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, void RrThemeFree(RrTheme *theme) { if (theme) { - g_free(theme->path); - g_free(theme->name); - - RrColorFree(theme->b_color); + RrColorFree(theme->menu_b_color); + RrColorFree(theme->frame_b_color); RrColorFree(theme->cb_unfocused_color); RrColorFree(theme->cb_focused_color); - RrColorFree(theme->title_unfocused_color); RrColorFree(theme->title_focused_color); + RrColorFree(theme->title_unfocused_color); RrColorFree(theme->titlebut_disabled_focused_color); RrColorFree(theme->titlebut_disabled_unfocused_color); RrColorFree(theme->titlebut_hover_focused_color); RrColorFree(theme->titlebut_hover_unfocused_color); RrColorFree(theme->titlebut_toggled_focused_color); RrColorFree(theme->titlebut_toggled_unfocused_color); - RrColorFree(theme->titlebut_unfocused_pressed_color); RrColorFree(theme->titlebut_focused_pressed_color); - RrColorFree(theme->titlebut_unfocused_unpressed_color); + RrColorFree(theme->titlebut_unfocused_pressed_color); RrColorFree(theme->titlebut_focused_unpressed_color); - RrColorFree(theme->menu_color); + RrColorFree(theme->titlebut_unfocused_unpressed_color); RrColorFree(theme->menu_title_color); + RrColorFree(theme->menu_color); RrColorFree(theme->menu_disabled_color); RrColorFree(theme->menu_selected_color); + RrColorFree(theme->title_focused_shadow_color); + RrColorFree(theme->title_unfocused_shadow_color); + RrColorFree(theme->osd_color); + RrColorFree(theme->osd_shadow_color); + RrColorFree(theme->menu_title_shadow_color); + RrColorFree(theme->menu_text_normal_shadow_color); + RrColorFree(theme->menu_text_selected_shadow_color); + RrColorFree(theme->menu_text_disabled_shadow_color); g_free(theme->def_win_icon); @@ -1110,175 +1124,75 @@ void RrThemeFree(RrTheme *theme) RrAppearanceFree(theme->a_menu_bullet_selected); RrAppearanceFree(theme->a_clear); RrAppearanceFree(theme->a_clear_tex); - RrAppearanceFree(theme->app_hilite_bg); - RrAppearanceFree(theme->app_unhilite_bg); - RrAppearanceFree(theme->app_hilite_fg); - RrAppearanceFree(theme->app_unhilite_fg); - RrAppearanceFree(theme->app_hilite_label); - RrAppearanceFree(theme->app_unhilite_label); + RrAppearanceFree(theme->osd_hilite_bg); + RrAppearanceFree(theme->osd_hilite_fg); + RrAppearanceFree(theme->osd_hilite_label); + RrAppearanceFree(theme->osd_unhilite_fg); g_free(theme); } } -static XrmDatabase loaddb(RrTheme *theme, gchar *name) -{ - GSList *it; - XrmDatabase db = NULL; - gchar *s; - - if (name[0] == '/') { - s = g_build_filename(name, "openbox-3", "themerc", NULL); - if ((db = XrmGetFileDatabase(s))) - theme->path = g_path_get_dirname(s); - g_free(s); - } else { - /* XXX backwards compatibility, remove me sometime later */ - s = g_build_filename(g_get_home_dir(), ".themes", name, - "openbox-3", "themerc", NULL); - if ((db = XrmGetFileDatabase(s))) - theme->path = g_path_get_dirname(s); - g_free(s); - - for (it = parse_xdg_data_dir_paths(); !db && it; - it = g_slist_next(it)) - { - s = g_build_filename(it->data, "themes", name, - "openbox-3", "themerc", NULL); - if ((db = XrmGetFileDatabase(s))) - theme->path = g_path_get_dirname(s); - g_free(s); - } - } - - if (db == NULL) { - s = g_build_filename(name, "themerc", NULL); - if ((db = XrmGetFileDatabase(s))) - theme->path = g_path_get_dirname(s); - g_free(s); - } - - return db; -} - -static gchar *create_class_name(gchar *rname) -{ - gchar *rclass = g_strdup(rname); - gchar *p = rclass; - - while (TRUE) { - *p = toupper(*p); - p = strchr(p+1, '.'); - if (p == NULL) break; - ++p; - if (*p == '\0') break; - } - return rclass; -} - -static gboolean read_bool(XrmDatabase db, gchar *rname, gint *value) +static gboolean read_mask(ParseState *ps, gchar *maskname, + RrPixmapMask **value) { gboolean ret = FALSE; - gchar *rclass = create_class_name(rname); - gchar *rettype; - XrmValue retvalue; - - if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && - retvalue.addr != NULL) { - if (!g_ascii_strcasecmp(retvalue.addr, "true")) { - *value = TRUE; - ret = TRUE; - } else if (!g_ascii_strcasecmp(retvalue.addr, "false")) { - *value = FALSE; - ret = TRUE; - } - } - - g_free(rclass); - return ret; -} + gchar *s; + gint hx, hy; /* ignored */ + guint w, h; + guchar *b; -static gboolean read_int(XrmDatabase db, gchar *rname, gint *value) -{ - gboolean ret = FALSE; - gchar *rclass = create_class_name(rname); - gchar *rettype, *end; - XrmValue retvalue; - - if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && - retvalue.addr != NULL) { - *value = (gint)strtol(retvalue.addr, &end, 10); - if (end != retvalue.addr) - ret = TRUE; + s = g_build_filename(ps->path, maskname, NULL); + if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) { + ret = TRUE; + *value = RrPixmapMaskNew(ps->inst, w, h, (gchar*)b); + XFree(b); } + g_free(s); - g_free(rclass); return ret; } -static gboolean read_string(XrmDatabase db, gchar *rname, gchar **value) +static void set_default_appearance(RrAppearance *a) { - gboolean ret = FALSE; - gchar *rclass = create_class_name(rname); - gchar *rettype; - XrmValue retvalue; - - if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && - retvalue.addr != NULL) { - *value = retvalue.addr; - ret = TRUE; - } - - g_free(rclass); - return ret; + a->surface.grad = RR_SURFACE_SOLID; + a->surface.relief = RR_RELIEF_FLAT; + a->surface.bevel = RR_BEVEL_1; + a->surface.interlaced = FALSE; + a->surface.border = FALSE; + a->surface.primary = RrColorNew(a->inst, 0, 0, 0); + a->surface.secondary = RrColorNew(a->inst, 0, 0, 0); } -static gboolean read_color(XrmDatabase db, const RrInstance *inst, - gchar *rname, RrColor **value) +/* Reads the output from gimp's C-Source file format into valid RGBA data for + an RrTextureRGBA. */ +static RrPixel32* read_c_image(gint width, gint height, const guint8 *data) { - gboolean ret = FALSE; - gchar *rclass = create_class_name(rname); - gchar *rettype; - XrmValue retvalue; - - if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && - retvalue.addr != NULL) { - RrColor *c = RrColorParse(inst, retvalue.addr); - if (c != NULL) { - *value = c; - ret = TRUE; - } - } + RrPixel32 *im, *p; + gint i; - g_free(rclass); - return ret; -} + p = im = g_memdup(data, width * height * sizeof(RrPixel32)); -static gboolean read_mask(const RrInstance *inst, - gchar *maskname, RrTheme *theme, - RrPixmapMask **value) -{ - gboolean ret = FALSE; - gchar *s; - gint hx, hy; /* ignored */ - guint w, h; - guchar *b; + for (i = 0; i < width * height; ++i) { + guchar a = ((*p >> 24) & 0xff); + guchar b = ((*p >> 16) & 0xff); + guchar g = ((*p >> 8) & 0xff); + guchar r = ((*p >> 0) & 0xff); - s = g_build_filename(theme->path, maskname, NULL); - if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) { - ret = TRUE; - *value = RrPixmapMaskNew(inst, w, h, (gchar*)b); - XFree(b); + *p = ((r << RrDefaultRedOffset) + + (g << RrDefaultGreenOffset) + + (b << RrDefaultBlueOffset) + + (a << RrDefaultAlphaOffset)); + p++; } - g_free(s); - return ret; + return im; } -static void parse_appearance(gchar *tex, RrSurfaceColorType *grad, - RrReliefType *relief, RrBevelType *bevel, - gboolean *interlaced, gboolean *border, - gboolean allow_trans) +static void parse_style(gchar *tex, RrSurfaceColorType *grad, + RrReliefType *relief, RrBevelType *bevel, + gboolean *interlaced, gboolean *border, + gboolean allow_trans) { gchar *t; @@ -1333,86 +1247,115 @@ static void parse_appearance(gchar *tex, RrSurfaceColorType *grad, } } +static xmlNodePtr find_node(xmlNodePtr n, gchar *names[]) +{ + gint i; + + for (i = 0; names[i] && n; ++i) + n = parse_find_node(names[i], n->children); + return n; +} -static gboolean read_appearance(XrmDatabase db, const RrInstance *inst, - gchar *rname, RrAppearance *value, - gboolean allow_trans) +static gboolean find_int(ParseState *ps, xmlNodePtr n, gchar *names[], + gint *integer, gint lower, gint upper) { - gboolean ret = FALSE; - gchar *rclass = create_class_name(rname); - gchar *cname, *ctoname, *bcname, *icname; - gchar *rettype; - XrmValue retvalue; - - cname = g_strconcat(rname, ".color", NULL); - ctoname = g_strconcat(rname, ".colorTo", NULL); - bcname = g_strconcat(rname, ".border.color", NULL); - icname = g_strconcat(rname, ".interlace.color", NULL); - - if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && - retvalue.addr != NULL) { - parse_appearance(retvalue.addr, - &value->surface.grad, - &value->surface.relief, - &value->surface.bevel, - &value->surface.interlaced, - &value->surface.border, - allow_trans); - if (!read_color(db, inst, cname, &value->surface.primary)) - value->surface.primary = RrColorNew(inst, 0, 0, 0); - if (!read_color(db, inst, ctoname, &value->surface.secondary)) - value->surface.secondary = RrColorNew(inst, 0, 0, 0); - if (value->surface.border) - if (!read_color(db, inst, bcname, - &value->surface.border_color)) - value->surface.border_color = RrColorNew(inst, 0, 0, 0); - if (value->surface.interlaced) - if (!read_color(db, inst, icname, - &value->surface.interlace_color)) - value->surface.interlace_color = RrColorNew(inst, 0, 0, 0); - ret = TRUE; + gint i; + + if ((n = find_node(n, names))) { + i = parse_int(ps->doc, n); + if (i >= lower && i <= upper) { + *integer = i; + return TRUE; + } } + return FALSE; +} - g_free(icname); - g_free(bcname); - g_free(ctoname); - g_free(cname); - g_free(rclass); - return ret; +static gboolean find_string(ParseState *ps, xmlNodePtr n, gchar *names[], + gchar **string) +{ + if ((n = find_node(n, names))) { + *string = parse_string(ps->doc, n); + return TRUE; + } + return FALSE; } -static void set_default_appearance(RrAppearance *a) +static gboolean find_color(ParseState *ps, xmlNodePtr n, gchar *names[], + RrColor **color, gchar *alpha) { - a->surface.grad = RR_SURFACE_SOLID; - a->surface.relief = RR_RELIEF_FLAT; - a->surface.bevel = RR_BEVEL_1; - a->surface.interlaced = FALSE; - a->surface.border = FALSE; - a->surface.primary = RrColorNew(a->inst, 0, 0, 0); - a->surface.secondary = RrColorNew(a->inst, 0, 0, 0); + if ((n = find_node(n, names))) { + int r,g,b,a; + if (parse_attr_int("r", n, &r) && + parse_attr_int("g", n, &g) && + parse_attr_int("b", n, &b) && + parse_attr_int("a", n, &a) && + r >= 0 && g >= 0 && b >= 0 && a >= 0 && + r < 256 && g < 256 && b < 256 && a < 256) + { + *color = RrColorNew(ps->inst, r, g, b); + if (alpha) *alpha = a; + return TRUE; + } + } + return FALSE; } -/* Reads the output from gimp's C-Source file format into valid RGBA data for - an RrTextureRGBA. */ -static RrPixel32* read_c_image(gint width, gint height, const guint8 *data) +static gboolean find_point(ParseState *ps, xmlNodePtr n, gchar *names[], + gint *x, gint *y, + gint lowx, gint upx, gint lowy, gint upy) { - RrPixel32 *im, *p; - gint i; + if ((n = find_node(n, names))) { + gint a, b; + if (parse_attr_int("horizontal", n, &a) && + parse_attr_int("vertical", n, &b) && + a >= lowx && a <= upx && b >= lowy && b <= upy) + { + *x = a; *y = b; + return TRUE; + } + } + return FALSE; +} - p = im = g_memdup(data, width * height * sizeof(RrPixel32)); +static gboolean find_shadow(ParseState *ps, xmlNodePtr n, gchar *names[], + RrAppearance *a) +{ + return find_point(ps, n, names, + &a->texture[0].data.text.shadow_offset_x, + &a->texture[0].data.text.shadow_offset_y, + -20, 20, -20, 20); +} - for (i = 0; i < width * height; ++i) { - guchar a = ((*p >> 24) & 0xff); - guchar b = ((*p >> 16) & 0xff); - guchar g = ((*p >> 8) & 0xff); - guchar r = ((*p >> 0) & 0xff); +static gboolean find_appearance(ParseState *ps, xmlNodePtr n, gchar *names[], + RrAppearance *a, gboolean allow_trans) +{ + xmlNodePtr n2; - *p = ((r << RrDefaultRedOffset) + - (g << RrDefaultGreenOffset) + - (b << RrDefaultBlueOffset) + - (a << RrDefaultAlphaOffset)); - p++; - } + if (!(n = find_node(n, names))) + return FALSE; - return im; + if ((n2 = find_node(n, L("style")))) { + gchar *s = parse_string(ps->doc, n2); + parse_style(s, &a->surface.grad, &a->surface.relief, + &a->surface.bevel, &a->surface.interlaced, + &a->surface.border, allow_trans); + g_free(s); + } else + return FALSE; + + if (!find_color(ps, n, L("primary"), &a->surface.primary, NULL)) + a->surface.primary = RrColorNew(ps->inst, 0, 0, 0); + if (!find_color(ps, n, L("secondary"), &a->surface.secondary, NULL)) + a->surface.secondary = RrColorNew(ps->inst, 0, 0, 0); + if (a->surface.border) + if (!find_color(ps, n, L("border"), + &a->surface.border_color, NULL)) + a->surface.border_color = RrColorNew(ps->inst, 0, 0, 0); + if (a->surface.interlaced) + if (!find_color(ps, n, L("interlace"), + &a->surface.interlace_color, NULL)) + a->surface.interlace_color = RrColorNew(ps->inst, 0, 0, 0); + + return TRUE; } diff --git a/render/theme.h b/render/theme.h index 22bf7e10..4d90dac8 100644 --- a/render/theme.h +++ b/render/theme.h @@ -2,7 +2,7 @@ theme.h for the Openbox window manager Copyright (c) 2006 Mikael Magnusson - Copyright (c) 2003 Ben Jansens + Copyright (c) 2003-2007 Dana Jansens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,28 +27,37 @@ G_BEGIN_DECLS typedef struct _RrTheme RrTheme; struct _RrTheme { - gchar *path; - gchar *name; - const RrInstance *inst; - /* style settings - optional decor */ - gboolean show_handle; + /* style settings - fonts */ + RrFont *win_font_focused; + RrFont *win_font_unfocused; + RrFont *menu_title_font; + RrFont *menu_font; /* style settings - geometry */ - gint padding; + gint paddingx; + gint paddingy; gint handle_height; - gint bwidth; - gint cbwidth; + gint fbwidth; /*!< frame border width */ + gint mbwidth; /*!< menu border width */ + gint cbwidthx; + gint cbwidthy; + gint menu_overlap; + /* these ones are calculated, not set directly by the theme file */ + gint win_font_height; + gint menu_title_font_height; + gint menu_font_height; gint label_height; gint title_height; gint menu_title_height; gint button_size; gint grip_width; - gint menu_overlap; + gint top_grip_height; /* style settings - colors */ - RrColor *b_color; + RrColor *menu_b_color; + RrColor *frame_b_color; RrColor *cb_focused_color; RrColor *cb_unfocused_color; RrColor *title_focused_color; @@ -67,15 +76,21 @@ struct _RrTheme { RrColor *menu_color; RrColor *menu_disabled_color; RrColor *menu_selected_color; - - /* style settings - fonts */ - gint win_font_height; - RrFont *win_font_focused; - RrFont *win_font_unfocused; - gint menu_title_font_height; - RrFont *menu_title_font; - gint menu_font_height; - RrFont *menu_font; + RrColor *title_focused_shadow_color; + gchar title_focused_shadow_alpha; + RrColor *title_unfocused_shadow_color; + gchar title_unfocused_shadow_alpha; + RrColor *osd_color; + RrColor *osd_shadow_color; + gchar osd_shadow_alpha; + RrColor *menu_title_shadow_color; + gchar menu_title_shadow_alpha; + RrColor *menu_text_normal_shadow_color; + gchar menu_text_normal_shadow_alpha; + RrColor *menu_text_selected_shadow_color; + gchar menu_text_selected_shadow_alpha; + RrColor *menu_text_disabled_shadow_color; + gchar menu_text_disabled_shadow_alpha; /* style settings - pics */ RrPixel32 *def_win_icon; /* 48x48 RGBA */ @@ -178,12 +193,10 @@ struct _RrTheme { RrAppearance *a_clear; /* clear with no texture */ RrAppearance *a_clear_tex; /* clear with a texture */ - RrAppearance *app_hilite_bg; - RrAppearance *app_unhilite_bg; - RrAppearance *app_hilite_fg; /* never parent relative */ - RrAppearance *app_unhilite_fg; /* never parent relative */ - RrAppearance *app_hilite_label; /* can be parent relative */ - RrAppearance *app_unhilite_label; /* can be parent relative */ + RrAppearance *osd_hilite_bg; /* can never be parent relative */ + RrAppearance *osd_hilite_fg; /* can never be parent relative */ + RrAppearance *osd_hilite_label; /* can be parent relative */ + RrAppearance *osd_unhilite_fg; /* can never be parent relative */ }; diff --git a/themes/Mikachu/openbox-3/themerc b/themes/Mikachu/openbox-3/themerc deleted file mode 100644 index b4e75479..00000000 --- a/themes/Mikachu/openbox-3/themerc +++ /dev/null @@ -1,159 +0,0 @@ -!! Menu settings - -menu.title.bg: raised gradient crossdiagonal bevel1 -menu.title.bg.color: #6699CC -menu.title.bg.colorTo: #334866 -menu.title.bg.border.color: #000000 -menu.title.text.color: #CCCCFF -menu.title.text.justify: center - -menu.items.bg: flat gradient horizontal bevel1 -menu.items.bg.color: #AAAACC -menu.items.bg.colorTo: #AAAAD0 -menu.items.bg.border.color: #000000 -menu.items.text.color: #000022 -menu.items.disabled.text.color: #711 - -menu.items.active.bg: raised gradient horizontal bevel1 -menu.items.active.bg.color: #555577 -menu.items.active.bg.colorTo: #6699CC -menu.items.active.bg.border.color: #000000 -menu.items.active.text.color: #CCCCFF - -menu.frame.justify: left - -!! General window settings -window.label.text.justify: left - -!! focused window settings -window.active.client.color: #8080A0 - -window.active.title.bg: raised gradient crossdiagonal bevel1 -window.active.title.bg.color: #6699CC -window.active.title.bg.colorTo: #334866 -window.active.title.bg.border.color: #000000 - -window.active.handle.bg: flat gradient crossdiagonal bevel1 -window.active.handle.bg.color: #6699CC -window.active.handle.bg.colorTo: #334866 -window.active.handle.bg.border.color: #000000 - -window.active.grip.bg: parentrelative -window.active.grip.bg.color: #000000 -window.active.grip.bg.colorTo: #000000 -window.active.grip.bg.border.color: #000000 - -window.active.label.bg: parentrelative -window.active.label.bg.color: #000000 -window.active.label.bg.colorTo: #000000 -window.active.label.bg.border.color: #000000 -window.active.label.text.color: #BFE9FF - -window.active.button.unpressed.bg: parentrelative -window.active.button.unpressed.bg.color: #000000 -window.active.button.unpressed.bg.colorTo: #000000 -window.active.button.unpressed.bg.border.color: #000000 -window.active.button.unpressed.image.color: grey85 - -window.active.button.pressed.bg: sunken gradient crossdiagonal bevel1 -window.active.button.pressed.bg.color: #6699CC -window.active.button.pressed.bg.colorTo: #334866 -window.active.button.pressed.bg.border.color: #000000 -window.active.button.pressed.image.color: green - -window.active.button.toggled.bg: sunken gradient crossdiagonal bevel1 -window.active.button.toggled.bg.color: #6699CC -window.active.button.toggled.bg.colorTo: #334866 -window.active.button.toggled.bg.border.color: #000000 -window.active.button.toggled.image.color: grey85 - -window.active.button.disabled.bg: parentrelative -window.active.button.disabled.bg.color: #000000 -window.active.button.disabled.bg.colorTo: #000000 -window.active.button.disabled.image.color: #000000 -window.active.button.disabled.bg.border.color: #000000 - -window.active.button.hover.bg: parentrelative -window.active.button.hover.image.color: #00FF00 -window.active.button.hover.bg.color: #000000 -window.active.button.hover.bg.colorTo: #000000 -window.active.button.hover.bg.border.color: #000000 - -!window.active.button.hover.bg: raised gradient crossdiagonal bevel1 -!window.active.button.hover.image.color: #00FF00 -!window.active.button.hover.bg.color: #334866 -!window.active.button.hover.bg.colorTo: #6699CC -!window.active.button.hover.bg.border.color: #000000 - -!! unfocused window settings -window.inactive.client.color: grey50 - -window.inactive.title.bg: flat gradient diagonal bevel1 -window.inactive.title.bg.color: #7F7F88 -window.inactive.title.bg.colorTo: #33333B -window.inactive.title.bg.border.color: #000000 - -window.inactive.handle.bg: flat gradient diagonal bevel1 -window.inactive.handle.bg.color: grey50 -window.inactive.handle.bg.colorTo: grey20 -window.inactive.handle.bg.border.color: #000000 - -window.inactive.grip.bg: parentrelative -window.inactive.grip.bg.color: #000000 -window.inactive.grip.bg.colorTo: #000000 -window.inactive.grip.bg.border.color: #000000 - -window.inactive.label.bg: parentrelative -window.inactive.label.bg.color: #000000 -window.inactive.label.bg.colorTo: #000000 -window.inactive.label.bg.border.color: #000000 -window.inactive.label.text.color: grey70 - -window.inactive.button.unpressed.bg: parentrelative -window.inactive.button.unpressed.bg.color: #000000 -window.inactive.button.unpressed.bg.colorTo: #000000 -window.inactive.button.unpressed.bg.border.color: #000000 -window.inactive.button.unpressed.image.color: grey60 - -window.inactive.button.pressed.bg: sunken gradient crossdiagonal bevel1 -window.inactive.button.pressed.bg.color: grey60 -window.inactive.button.pressed.bg.colorTo: grey20 -window.inactive.button.pressed.bg.border.color: #000000 -window.inactive.button.pressed.image.color: #00CC00 - -window.inactive.button.disabled.bg: parentrelative -window.inactive.button.disabled.bg.color: #000000 -window.inactive.button.disabled.bg.colorTo: #000000 -window.inactive.button.disabled.bg.border.color: #000000 -window.inactive.button.disabled.image.color: #000000 - -window.inactive.button.toggled.bg: sunken gradient crossdiagonal bevel1 -window.inactive.button.toggled.bg.color: grey60 -window.inactive.button.toggled.bg.colorTo: grey20 -window.inactive.button.toggled.bg.border.color: #000000 -window.inactive.button.toggled.image.color: grey60 - -window.inactive.button.hover.bg: parentrelative -window.inactive.button.hover.bg.color: #000000 -window.inactive.button.hover.bg.colorTo: #000000 -window.inactive.button.hover.image.color: #00CC00 -window.inactive.button.hover.bg.border.color: #000000 - -!! Global width settings -border.width: 1 -padding.width: 1 -window.handle.width: 0 -window.client.padding.width: 0 -focus.inner.color: #A6CAF3 -focus.outer.color: #0000A0 - -!! Miscellaneous settings -border.color: #223344 - -!! Font stuff -window.active.label.text.font: Candara,sans:pixelsize=14:shadow=n:weight=0 -window.inactive.label.text.font: Candara,sans:pixelsize=14:shadowoffset=3:shadowtint=32:shadow=y:weight=0 -menu.title.text.font: Technical,sans:pixelsize=26:shadowoffset=2:shadowtint=35:shadow=y -menu.items.font: Technical,sans:pixelsize=14:shadowoffset=2:shadowtint=15:shadow=y - -!menu.overlap: 3 diff --git a/themes/Mikachu/openbox-3/themerc.xml b/themes/Mikachu/openbox-3/themerc.xml new file mode 100644 index 00000000..6ea59cb2 --- /dev/null +++ b/themes/Mikachu/openbox-3/themerc.xml @@ -0,0 +1,194 @@ + + + + 0 + + + + + 1 + + + + left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + center + + <text> + <primary r="204" g="204" b="255" a="255"/> + <shadow> + <offset x="2" y="2"/> + <primary r="0" g="0" b="0" a="35"/> + </shadow> + </text> + <style>raised gradient crossdiagonal bevel1</style> + <primary r="102" g="153" b="204" a="255"/> + <secondary r="51" g="72" b="102" a="255"/> + <border r="0" g="0" b="0" a="255"/> + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/themes/Natura/openbox-3/themerc b/themes/Natura/openbox-3/themerc deleted file mode 100644 index 10b30f17..00000000 --- a/themes/Natura/openbox-3/themerc +++ /dev/null @@ -1,96 +0,0 @@ -!! Natura by quandar (http://deletefactory.net/quandar) - -!! Global Width -window.handle.width: 2 - -window.client.padding.width: 0 -border.Width: 1 -padding.width: 2 - -border.color: #000000 -menu.overlap: 0 -window.frameColor: #eeeeee -window.*.client.color: #eeeeee -*.text.justify: left - -!! Menu -menu.title.bg: flat gradient splitvertical -menu.title.bg.color: #5c4e45 -menu.title.bg.colorTo: #51443e -menu.title.text.color: #ffffff - -menu.items.bg: flat solid -menu.items.bg.color: #f9f2ee - -menu.items.text.color: #000000 -menu.items.disabled.text.color: #737573 - -menu.items.active.bg: flat gradient splitvertical -menu.items.active.bg.color: #5c4e45 -menu.items.active.bg.colorTo:#51443e -menu.items.active.text.color: #f9f2ee - -!! Active Windows -window.active.title.bg: flat gradient splitvertical -window.active.title.bg.color: #5c4e45 -window.active.title.bg.colorTo: #51443e -window.active.*.bg.border.color: #000000 - -window.active.label.bg: parentrelative -window.active.label.text.color: #f9f2ee - -window.active.button.*.bg: parentrelative -window.active.button.*.image.color: #f9f2ee -window.active.button.*.bg.border.color: #4e5860 - -window.active.button.hover.bg.color: #576773 -window.active.button.hover.bg.border.color: #9aabb9 -window.active.button.pressed.bg.color: #343b40 -window.active.button.pressed.bg.colorTo: #000000 -window.active.button.pressed.image.color: #b6b6b6 -window.active.button.pressed.bg.border.color: #95a5b2 - -window.active.button.disabled.bg: parentrelative -window.active.button.disabled.image.color: #ffffff - -window.active.handle.bg: flat solid -window.active.handle.bg.color:#51443e - -window.*.grip.bg: flat solid -window.*.grip.bg.color: #51443e - -window.handle.width: 2 - -!! Inactive Windows -window.inactive.title.bg: flat gradient vertical -window.inactive.title.bg.color: #f0ece3 -window.inactive.title.bg.colorTo: #f8f7f2 -window.inactive.*.border.color: #bfbfbf - -window.inactive.label.bg: parentrelative -window.inactive.label.text.color: #919191 - -window.inactive.button.*.bg: parentrelative -window.inactive.button.*.bg.color: #eeeeee -window.inactive.button.*.image.color: #b6b6b6 -window.inactive.button.*.bg.border.color: #c9c9c9 - -window.inactive.button.pressed.bg.color: #c5c2c5 -window.inactive.button.pressed.bg.border.color: #7b7d7b -window.inactive.button.pressed.image.color: #999999 - -window.inactive.button.hover.bg.color: #afb1b2 -window.inactive.button.hover.bg.border.color: #d9dfe4 -window.inactive.button.hover.image.color: #ffffff -window.inactive.button.disabled.bg: parentrelative -window.inactive.button.disabled.image.color: #ffffff - -window.inactive.handle.bg: flat solid -window.inactive.handle.bg.color: #f9f7f3 -window.inactive.grip.bg: parentrelative - -!! Fonts -window.active.label.text.font: sans:pixelsize=12:bold:shadow=y:shadowoffset=1:shadowtint=75 -window.inactive.label.text.font: sans:pixelsize=12:bold:shadow=y:shadowoffset=1:shadowtint=0 -menu.items.font: sans:pixelsize=12 -menu.title.text.font: sans:pixelsize=12:bold:shadow=y:shadowoffset=1:shadowtint=75 diff --git a/themes/Natura/openbox-3/themerc.xml b/themes/Natura/openbox-3/themerc.xml new file mode 100644 index 00000000..b94e2819 --- /dev/null +++ b/themes/Natura/openbox-3/themerc.xml @@ -0,0 +1,177 @@ + + + + + + 2 + + + + + 1 + + + + left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + left + 0 + + <text> + <primary r="255" g="255" b="255" a="255"/> + <shadow> + <offset x="1" y="1"/> + <primary r="0" g="0" b="0" a="75"/> + </shadow> + </text> + <style>flat gradient splitvertical</style> + <primary r="92" g="78" b="69" a="255"/> + <secondary r="81" g="68" b="62" a="255"/> + + + + + + + + + + + + + + + + + + + + + diff --git a/themes/artwiz-boxed/openbox-3/themerc b/themes/artwiz-boxed/openbox-3/themerc deleted file mode 100644 index e10ad8c0..00000000 --- a/themes/artwiz-boxed/openbox-3/themerc +++ /dev/null @@ -1,102 +0,0 @@ -menu.title.bg: raised gradient diagonal -menu.title.bg.color: rgb:90/94/98 -menu.title.bg.colorTo: rgb:20/24/28 -menu.title.text.color: white -menu.title.text.justify: center - -menu.items.bg: sunken gradient diagonal -menu.items.bg.color: rgb:10/20/30 -menu.items.bg.colorTo: rgb:70/80/90 -menu.items.text.color: rgb:90/a0/b0 -menu.items.justify: center - -menu.items.active.bg: raised gradient diagonal -menu.items.active.bg.color: rgb:90/94/98 -menu.items.active.bg.colorTo: rgb:20/24/28 -menu.items.active.text.color: white -menu.bullet.image.color: rgb:90/a0/b0 -menu.bullet.selected.image.color: #ffffff - -window.active.title.bg: raised gradient vertical -window.active.title.bg.color: rgb:80/84/88 -window.active.title.bg.colorTo: rgb:30/34/38 -window.inactive.title.bg: raised vertical gradient -window.inactive.title.bg.color: rgb:50/54/58 -window.inactive.title.bg.colorTo: black - -window.active.label.bg: sunken diagonal gradient -window.active.label.bg.color: rgb:10/20/30 -window.active.label.bg.colorTo: rgb:70/80/90 -window.active.label.text.color: white -window.inactive.label.bg: sunken gradient diagonal -window.inactive.label.bg.color: black -window.inactive.label.bg.colorTo: rgb:40/50/60 -window.inactive.label.text.color: rgb:60/64/68 -window.label.text.justify: center - -window.active.button.unpressed.bg: raised gradient diagonal -window.active.button.unpressed.bg.color: rgb:90/94/98 -window.active.button.unpressed.bg.colorTo: rgb:20/24/28 -window.active.button.unpressed.image.color: white - -window.inactive.button.unpressed.bg: raised gradient diagonal -window.inactive.button.unpressed.bg.color: rgb:50/54/58 -window.inactive.button.unpressed.bg.colorTo: black -window.inactive.button.unpressed.image.color: rgb:70/74/78 - -window.active.button.pressed.bg: sunken gradient diagonal -window.active.button.pressed.bg.color: rgb:20/40/50 -window.active.button.pressed.bg.colorTo: rgb:60/70/80 - -window.inactive.button.pressed.bg: sunken gradient diagonal -window.inactive.button.pressed.bg.color: rgb:50/54/58 -window.inactive.button.pressed.bg.colorTo: black -window.inactive.button.pressed.image.color: rgb:70/74/78 - -window.active.client.color: rgb:40/44/48 -window.inactive.client.color: rgb:20/24/28 - -window.active.handle.bg: raised gradient diagonal -window.active.handle.bg.color: rgb:70/74/78 -window.active.handle.bg.colorTo: rgb:40/44/48 - -window.inactive.handle.bg: raised gradient diagonal -window.inactive.handle.bg.color: rgb:50/54/58 -window.inactive.handle.bg.colorTo: black - -window.active.grip.bg: sunken diagonal gradient -window.active.grip.bg.color: rgb:20/30/40 -window.active.grip.bg.colorTo: rgb:60/70/80 - -window.inactive.grip.bg: sunken diagonal gradient -window.inactive.grip.bg.color: black -window.inactive.grip.bg.colorTo: rgb:30/40/50 - -window.active.button.toggled.bg: raised gradient diagonal -window.active.button.toggled.bg.color: rgb:90/94/98 -window.active.button.toggled.bg.colorTo: rgb:20/24/28 -window.active.button.toggled.image.color: white - -window.inactive.button.toggled.bg: raised gradient diagonal -window.inactive.button.toggled.bg.color: rgb:50/54/58 -window.inactive.button.toggled.bg.colorTo: black -window.inactive.button.toggled.image.color: rgb:70/74/78 - -window.active.button.disabled.bg: raised gradient diagonal -window.active.button.disabled.bg.color: rgb:90/94/98 -window.active.button.disabled.bg.colorTo: rgb:20/24/28 -window.active.button.disabled.image.color: grey - -window.inactive.button.disabled.bg: raised gradient diagonal -window.inactive.button.disabled.bg.color: rgb:50/54/58 -window.inactive.button.disabled.bg.colorTo: black -window.inactive.button.disabled.image.color: rgb:70/74/78 - -border.color: black -padding.width: 1 -borderWidth: 1 -window.handle.width: 4 - -window.active.label.text.font: sans:pixelsize=10 -menu.title.text.font: sans:pixelsize=10 -menu.items.font: sans:pixelsize=10 diff --git a/themes/artwiz-boxed/openbox-3/themerc.xml b/themes/artwiz-boxed/openbox-3/themerc.xml new file mode 100644 index 00000000..73cf82c4 --- /dev/null +++ b/themes/artwiz-boxed/openbox-3/themerc.xml @@ -0,0 +1,148 @@ + + + + 4 + + + + + 1 + + + center + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + center + + <text> + <primary r="255" g="255" b="255" a="255"/> + </text> + <style>raised gradient diagonal</style> + <primary r="144" g="148" b="152" a="255"/> + <secondary r="32" g="36" b="40" a="255"/> + + + + + + + + + + + + + + + + + + + diff --git a/themes/bear2/openbox-3/themerc b/themes/bear2/openbox-3/themerc deleted file mode 100644 index b4c51d03..00000000 --- a/themes/bear2/openbox-3/themerc +++ /dev/null @@ -1,78 +0,0 @@ -!!General - -window.handle.width: 4 -window.client.padding.width: 0 -border.Width: 1 -padding.width: 3 -menu.overlap: 2 -border.color: #4e4e4e -window.frameColor: #eeeeec -window.*.client.color: #eeeeec -*.text.justify: center - -!!Fonts - -window.active.label.text.font: sans:pixelsize=12:shadow=y:shadowoffset=1:shadowtint=3:bold -window.inactive.label.text.font: sans:pixelsize=12:shadow=y:shadowoffset=1:shadowtint=0:bold -menu.items.font: sans:pixelsize=12 -menu.title.text.font: sans:pixelsize=12:shadow=y:shadowoffset=1:shadowtint=30:bold - -!!Menu -menu.border.color: #9d9d9d -menu.title.bg: flat border vertical gradient -menu.title.bg.color: #3465A4 -menu.title.bg.colorTo: #407CCA -menu.title.bg.border.color: #729fcf -menu.title.text.color: #ffffff - -menu.items.bg: flat border solid -menu.items.bg.color: #eeeeec -menu.items.bg.border.color: #EFEBE7 - -menu.items.text.color: #444444 -menu.items.disabled.text.color: #babdb6 - -menu.items.active.bg: flat solid -menu.items.active.bg.color: #4481c0 -menu.items.active.bg.colorTo: #4175aa -menu.items.active.text.color: #f6f8fb -menu.items.active.bg.border.color: #416c98 - -!!Active - -window.active.title.bg: flat border gradient mirrorhorizontal -window.active.title.bg.color: #3465A4 -window.active.title.bg.colorTo: #407CCA -window.active.title.bg.border.color: #699acd - -window.active.label.bg: parentrelative -window.active.label.text.color: #ffffff - -window.active.button.*.bg: parentrelative -window.active.button.*.image.color: #efefef -window.active.button.hover.bg.color: #729fcf -window.active.button.hover.image.color: #ffffff -window.active.button.pressed.bg.color: #a7cef2 -window.active.button.disabled.image.color: #dddddd - -window.active.handle.bg: raised solid -window.active.handle.bg.color: #E7e7e7 -window.*.grip.bg: parentrelative - -!!Inactive - -window.inactive.title.bg: flat border gradient mirrorhorizontal -window.inactive.title.bg.color: #dcdcdc -window.inactive.title.bg.colorTo: #eeeeec -window.inactive.title.bg.border.color: #efefef -window.inactive.label.bg: parentrelative -window.inactive.label.text.color: #888a85 - -window.inactive.button.*.bg: parentrelative -window.inactive.button.*.image.color: #888a85 -window.inactive.button.pressed.bg.color: #d3d7cf -window.inactive.button.pressed.bg.color: #4f5051 -window.inactive.button.disabled.image.color: #ffffff - -window.inactive.handle.bg: raised solid -window.inactive.handle.bg.color: #E7e7e7 diff --git a/themes/bear2/openbox-3/themerc.xml b/themes/bear2/openbox-3/themerc.xml new file mode 100644 index 00000000..e1e17223 --- /dev/null +++ b/themes/bear2/openbox-3/themerc.xml @@ -0,0 +1,155 @@ + + + + 4 + + + + + 1 + + + + center + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + center + 2 + + <text> + <primary r="255" g="255" b="255" a="255"/> + <shadow> + <offset x="1" y="1"/> + <primary r="0" g="0" b="0" a="30"/> + </shadow> + </text> + <style>flat border vertical gradient</style> + <primary r="52" g="101" b="164" a="255"/> + <secondary r="64" g="124" b="202" a="255"/> + <border r="114" g="159" b="207" a="255"/> + + + + + + + + + + + + + + + + + + + + + + + diff --git a/themes/orang/openbox-3/themerc b/themes/orang/openbox-3/themerc deleted file mode 100644 index 0cebbab9..00000000 --- a/themes/orang/openbox-3/themerc +++ /dev/null @@ -1,100 +0,0 @@ -!! i be a mess - -menu.title.bg: flat solid border -menu.title.bg.color: #ce5c00 -menu.title.bg.border.color: #fcaf3e -menu.title.text.color: #ffffff - -menu.items.bg: flat solid -#menu.items.bg.color: #ffffff -menu.items.bg.color: #d3d7cf -menu.items.text.color: #000000 -menu.items.disabled.text.color: #737573 - -menu.items.active.bg: flat solid -menu.items.active.bg.color: #ce5c00 -menu.items.active.text.color: #ffffff - -!! General window settings -*.justify: left - -!! focused window settings -window.active.client.color: #f7f7f7 - -window.active.title.bg: flat border solid -window.active.title.bg.color: #ce5c00 -window.active.title.bg.border.color: #fcaf3e - -window.active.handle.bg: flat solid border -window.active.handle.bg.color: #d3d7cf -window.active.handle.bg.border.color: #eeeeec -!window.active.handle.bg.color: #969494 -window.active.grip.bg: parentrelative - -window.active.label.bg: parentrelative -window.active.label.text.color: #ffffff - -window.active.button.*.bg: parentrelative -window.active.button.*.image.color: #ffffff - -window.active.button.pressed.bg: flat solid bevel1 -!window.active.button.pressed.bg.color: #888888 -window.active.button.pressed.bg.color: #f57900 -window.active.button.pressed.image.color: #d3d7cf - -!#hover -window.active.button.hover.bg: flat solid -window.active.button.hover.image.color: #ffffff -window.active.button.hover.bg.color: #fcaf3e - -window.active.button.disabled.bg: flat solid -window.active.button.disabled.bg.color: #dfb454 -window.active.button.disabled.image.color: #ffffff - - -!! unfocused window settings -window.inactive.client.color: #f7f7f7 - -window.inactive.title.bg: flat solid border -window.inactive.title.bg.color: #d3d7cf -window.inactive.title.bg.border.color: #dfe3db - -window.inactive.handle.bg: flat solid -window.inactive.handle.bg.color: #d3d7cf - -window.inactive.grip.bg: parentrelative - -window.inactive.label.bg: parentrelative -window.inactive.label.text.color: #888a85 - -window.inactive.button.*.bg: parentrelative -window.inactive.button.unpressed.image.color: #555555 - -window.inactive.button.pressed.bg: flat border solid -window.inactive.button.pressed.bg.color: #aaaaaa -window.inactive.button.pressed.bg.border.color: #e5e5e5 - -window.inactive.button.hover.bg: flat solid -window.inactive.button.hover.bg.color: #e3e3e3 - -window.inactive.button.disabled.bg:flat solid -window.inactive.button.disabled.bg.color: #e3e3e3 - - -!! Global width settings -border.Width: 1 -padding.width: 1 -window.handle.width: 3 -window.client.padding.width: 0 -menu.overlap: 2 - -!! Miscellaneous settings -border.color: #000000 - -!! font me! -window.active.label.text.font: sans:pixelsize=10:bold -window.inactive.label.text.font: sans:pixelsize=10:bold - -menu.title.text.font: sans:pixelsize=10:bold -menu.items.font: sans:pixelsize=9 - diff --git a/themes/orang/openbox-3/themerc.xml b/themes/orang/openbox-3/themerc.xml new file mode 100644 index 00000000..d5333675 --- /dev/null +++ b/themes/orang/openbox-3/themerc.xml @@ -0,0 +1,140 @@ + + + + + + 3 + + + + + 1 + + + + left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + left + 2 + + <text> + <primary r="255" g="255" b="255" a="255"/> + </text> + <style>flat solid border</style> + <primary r="206" g="92" b="0" a="255"/> + <border r="252" g="175" b="62" a="255"/> + + + + + + + + + + + + + + + + + + + + diff --git a/themes/syscrash/openbox-3/themerc b/themes/syscrash/openbox-3/themerc deleted file mode 100644 index b1faa671..00000000 --- a/themes/syscrash/openbox-3/themerc +++ /dev/null @@ -1,107 +0,0 @@ -!! syscrash's theme, based off nightm4re's flax or something - -!!--------------------------------------------------------------------------- -!! Dimensions - -border.width: 1 -border.color: #22221c - -padding.width: 2 -window.handle.width: 3 -window.client.padding.width: 0 - -menu.overlap: 0 - -!!--------------------------------------------------------------------------- -!! Fonts - -*.font: sans:pixelsize=11 -window.label.text.justify: left - -menu.title.text.justify: left - - -!!--------------------------------------------------------------------------- -!! Menu Settings - -menu.title.bg: flat gradient vertical -menu.title.bg.color: #4c4c4c -menu.title.bg.colorTo: #707070 -menu.title.text.color: white - -menu.items.bg: flat solid -menu.items.bg.color: #e6e6e0 -menu.items.text.color: #22221c - -menu.items.active.bg: flat solid -menu.items.active.bg.color: #4c4c4c -menu.items.active.text.color: #ffffff - -menu.items.disabled.text.color: #444438 - -!!--------------------------------------------------------------------------- -!! Window Settings - -window.active.padding.width: 10 -window.active.title.bg: flat solid -window.active.title.bg.color: #9b9b9b - -window.active.label.bg: flat gradient vertical border -window.active.label.bg.color: #4c4c4c -window.active.label.bg.colorTo: #707070 -window.active.label.text.color: white - -window.active.handle.bg: flat solid -window.active.handle.bg.color: #9b9b9b - -window.active.grip.bg: flat solid -window.active.grip.bg.color: #4c4c4c -window.active.grip.bg.colorTo: #707070 -window.inactive.title.bg: flat solid -window.inactive.title.bg.color: #9b9b9b - -window.inactive.label.bg: parentrelative -window.inactive.label.text.color: #4c4c4c - -window.inactive.handle.bg: flat solid -window.inactive.handle.bg.color: #e6e6e0 - -window.inactive.grip.bg: flat solid -window.inactive.grip.bg.color: #e6e6e0 - -!!--------------------------------------------------------------------------- -!! Button Settings - -window.active.button.unpressed.bg: flat gradient vertical border -window.active.button.unpressed.bg.color: #515151 -window.active.button.unpressed.bg.colorTo: #676767 -window.active.button.unpressed.image.color: white - -window.active.button.pressed.bg: flat gradient crossdiagonal border -window.active.button.pressed.bg.color: #d3deda -window.active.button.pressed.bg.colorTo: #9fbfc1 - -window.active.button.hover.bg: flat solid border -window.active.button.hover.bg.color: #e6e6e0 - -window.active.button.disabled.bg: parentrelative -window.active.button.disabled.image.color: #9fbfc1 - -!! without this it looks right -!!window.active.button.toggled.bg: flat solid -!!window.active.button.toggled.bg.color: #9fbfc1 - -window.inactive.button.unpressed.bg: parentrelative -window.inactive.button.unpressed.image.color: #4c4c4c - -window.inactive.button.hover.bg: flat solid border -window.inactive.button.hover.bg.color: #e6e6e0 -window.inactive.button.pressed.bg: flat gradient crossdiagonal border -window.inactive.button.pressed.bg.color: #d3deda -window.inactive.button.pressed.bg.colorTo: #9fbfc1 - -window.inactive.button.disabled.bg: flat solid -window.inactive.button.disabled.bg.image.color: #444438 - -!! window.inactive.button.toggled.bg: flat solid -!! window.inactive.button.toggled.bg.color: #444438 diff --git a/themes/syscrash/openbox-3/themerc.xml b/themes/syscrash/openbox-3/themerc.xml new file mode 100644 index 00000000..5048cf06 --- /dev/null +++ b/themes/syscrash/openbox-3/themerc.xml @@ -0,0 +1,131 @@ + + + + + + 3 + + + + + 1 + + + + left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + left + 0 + + <text> + <primary r="255" g="255" b="255" a="255"/> + </text> + <style>flat gradient vertical</style> + <primary r="76" g="76" b="76" a="255"/> + <secondary r="112" g="112" b="112" a="255"/> + + + + + + + + + + + + + + + + + + + + diff --git a/tools/themetoxml/themetoxml.c b/tools/themetoxml/themetoxml.c index fa98a158..56a5f9c7 100644 --- a/tools/themetoxml/themetoxml.c +++ b/tools/themetoxml/themetoxml.c @@ -99,8 +99,8 @@ static gboolean read_string(XrmDatabase db, gchar *rname, gchar **value) static gchar hextodec(gchar h) { if (h >= '0' && h <= '9') return h - '0'; - else if (h >= 'a' && h <= 'f') return h - 'a' + 9; - else if (h >= 'A' && h <= 'F') return h - 'A' + 9; + else if (h >= 'a' && h <= 'f') return h - 'a' + 10; + else if (h >= 'A' && h <= 'F') return h - 'A' + 10; return -1; } @@ -109,9 +109,33 @@ static gboolean parse_color(gchar *c, gint *r, gint *g, gint *b) int dig1, dig2, i, color[3]; int len = strlen(c); - if (c[0] == '#' && (len != 4 && len != 7)) return FALSE; + if (len > 4 && c[0] == 'r' && c[1] == 'g' && c[2] == 'b' && c[3] == ':') { + c += 4; + for (i = 0; i < 3; ++i) { + dig1 = hextodec(c[0]); + if (c[1] == '/') { dig2 = dig1; c+=2; } + else { dig2 = hextodec(c[1]); c+=3; } - if (c[0] != '#') { + if (dig1 < 0 || dig2 < 0) return FALSE; + + color[i] = dig1*16 + dig2; + } + *r = color[0]; *g = color[1]; *b = color[2]; + return TRUE; + } else if ((len == 4 || len == 7) && c[0] == '#') { + c++; + for (i = 0; i < 3; ++i) { + dig1 = hextodec(c[0]); + if (len == 4) { dig2 = dig1; c++; } + else { dig2 = hextodec(c[1]); c+=2; } + + if (dig1 < 0 || dig2 < 0) return FALSE; + + color[i] = dig1*16 + dig2; + } + *r = color[0]; *g = color[1]; *b = color[2]; + return TRUE; + } else { int i; for (i = 0; colornames[i].name != NULL; ++i) { @@ -122,21 +146,8 @@ static gboolean parse_color(gchar *c, gint *r, gint *g, gint *b) return TRUE; } } - return FALSE; - } - - c++; - for (i = 0; i < 3; ++i, c += (len == 4 ? 1 : 2)) { - dig2 = hextodec(c[1]); - if (len == 4) dig1 = dig2; - else dig1 = hextodec(c[0]); - - if (dig1 < 0 || dig2 < 0) return FALSE; - - color[i] = dig1*16 + dig2; } - *r = color[0]; *g = color[1]; *b = color[2]; - return TRUE; + return FALSE; } static gboolean read_color(XrmDatabase db, gchar *rname, @@ -197,48 +208,35 @@ static xmlNodePtr root; #define ATTR6(a,b,c,d,e,f,name,cont) (xmlSetProp(GO6(a,b,c,d,e,f), (const xmlChar*)name, (const xmlChar*)cont)) #define ATTR7(a,b,c,d,e,f,g,name,cont) (xmlSetProp(GO7(a,b,c,d,e,f,g), (const xmlChar*)name, (const xmlChar*)cont)) -#define APPCONT1(a,cont) (CONT2("appearance",a,cont)) -#define APPCONT2(a,b,cont) (CONT3("appearance",a,b,cont)) -#define APPCONT3(a,b,c,cont) (CONT4("appearance",a,b,c,cont)) -#define APPCONT4(a,b,c,d,cont) (CONT5("appearance",a,b,c,d,cont)) -#define APPCONT5(a,b,c,d,e,cont) (CONT6("appearance",a,b,c,d,e,cont)) - -#define APPATTR1(a,name,cont) (ATTR2("appearance",a,name,cont)) -#define APPATTR2(a,b,name,cont) (ATTR3("appearance",a,b,name,cont)) -#define APPATTR3(a,b,c,name,cont) (ATTR4("appearance",a,b,c,name,cont)) -#define APPATTR4(a,b,c,d,name,cont) (ATTR5("appearance",a,b,c,d,name,cont)) -#define APPATTR5(a,b,c,d,e,name,cont) (ATTR6("appearance",a,b,c,d,e,name,cont)) -#define APPATTR6(a,b,c,d,e,f,name,cont) (ATTR7("appearance",a,b,c,d,e,f,name,cont)) - -#define COLOR1(a,R,G,B,A) (APPATTR1(a,"r",NUM(R)), \ - APPATTR1(a,"g",NUM(G)), \ - APPATTR1(a,"b",NUM(B)), \ - APPATTR1(a,"a",NUM(A))) -#define COLOR2(a,b,R,G,B,A) (APPATTR2(a,b,"r",NUM(R)), \ - APPATTR2(a,b,"g",NUM(G)), \ - APPATTR2(a,b,"b",NUM(B)), \ - APPATTR2(a,b,"a",NUM(A))) -#define COLOR3(a,b,c,R,G,B,A) (APPATTR3(a,b,c,"r",NUM(R)), \ - APPATTR3(a,b,c,"g",NUM(G)), \ - APPATTR3(a,b,c,"b",NUM(B)), \ - APPATTR3(a,b,c,"a",NUM(A))) -#define COLOR4(a,b,c,d,R,G,B,A) (APPATTR4(a,b,c,d,"r",NUM(R)), \ - APPATTR4(a,b,c,d,"g",NUM(G)), \ - APPATTR4(a,b,c,d,"b",NUM(B)), \ - APPATTR4(a,b,c,d,"a",NUM(A))) -#define COLOR5(a,b,c,d,e,R,G,B,A) (APPATTR5(a,b,c,d,e,"r",NUM(R)), \ - APPATTR5(a,b,c,d,e,"g",NUM(G)), \ - APPATTR5(a,b,c,d,e,"b",NUM(B)), \ - APPATTR5(a,b,c,d,e,"a",NUM(A))) -#define COLOR6(a,b,c,d,e,f,R,G,B,A) (APPATTR6(a,b,c,d,e,f,"r",NUM(R)), \ - APPATTR6(a,b,c,d,e,f,"g",NUM(G)), \ - APPATTR6(a,b,c,d,e,f,"b",NUM(B)), \ - APPATTR6(a,b,c,d,e,f,"a",NUM(A))) +#define COLOR1(a,R,G,B,A) (ATTR1(a,"r",NUM(R)), \ + ATTR1(a,"g",NUM(G)), \ + ATTR1(a,"b",NUM(B)), \ + ATTR1(a,"a",NUM(A))) +#define COLOR2(a,b,R,G,B,A) (ATTR2(a,b,"r",NUM(R)), \ + ATTR2(a,b,"g",NUM(G)), \ + ATTR2(a,b,"b",NUM(B)), \ + ATTR2(a,b,"a",NUM(A))) +#define COLOR3(a,b,c,R,G,B,A) (ATTR3(a,b,c,"r",NUM(R)), \ + ATTR3(a,b,c,"g",NUM(G)), \ + ATTR3(a,b,c,"b",NUM(B)), \ + ATTR3(a,b,c,"a",NUM(A))) +#define COLOR4(a,b,c,d,R,G,B,A) (ATTR4(a,b,c,d,"r",NUM(R)), \ + ATTR4(a,b,c,d,"g",NUM(G)), \ + ATTR4(a,b,c,d,"b",NUM(B)), \ + ATTR4(a,b,c,d,"a",NUM(A))) +#define COLOR5(a,b,c,d,e,R,G,B,A) (ATTR5(a,b,c,d,e,"r",NUM(R)), \ + ATTR5(a,b,c,d,e,"g",NUM(G)), \ + ATTR5(a,b,c,d,e,"b",NUM(B)), \ + ATTR5(a,b,c,d,e,"a",NUM(A))) +#define COLOR6(a,b,c,d,e,f,R,G,B,A) (ATTR6(a,b,c,d,e,f,"r",NUM(R)), \ + ATTR6(a,b,c,d,e,f,"g",NUM(G)), \ + ATTR6(a,b,c,d,e,f,"b",NUM(B)), \ + ATTR6(a,b,c,d,e,f,"a",NUM(A))) #define APPEARANCE2(res,a,b) \ { \ if (read_string(db, res, &s)) \ - APPCONT3(a, b, "style", s); \ + CONT3(a, b, "style", s); \ if (read_color(db, res".color", &i, &j, &k)) \ COLOR3(a, b, "primary", i, j, k, 255); \ if (read_color(db, res".colorTo", &i, &j, &k)) \ @@ -252,7 +250,7 @@ static xmlNodePtr root; #define APPEARANCE3(res,a,b,c) \ { \ if (read_string(db, res, &s)) \ - APPCONT4(a, b, c, "style", s); \ + CONT4(a, b, c, "style", s); \ if (read_color(db, res".color", &i, &j, &k)) \ COLOR4(a, b, c, "primary", i, j, k, 255); \ if (read_color(db, res".colorTo", &i, &j, &k)) \ @@ -266,7 +264,7 @@ static xmlNodePtr root; #define APPEARANCE4(res,a,b,c,d) \ { \ if (read_string(db, res, &s)) \ - APPCONT5(a, b, c, d, "style", s); \ + CONT5(a, b, c, d, "style", s); \ if (read_color(db, res".color", &i, &j, &k)) \ COLOR5(a, b, c, d, "primary", i, j, k, 255); \ if (read_color(db, res".colorTo", &i, &j, &k)) \ @@ -284,19 +282,40 @@ int main(int argc, char **argv) gchar *s; int ret = 0; - if (argc < 2) { - printf("Please specify an Openbox3 themerc file\n"); - return 1; + if (argc > 1) { + fprintf(stderr, "themetoxml (C) 2007 Dana Jansens\n" + "This tool takes an older Openbox3 themerc file on stdin," + " and gives back the\n" + "theme in the newer themerc.xml XML style.\n"); + return 0; } + { + gchar *buf = g_new(gchar, 1000); + gint sz = 1000; + gint r = 0, rthis; + + while ((rthis = read(0, buf + r, sz - r)) > 0) { + r+=rthis; + if (r==sz) { + sz+=1000; + buf = g_renew(gchar,buf,sz); + } + } + - if ((db = XrmGetFileDatabase(argv[1])) == NULL) { - printf("Unable to open the database from stdin\n"); - return 1; + if ((db = XrmGetStringDatabase(buf)) == NULL) { + fprintf(stderr, "Unable to read the database from stdin\n"); + return 1; + } + g_free(buf); } doc = xmlNewDoc((const xmlChar*) "1.0"); xmlDocSetRootElement (doc,(root = xmlNewNode(NULL, (const xmlChar*)"openbox_theme"))); + xmlSetProp(root, (const xmlChar*)"version", (const xmlChar*)"1"); + xmlSetProp(root, (const xmlChar*)"xmlns", + (const xmlChar*)"http://openbox.org/themerc"); if (read_int(db, "window.handle.width", &i)) CONT2("dimensions", "handle", NUM(i)); @@ -306,9 +325,12 @@ int main(int argc, char **argv) ATTR2("dimensions", "padding", "vertical", NUM(i)); } - if (read_int(db, "border.width", &i)) { - APPCONT3("window", "border", "width", NUM(i)); - APPCONT3("menu", "border", "width", NUM(i)); + if (read_int(db, "borderWidth", &i)) { + CONT3("window", "border", "width", NUM(i)); + CONT3("menu", "border", "width", NUM(i)); + } else if (read_int(db, "border.width", &i)) { + CONT3("window", "border", "width", NUM(i)); + CONT3("menu", "border", "width", NUM(i)); } if (read_color(db, "border.color", &i, &j, &k)) { @@ -316,31 +338,33 @@ int main(int argc, char **argv) COLOR3("menu", "border", "primary", i, j, k, 255); } - if (read_int(db, "window.client.padding.width", &i)) - APPCONT3("window", "clientborder", "width", NUM(i)); + if (read_int(db, "window.client.padding.width", &i)) { + ATTR2("window", "clientpadding", "horizontal", NUM(i)); + ATTR2("window", "clientpadding", "vertical", NUM(i)); + } if (read_string(db, "window.label.text.justify", &s)) { if (!g_ascii_strcasecmp(s, "right")) s = "right"; else if (!g_ascii_strcasecmp(s, "center")) s = "center"; else s = "left"; - APPCONT5("window", "inactive", "label", "text", "justify", s); + CONT2("window", "justify", s); } if (read_string(db, "menu.title.text.justify", &s)) { if (!g_ascii_strcasecmp(s, "right")) s = "right"; else if (!g_ascii_strcasecmp(s, "center")) s = "center"; else s = "left"; - APPCONT4("menu", "title", "text", "justify", s); + CONT2("menu", "justify", s); } if (read_int(db, "menu.overlap", &i)) - APPCONT2("menu", "overlap", NUM(i)); + CONT2("menu", "overlap", NUM(i)); if (read_color(db, "window.active.client.color", &i, &j, &k)) - COLOR4("window","active","clientborder","primary",i,j,k,255); + COLOR3("window","active","clientpadding",i,j,k,255); if (read_color(db, "window.inactive.client.color", &i, &j, &k)) - COLOR4("window","inactive","clientborder","primary",i,j,k,255); + COLOR3("window","inactive","clientpadding",i,j,k,255); if (read_color(db, "window.active.label.text.color", &i, &j, &k)) COLOR5("window","active","label","text","primary",i,j,k,255); @@ -394,7 +418,7 @@ int main(int argc, char **argv) if (read_color(db, "menu.items.text.color", &i, &j, &k)) - COLOR4("menu","inactive","text","primary",i,j,k,255); + COLOR3("menu","inactive","primary",i,j,k,255); if (read_color(db, "menu.items.disabled.text.color", &i, &j, &k)) @@ -412,7 +436,7 @@ int main(int argc, char **argv) APPEARANCE3("window.inactive.handle.bg", "window", "inactive", "handle"); APPEARANCE3("window.active.grip.bg", "window", "active", "grip"); APPEARANCE3("window.inactive.grip.bg", "window", "inactive", "grip"); - APPEARANCE2("menu.items.bg", "menu", "inactive"); + APPEARANCE2("menu.items.bg", "menu", "entries"); APPEARANCE2("menu.items.active.bg", "menu", "active"); APPEARANCE2("menu.title.bg", "menu", "title"); @@ -444,9 +468,9 @@ int main(int argc, char **argv) i = parse_inline_number(p + strlen("shadowoffset=")); else i = 1; - APPATTR6("window","active","label","text","shadow","offset", + ATTR6("window","active","label","text","shadow","offset", "x",NUM(i)); - APPATTR6("window","active","label","text","shadow","offset", + ATTR6("window","active","label","text","shadow","offset", "y",NUM(i)); } if ((p = strstr(s, "shadowtint="))) @@ -466,9 +490,9 @@ int main(int argc, char **argv) i = parse_inline_number(p + strlen("shadowoffset=")); else i = 1; - APPATTR6("window","inactive","label","text","shadow","offset", + ATTR6("window","inactive","label","text","shadow","offset", "x",NUM(i)); - APPATTR6("window","inactive","label","text","shadow","offset", + ATTR6("window","inactive","label","text","shadow","offset", "y",NUM(i)); } if ((p = strstr(s, "shadowtint="))) @@ -488,8 +512,8 @@ int main(int argc, char **argv) i = parse_inline_number(p + strlen("shadowoffset=")); else i = 1; - APPATTR5("menu","title","text","shadow","offset","x",NUM(i)); - APPATTR5("menu","title","text","shadow","offset","y",NUM(i)); + ATTR5("menu","title","text","shadow","offset","x",NUM(i)); + ATTR5("menu","title","text","shadow","offset","y",NUM(i)); } if ((p = strstr(s, "shadowtint="))) { @@ -507,26 +531,26 @@ int main(int argc, char **argv) i = parse_inline_number(p + strlen("shadowoffset=")); else i = 1; - APPATTR5("menu","inactive","text","shadow","offset","x",NUM(i)); - APPATTR5("menu","inactive","text","shadow","offset","y",NUM(i)); - APPATTR5("menu","active","text","shadow","offset","x",NUM(i)); - APPATTR5("menu","active","text","shadow","offset","y",NUM(i)); - APPATTR5("menu","disabled","text","shadow","offset","x",NUM(i)); - APPATTR5("menu","disabled","text","shadow","offset","y",NUM(i)); + ATTR4("menu","inactive","shadow","offset","x",NUM(i)); + ATTR4("menu","inactive","shadow","offset","y",NUM(i)); + ATTR5("menu","active","text","shadow","offset","x",NUM(i)); + ATTR5("menu","active","text","shadow","offset","y",NUM(i)); + ATTR4("menu","disabled","shadow","offset","x",NUM(i)); + ATTR4("menu","disabled","shadow","offset","y",NUM(i)); } if ((p = strstr(s, "shadowtint="))) { i = parse_inline_number(p + strlen("shadowtint=")); j = (i > 0 ? 0 : 255); i = ABS(i); - COLOR5("menu","inactive","text","shadow","primary",j,j,j,i); + COLOR4("menu","inactive","shadow","primary",j,j,j,i); COLOR5("menu","active","text","shadow","primary",j,j,j,i); - COLOR5("menu","disabled","text","shadow","primary",j,j,j,i); + COLOR4("menu","disabled","shadow","primary",j,j,j,i); } } if (xmlSaveFormatFile("-", doc, 1) < 0) { - printf("Error writing the xml tree\n"); + fprintf(stderr, "Error writing the xml tree\n"); ret = 1; }