diff options
Diffstat (limited to 'capplets/appearance')
-rw-r--r-- | capplets/appearance/Makefile.am | 2 | ||||
-rw-r--r-- | capplets/appearance/appearance-font.c | 326 | ||||
-rw-r--r-- | capplets/appearance/appearance-main.c | 6 | ||||
-rw-r--r-- | capplets/appearance/appearance-support.c | 5 | ||||
-rw-r--r-- | capplets/appearance/appearance-ui.c | 244 | ||||
-rw-r--r-- | capplets/appearance/appearance-ui.h | 21 | ||||
-rw-r--r-- | capplets/appearance/appearance.h | 8 | ||||
-rw-r--r-- | capplets/appearance/data/appearance.ui | 384 | ||||
-rw-r--r-- | capplets/appearance/theme-installer.c | 2 | ||||
-rw-r--r-- | capplets/appearance/theme-save.c | 11 |
10 files changed, 765 insertions, 244 deletions
diff --git a/capplets/appearance/Makefile.am b/capplets/appearance/Makefile.am index c28d3815..500fcc64 100644 --- a/capplets/appearance/Makefile.am +++ b/capplets/appearance/Makefile.am @@ -16,6 +16,8 @@ mate_appearance_properties_SOURCES = \ appearance-themes.h \ appearance-style.c \ appearance-style.h \ + appearance-ui.c \ + appearance-ui.h \ appearance-support.c \ appearance-support.h \ mate-wp-info.c \ diff --git a/capplets/appearance/appearance-font.c b/capplets/appearance/appearance-font.c index 99281f23..19583a4f 100644 --- a/capplets/appearance/appearance-font.c +++ b/capplets/appearance/appearance-font.c @@ -25,17 +25,11 @@ #include <stdarg.h> #include <math.h> -#ifdef HAVE_XFT2 - #include <gdk/gdkx.h> - #include <X11/Xft/Xft.h> -#endif /* HAVE_XFT2 */ - #include <glib/gi18n.h> #include <gio/gio.h> #include "capplet-util.h" -#ifdef HAVE_XFT2 /* X servers sometimes lie about the screen's physical dimensions, so we cannot * compute an accurate DPI value. When this happens, the user gets fonts that * are too huge or too tiny. So, we see what the server returns: if it reports @@ -49,66 +43,44 @@ #define DPI_FALLBACK 96 #define DPI_LOW_REASONABLE_VALUE 50 #define DPI_HIGH_REASONABLE_VALUE 500 -#endif /* HAVE_XFT2 */ static gboolean in_change = FALSE; -#define MAX_FONT_POINT_WITHOUT_WARNING 32 -#define MAX_FONT_SIZE_WITHOUT_WARNING MAX_FONT_POINT_WITHOUT_WARNING * 1024 - -#ifdef HAVE_XFT2 - -/* - * Code for displaying previews of font rendering with various Xft options - */ - -static void sample_size_request(GtkWidget* darea, GtkRequisition* requisition) -{ - GdkPixbuf* pixbuf = g_object_get_data(G_OBJECT(darea), "sample-pixbuf"); - - requisition->width = gdk_pixbuf_get_width(pixbuf) + 2; - requisition->height = gdk_pixbuf_get_height(pixbuf) + 2; -} - #if GTK_CHECK_VERSION (3, 0, 0) static void sample_draw(GtkWidget* darea, cairo_t* cr) #else static void sample_expose(GtkWidget* darea, GdkEventExpose* expose) #endif { + cairo_surface_t* surface = g_object_get_data(G_OBJECT(darea), "sample-surface"); GtkAllocation allocation; - GdkPixbuf* pixbuf = g_object_get_data(G_OBJECT(darea), "sample-pixbuf"); - GdkWindow* window = gtk_widget_get_window(darea); - GtkStyle* style = gtk_widget_get_style(darea); - int width = gdk_pixbuf_get_width(pixbuf); - int height = gdk_pixbuf_get_height(pixbuf); + int x, y, w, h; gtk_widget_get_allocation (darea, &allocation); + x = allocation.width; + y = allocation.height; + w = cairo_image_surface_get_width (surface); + h = cairo_image_surface_get_height (surface); - int x = (allocation.width - width) / 2; - int y = (allocation.height - height) / 2; +#if !GTK_CHECK_VERSION (3, 0, 0) + cairo_t *cr = gdk_cairo_create (expose->window); +#endif -#if GTK_CHECK_VERSION (3, 0, 0) - cairo_set_line_width(cr, 1); + cairo_set_line_width (cr, 1); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); - cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); - cairo_rectangle(cr, 0, 0, allocation.width, allocation.height); - cairo_stroke_preserve(cr); - cairo_fill(cr); + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); + cairo_rectangle (cr, 0, 0, x, y); + cairo_fill_preserve (cr); + cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); + cairo_stroke (cr); - cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); - cairo_rectangle(cr, 0, 0, allocation.width - 1, allocation.height - 1); - cairo_stroke_preserve(cr); - cairo_fill(cr); + cairo_set_source_surface (cr, surface, (x - w) / 2, (y - h) / 2); - gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0); cairo_paint(cr); - cairo_fill (cr); -#else - gdk_draw_rectangle(window, style->white_gc, TRUE, 0, 0, allocation.width, allocation.height); - gdk_draw_rectangle(window, style->black_gc, FALSE, 0, 0, allocation.width - 1, allocation.height - 1); - gdk_draw_pixbuf(window, NULL, pixbuf, 0, 0, x, y, width, height, GDK_RGB_DITHER_NORMAL, 0, 0); +#if !GTK_CHECK_VERSION (3, 0, 0) + cairo_destroy (cr); #endif } @@ -132,193 +104,90 @@ typedef enum { RGBA_VBGR } RgbaOrder; -static XftFont* open_pattern(FcPattern* pattern, Antialiasing antialiasing, Hinting hinting) +static void set_fontoptions(PangoContext *context, Antialiasing antialiasing, Hinting hinting) { - #ifdef FC_HINT_STYLE - static const int hintstyles[] = { - FC_HINT_NONE, FC_HINT_SLIGHT, FC_HINT_MEDIUM, FC_HINT_FULL - }; - #endif /* FC_HINT_STYLE */ - - FcPattern* res_pattern; - FcResult result; - XftFont* font; - - Display* xdisplay = gdk_x11_get_default_xdisplay(); - int screen = gdk_x11_get_default_screen(); - - res_pattern = XftFontMatch(xdisplay, screen, pattern, &result); + cairo_font_options_t *opt; + cairo_antialias_t aa; + cairo_hint_style_t hs; - if (res_pattern == NULL) - { - return NULL; + switch (antialiasing) { + case ANTIALIAS_NONE: + aa = CAIRO_ANTIALIAS_NONE; + break; + case ANTIALIAS_GRAYSCALE: + aa = CAIRO_ANTIALIAS_GRAY; + break; + case ANTIALIAS_RGBA: + aa = CAIRO_ANTIALIAS_SUBPIXEL; + break; + default: + aa = CAIRO_ANTIALIAS_DEFAULT; + break; } - FcPatternDel(res_pattern, FC_HINTING); - FcPatternAddBool(res_pattern, FC_HINTING, hinting != HINT_NONE); - - #ifdef FC_HINT_STYLE - FcPatternDel(res_pattern, FC_HINT_STYLE); - FcPatternAddInteger(res_pattern, FC_HINT_STYLE, hintstyles[hinting]); - #endif /* FC_HINT_STYLE */ - - FcPatternDel(res_pattern, FC_ANTIALIAS); - FcPatternAddBool(res_pattern, FC_ANTIALIAS, antialiasing != ANTIALIAS_NONE); - - FcPatternDel(res_pattern, FC_RGBA); - FcPatternAddInteger(res_pattern, FC_RGBA, antialiasing == ANTIALIAS_RGBA ? FC_RGBA_RGB : FC_RGBA_NONE); - - FcPatternDel(res_pattern, FC_DPI); - FcPatternAddInteger(res_pattern, FC_DPI, 96); - - font = XftFontOpenPattern(xdisplay, res_pattern); - - if (!font) - { - FcPatternDestroy(res_pattern); + switch (hinting) { + case HINT_NONE: + hs = CAIRO_HINT_STYLE_NONE; + break; + case HINT_SLIGHT: + hs = CAIRO_HINT_STYLE_SLIGHT; + break; + case HINT_MEDIUM: + hs = CAIRO_HINT_STYLE_MEDIUM; + break; + case HINT_FULL: + hs = CAIRO_HINT_STYLE_FULL; + break; + default: + hs = CAIRO_HINT_STYLE_DEFAULT; + break; } - return font; + opt = cairo_font_options_create (); + cairo_font_options_set_antialias (opt, aa); + cairo_font_options_set_hint_style (opt, hs); + pango_cairo_context_set_font_options (context, opt); + cairo_font_options_destroy (opt); } static void setup_font_sample(GtkWidget* darea, Antialiasing antialiasing, Hinting hinting) { - const char* string1 = "abcfgop AO "; - const char* string2 = "abcfgop"; - - XftColor black, white; - XRenderColor rendcolor; - - Display* xdisplay = gdk_x11_get_default_xdisplay(); - -#if GTK_CHECK_VERSION (3, 0, 0) - Colormap xcolormap = DefaultColormap(xdisplay, 0); -#else - GdkColormap* colormap = gdk_rgb_get_colormap(); - Colormap xcolormap = GDK_COLORMAP_XCOLORMAP(colormap); -#endif - -#if GTK_CHECK_VERSION (3, 0, 0) - GdkVisual* visual = gdk_visual_get_system (); -#else - GdkVisual* visual = gdk_colormap_get_visual(colormap); -#endif - Visual* xvisual = GDK_VISUAL_XVISUAL(visual); - - FcPattern* pattern; - XftFont* font1; - XftFont* font2; - XGlyphInfo extents1 = { 0 }; - XGlyphInfo extents2 = { 0 }; -#if !GTK_CHECK_VERSION (3, 0, 0) - GdkPixmap* pixmap; -#endif - XftDraw* draw; - GdkPixbuf* tmp_pixbuf; - GdkPixbuf* pixbuf; - + const char *str = "<span font=\"18\" style=\"normal\">abcfgop AO </span>" + "<span font=\"20\" style=\"italic\">abcfgop</span>"; + + PangoContext *context; + PangoLayout *layout; + PangoFontDescription *fd; + PangoRectangle extents; + cairo_surface_t *surface; + cairo_t *cr; int width, height; - int ascent, descent; - - pattern = FcPatternBuild (NULL, - FC_FAMILY, FcTypeString, "Serif", - FC_SLANT, FcTypeInteger, FC_SLANT_ROMAN, - FC_SIZE, FcTypeDouble, 18., - NULL); - font1 = open_pattern (pattern, antialiasing, hinting); - FcPatternDestroy (pattern); - - pattern = FcPatternBuild (NULL, - FC_FAMILY, FcTypeString, "Serif", - FC_SLANT, FcTypeInteger, FC_SLANT_ITALIC, - FC_SIZE, FcTypeDouble, 20., - NULL); - font2 = open_pattern (pattern, antialiasing, hinting); - FcPatternDestroy (pattern); - - ascent = 0; - descent = 0; - - if (font1) - { - XftTextExtentsUtf8 (xdisplay, font1, (unsigned char*) string1, - strlen (string1), &extents1); - ascent = MAX (ascent, font1->ascent); - descent = MAX (descent, font1->descent); - } - - if (font2) - { - XftTextExtentsUtf8 (xdisplay, font2, (unsigned char*) string2, strlen (string2), &extents2); - ascent = MAX (ascent, font2->ascent); - descent = MAX (descent, font2->descent); - } - - width = extents1.xOff + extents2.xOff + 4; - height = ascent + descent + 2; - -#if !GTK_CHECK_VERSION (3, 0, 0) - pixmap = gdk_pixmap_new (NULL, width, height, visual->depth); -#endif - -#if GTK_CHECK_VERSION (3, 0, 0) - draw = XftDrawCreate (xdisplay, GDK_WINDOW_XID (gdk_screen_get_root_window (gdk_screen_get_default ())), xvisual, xcolormap); -#else - draw = XftDrawCreate (xdisplay, GDK_DRAWABLE_XID (pixmap), xvisual, xcolormap); -#endif - rendcolor.red = 0; - rendcolor.green = 0; - rendcolor.blue = 0; - rendcolor.alpha = 0xffff; - - XftColorAllocValue(xdisplay, xvisual, xcolormap, &rendcolor, &black); + context = gtk_widget_get_pango_context (darea); + set_fontoptions (context, antialiasing, hinting); + layout = pango_layout_new (context); - rendcolor.red = 0xffff; - rendcolor.green = 0xffff; - rendcolor.blue = 0xffff; - rendcolor.alpha = 0xffff; - - XftColorAllocValue(xdisplay, xvisual, xcolormap, &rendcolor, &white); - XftDrawRect(draw, &white, 0, 0, width, height); - - if (font1) - { - XftDrawStringUtf8(draw, &black, font1, 2, 2 + ascent, (unsigned char*) string1, strlen(string1)); - } - - if (font2) - { - XftDrawStringUtf8(draw, &black, font2, 2 + extents1.xOff, 2 + ascent, (unsigned char*) string2, strlen(string2)); - } + fd = pango_font_description_from_string ("Serif"); + pango_layout_set_font_description (layout, fd); + pango_font_description_free (fd); - XftDrawDestroy(draw); + pango_layout_set_markup (layout, str, -1); - if (font1) - { - XftFontClose(xdisplay, font1); - } - - if (font2) - { - XftFontClose(xdisplay, font2); - } + pango_layout_get_extents (layout, NULL, &extents); + width = PANGO_PIXELS(extents.width) + 4; + height = PANGO_PIXELS(extents.height) + 2; -#if GTK_CHECK_VERSION (3, 0, 0) - tmp_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE,8, width, height); -#else - tmp_pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, colormap, 0, 0, 0, 0, width, height); -#endif - pixbuf = gdk_pixbuf_scale_simple(tmp_pixbuf, 1 * width, 1 * height, GDK_INTERP_TILES); + surface = cairo_image_surface_create (CAIRO_FORMAT_A8, width, height); + cr = cairo_create (surface); -#if !GTK_CHECK_VERSION (3, 0, 0) - g_object_unref(pixmap); -#endif - g_object_unref(tmp_pixbuf); + cairo_move_to (cr, 2, 1); + pango_cairo_show_layout (cr, layout); + g_object_unref (layout); + cairo_destroy (cr); - g_object_set_data_full(G_OBJECT(darea), "sample-pixbuf", pixbuf, (GDestroyNotify) g_object_unref); + g_object_set_data_full(G_OBJECT(darea), "sample-surface", surface, (GDestroyNotify) cairo_surface_destroy); - g_signal_connect(darea, "size_request", G_CALLBACK(sample_size_request), NULL); + gtk_widget_set_size_request (GTK_WIDGET(darea), width + 2, height + 2); #if GTK_CHECK_VERSION (3, 0, 0) g_signal_connect(darea, "draw", G_CALLBACK(sample_draw), NULL); #else @@ -327,7 +196,7 @@ static void setup_font_sample(GtkWidget* darea, Antialiasing antialiasing, Hinti } /* - * Code implementing a group of radio buttons with different Xft option combinations. + * Code implementing a group of radio buttons with different cairo option combinations. * If one of the buttons is matched by the GSettings key, we pick it. Otherwise we * show the group as inconsistent. */ @@ -414,7 +283,6 @@ setup_font_pair (GtkWidget *radio, g_signal_connect (radio, "toggled", G_CALLBACK (font_radio_toggled), pair); } -#endif /* HAVE_XFT2 */ static void marco_titlebar_load_sensitivity (AppearanceData *data) @@ -432,7 +300,6 @@ marco_changed (GSettings *settings, marco_titlebar_load_sensitivity (user_data); } -#ifdef HAVE_XFT2 /* * EnumGroup - a group of radio buttons for a gsettings enum */ @@ -503,7 +370,7 @@ enum_group_create (GSettings *settings, group = g_new (EnumGroup, 1); - group->settings = settings; + group->settings = g_object_ref (settings); group->settings_key = g_strdup (settings_key); group->items = NULL; @@ -541,8 +408,8 @@ enum_group_create (GSettings *settings, static void enum_group_destroy (EnumGroup *group) { - group->settings = NULL; g_signal_handler_disconnect (group->settings, group->settings_signal_id); + g_clear_object (&group->settings); group->settings_signal_id = 0; g_free (group->settings_key); @@ -735,7 +602,6 @@ cb_show_details (GtkWidget *button, gtk_window_present (GTK_WINDOW (data->font_details)); } -#endif /* HAVE_XFT2 */ void font_init(AppearanceData* data) { @@ -790,20 +656,16 @@ void font_init(AppearanceData* data) marco_titlebar_load_sensitivity(data); - #ifdef HAVE_XFT2 - setup_font_pair(appearance_capplet_get_widget(data, "monochrome_radio"), appearance_capplet_get_widget (data, "monochrome_sample"), ANTIALIAS_NONE, HINT_FULL); - setup_font_pair(appearance_capplet_get_widget(data, "best_shapes_radio"), appearance_capplet_get_widget (data, "best_shapes_sample"), ANTIALIAS_GRAYSCALE, HINT_MEDIUM); - setup_font_pair(appearance_capplet_get_widget(data, "best_contrast_radio"), appearance_capplet_get_widget (data, "best_contrast_sample"), ANTIALIAS_GRAYSCALE, HINT_FULL); - setup_font_pair(appearance_capplet_get_widget(data, "subpixel_radio"), appearance_capplet_get_widget (data, "subpixel_sample"), ANTIALIAS_RGBA, HINT_FULL); + setup_font_pair(appearance_capplet_get_widget(data, "monochrome_radio"), appearance_capplet_get_widget (data, "monochrome_sample"), ANTIALIAS_NONE, HINT_FULL); + setup_font_pair(appearance_capplet_get_widget(data, "best_shapes_radio"), appearance_capplet_get_widget (data, "best_shapes_sample"), ANTIALIAS_GRAYSCALE, HINT_MEDIUM); + setup_font_pair(appearance_capplet_get_widget(data, "best_contrast_radio"), appearance_capplet_get_widget (data, "best_contrast_sample"), ANTIALIAS_GRAYSCALE, HINT_FULL); + setup_font_pair(appearance_capplet_get_widget(data, "subpixel_radio"), appearance_capplet_get_widget (data, "subpixel_sample"), ANTIALIAS_RGBA, HINT_FULL); - font_render_load (data->font_settings); + font_render_load (data->font_settings); - g_signal_connect (data->font_settings, "changed", G_CALLBACK (font_render_changed), NULL); + g_signal_connect (data->font_settings, "changed", G_CALLBACK (font_render_changed), NULL); - g_signal_connect (appearance_capplet_get_widget (data, "details_button"), "clicked", G_CALLBACK (cb_show_details), data); - #else /* !HAVE_XFT2 */ - gtk_widget_hide (appearance_capplet_get_widget (data, "font_render_frame")); - #endif /* HAVE_XFT2 */ + g_signal_connect (appearance_capplet_get_widget (data, "details_button"), "clicked", G_CALLBACK (cb_show_details), data); } void font_shutdown(AppearanceData* data) diff --git a/capplets/appearance/appearance-main.c b/capplets/appearance/appearance-main.c index be4f3682..b51591e9 100644 --- a/capplets/appearance/appearance-main.c +++ b/capplets/appearance/appearance-main.c @@ -25,6 +25,7 @@ #include "appearance-font.h" #include "appearance-themes.h" #include "appearance-style.h" +#include "appearance-ui.h" #include "appearance-support.h" #include "theme-installer.h" #include "theme-thumbnail.h" @@ -72,9 +73,7 @@ init_appearance_data (int *argc, char ***argv, GOptionContext *context) data->interface_settings = g_settings_new (INTERFACE_SCHEMA); data->marco_settings = g_settings_new (MARCO_SCHEMA); data->mouse_settings = g_settings_new (MOUSE_SCHEMA); -#ifdef HAVE_XFT2 data->font_settings = g_settings_new (FONT_RENDER_SCHEMA); -#endif /* HAVE_XFT2 */ data->ui = ui; data->thumb_factory = mate_desktop_thumbnail_factory_new (MATE_DESKTOP_THUMBNAIL_SIZE_NORMAL); } @@ -108,9 +107,7 @@ main_window_response (GtkWidget *widget, g_object_unref (data->interface_settings); g_object_unref (data->marco_settings); g_object_unref (data->mouse_settings); -#ifdef HAVE_XFT2 g_object_unref (data->font_settings); -#endif /* HAVE_XFT2 */ g_object_unref (data->ui); } else if (response_id == GTK_RESPONSE_HELP) @@ -192,6 +189,7 @@ main (int argc, char **argv) desktop_init (data, (const gchar **) wallpaper_files); g_strfreev (wallpaper_files); font_init (data); + ui_init (data); /* init support for other window managers */ support_init (data); diff --git a/capplets/appearance/appearance-support.c b/capplets/appearance/appearance-support.c index 25cc003c..35e4f263 100644 --- a/capplets/appearance/appearance-support.c +++ b/capplets/appearance/appearance-support.c @@ -77,6 +77,7 @@ metacity_theme_apply(const gchar *theme, const gchar *font) { gchar *gsettings_cmd = NULL; + /* for metacity <= 3.12 */ gsettings_cmd = g_strdup_printf("gsettings set org.gnome.desktop.wm.preferences theme '%s'", theme); g_spawn_command_line_async (gsettings_cmd, NULL); g_free (gsettings_cmd); @@ -85,6 +86,10 @@ metacity_theme_apply(const gchar *theme, const gchar *font) g_spawn_command_line_async (gsettings_cmd, NULL); g_free (gsettings_cmd); + /* for metacity >= 3.16 */ + gsettings_cmd = g_strdup_printf("gsettings set org.gnome.metacity theme '%s'", theme); + g_spawn_command_line_async (gsettings_cmd, NULL); + g_free (gsettings_cmd); } } diff --git a/capplets/appearance/appearance-ui.c b/capplets/appearance/appearance-ui.c new file mode 100644 index 00000000..04b8a49e --- /dev/null +++ b/capplets/appearance/appearance-ui.c @@ -0,0 +1,244 @@ +/* + * Copyright (C) 2007 The GNOME Foundation + * Written by Jonathan Blandford <[email protected]> + * Jens Granseuer <[email protected]> + * All Rights Reserved + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "appearance.h" +#include "stdio.h" + + +static void +show_handlebar (AppearanceData *data, gboolean show) +{ + GtkWidget *handlebox = appearance_capplet_get_widget (data, "toolbar_handlebox"); + GtkWidget *toolbar = appearance_capplet_get_widget (data, "toolbar_toolbar"); + GtkWidget *align = appearance_capplet_get_widget (data, "toolbar_align"); + + g_object_ref (handlebox); + g_object_ref (toolbar); + + if (gtk_bin_get_child (GTK_BIN (align))) + gtk_container_remove (GTK_CONTAINER (align), gtk_bin_get_child (GTK_BIN (align))); + + if (gtk_bin_get_child (GTK_BIN (handlebox))) + gtk_container_remove (GTK_CONTAINER (handlebox), gtk_bin_get_child (GTK_BIN (handlebox))); + + if (show) { + gtk_container_add (GTK_CONTAINER (align), handlebox); + gtk_container_add (GTK_CONTAINER (handlebox), toolbar); + g_object_unref (handlebox); + } else { + gtk_container_add (GTK_CONTAINER (align), toolbar); + } + + g_object_unref (toolbar); +} + +#if !GTK_CHECK_VERSION (3, 10, 0) +static void +set_toolbar_style (AppearanceData *data, const char *value) +{ + static const GtkToolbarStyle gtk_toolbar_styles[] = + { GTK_TOOLBAR_BOTH, GTK_TOOLBAR_BOTH_HORIZ, GTK_TOOLBAR_ICONS, GTK_TOOLBAR_TEXT }; + + int enum_val = gtk_combo_box_get_active((GtkComboBox *) + appearance_capplet_get_widget (data, "toolbar_style_select")); + + gtk_toolbar_set_style (GTK_TOOLBAR (appearance_capplet_get_widget (data, "toolbar_toolbar")), + gtk_toolbar_styles[enum_val]); +} +#endif + +static void +set_have_icons (AppearanceData *data, gboolean value) +{ + static const char *menu_item_names[] = { + "menu_item_1", + "menu_item_2", + "menu_item_3", + "menu_item_4", + "menu_item_5", + "cut", + "copy", + "paste", + NULL + }; + + const char **name; + + for (name = menu_item_names; *name != NULL; name++) { + GtkImageMenuItem *item = GTK_IMAGE_MENU_ITEM (appearance_capplet_get_widget (data, *name)); + GtkWidget *image; + + if (value) { + image = g_object_get_data (G_OBJECT (item), "image"); + if (image) { + gtk_image_menu_item_set_image (item, image); + g_object_unref (image); + } + } else { + image = gtk_image_menu_item_get_image (item); + g_object_set_data (G_OBJECT (item), "image", image); + g_object_ref (image); + gtk_image_menu_item_set_image (item, NULL); + } + } +} + +/** GConf Callbacks and Conversions **/ + +#if !GTK_CHECK_VERSION (3, 10, 0) +static gboolean +toolbar_to_widget (GValue *value, GVariant *variant, gpointer user_data) +{ + const gchar *val = g_variant_get_string(variant, NULL); + gint i = 0; + + if (g_strcmp0(val, "both-horiz") == 0 || g_strcmp0(val, "both_horiz") == 0) + i = 1; + else if (g_strcmp0(val, "icons") == 0) + i = 2; + else if (g_strcmp0(val, "text") == 0) + i = 3; + + g_value_set_int(value, i); + + return TRUE; +} + +static GVariant * +toolbar_from_widget (const GValue *value, + const GVariantType *expected_type, + gpointer user_data) +{ + static const char *gtk_toolbar_styles_str[] = { + "both", "both-horiz", "icons", "text" }; + + gint index = g_value_get_int(value); + return g_variant_new_string(gtk_toolbar_styles_str[index]); +} + +static void +toolbar_style_cb (GSettings *settings, + gchar *key, + AppearanceData *data) +{ + set_toolbar_style (data, g_settings_get_string (settings, key)); +} +#endif + +static void +menus_have_icons_cb (GSettings *settings, + gchar *key, + AppearanceData *data) +{ + set_have_icons (data, g_settings_get_boolean (settings, key)); +} + +static void +toolbar_detachable_cb (GSettings *settings, + gchar *key, + AppearanceData *data) +{ + show_handlebar (data, g_settings_get_boolean (settings, key)); +} + +/** GUI Callbacks **/ + +static gint +button_press_block_cb (GtkWidget *toolbar, + GdkEvent *event, + gpointer data) +{ + return TRUE; +} + +/** Public Functions **/ + +void +ui_init (AppearanceData *data) +{ + GtkWidget* widget; + +#if GTK_CHECK_VERSION (3, 10, 0) + GtkWidget* container = appearance_capplet_get_widget(data, "vbox24"); + + // Remove menu accels and toolbar style toggles for new GTK versions + gtk_container_remove((GtkContainer *) container, + appearance_capplet_get_widget(data, "menu_accel_toggle")); + gtk_container_remove((GtkContainer *) container, + appearance_capplet_get_widget(data, "hbox11")); +#endif + + widget = appearance_capplet_get_widget(data, "menu_icons_toggle"); + g_settings_bind (data->interface_settings, + MENU_ICONS_KEY, + G_OBJECT (widget), + "active", + G_SETTINGS_BIND_DEFAULT); + g_signal_connect (data->interface_settings, "changed::" MENU_ICONS_KEY, + G_CALLBACK (menus_have_icons_cb), data); + + set_have_icons (data, + g_settings_get_boolean (data->interface_settings, + MENU_ICONS_KEY)); + +#if !GTK_CHECK_VERSION (3, 10, 0) + widget = appearance_capplet_get_widget(data, "menu_accel_toggle"); + g_settings_bind (data->interface_settings, + ACCEL_CHANGE_KEY, + G_OBJECT (widget), + "active", + G_SETTINGS_BIND_DEFAULT); + + widget = appearance_capplet_get_widget(data, "toolbar_style_select"); + g_settings_bind_with_mapping (data->interface_settings, + TOOLBAR_STYLE_KEY, + G_OBJECT (widget), + "active", + G_SETTINGS_BIND_DEFAULT, + toolbar_to_widget, + toolbar_from_widget, + data, + NULL); + + g_signal_connect (data->interface_settings, "changed::" TOOLBAR_STYLE_KEY, + (GCallback) toolbar_style_cb, data); + + char* toolbar_style; + + toolbar_style = g_settings_get_string + (data->interface_settings, + TOOLBAR_STYLE_KEY); + set_toolbar_style (data, toolbar_style); + g_free (toolbar_style); +#endif + + g_signal_connect (appearance_capplet_get_widget (data, "toolbar_handlebox"), + "button_press_event", + (GCallback) button_press_block_cb, NULL); + + show_handlebar (data, + g_settings_get_boolean (data->interface_settings, + TOOLBAR_DETACHABLE_KEY)); + + /* no ui for detachable toolbars */ + g_signal_connect (data->interface_settings, + "changed::" TOOLBAR_DETACHABLE_KEY, (GCallback) toolbar_detachable_cb, data); +} diff --git a/capplets/appearance/appearance-ui.h b/capplets/appearance/appearance-ui.h new file mode 100644 index 00000000..5817a735 --- /dev/null +++ b/capplets/appearance/appearance-ui.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2007 The GNOME Foundation + * Written by Jens Granseuer <[email protected]> + * All Rights Reserved + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +void ui_init (AppearanceData *data); diff --git a/capplets/appearance/appearance.h b/capplets/appearance/appearance.h index 2091324c..37f58291 100644 --- a/capplets/appearance/appearance.h +++ b/capplets/appearance/appearance.h @@ -45,6 +45,10 @@ #define GTK_THEME_KEY "gtk-theme" #define ICON_THEME_KEY "icon-theme" #define COLOR_SCHEME_KEY "gtk-color-scheme" +#define ACCEL_CHANGE_KEY "can-change-accels" +#define MENU_ICONS_KEY "menus-have-icons" +#define TOOLBAR_DETACHABLE_KEY "toolbar-detachable" +#define TOOLBAR_STYLE_KEY "toolbar-style" #define GTK_FONT_DEFAULT_VALUE "Sans 10" #define LOCKDOWN_SCHEMA "org.mate.lockdown" @@ -65,13 +69,11 @@ #define CURSOR_THEME_KEY "cursor-theme" #define CURSOR_SIZE_KEY "cursor-size" -#ifdef HAVE_XFT2 #define FONT_RENDER_SCHEMA "org.mate.font-rendering" #define FONT_ANTIALIASING_KEY "antialiasing" #define FONT_HINTING_KEY "hinting" #define FONT_RGBA_ORDER_KEY "rgba-order" #define FONT_DPI_KEY "dpi" -#endif /* HAVE_XFT2 */ typedef struct { GSettings* settings; @@ -80,9 +82,7 @@ typedef struct { GSettings* interface_settings; GSettings* marco_settings; GSettings* mouse_settings; -#ifdef HAVE_XFT2 GSettings* font_settings; -#endif /* HAVE_XFT2 */ GtkBuilder* ui; MateDesktopThumbnailFactory* thumb_factory; gulong screen_size_handler; diff --git a/capplets/appearance/data/appearance.ui b/capplets/appearance/data/appearance.ui index 5f117007..d2c9fdda 100644 --- a/capplets/appearance/data/appearance.ui +++ b/capplets/appearance/data/appearance.ui @@ -1549,6 +1549,370 @@ <property name="tab_fill">False</property> </packing> </child> + <child> + <object class="GtkVBox" id="interface_vbox"> + <property name="visible">True</property> + <property name="border_width">12</property> + <property name="orientation">vertical</property> + <property name="spacing">18</property> + <child> + <object class="GtkVBox" id="vbox23"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="label35"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Menus and Toolbars</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkHBox" id="hbox10"> + <property name="visible">True</property> + <child> + <object class="GtkLabel" id="label36"> + <property name="visible">True</property> + <property name="label"> </property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox24"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkCheckButton" id="menu_icons_toggle"> + <property name="label" translatable="yes">Show _icons in menus</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="menu_accel_toggle"> + <property name="label" translatable="yes">_Editable menu shortcut keys</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkHBox" id="hbox11"> + <property name="visible">True</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel" id="label37"> + <property name="visible">True</property> + <property name="label" translatable="yes">Toolbar _button labels:</property> + <property name="use_underline">True</property> + <property name="justify">center</property> + <property name="mnemonic_widget">toolbar_style_select</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="toolbar_style_select"> + <property name="visible">True</property> + <property name="model">toolbar_style_liststore</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext3"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">4</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox25"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="label38"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Preview</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkHBox" id="hbox12"> + <property name="visible">True</property> + <child> + <object class="GtkLabel" id="label39"> + <property name="visible">True</property> + <property name="label"> </property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox26"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkMenuBar" id="menubar"> + <property name="visible">True</property> + <child> + <object class="GtkMenuItem" id="File Menu"> + <property name="visible">True</property> + <property name="label" translatable="yes">_File</property> + <property name="use_underline">True</property> + <child type="submenu"> + <object class="GtkMenu" id="File Menu_menu"> + <child> + <object class="GtkImageMenuItem" id="menu_item_1"> + <property name="label">gtk-new</property> + <property name="visible">True</property> + <property name="use_underline">True</property> + <property name="use-stock">True</property> + </object> + </child> + <child> + <object class="GtkImageMenuItem" id="menu_item_2"> + <property name="label">gtk-open</property> + <property name="visible">True</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + </object> + </child> + <child> + <object class="GtkImageMenuItem" id="menu_item_3"> + <property name="label">gtk-save</property> + <property name="visible">True</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="separator1"> + <property name="visible">True</property> + </object> + </child> + <child> + <object class="GtkImageMenuItem" id="menu_item_4"> + <property name="label">gtk-print</property> + <property name="visible">True</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="separator2"> + <property name="visible">True</property> + </object> + </child> + <child> + <object class="GtkImageMenuItem" id="menu_item_5"> + <property name="label">gtk-quit</property> + <property name="visible">True</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkMenuItem" id="edit"> + <property name="visible">True</property> + <property name="label" translatable="yes">Edit</property> + <property name="use_underline">True</property> + <child type="submenu"> + <object class="GtkMenu" id="edit1_menu"> + <child> + <object class="GtkImageMenuItem" id="cut"> + <property name="label">gtk-cut</property> + <property name="visible">True</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + </object> + </child> + <child> + <object class="GtkImageMenuItem" id="copy"> + <property name="label">gtk-copy</property> + <property name="visible">True</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + </object> + </child> + <child> + <object class="GtkImageMenuItem" id="paste"> + <property name="label">gtk-paste</property> + <property name="visible">True</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkAlignment" id="toolbar_align"> + <property name="visible">True</property> + <child> + <object class="GtkHandleBox" id="toolbar_handlebox"> + <property name="visible">True</property> + <child> + <object class="GtkToolbar" id="toolbar_toolbar"> + <property name="visible">True</property> + <property name="toolbar_style">both-horiz</property> + <child> + <object class="GtkToolButton" id="button2"> + <property name="visible">True</property> + <property name="is_important">True</property> + <property name="stock_id">gtk-new</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToolButton" id="button4"> + <property name="visible">True</property> + <property name="stock_id">gtk-open</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToolButton" id="save_button"> + <property name="visible">True</property> + <property name="stock_id">gtk-save</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">3</property> + </packing> + </child> + <child type="tab"> + <object class="GtkLabel" id="label40"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Interface</property> + </object> + <packing> + <property name="position">3</property> + <property name="tab_fill">False</property> + </packing> + </child> </object> <packing> <property name="position">1</property> @@ -2455,7 +2819,7 @@ <object class="GtkTable" id="table3"> <property name="visible">True</property> <property name="border_width">6</property> - <property name="n_rows">3</property> + <property name="n_rows">4</property> <property name="n_columns">2</property> <property name="column_spacing">12</property> <property name="row_spacing">6</property> @@ -2542,6 +2906,24 @@ </packing> </child> <child> + <object class="GtkCheckButton" id="save_notification_checkbutton"> + <property name="label" translatable="yes">Save _notification theme</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options"></property> + </packing> + </child> + <child> <placeholder/> </child> </object> diff --git a/capplets/appearance/theme-installer.c b/capplets/appearance/theme-installer.c index 23c94f99..9630d98d 100644 --- a/capplets/appearance/theme-installer.c +++ b/capplets/appearance/theme-installer.c @@ -689,6 +689,8 @@ mate_theme_install (GFile *file, return; } + g_free (path); + base = g_file_get_basename (file); if (g_str_has_suffix (base, ".tar.gz") diff --git a/capplets/appearance/theme-save.c b/capplets/appearance/theme-save.c index 64184444..81265b79 100644 --- a/capplets/appearance/theme-save.c +++ b/capplets/appearance/theme-save.c @@ -172,6 +172,7 @@ write_theme_to_disk (MateThemeMetaInfo *theme_info, const gchar *theme_name, const gchar *theme_description, gboolean save_background, + gboolean save_notification, GError **error) { gchar* dir; @@ -237,7 +238,7 @@ write_theme_to_disk (MateThemeMetaInfo *theme_info, g_free (str); } - if (theme_info->notification_theme_name) { + if (theme_info->notification_theme_name && save_notification) { str = g_strdup_printf ("NotificationTheme=%s\n", theme_info->notification_theme_name); g_output_stream_write (output, str, strlen (str), NULL, NULL); g_free (str); @@ -272,6 +273,7 @@ save_theme_to_disk (MateThemeMetaInfo *theme_info, const gchar *theme_name, const gchar *theme_description, gboolean save_background, + gboolean save_notification, GError **error) { if (!check_theme_name (theme_name, error)) @@ -280,7 +282,7 @@ save_theme_to_disk (MateThemeMetaInfo *theme_info, if (!setup_directory_structure (theme_name, error)) return FALSE; - if (!write_theme_to_disk (theme_info, theme_name, theme_description, save_background, error)) + if (!write_theme_to_disk (theme_info, theme_name, theme_description, save_background, save_notification, error)) return FALSE; return TRUE; @@ -302,6 +304,7 @@ save_dialog_response (GtkWidget *save_dialog, gchar *theme_description = NULL; gchar *theme_name = NULL; gboolean save_background; + gboolean save_notification; GError *error = NULL; entry = appearance_capplet_get_widget (data, "save_dialog_entry"); @@ -317,8 +320,10 @@ save_dialog_response (GtkWidget *save_dialog, theme_info = (MateThemeMetaInfo *) g_object_get_data (G_OBJECT (save_dialog), "meta-theme-info"); save_background = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ( appearance_capplet_get_widget (data, "save_background_checkbutton"))); + save_notification = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ( + appearance_capplet_get_widget (data, "save_notification_checkbutton"))); - if (save_theme_to_disk (theme_info, theme_name, theme_description, save_background, &error)) { + if (save_theme_to_disk (theme_info, theme_name, theme_description, save_background, save_notification, &error)) { /* remove the custom theme */ GtkTreeIter iter; |