summaryrefslogtreecommitdiff
path: root/src/frames.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2002-10-04 02:28:57 +0000
committerHavoc Pennington <hp@src.gnome.org>2002-10-04 02:28:57 +0000
commit7641c6f95200fdd23b75e85481b23219d950b337 (patch)
treed1c2ddd111ebdc908a6f79af9fd0848fbf719004 /src/frames.c
parent261c9a74ef6f15c200ccd5ad06d765747d0477d0 (diff)
downloadmetacity-7641c6f95200fdd23b75e85481b23219d950b337.tar.gz
Button-reordering patch. Has all the code except actually installing a
2002-10-03 Havoc Pennington <hp@pobox.com> Button-reordering patch. Has all the code except actually installing a gconf schema and reading the gconf key in prefs.c. metacity-theme-viewer displays the button layouts for testing themes. * src/preview-widget.c (meta_preview_size_request): make up a width/height if no child widget * src/prefs.c (meta_prefs_get_button_layout): new function * src/frames.c: get the button layout from prefs and use it when drawing * src/theme.c (meta_frame_layout_calc_geometry): enhance to be able to lay out buttons in different arrangements (button_rect): draw the new button background rectangles (meta_theme_draw_frame): require a button layout argument (meta_theme_calc_geometry): pass in the button layout * src/preview-widget.h: mod to handle button layouts * src/theme-viewer.c: mod to handle button layouts
Diffstat (limited to 'src/frames.c')
-rw-r--r--src/frames.c56
1 files changed, 49 insertions, 7 deletions
diff --git a/src/frames.c b/src/frames.c
index 9736976e..936c7535 100644
--- a/src/frames.c
+++ b/src/frames.c
@@ -73,7 +73,9 @@ static void meta_frames_ensure_layout (MetaFrames *frames,
static MetaUIFrame* meta_frames_lookup_window (MetaFrames *frames,
Window xwindow);
-static void meta_frames_font_changed (MetaFrames *frames);
+static void meta_frames_font_changed (MetaFrames *frames);
+static void meta_frames_button_layout_changed (MetaFrames *frames);
+
static GdkRectangle* control_rect (MetaFrameControl control,
MetaFrameGeometry *fgeom);
@@ -161,12 +163,19 @@ unsigned_long_hash (gconstpointer v)
}
static void
-font_changed_callback (MetaPreference pref,
- void *data)
+prefs_changed_callback (MetaPreference pref,
+ void *data)
{
- if (pref == META_PREF_TITLEBAR_FONT)
+ switch (pref)
{
+ case META_PREF_TITLEBAR_FONT:
meta_frames_font_changed (META_FRAMES (data));
+ break;
+ case META_PREF_BUTTON_LAYOUT:
+ meta_frames_button_layout_changed (META_FRAMES (data));
+ break;
+ default:
+ break;
}
}
@@ -185,7 +194,7 @@ meta_frames_init (MetaFrames *frames)
gtk_widget_set_double_buffered (GTK_WIDGET (frames), FALSE);
- meta_prefs_add_listener (font_changed_callback, frames);
+ meta_prefs_add_listener (prefs_changed_callback, frames);
}
static void
@@ -237,7 +246,7 @@ meta_frames_finalize (GObject *object)
frames = META_FRAMES (object);
- meta_prefs_remove_listener (font_changed_callback, frames);
+ meta_prefs_remove_listener (prefs_changed_callback, frames);
g_hash_table_destroy (frames->text_heights);
@@ -293,6 +302,31 @@ meta_frames_font_changed (MetaFrames *frames)
}
static void
+queue_draw_func (gpointer key, gpointer value, gpointer data)
+{
+ MetaUIFrame *frame;
+ MetaFrames *frames;
+
+ frames = META_FRAMES (data);
+ frame = value;
+
+ /* If a resize occurs it will cause a redraw, but the
+ * resize may not actually be needed so we always redraw
+ * in case of color change.
+ */
+ gtk_style_set_background (GTK_WIDGET (frames)->style,
+ frame->window, GTK_STATE_NORMAL);
+ gdk_window_invalidate_rect (frame->window, NULL, FALSE);
+}
+
+static void
+meta_frames_button_layout_changed (MetaFrames *frames)
+{
+ g_hash_table_foreach (frames->frames,
+ queue_draw_func, frames);
+}
+
+static void
meta_frames_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
@@ -394,6 +428,7 @@ meta_frames_calc_geometry (MetaFrames *frames,
int width, height;
MetaFrameFlags flags;
MetaFrameType type;
+ MetaButtonLayout button_layout;
meta_core_get_client_size (gdk_display, frame->xwindow,
&width, &height);
@@ -402,12 +437,15 @@ meta_frames_calc_geometry (MetaFrames *frames,
type = meta_core_get_frame_type (gdk_display, frame->xwindow);
meta_frames_ensure_layout (frames, frame);
+
+ meta_prefs_get_button_layout (&button_layout);
meta_theme_calc_geometry (meta_theme_get_current (),
type,
frame->text_height,
flags,
width, height,
+ &button_layout,
fgeom);
}
@@ -1524,6 +1562,7 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
GdkRectangle *areas;
int n_areas;
int screen_width, screen_height;
+ MetaButtonLayout button_layout;
widget = GTK_WIDGET (frames);
@@ -1656,10 +1695,12 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
/* Now draw remaining portion of region */
gdk_region_get_rectangles (edges, &areas, &n_areas);
+
+ meta_prefs_get_button_layout (&button_layout);
i = 0;
while (i < n_areas)
- {
+ {
if (GDK_IS_WINDOW (drawable))
gdk_window_begin_paint_rect (drawable, &areas[i]);
@@ -1673,6 +1714,7 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
w, h,
frame->layout,
frame->text_height,
+ &button_layout,
button_states,
mini_icon, icon);