File indexing completed on 2024-05-12 17:10:53

0001 /*
0002  * oxygen theme engine
0003  *
0004  * oxygen.c
0005  *
0006  * Copyright (C) 2006 Quinn Storm <livinglatexkali@gmail.com> (original legacy theme engine)
0007  * Copyright (C) 2006 Varun <varunratnakar@gmail.com>
0008  *
0009  * This program is free software; you can redistribute it and/or
0010  * modify it under the terms of the GNU General Public License
0011  * as published by the Free Software Foundation; either version 2
0012  * of the License, or (at your option) any later version.
0013  *
0014  * This program is distributed in the hope that it will be useful,
0015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  * GNU General Public License for more details.
0018  *
0019  * You should have received a copy of the GNU General Public License
0020  * along with this program; if not, write to the Free Software
0021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0022  */
0023 
0024 //pixmap engine
0025 #include <emerald.h>
0026 #include <engine.h>
0027 #include "pixmap_engine.h"
0028 
0029 #define SECT "pixmap_settings"
0030 #define TEXTURE_FROM_PNG(surface, png) \
0031         surface = (cairo_surface_t*) cairo_image_surface_create_from_png(png);
0032 
0033 /*
0034  * pixmap data structs
0035  */
0036 static const gchar * const p_types[]=
0037 {
0038     "top",
0039     "top_left",
0040     "top_right",
0041     "left",
0042     "right",
0043     "bottom",
0044     "bottom_left",
0045     "bottom_right",
0046     "title",
0047     "title_left",
0048     "title_right"
0049 };
0050 static const gchar * const names[]={
0051     "Top",
0052     "Top Left",
0053     "Top Right",
0054     "Left",
0055     "Right", 
0056     "Bottom", 
0057     "Bottom Left", 
0058     "Bottom Right",
0059     "Title",
0060     "Title Left",
0061     "Title Right"
0062 };
0063 enum {
0064     TOP = 0,
0065     TOP_LEFT,
0066     TOP_RIGHT,
0067     LEFT,
0068     RIGHT,
0069     BOTTOM,
0070     BOTTOM_LEFT,
0071     BOTTOM_RIGHT,
0072     TITLE,
0073     TITLE_LEFT,
0074     TITLE_RIGHT
0075 };
0076 typedef struct _pixmap_data
0077 {
0078     cairo_surface_t* surface;
0079     gboolean use_scaled;
0080     gboolean use_width;
0081     gboolean use_height;
0082     double width;
0083     double height;
0084 } pixmap_data;
0085 
0086 /*
0087  * settings structs
0088  */
0089 typedef struct _private_fs
0090 {
0091     alpha_color inner;
0092     alpha_color outer;
0093     alpha_color title_inner;
0094     alpha_color title_outer;
0095     pixmap_data pixmaps[11];
0096 } private_fs;
0097 
0098 typedef struct _private_ws
0099 {
0100     gboolean round_top_left;
0101     gboolean round_top_right;
0102     gboolean round_bottom_left;
0103     gboolean round_bottom_right;
0104     gboolean inactive_use_active_pixmaps;
0105     double  top_corner_radius;
0106     double  bottom_corner_radius;
0107 } private_ws;
0108 
0109 void get_meta_info (EngineMetaInfo * emi)
0110 {
0111     emi->version = g_strdup("0.2");
0112     emi->description = g_strdup(_("Everything done with customizable pixmaps!"));
0113     emi->last_compat = g_strdup("0.0"); // old themes marked still compatible
0114     emi->icon = gdk_pixbuf_new_from_inline(-1,my_pixbuf,TRUE,NULL);
0115 }
0116 
0117 void
0118 fill_rounded_rectangle_pixmap_blend (cairo_t       *cr,
0119         double        x, double        y,
0120         double        w, double        h,
0121         int           corner,
0122         alpha_color * c0,
0123         alpha_color * c1,
0124         int           gravity,
0125         pixmap_data * pix,
0126         window_settings * ws,
0127         double    radius,
0128         gboolean blend_only_if_pixmaps_available)
0129 {
0130     cairo_pattern_t * pattern;
0131     gboolean blend = TRUE;
0132     int iw, ih;
0133 
0134     if(cairo_surface_status(pix->surface) == CAIRO_STATUS_SUCCESS) {
0135         iw = cairo_image_surface_get_width(pix->surface);
0136         ih = cairo_image_surface_get_height(pix->surface);
0137 
0138         cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
0139         cairo_set_line_width (cr, 0.0);
0140 
0141         // While using scaled pixmaps
0142         if(pix->use_scaled) {
0143             cairo_matrix_t matrix;
0144             cairo_matrix_init_scale(&matrix, iw/w, ih/h);
0145             cairo_matrix_translate(&matrix, -x, -y);
0146 
0147             pattern = cairo_pattern_create_for_surface(pix->surface);
0148             cairo_pattern_set_matrix(pattern, &matrix);
0149             cairo_set_source (cr, pattern);
0150             cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
0151         } else {
0152         // While using tiled pixmaps
0153             cairo_set_source_surface (cr, pix->surface, x, y);
0154             pattern = cairo_pattern_reference(cairo_get_source(cr));
0155             cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
0156         }
0157 
0158         rounded_rectangle (cr, x, y, w, h, corner,ws,radius);
0159         cairo_fill (cr);
0160         cairo_pattern_destroy (pattern);
0161     }
0162     else if(blend_only_if_pixmaps_available) blend = FALSE;
0163 
0164     cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
0165     if(w > 0 && blend) {
0166        // Now blend in the gradients
0167        fill_rounded_rectangle (cr, x, y, w, h, corner, c0, c1, gravity, ws, radius);
0168     }
0169 }
0170 static gint get_real_pos(window_settings * ws, gint tobj, decor_t * d)
0171 {
0172     gint width = d->width;
0173     gint base = ws->left_space;
0174     switch(d->tobj_item_state[tobj])
0175     {
0176         case 1:
0177             base = (width - ws->left_space - ws->right_space - d->tobj_size[0] - d->tobj_size[2])/2
0178                  - d->tobj_size[1]/2 + ws->left_space + d->tobj_size[0];
0179             break;
0180         case 2:
0181             base = width - ws->right_space - d->tobj_size[2];
0182             break;
0183         case 3:
0184             return -1;
0185         default:
0186             break;
0187     }
0188     return base + d->tobj_item_pos[tobj];
0189 }
0190 void engine_draw_frame (decor_t * d, cairo_t * cr)
0191 {
0192     double        x1, y1, x2, y2, h;
0193     double        top_left_width, top_right_width;
0194     double        top_left_height, top_right_height;
0195     double        left_width, right_width;
0196     double        bottom_left_width, bottom_right_width;
0197     double        bottom_left_height, bottom_right_height;
0198     int           top, title_width, title_pos;
0199     int           title_left_width, title_right_width;
0200     frame_settings * fs = d->fs;
0201     private_fs * pfs = fs->engine_fs;
0202     window_settings * ws = fs->ws;
0203     private_ws * pws = ws->engine_ws;
0204 
0205     top = ws->win_extents.top + ws->titlebar_height;
0206     x1 = ws->left_space - ws->win_extents.left;
0207     y1 = ws->top_space - ws->win_extents.top;
0208     x2 = d->width - ws->right_space + ws->win_extents.right;
0209     y2 = d->height - ws->bottom_space + ws->win_extents.bottom;
0210 
0211     h = d->height - ws->top_space - ws->titlebar_height - ws->bottom_space;
0212 
0213     int corners = 
0214         ((pws->round_top_left)?CORNER_TOPLEFT:0) |
0215         ((pws->round_top_right)?CORNER_TOPRIGHT:0) |
0216         ((pws->round_bottom_left)?CORNER_BOTTOMLEFT:0) |
0217         ((pws->round_bottom_right)?CORNER_BOTTOMRIGHT:0);
0218     
0219     // maximize work-a-round
0220     if (d->state & (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY |
0221                 WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY))
0222         corners = 0;
0223 
0224     left_width = top_left_width = bottom_left_width = ws->win_extents.left;
0225     right_width = top_right_width = bottom_right_width = ws->win_extents.right;
0226     title_width = title_left_width = title_right_width = 0;
0227 
0228     if(cairo_surface_status(pfs->pixmaps[TITLE].surface) == CAIRO_STATUS_SUCCESS) 
0229        title_left_width = cairo_image_surface_get_width(pfs->pixmaps[TITLE].surface);
0230     if(cairo_surface_status(pfs->pixmaps[TITLE_LEFT].surface) == CAIRO_STATUS_SUCCESS) 
0231        title_right_width = cairo_image_surface_get_width(pfs->pixmaps[TITLE_LEFT].surface);
0232 
0233     top_left_height = top_right_height = top;
0234     bottom_left_height = bottom_right_height = ws->win_extents.bottom;
0235 
0236     // Adjustments of the (top/bottom)-(left/right) bar 
0237     // if the radius is bigger than left/right extents
0238     if((ws->win_extents.left < pws->top_corner_radius) &&
0239         (CORNER_TOPLEFT & corners)) {
0240         top_left_width = pws->top_corner_radius;
0241     }
0242     if((ws->win_extents.left < pws->bottom_corner_radius) &&
0243         (CORNER_BOTTOMLEFT & corners)) {
0244         bottom_left_width = pws->bottom_corner_radius;
0245     }
0246     if((ws->win_extents.right < pws->top_corner_radius) &&
0247         (CORNER_TOPRIGHT & corners)) {
0248         top_right_width = pws->top_corner_radius;
0249     }
0250     if((ws->win_extents.right < pws->bottom_corner_radius) &&
0251         (CORNER_BOTTOMRIGHT & corners)) {
0252         bottom_right_width = pws->bottom_corner_radius;
0253     }
0254 
0255     // Manual Width overrides
0256     if(pfs->pixmaps[TOP_LEFT].use_width) top_left_width = pfs->pixmaps[TOP_LEFT].width;
0257     if(pfs->pixmaps[TOP_RIGHT].use_width) top_right_width = pfs->pixmaps[TOP_RIGHT].width;
0258     if(pfs->pixmaps[LEFT].use_width) left_width = pfs->pixmaps[LEFT].width;
0259     if(pfs->pixmaps[RIGHT].use_width) right_width = pfs->pixmaps[RIGHT].width;
0260     if(pfs->pixmaps[BOTTOM-LEFT].use_width) bottom_left_width = pfs->pixmaps[BOTTOM_LEFT].width;
0261     if(pfs->pixmaps[BOTTOM_RIGHT].use_width) bottom_right_width = pfs->pixmaps[BOTTOM_RIGHT].width;
0262 
0263     if(pfs->pixmaps[TITLE_LEFT].use_width) title_left_width = pfs->pixmaps[TITLE_LEFT].width;
0264     if(pfs->pixmaps[TITLE_RIGHT].use_width) title_right_width = pfs->pixmaps[TITLE_RIGHT].width;
0265 
0266     if(pfs->pixmaps[TOP_LEFT].use_height) top_left_height = pfs->pixmaps[TOP_LEFT].height;
0267     if(pfs->pixmaps[TOP_RIGHT].use_height) top_right_height = pfs->pixmaps[TOP_RIGHT].height;
0268     if(pfs->pixmaps[BOTTOM_LEFT].use_height) bottom_left_height = pfs->pixmaps[BOTTOM_LEFT].height;
0269     if(pfs->pixmaps[BOTTOM_RIGHT].use_height) bottom_right_height = pfs->pixmaps[BOTTOM_RIGHT].height;
0270 
0271     // Top Left Bar
0272     fill_rounded_rectangle_pixmap_blend (cr,
0273             x1,
0274             y1,
0275             top_left_width,
0276             top_left_height +1,
0277             CORNER_TOPLEFT & corners,
0278             &pfs->title_inner, &pfs->title_outer,
0279             SHADE_TOP | SHADE_LEFT, &pfs->pixmaps[TOP_LEFT], ws,
0280             pws->top_corner_radius, TRUE);
0281 
0282     // Top Bar
0283     fill_rounded_rectangle_pixmap_blend (cr,
0284             x1 + top_left_width,
0285             y1,
0286             x2 - x1 - top_left_width - top_right_width,
0287             top + 1,
0288             0,
0289             &pfs->title_inner,&pfs->title_outer,
0290             SHADE_TOP, &pfs->pixmaps[TOP], ws,
0291             pws->top_corner_radius, TRUE);
0292 
0293     // Top Right Bar
0294     fill_rounded_rectangle_pixmap_blend (cr,
0295             x2 - top_right_width,
0296             y1,
0297             top_right_width,
0298             top_right_height + 1,
0299             CORNER_TOPRIGHT & corners,
0300             &pfs->title_inner, &pfs->title_outer,
0301             SHADE_TOP | SHADE_RIGHT, &pfs->pixmaps[TOP_RIGHT], ws,
0302             pws->top_corner_radius, TRUE);
0303 
0304     // Left Bar
0305     fill_rounded_rectangle_pixmap_blend (cr,
0306         x1 + ws->win_extents.left - left_width, 
0307         y1 + top_left_height - 1,
0308         left_width, 
0309         h+1 - (top_left_height - top),
0310         0,
0311         &pfs->inner, &pfs->outer,
0312         SHADE_LEFT, &pfs->pixmaps[LEFT], ws,
0313         pws->top_corner_radius, FALSE);
0314 
0315     // Right Bar
0316     fill_rounded_rectangle_pixmap_blend (cr,
0317         x2 - ws->win_extents.right, 
0318         y1 + top_right_height - 1, 
0319         right_width, 
0320         h+1 - (top_right_height - top),
0321         0,
0322         &pfs->inner, &pfs->outer,
0323         SHADE_RIGHT, &pfs->pixmaps[RIGHT], ws,
0324         pws->top_corner_radius, FALSE);
0325 
0326     // Bottom Left Bar
0327     fill_rounded_rectangle_pixmap_blend (cr,
0328             x1,
0329             y2 - bottom_left_height,
0330             bottom_left_width,
0331             bottom_left_height,
0332             CORNER_BOTTOMLEFT & corners,
0333             &pfs->inner, &pfs->outer,
0334             SHADE_BOTTOM | SHADE_LEFT, &pfs->pixmaps[BOTTOM_LEFT], ws,
0335             pws->bottom_corner_radius, FALSE);
0336 
0337     // Bottom Bar
0338     fill_rounded_rectangle_pixmap_blend (cr,
0339             x1 + bottom_left_width,
0340             y2 - ws->win_extents.bottom,
0341             x2 - x1 - bottom_left_width - bottom_right_width,
0342             ws->win_extents.bottom, 0,
0343             &pfs->inner,&pfs->outer,
0344             SHADE_BOTTOM, &pfs->pixmaps[BOTTOM], ws,
0345             pws->bottom_corner_radius, FALSE);
0346 
0347     // Bottom Right Bar
0348     fill_rounded_rectangle_pixmap_blend (cr,
0349             x2 - bottom_right_width,
0350             y2 - bottom_right_height,
0351             bottom_right_width,
0352             bottom_right_height,
0353             CORNER_BOTTOMRIGHT & corners,
0354             &pfs->inner,&pfs->outer,
0355             SHADE_BOTTOM | SHADE_RIGHT,&pfs->pixmaps[BOTTOM_RIGHT], ws,
0356             pws->bottom_corner_radius, FALSE);
0357 
0358     cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
0359 
0360     // Draw Title pixmaps
0361     if(PANGO_IS_LAYOUT(d->layout))
0362        pango_layout_get_pixel_size(d->layout, &title_width, NULL);
0363     title_pos = get_real_pos(ws, TBT_TITLE, d);
0364 
0365     // Check that it doesn't overflow
0366     if((title_width + title_left_width + title_right_width) > 
0367        (x2 - x1 - top_left_width - top_right_width - 10)) {
0368        double scaledown = (x2 - x1 - top_left_width - top_right_width - 10) /
0369                           (title_width + title_left_width + title_right_width);
0370        title_width = scaledown*title_width;
0371        title_left_width = scaledown*title_left_width - 1;
0372        title_right_width = scaledown*title_right_width;
0373     }
0374 
0375     // Title Left
0376     fill_rounded_rectangle_pixmap_blend (cr,
0377             title_pos - title_left_width - 1,
0378             y1,
0379             title_left_width + 1,
0380             top,
0381             0,
0382             &pfs->title_inner, &pfs->title_outer,
0383             SHADE_TOP, &pfs->pixmaps[TITLE_LEFT], ws,
0384             pws->top_corner_radius, TRUE);
0385 
0386     // Title
0387     fill_rounded_rectangle_pixmap_blend (cr,
0388             title_pos - 0.5,
0389             y1,
0390             title_width + 0.5,
0391             top,
0392             0,
0393             &pfs->title_inner, &pfs->title_outer,
0394             SHADE_TOP, &pfs->pixmaps[TITLE], ws,
0395             pws->top_corner_radius, TRUE);
0396 
0397     // Title Right
0398     fill_rounded_rectangle_pixmap_blend (cr,
0399             title_pos + title_width - 1,
0400             y1,
0401             title_right_width + 1,
0402             top,
0403             0,
0404             &pfs->title_inner, &pfs->title_outer,
0405             SHADE_TOP, &pfs->pixmaps[TITLE_RIGHT], ws,
0406             pws->top_corner_radius, TRUE);
0407 
0408     cairo_stroke (cr);
0409 }
0410 void load_engine_settings(GKeyFile * f, window_settings * ws)
0411 {
0412     private_ws * pws = ws->engine_ws;
0413     int i;
0414     const char *pre = "active";
0415     char *junk;
0416     PFACS(outer);
0417     PFACS(inner);
0418     PFACS(title_outer);
0419     PFACS(title_inner);
0420     load_bool_setting(f, &pws->round_top_left, "round_top_left", SECT);
0421     load_bool_setting(f, &pws->round_top_right, "round_top_right", SECT);
0422     load_bool_setting(f, &pws->round_bottom_left, "round_bottom_left", SECT);
0423     load_bool_setting(f, &pws->round_bottom_right, "round_bottom_right", SECT);
0424     load_bool_setting(f, &pws->inactive_use_active_pixmaps, "inactive_use_active_pixmaps", SECT);
0425     load_float_setting(f, &pws->top_corner_radius, "top_radius", SECT);
0426     load_float_setting(f, &pws->bottom_corner_radius, "bottom_radius", SECT);
0427 
0428     // Active window
0429     private_fs * pfs = ws->fs_act->engine_fs;
0430     for(i = 0; i < 11; i++) {
0431         junk = g_strdup_printf("%s_%s", pre, p_types[i]);
0432         TEXTURE_FROM_PNG(pfs->pixmaps[i].surface, make_filename("pixmaps", junk, "png"));
0433 
0434         load_bool_setting(f, &pfs->pixmaps[i].use_scaled,  
0435         g_strdup_printf("%s_%s_use_scaled", pre, p_types[i]), SECT);
0436         load_bool_setting(f, &pfs->pixmaps[i].use_width, 
0437         g_strdup_printf("%s_%s_use_width", pre, p_types[i]), SECT);
0438         load_float_setting(f, &pfs->pixmaps[i].width, 
0439         g_strdup_printf("%s_%s_width", pre, p_types[i]), SECT);
0440         load_bool_setting(f, &pfs->pixmaps[i].use_height, 
0441         g_strdup_printf("%s_%s_use_height", pre, p_types[i]), SECT);
0442         load_float_setting(f, &pfs->pixmaps[i].height, 
0443         g_strdup_printf("%s_%s_height", pre, p_types[i]), SECT);
0444     }
0445 
0446     // Inactive window
0447     pfs = ws->fs_inact->engine_fs;
0448     if(!pws->inactive_use_active_pixmaps) pre = "inactive";
0449     for(i = 0; i < 11; i++) {
0450         junk = g_strdup_printf("%s_%s", pre, p_types[i]);
0451         TEXTURE_FROM_PNG(pfs->pixmaps[i].surface, make_filename("pixmaps", junk, "png"));
0452 
0453         load_bool_setting(f, &pfs->pixmaps[i].use_scaled, 
0454         g_strdup_printf("%s_%s_use_scaled", pre, p_types[i]),SECT);
0455         load_bool_setting(f, &pfs->pixmaps[i].use_width, 
0456         g_strdup_printf("%s_%s_use_width", pre, p_types[i]),SECT);
0457         load_float_setting(f, &pfs->pixmaps[i].width, 
0458         g_strdup_printf("%s_%s_width", pre, p_types[i]),SECT);
0459         load_bool_setting(f, &pfs->pixmaps[i].use_height, 
0460         g_strdup_printf("%s_%s_use_height", pre, p_types[i]),SECT);
0461         load_float_setting(f, &pfs->pixmaps[i].height, 
0462         g_strdup_printf("%s_%s_height", pre, p_types[i]),SECT);
0463     }
0464 }
0465 
0466 void init_engine(window_settings * ws)
0467 {
0468     private_fs * pfs;
0469     private_ws * pws;
0470 
0471     // private window settings
0472     pws = malloc(sizeof(private_ws));
0473     ws->engine_ws = pws;
0474     bzero(pws,sizeof(private_ws));
0475     pws->round_top_left = TRUE;
0476     pws->round_top_right = TRUE;
0477     pws->round_bottom_left = TRUE;
0478     pws->round_bottom_right = TRUE;
0479     pws->top_corner_radius = 5.0;
0480     pws->bottom_corner_radius = 5.0;
0481 
0482     // private frame settings for active frames
0483     pfs = malloc(sizeof(private_fs));
0484     ws->fs_act->engine_fs = pfs;
0485     bzero(pfs, sizeof(private_fs));
0486     ACOLOR(inner, 0.8, 0.8, 0.8, 0.5);
0487     ACOLOR(outer, 0.8, 0.8, 0.8, 0.5);
0488     ACOLOR(title_inner, 0.8, 0.8, 0.8, 0.8);
0489     ACOLOR(title_outer, 0.8, 0.8, 0.8, 0.8);
0490 
0491     // private frame settings for inactive frames
0492     pfs = malloc(sizeof(private_fs));
0493     bzero(pfs, sizeof(private_fs));
0494     ws->fs_inact->engine_fs = pfs;
0495     ACOLOR(inner, 0.8, 0.8, 0.8, 0.3);
0496     ACOLOR(outer, 0.8, 0.8, 0.8, 0.3);
0497     ACOLOR(title_inner, 0.8, 0.8, 0.8, 0.6);
0498     ACOLOR(title_outer, 0.8, 0.8, 0.8, 0.6);
0499 }
0500 
0501 void fini_engine(window_settings * ws)
0502 {
0503     free(ws->fs_act->engine_fs);
0504     free(ws->fs_inact->engine_fs);
0505 }
0506 #if 0
0507 void layout_corners_frame(GtkWidget * vbox)
0508 {
0509     GtkWidget * hbox;
0510     GtkWidget * junk;
0511 
0512     junk = gtk_check_button_new_with_label(_("Round Top Left Corner"));
0513     gtk_box_pack_startC(vbox, junk, FALSE, FALSE, 0);
0514     register_setting(junk, ST_BOOL, SECT, "round_top_left");
0515 
0516     junk = gtk_check_button_new_with_label(_("Round Top Right Corner"));
0517     gtk_box_pack_startC(vbox, junk, FALSE, FALSE, 0);
0518     register_setting(junk, ST_BOOL, SECT, "round_top_right");
0519 
0520     junk = gtk_check_button_new_with_label(_("Round Bottom Left Corner"));
0521     gtk_box_pack_startC(vbox, junk, FALSE, FALSE, 0);
0522     register_setting(junk, ST_BOOL, SECT, "round_bottom_left");
0523 
0524     junk = gtk_check_button_new_with_label(_("Round Bottom Right Corner"));
0525     gtk_box_pack_startC(vbox, junk, FALSE, FALSE, 0);
0526     register_setting(junk, ST_BOOL, SECT, "round_bottom_right");
0527 
0528     hbox = gtk_hbox_new(FALSE, 2);
0529     gtk_box_pack_startC(vbox, hbox, FALSE, FALSE, 0);
0530     gtk_box_pack_startC(hbox, gtk_label_new(_("Top Rounding Radius")), FALSE, FALSE, 0);
0531     junk = scaler_new(0, 20, 0.5);
0532     gtk_box_pack_startC(hbox, junk, TRUE, TRUE, 0);
0533     register_setting(junk, ST_FLOAT, SECT, "top_radius");
0534 
0535     hbox = gtk_hbox_new(FALSE, 2);
0536     gtk_box_pack_startC(vbox, hbox, FALSE, FALSE, 0);
0537     gtk_box_pack_startC(hbox, gtk_label_new(_("Bottom Rounding Radius")), FALSE, FALSE, 0);
0538     junk = scaler_new(0, 20, 0.5);
0539     gtk_box_pack_startC(hbox, junk, TRUE, TRUE, 0);
0540     register_setting(junk, ST_FLOAT, SECT, "bottom_radius");
0541 }
0542 void my_engine_settings(GtkWidget * hbox,  gboolean active)
0543 {
0544     GtkWidget * vbox;
0545     GtkWidget * scroller;
0546     vbox = gtk_vbox_new(FALSE, 2);
0547     gtk_box_pack_startC(hbox, vbox, TRUE, TRUE, 0);
0548     gtk_box_pack_startC(vbox, gtk_label_new(active?"Active Window":"Inactive Window"), FALSE, FALSE, 0);
0549     gtk_box_pack_startC(vbox, gtk_hseparator_new(), FALSE, FALSE, 0);
0550     scroller = gtk_scrolled_window_new(NULL, NULL);
0551     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroller), 
0552             GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
0553     gtk_box_pack_startC(vbox, scroller, TRUE, TRUE, 0);
0554     
0555     table_new(3, FALSE, FALSE);
0556 
0557     gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroller), GTK_WIDGET(get_current_table()));
0558     
0559     make_labels("Colors");
0560     table_append_separator();
0561     ACAV(_("Outer Frame Blend"), "outer", SECT);
0562     ACAV(_("Inner Frame Blend"), "inner", SECT);
0563     table_append_separator();
0564     ACAV(_("Outer Titlebar Blend"), "title_outer", SECT);
0565     ACAV(_("Inner Titlebar Blend"), "title_inner", SECT);
0566     table_append_separator();
0567     ACAV(_("Titlebar Separator"), "separator_line", SECT);
0568 }
0569 void layout_engine_colors(GtkWidget * vbox)
0570 {
0571     GtkWidget * hbox;
0572     hbox = gtk_hbox_new(FALSE, 2);
0573     gtk_box_pack_startC(vbox, hbox, TRUE, TRUE, 0);
0574     my_engine_settings(hbox, TRUE);
0575     gtk_box_pack_startC(hbox, gtk_vseparator_new(), FALSE, FALSE, 0);
0576     my_engine_settings(hbox, FALSE);
0577 }
0578 static void layout_pixmap_box(GtkWidget * vbox, gint b_t, gboolean active)
0579 {
0580     GtkWidget * filesel;
0581     GtkWidget * scroller;
0582     GtkFileFilter * imgfilter;
0583     GtkWidget * clearer;
0584     GtkWidget * use_scaled;
0585     GtkWidget * width;
0586     GtkWidget * use_my_width;
0587     GtkWidget * height;
0588     GtkWidget * use_my_height;
0589     GtkWidget * image;
0590     GtkWidget * tbox;
0591     GtkWidget * ttbox;
0592     SettingItem * item;
0593     char * pre = "active";
0594     if(!active) pre = "inactive";
0595 
0596     table_append(gtk_label_new(names[b_t]), FALSE);
0597     
0598     filesel = gtk_file_chooser_button_new(g_strdup_printf("%s Pixmap", names[b_t]), 
0599             GTK_FILE_CHOOSER_ACTION_OPEN);
0600     table_append(filesel, FALSE);
0601     imgfilter = gtk_file_filter_new();
0602     gtk_file_filter_set_name(imgfilter, "Images");
0603     gtk_file_filter_add_pixbuf_formats(imgfilter);
0604     gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filesel), imgfilter);
0605     
0606     scroller = gtk_scrolled_window_new(NULL, NULL);
0607     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroller), 
0608             GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
0609     gtk_widget_set_size_request(scroller,  150, 50);
0610 
0611     image = gtk_image_new();
0612     item = register_img_file_setting(filesel, "pixmaps",  g_strdup_printf("%s_%s", pre, p_types[b_t]), (GtkImage *)image);
0613     gtk_scrolled_window_add_with_viewport(
0614             GTK_SCROLLED_WINDOW(scroller), GTK_WIDGET(image));
0615     table_append(scroller, TRUE);
0616 
0617     clearer = gtk_button_new_from_stock(GTK_STOCK_CLEAR);
0618     g_signal_connect(clearer, "clicked", G_CALLBACK(cb_clear_file), item);
0619     table_append(clearer, FALSE);
0620 
0621     // Style : Use Tiled or Scaled pixmaps
0622     use_scaled = gtk_check_button_new_with_label(_("Scaled"));
0623     register_setting(use_scaled,  ST_BOOL,  SECT,  g_strdup_printf("%s_%s_use_scaled", pre, p_types[b_t]));
0624     table_append(use_scaled, FALSE);
0625 
0626     // Width : Checkbox (Use my width) + Number (0-500)
0627     if(b_t == 0 || b_t == 5 || b_t == 8) {
0628         table_append(gtk_label_new(_("Not adjustable")), FALSE);
0629     } else {
0630         width = gtk_spin_button_new_with_range(0, 500, 1);
0631         register_setting(width,
0632           ST_INT, SECT, g_strdup_printf("%s_%s_width", pre, p_types[b_t]));
0633 
0634         use_my_width = gtk_check_button_new_with_label("");
0635         register_setting(use_my_width, ST_BOOL,SECT, g_strdup_printf("%s_%s_use_width", pre, p_types[b_t]));
0636 
0637         tbox = gtk_hbox_new(FALSE, 2);
0638         gtk_box_pack_startC(tbox, width, FALSE, FALSE, 0);
0639         gtk_box_pack_startC(tbox, use_my_width, FALSE, FALSE, 0);
0640         table_append(tbox, FALSE);
0641     }
0642 
0643     // Height : Checkbox (Use my width) + Number (0-500)
0644     if(b_t == 1 || b_t == 2 || b_t == 6 || b_t == 7) {
0645         height = gtk_spin_button_new_with_range(0,500,1);
0646         register_setting(height, ST_INT, SECT, g_strdup_printf("%s_%s_height", pre, p_types[b_t]));
0647 
0648         use_my_height = gtk_check_button_new_with_label("");
0649         register_setting(use_my_height, ST_BOOL,SECT, g_strdup_printf("%s_%s_use_height", pre, p_types[b_t]));
0650 
0651         ttbox = gtk_hbox_new(FALSE, 2);
0652         gtk_box_pack_startC(ttbox, height, FALSE, FALSE, 0);
0653         gtk_box_pack_startC(ttbox, use_my_height, FALSE, FALSE, 0);
0654         table_append(ttbox, FALSE);
0655     } else {
0656         table_append(gtk_label_new(_("Not adjustable")), FALSE);
0657     }
0658 
0659 }
0660 void layout_engine_pixmaps(GtkWidget * vbox, gboolean active)
0661 {
0662     GtkWidget * scroller;
0663     GtkWidget * hbox;
0664     GtkWidget * junk;
0665     gint i;
0666    
0667     hbox = gtk_hbox_new(TRUE, 2);
0668     gtk_box_pack_startC(vbox, hbox, FALSE, FALSE, 0);
0669 
0670     if(!active) {
0671        junk = gtk_check_button_new_with_label(_("Same as Active"));
0672        gtk_box_pack_startC(hbox, junk, TRUE, TRUE, 0);
0673        register_setting(junk, ST_BOOL, SECT, "inactive_use_active_pixmaps");
0674     }
0675 
0676     scroller=gtk_scrolled_window_new(NULL, NULL);
0677     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroller), 
0678             GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
0679     gtk_box_pack_startC(vbox, scroller, TRUE, TRUE, 0);
0680     
0681     table_new(7, FALSE, FALSE);
0682     gtk_scrolled_window_add_with_viewport(
0683             GTK_SCROLLED_WINDOW(scroller), GTK_WIDGET(get_current_table()));
0684     
0685     table_append(gtk_label_new(_("Pixmap")), FALSE);
0686     table_append(gtk_label_new(_("File")), FALSE);
0687     table_append(gtk_label_new(_("Preview")), FALSE);
0688     table_append(gtk_label_new(_("Clear")), FALSE);
0689     table_append(gtk_label_new(_("Tiled/Scaled")), FALSE);
0690     table_append(gtk_label_new(_("Width Override")), FALSE);
0691     table_append(gtk_label_new(_("Height Override")), FALSE);
0692     
0693     for(i=0;i<11;i++)
0694     {
0695         layout_pixmap_box(vbox, i, active);
0696     }
0697 }
0698 void layout_engine_settings(GtkWidget * vbox)
0699 {
0700     GtkWidget * note;
0701     note = gtk_notebook_new();
0702     gtk_box_pack_startC(vbox, note, TRUE, TRUE, 0);
0703     layout_engine_pixmaps(build_notebook_page("Pixmaps (Active)", note), TRUE);
0704     layout_engine_pixmaps(build_notebook_page("Pixmaps (Inactive)", note), FALSE);
0705     layout_engine_colors(build_notebook_page("Colors", note));
0706     layout_corners_frame(build_notebook_page("Frame", note));
0707 }
0708 #endif