mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-16 19:56:31 +01:00
Update clearlooks to fancy new cairo version.
Twiddle colours and throw some gloss in there mostly just to show off. git-svn-id: svn://localhost/ardour2/branches/3.0@3000 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
bf687f5dc5
commit
b4b3278bd8
23 changed files with 10411 additions and 5123 deletions
|
|
@ -91,7 +91,7 @@ style "default_base" = "medium_text"
|
||||||
GtkTreeView::vertical-padding = 0
|
GtkTreeView::vertical-padding = 0
|
||||||
GtkTreeView::horizontal-padding = 0
|
GtkTreeView::horizontal-padding = 0
|
||||||
GtkTreeView::even-row-color = { 0, 0, 0 }
|
GtkTreeView::even-row-color = { 0, 0, 0 }
|
||||||
GtkTreeView::odd-row-color = { 0.10, 0.10, 0.15 }
|
GtkTreeView::odd-row-color = { 0.08, 0.10, 0.15 }
|
||||||
|
|
||||||
fg[NORMAL] = { 0.80, 0.80, 0.80 }
|
fg[NORMAL] = { 0.80, 0.80, 0.80 }
|
||||||
fg[ACTIVE] = { 0.80, 0.80, 0.80 }
|
fg[ACTIVE] = { 0.80, 0.80, 0.80 }
|
||||||
|
|
@ -99,10 +99,10 @@ style "default_base" = "medium_text"
|
||||||
fg[INSENSITIVE] = { 0.80, 0.80, 0.80 }
|
fg[INSENSITIVE] = { 0.80, 0.80, 0.80 }
|
||||||
fg[SELECTED] = { 0.80, 0.80, 0.80 }
|
fg[SELECTED] = { 0.80, 0.80, 0.80 }
|
||||||
|
|
||||||
bg[NORMAL] = { 0.35, 0.35, 0.40 }
|
bg[NORMAL] = { 0.31, 0.35, 0.40 }
|
||||||
bg[ACTIVE] = { 0.35, 0.35, 0.40 }
|
bg[ACTIVE] = { 0.31, 0.35, 0.40 }
|
||||||
bg[PRELIGHT] = "#565690"
|
bg[PRELIGHT] = "#515690"
|
||||||
bg[INSENSITIVE] = { 0.10, 0.10, 0.10 }
|
bg[INSENSITIVE] = { 0.06, 0.10, 0.10 }
|
||||||
bg[SELECTED] = { 0, 0.40, 0.60 }
|
bg[SELECTED] = { 0, 0.40, 0.60 }
|
||||||
|
|
||||||
text[NORMAL] = { 0.80, 0.80, 0.80 }
|
text[NORMAL] = { 0.80, 0.80, 0.80 }
|
||||||
|
|
@ -113,13 +113,18 @@ style "default_base" = "medium_text"
|
||||||
|
|
||||||
base[ACTIVE] = "#272a2f"
|
base[ACTIVE] = "#272a2f"
|
||||||
base[NORMAL] = "#1a1e20"
|
base[NORMAL] = "#1a1e20"
|
||||||
base[PRELIGHT] = { 0.20, 0.20, 0.20 }
|
base[PRELIGHT] = { 0.18, 0.20, 0.20 }
|
||||||
base[INSENSITIVE] = "#4c5159"
|
base[INSENSITIVE] = "#4c5159"
|
||||||
base[SELECTED] = { 0.25, 0.25, 0.25 }
|
base[SELECTED] = { 0.23, 0.25, 0.25 }
|
||||||
|
|
||||||
engine "clearlooks"
|
engine "clearlooks"
|
||||||
{
|
{
|
||||||
menubarstyle = 0 # 0 = flat, 1 = sunken, 2 = flat gradient
|
menubarstyle = 0 # 0 = flat, 1 = sunken, 2 = flat gradient
|
||||||
|
style = GLOSSY
|
||||||
|
colorize_scrollbar = TRUE
|
||||||
|
menubarstyle = 2 # 0 = flat, 1 = sunken, 2 = flat gradient
|
||||||
|
toolbarstyle = 0 # 0 = flat, 1 = enable effects
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,25 @@ import os.path
|
||||||
import glob
|
import glob
|
||||||
|
|
||||||
libclearlooks_files = [
|
libclearlooks_files = [
|
||||||
|
'animation.c',
|
||||||
|
'cairo-support.c',
|
||||||
'clearlooks_draw.c',
|
'clearlooks_draw.c',
|
||||||
'clearlooks_rc_style.c',
|
'clearlooks_draw_glossy.c',
|
||||||
'clearlooks_style.c',
|
'clearlooks_draw_gummy.c',
|
||||||
'clearlooks_theme_main.c',
|
'clearlooks_draw_inverted.c',
|
||||||
'support.c' ]
|
'clearlooks_rc_style.c',
|
||||||
|
'clearlooks_style.c',
|
||||||
|
'clearlooks_theme_main.c',
|
||||||
|
'support.c',
|
||||||
|
'widget-information.c'
|
||||||
|
]
|
||||||
|
|
||||||
Import ('env install_prefix')
|
Import ('env install_prefix')
|
||||||
|
|
||||||
clearlooks = env.Copy()
|
clearlooks = env.Copy()
|
||||||
|
|
||||||
clearlooks.Replace(CCFLAGS = ' `pkg-config --cflags gtk+-2.0` ',
|
clearlooks.Replace(CCFLAGS = ' `pkg-config --cflags gtk+-2.0 cairo` ',
|
||||||
LINKFLAGS = ' `pkg-config --libs gtk+-2.0` ')
|
LINKFLAGS = ' `pkg-config --libs gtk+-2.0 cairo` ')
|
||||||
|
|
||||||
if env['GTKOSX']:
|
if env['GTKOSX']:
|
||||||
clearlooks.Append (CCFLAGS = '-DGTKOSX')
|
clearlooks.Append (CCFLAGS = '-DGTKOSX')
|
||||||
|
|
|
||||||
337
libs/clearlooks/animation.c
Normal file
337
libs/clearlooks/animation.c
Normal file
|
|
@ -0,0 +1,337 @@
|
||||||
|
/* Clearlooks theme engine
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Kulyk Nazar <schamane@myeburg.net>
|
||||||
|
* Copyright (C) 2006 Benjamin Berg <benjamin@sipsolutions.net>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This code is responsible for the clearlooks animation support. The code
|
||||||
|
* works by forcing a redraw on the animated widget.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "animation.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_ANIMATION
|
||||||
|
#include <glib/gtimer.h>
|
||||||
|
|
||||||
|
struct _AnimationInfo {
|
||||||
|
GTimer *timer;
|
||||||
|
|
||||||
|
gdouble start_modifier;
|
||||||
|
gdouble stop_time;
|
||||||
|
GtkWidget *widget;
|
||||||
|
};
|
||||||
|
typedef struct _AnimationInfo AnimationInfo;
|
||||||
|
|
||||||
|
struct _SignalInfo {
|
||||||
|
GtkWidget *widget;
|
||||||
|
gulong handler_id;
|
||||||
|
};
|
||||||
|
typedef struct _SignalInfo SignalInfo;
|
||||||
|
|
||||||
|
static GSList *connected_widgets = NULL;
|
||||||
|
static GHashTable *animated_widgets = NULL;
|
||||||
|
static int animation_timer_id = 0;
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean animation_timeout_handler (gpointer data);
|
||||||
|
|
||||||
|
/* This forces a redraw on a widget */
|
||||||
|
static void
|
||||||
|
force_widget_redraw (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
if (GE_IS_PROGRESS_BAR (widget))
|
||||||
|
gtk_widget_queue_resize (widget);
|
||||||
|
else
|
||||||
|
gtk_widget_queue_draw (widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ensures that the timer is running */
|
||||||
|
static void
|
||||||
|
start_timer ()
|
||||||
|
{
|
||||||
|
if (animation_timer_id == 0)
|
||||||
|
animation_timer_id = g_timeout_add (ANIMATION_DELAY, animation_timeout_handler, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ensures that the timer is stopped */
|
||||||
|
static void
|
||||||
|
stop_timer ()
|
||||||
|
{
|
||||||
|
if (animation_timer_id != 0)
|
||||||
|
{
|
||||||
|
g_source_remove(animation_timer_id);
|
||||||
|
animation_timer_id = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* destroys an AnimationInfo structure including the GTimer */
|
||||||
|
static void
|
||||||
|
animation_info_destroy (AnimationInfo *animation_info)
|
||||||
|
{
|
||||||
|
g_timer_destroy (animation_info->timer);
|
||||||
|
g_free (animation_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* This function does not unref the weak reference, because the object
|
||||||
|
* is beeing destroyed currently. */
|
||||||
|
static void
|
||||||
|
on_animated_widget_destruction (gpointer data, GObject *object)
|
||||||
|
{
|
||||||
|
/* steal the animation info from the hash table (destroying it would
|
||||||
|
* result in the weak reference to be unrefed, which does not work
|
||||||
|
* as the widget is already destroyed. */
|
||||||
|
g_hash_table_steal (animated_widgets, object);
|
||||||
|
animation_info_destroy ((AnimationInfo*) data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function also needs to unref the weak reference. */
|
||||||
|
static void
|
||||||
|
destroy_animation_info_and_weak_unref (gpointer data)
|
||||||
|
{
|
||||||
|
AnimationInfo *animation_info = data;
|
||||||
|
|
||||||
|
/* force a last redraw. This is so that if the animation is removed,
|
||||||
|
* the widget is left in a sane state. */
|
||||||
|
force_widget_redraw (animation_info->widget);
|
||||||
|
|
||||||
|
g_object_weak_unref (G_OBJECT (animation_info->widget), on_animated_widget_destruction, data);
|
||||||
|
animation_info_destroy (animation_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find and return a pointer to the data linked to this widget, if it exists */
|
||||||
|
static AnimationInfo*
|
||||||
|
lookup_animation_info (const GtkWidget *widget)
|
||||||
|
{
|
||||||
|
if (animated_widgets)
|
||||||
|
return g_hash_table_lookup (animated_widgets, widget);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create all the relevant information for the animation, and insert it into the hash table. */
|
||||||
|
static void
|
||||||
|
add_animation (const GtkWidget *widget, gdouble stop_time)
|
||||||
|
{
|
||||||
|
AnimationInfo *value;
|
||||||
|
|
||||||
|
/* object already in the list, do not add it twice */
|
||||||
|
if (lookup_animation_info (widget))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (animated_widgets == NULL)
|
||||||
|
animated_widgets = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||||
|
NULL, destroy_animation_info_and_weak_unref);
|
||||||
|
|
||||||
|
value = g_new(AnimationInfo, 1);
|
||||||
|
|
||||||
|
value->widget = (GtkWidget*) widget;
|
||||||
|
|
||||||
|
value->timer = g_timer_new ();
|
||||||
|
value->stop_time= stop_time;
|
||||||
|
value->start_modifier = 0.0;
|
||||||
|
|
||||||
|
g_object_weak_ref (G_OBJECT (widget), on_animated_widget_destruction, value);
|
||||||
|
g_hash_table_insert (animated_widgets, (GtkWidget*) widget, value);
|
||||||
|
|
||||||
|
start_timer ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* update the animation information for each widget. This will also queue a redraw
|
||||||
|
* and stop the animation if it is done. */
|
||||||
|
static gboolean
|
||||||
|
update_animation_info (gpointer key, gpointer value, gpointer user_data)
|
||||||
|
{
|
||||||
|
AnimationInfo *animation_info = value;
|
||||||
|
GtkWidget *widget = key;
|
||||||
|
|
||||||
|
g_assert ((widget != NULL) && (animation_info != NULL));
|
||||||
|
|
||||||
|
/* remove the widget from the hash table if it is not drawable */
|
||||||
|
if (!GTK_WIDGET_DRAWABLE (widget))
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GE_IS_PROGRESS_BAR (widget))
|
||||||
|
{
|
||||||
|
gfloat fraction = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget));
|
||||||
|
|
||||||
|
/* stop animation for filled/not filled progress bars */
|
||||||
|
if (fraction <= 0.0 || fraction >= 1.0)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
force_widget_redraw (widget);
|
||||||
|
|
||||||
|
/* stop at stop_time */
|
||||||
|
if (animation_info->stop_time != 0 &&
|
||||||
|
g_timer_elapsed (animation_info->timer, NULL) > animation_info->stop_time)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This gets called by the glib main loop every once in a while. */
|
||||||
|
static gboolean
|
||||||
|
animation_timeout_handler (gpointer data)
|
||||||
|
{
|
||||||
|
/*g_print("** TICK **\n");*/
|
||||||
|
|
||||||
|
/* enter threads as update_animation_info will use gtk/gdk. */
|
||||||
|
gdk_threads_enter ();
|
||||||
|
g_hash_table_foreach_remove (animated_widgets, update_animation_info, NULL);
|
||||||
|
/* leave threads again */
|
||||||
|
gdk_threads_leave ();
|
||||||
|
|
||||||
|
if(g_hash_table_size(animated_widgets)==0)
|
||||||
|
{
|
||||||
|
stop_timer ();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_checkbox_toggle (GtkWidget *widget, gpointer data)
|
||||||
|
{
|
||||||
|
AnimationInfo *animation_info = lookup_animation_info (widget);
|
||||||
|
|
||||||
|
if (animation_info != NULL)
|
||||||
|
{
|
||||||
|
gfloat elapsed = g_timer_elapsed (animation_info->timer, NULL);
|
||||||
|
|
||||||
|
animation_info->start_modifier = elapsed - animation_info->start_modifier;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
add_animation (widget, CHECK_ANIMATION_TIME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_connected_widget_destruction (gpointer data, GObject *widget)
|
||||||
|
{
|
||||||
|
connected_widgets = g_slist_remove (connected_widgets, data);
|
||||||
|
g_free (data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
disconnect_all_signals ()
|
||||||
|
{
|
||||||
|
GSList * item = connected_widgets;
|
||||||
|
while (item != NULL)
|
||||||
|
{
|
||||||
|
SignalInfo *signal_info = (SignalInfo*) item->data;
|
||||||
|
|
||||||
|
g_signal_handler_disconnect (signal_info->widget, signal_info->handler_id);
|
||||||
|
g_object_weak_unref (G_OBJECT (signal_info->widget), on_connected_widget_destruction, signal_info);
|
||||||
|
g_free (signal_info);
|
||||||
|
|
||||||
|
item = g_slist_next (item);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_slist_free (connected_widgets);
|
||||||
|
connected_widgets = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* helper function for clearlooks_animation_connect_checkbox */
|
||||||
|
static gint
|
||||||
|
find_signal_info (gconstpointer signal_info, gconstpointer widget)
|
||||||
|
{
|
||||||
|
if (((SignalInfo*)signal_info)->widget == widget)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* external interface */
|
||||||
|
|
||||||
|
/* adds a progress bar */
|
||||||
|
void
|
||||||
|
clearlooks_animation_progressbar_add (GtkWidget *progressbar)
|
||||||
|
{
|
||||||
|
gdouble fraction = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (progressbar));
|
||||||
|
|
||||||
|
if (fraction < 1.0 && fraction > 0.0)
|
||||||
|
add_animation ((GtkWidget*) progressbar, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* hooks up the signals for check and radio buttons */
|
||||||
|
void
|
||||||
|
clearlooks_animation_connect_checkbox (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
if (GE_IS_CHECK_BUTTON (widget))
|
||||||
|
{
|
||||||
|
if (!g_slist_find_custom (connected_widgets, widget, find_signal_info))
|
||||||
|
{
|
||||||
|
SignalInfo * signal_info = g_new (SignalInfo, 1);
|
||||||
|
|
||||||
|
signal_info->widget = widget;
|
||||||
|
signal_info->handler_id = g_signal_connect ((GObject*)widget, "toggled", G_CALLBACK (on_checkbox_toggle), NULL);
|
||||||
|
|
||||||
|
connected_widgets = g_slist_append (connected_widgets, signal_info);
|
||||||
|
g_object_weak_ref (G_OBJECT (widget), on_connected_widget_destruction, signal_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* returns TRUE if the widget is animated, and FALSE otherwise */
|
||||||
|
gboolean
|
||||||
|
clearlooks_animation_is_animated (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
return lookup_animation_info (widget) != NULL ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* returns the elapsed time for the animation */
|
||||||
|
gdouble
|
||||||
|
clearlooks_animation_elapsed (gpointer data)
|
||||||
|
{
|
||||||
|
AnimationInfo *animation_info = lookup_animation_info (data);
|
||||||
|
|
||||||
|
if (animation_info)
|
||||||
|
return g_timer_elapsed (animation_info->timer, NULL)
|
||||||
|
- animation_info->start_modifier;
|
||||||
|
else
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* cleans up all resources of the animation system */
|
||||||
|
void
|
||||||
|
clearlooks_animation_cleanup ()
|
||||||
|
{
|
||||||
|
disconnect_all_signals ();
|
||||||
|
|
||||||
|
if (animated_widgets != NULL)
|
||||||
|
{
|
||||||
|
g_hash_table_destroy (animated_widgets);
|
||||||
|
animated_widgets = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_timer ();
|
||||||
|
}
|
||||||
|
#else /* !HAVE_ANIMATION */
|
||||||
|
static void clearlooks_animation_dummy_function_so_wall_shuts_up_when_animations_is_disabled()
|
||||||
|
{
|
||||||
|
clearlooks_animation_dummy_function_so_wall_shuts_up_when_animations_is_disabled();
|
||||||
|
}
|
||||||
|
#endif /* HAVE_ANIMATION */
|
||||||
34
libs/clearlooks/animation.h
Normal file
34
libs/clearlooks/animation.h
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
/* Clearlooks Engine
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_ANIMATION
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <ge-support.h>
|
||||||
|
|
||||||
|
#define CL_IS_PROGRESS_BAR(widget) GE_IS_PROGRESS_BAR(widget) && widget->allocation.x != -1 && widget->allocation.y != -1
|
||||||
|
#define ANIMATION_DELAY 100
|
||||||
|
#define CHECK_ANIMATION_TIME 0.5
|
||||||
|
|
||||||
|
GE_INTERNAL void clearlooks_animation_progressbar_add (GtkWidget *progressbar);
|
||||||
|
GE_INTERNAL void clearlooks_animation_connect_checkbox (GtkWidget *widget);
|
||||||
|
GE_INTERNAL gboolean clearlooks_animation_is_animated (GtkWidget *widget);
|
||||||
|
GE_INTERNAL gdouble clearlooks_animation_elapsed (gpointer data);
|
||||||
|
GE_INTERNAL void clearlooks_animation_cleanup ();
|
||||||
|
#endif /* HAVE_ANIMATION */
|
||||||
815
libs/clearlooks/cairo-support.c
Normal file
815
libs/clearlooks/cairo-support.c
Normal file
|
|
@ -0,0 +1,815 @@
|
||||||
|
#include <math.h>
|
||||||
|
#include "general-support.h"
|
||||||
|
#include "cairo-support.h"
|
||||||
|
|
||||||
|
/***********************************************
|
||||||
|
* ge_hsb_from_color -
|
||||||
|
*
|
||||||
|
* Get HSB values from RGB values.
|
||||||
|
*
|
||||||
|
* Modified from Smooth but originated in GTK+
|
||||||
|
***********************************************/
|
||||||
|
void
|
||||||
|
ge_hsb_from_color (const CairoColor *color,
|
||||||
|
gdouble *hue,
|
||||||
|
gdouble *saturation,
|
||||||
|
gdouble *brightness)
|
||||||
|
{
|
||||||
|
gdouble min, max, delta;
|
||||||
|
gdouble red, green, blue;
|
||||||
|
|
||||||
|
red = color->r;
|
||||||
|
green = color->g;
|
||||||
|
blue = color->b;
|
||||||
|
|
||||||
|
if (red > green)
|
||||||
|
{
|
||||||
|
max = MAX(red, blue);
|
||||||
|
min = MIN(green, blue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
max = MAX(green, blue);
|
||||||
|
min = MIN(red, blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
*brightness = (max + min) / 2;
|
||||||
|
|
||||||
|
if (fabs(max - min) < 0.0001)
|
||||||
|
{
|
||||||
|
*hue = 0;
|
||||||
|
*saturation = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (*brightness <= 0.5)
|
||||||
|
*saturation = (max - min) / (max + min);
|
||||||
|
else
|
||||||
|
*saturation = (max - min) / (2 - max - min);
|
||||||
|
|
||||||
|
delta = max -min;
|
||||||
|
|
||||||
|
if (red == max)
|
||||||
|
*hue = (green - blue) / delta;
|
||||||
|
else if (green == max)
|
||||||
|
*hue = 2 + (blue - red) / delta;
|
||||||
|
else if (blue == max)
|
||||||
|
*hue = 4 + (red - green) / delta;
|
||||||
|
|
||||||
|
*hue *= 60;
|
||||||
|
if (*hue < 0.0)
|
||||||
|
*hue += 360;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************
|
||||||
|
* ge_color_from_hsb -
|
||||||
|
*
|
||||||
|
* Get RGB values from HSB values.
|
||||||
|
*
|
||||||
|
* Modified from Smooth but originated in GTK+
|
||||||
|
***********************************************/
|
||||||
|
#define MODULA(number, divisor) (((gint)number % divisor) + (number - (gint)number))
|
||||||
|
void
|
||||||
|
ge_color_from_hsb (gdouble hue,
|
||||||
|
gdouble saturation,
|
||||||
|
gdouble brightness,
|
||||||
|
CairoColor *color)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
gdouble hue_shift[3], color_shift[3];
|
||||||
|
gdouble m1, m2, m3;
|
||||||
|
|
||||||
|
if (!color) return;
|
||||||
|
|
||||||
|
if (brightness <= 0.5)
|
||||||
|
m2 = brightness * (1 + saturation);
|
||||||
|
else
|
||||||
|
m2 = brightness + saturation - brightness * saturation;
|
||||||
|
|
||||||
|
m1 = 2 * brightness - m2;
|
||||||
|
|
||||||
|
hue_shift[0] = hue + 120;
|
||||||
|
hue_shift[1] = hue;
|
||||||
|
hue_shift[2] = hue - 120;
|
||||||
|
|
||||||
|
color_shift[0] = color_shift[1] = color_shift[2] = brightness;
|
||||||
|
|
||||||
|
i = (saturation == 0)?3:0;
|
||||||
|
|
||||||
|
for (; i < 3; i++)
|
||||||
|
{
|
||||||
|
m3 = hue_shift[i];
|
||||||
|
|
||||||
|
if (m3 > 360)
|
||||||
|
m3 = MODULA(m3, 360);
|
||||||
|
else if (m3 < 0)
|
||||||
|
m3 = 360 - MODULA(ABS(m3), 360);
|
||||||
|
|
||||||
|
if (m3 < 60)
|
||||||
|
color_shift[i] = m1 + (m2 - m1) * m3 / 60;
|
||||||
|
else if (m3 < 180)
|
||||||
|
color_shift[i] = m2;
|
||||||
|
else if (m3 < 240)
|
||||||
|
color_shift[i] = m1 + (m2 - m1) * (240 - m3) / 60;
|
||||||
|
else
|
||||||
|
color_shift[i] = m1;
|
||||||
|
}
|
||||||
|
|
||||||
|
color->r = color_shift[0];
|
||||||
|
color->g = color_shift[1];
|
||||||
|
color->b = color_shift[2];
|
||||||
|
color->a = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_gdk_color_to_cairo (const GdkColor *c, CairoColor *cc)
|
||||||
|
{
|
||||||
|
gdouble r, g, b;
|
||||||
|
|
||||||
|
g_return_if_fail (c && cc);
|
||||||
|
|
||||||
|
r = c->red / 65535.0;
|
||||||
|
g = c->green / 65535.0;
|
||||||
|
b = c->blue / 65535.0;
|
||||||
|
|
||||||
|
cc->r = r;
|
||||||
|
cc->g = g;
|
||||||
|
cc->b = b;
|
||||||
|
cc->a = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_cairo_color_to_gtk (const CairoColor *cc, GdkColor *c)
|
||||||
|
{
|
||||||
|
gdouble r, g, b;
|
||||||
|
|
||||||
|
g_return_if_fail (c && cc);
|
||||||
|
|
||||||
|
r = cc->r * 65535.0;
|
||||||
|
g = cc->g * 65535.0;
|
||||||
|
b = cc->b * 65535.0;
|
||||||
|
|
||||||
|
c->red = r;
|
||||||
|
c->green = g;
|
||||||
|
c->blue = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_gtk_style_to_cairo_color_cube (GtkStyle * style, CairoColorCube *cube)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
g_return_if_fail (style && cube);
|
||||||
|
|
||||||
|
for (i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
ge_gdk_color_to_cairo (&style->bg[i], &cube->bg[i]);
|
||||||
|
ge_gdk_color_to_cairo (&style->fg[i], &cube->fg[i]);
|
||||||
|
|
||||||
|
ge_gdk_color_to_cairo (&style->dark[i], &cube->dark[i]);
|
||||||
|
ge_gdk_color_to_cairo (&style->light[i], &cube->light[i]);
|
||||||
|
ge_gdk_color_to_cairo (&style->mid[i], &cube->mid[i]);
|
||||||
|
|
||||||
|
ge_gdk_color_to_cairo (&style->base[i], &cube->base[i]);
|
||||||
|
ge_gdk_color_to_cairo (&style->text[i], &cube->text[i]);
|
||||||
|
ge_gdk_color_to_cairo (&style->text_aa[i], &cube->text_aa[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
cube->black.r = cube->black.g = cube->black.b = 0;
|
||||||
|
cube->black.a = 1;
|
||||||
|
|
||||||
|
cube->white.r = cube->white.g = cube->white.b = 1;
|
||||||
|
cube->white.a = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_shade_color(const CairoColor *base, gdouble shade_ratio, CairoColor *composite)
|
||||||
|
{
|
||||||
|
gdouble hue = 0;
|
||||||
|
gdouble saturation = 0;
|
||||||
|
gdouble brightness = 0;
|
||||||
|
|
||||||
|
g_return_if_fail (base && composite);
|
||||||
|
|
||||||
|
ge_hsb_from_color (base, &hue, &saturation, &brightness);
|
||||||
|
|
||||||
|
brightness = MIN(brightness*shade_ratio, 1.0);
|
||||||
|
brightness = MAX(brightness, 0.0);
|
||||||
|
|
||||||
|
saturation = MIN(saturation*shade_ratio, 1.0);
|
||||||
|
saturation = MAX(saturation, 0.0);
|
||||||
|
|
||||||
|
ge_color_from_hsb (hue, saturation, brightness, composite);
|
||||||
|
composite->a = base->a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_saturate_color (const CairoColor *base, gdouble saturate_level, CairoColor *composite)
|
||||||
|
{
|
||||||
|
gdouble hue = 0;
|
||||||
|
gdouble saturation = 0;
|
||||||
|
gdouble brightness = 0;
|
||||||
|
|
||||||
|
g_return_if_fail (base && composite);
|
||||||
|
|
||||||
|
ge_hsb_from_color (base, &hue, &saturation, &brightness);
|
||||||
|
|
||||||
|
saturation = MIN(saturation*saturate_level, 1.0);
|
||||||
|
saturation = MAX(saturation, 0.0);
|
||||||
|
|
||||||
|
ge_color_from_hsb (hue, saturation, brightness, composite);
|
||||||
|
composite->a = base->a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_mix_color (const CairoColor *color1, const CairoColor *color2,
|
||||||
|
gdouble mix_factor, CairoColor *composite)
|
||||||
|
{
|
||||||
|
g_return_if_fail (color1 && color2 && composite);
|
||||||
|
|
||||||
|
composite->r = color1->r * (1-mix_factor) + color2->r * mix_factor;
|
||||||
|
composite->g = color1->g * (1-mix_factor) + color2->g * mix_factor;
|
||||||
|
composite->b = color1->b * (1-mix_factor) + color2->b * mix_factor;
|
||||||
|
composite->a = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cairo_t *
|
||||||
|
ge_gdk_drawable_to_cairo (GdkDrawable *window, GdkRectangle *area)
|
||||||
|
{
|
||||||
|
cairo_t *cr;
|
||||||
|
|
||||||
|
g_return_val_if_fail (window != NULL, NULL);
|
||||||
|
|
||||||
|
cr = (cairo_t*) gdk_cairo_create (window);
|
||||||
|
cairo_set_line_width (cr, 1.0);
|
||||||
|
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
|
||||||
|
cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
|
||||||
|
|
||||||
|
if (area)
|
||||||
|
{
|
||||||
|
cairo_rectangle (cr, area->x, area->y, area->width, area->height);
|
||||||
|
cairo_clip_preserve (cr);
|
||||||
|
cairo_new_path (cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_cairo_set_color (cairo_t *cr, const CairoColor *color)
|
||||||
|
{
|
||||||
|
g_return_if_fail (cr && color);
|
||||||
|
|
||||||
|
cairo_set_source_rgba (cr, color->r, color->g, color->b, color->a);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_cairo_set_gdk_color_with_alpha (cairo_t *cr, const GdkColor *color, gdouble alpha)
|
||||||
|
{
|
||||||
|
g_return_if_fail (cr && color);
|
||||||
|
|
||||||
|
cairo_set_source_rgba (cr, color->red / 65535.0,
|
||||||
|
color->green / 65535.0,
|
||||||
|
color->blue / 65535.0,
|
||||||
|
alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_cairo_pattern_add_color_stop_color (cairo_pattern_t *pattern,
|
||||||
|
gfloat offset,
|
||||||
|
const CairoColor *color)
|
||||||
|
{
|
||||||
|
g_return_if_fail (pattern && color);
|
||||||
|
|
||||||
|
cairo_pattern_add_color_stop_rgba (pattern, offset, color->r, color->g, color->b, color->a);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_cairo_pattern_add_color_stop_shade(cairo_pattern_t *pattern,
|
||||||
|
gdouble offset,
|
||||||
|
const CairoColor *color,
|
||||||
|
gdouble shade)
|
||||||
|
{
|
||||||
|
CairoColor shaded;
|
||||||
|
|
||||||
|
g_return_if_fail (pattern && color && (shade >= 0) && (shade <= 3));
|
||||||
|
|
||||||
|
shaded = *color;
|
||||||
|
|
||||||
|
if (shade != 1)
|
||||||
|
{
|
||||||
|
ge_shade_color(color, shade, &shaded);
|
||||||
|
}
|
||||||
|
|
||||||
|
ge_cairo_pattern_add_color_stop_color(pattern, offset, &shaded);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function will draw a rounded corner at position x,y. If the radius
|
||||||
|
* is very small (or negative) it will instead just do a line_to.
|
||||||
|
* ge_cairo_rounded_corner assumes clockwise drawing. */
|
||||||
|
void
|
||||||
|
ge_cairo_rounded_corner (cairo_t *cr,
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
double radius,
|
||||||
|
CairoCorners corner)
|
||||||
|
{
|
||||||
|
if (radius < 0.0001)
|
||||||
|
{
|
||||||
|
cairo_line_to (cr, x, y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (corner) {
|
||||||
|
case CR_CORNER_NONE:
|
||||||
|
cairo_line_to (cr, x, y);
|
||||||
|
break;
|
||||||
|
case CR_CORNER_TOPLEFT:
|
||||||
|
cairo_arc (cr, x + radius, y + radius, radius, G_PI, G_PI * 3/2);
|
||||||
|
break;
|
||||||
|
case CR_CORNER_TOPRIGHT:
|
||||||
|
cairo_arc (cr, x - radius, y + radius, radius, G_PI * 3/2, G_PI * 2);
|
||||||
|
break;
|
||||||
|
case CR_CORNER_BOTTOMRIGHT:
|
||||||
|
cairo_arc (cr, x - radius, y - radius, radius, 0, G_PI * 1/2);
|
||||||
|
break;
|
||||||
|
case CR_CORNER_BOTTOMLEFT:
|
||||||
|
cairo_arc (cr, x + radius, y - radius, radius, G_PI * 1/2, G_PI);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* A bitfield and not a sane value ... */
|
||||||
|
g_assert_not_reached ();
|
||||||
|
cairo_line_to (cr, x, y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_cairo_rounded_rectangle (cairo_t *cr,
|
||||||
|
double x, double y, double w, double h,
|
||||||
|
double radius, CairoCorners corners)
|
||||||
|
{
|
||||||
|
g_return_if_fail (cr != NULL);
|
||||||
|
|
||||||
|
if (radius < 0.0001 || corners == CR_CORNER_NONE)
|
||||||
|
{
|
||||||
|
cairo_rectangle (cr, x, y, w, h);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#ifdef DEVELOPMENT
|
||||||
|
if ((corners == CR_CORNER_ALL) && (radius > w / 2.0 || radius > h / 2.0))
|
||||||
|
g_warning ("Radius is too large for width/height in ge_rounded_rectangle.\n");
|
||||||
|
else if (radius > w || radius > h) /* This isn't perfect. Assumes that only one corner is set. */
|
||||||
|
g_warning ("Radius is too large for width/height in ge_rounded_rectangle.\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (corners & CR_CORNER_TOPLEFT)
|
||||||
|
cairo_move_to (cr, x+radius, y);
|
||||||
|
else
|
||||||
|
cairo_move_to (cr, x, y);
|
||||||
|
|
||||||
|
if (corners & CR_CORNER_TOPRIGHT)
|
||||||
|
cairo_arc (cr, x+w-radius, y+radius, radius, G_PI * 1.5, G_PI * 2);
|
||||||
|
else
|
||||||
|
cairo_line_to (cr, x+w, y);
|
||||||
|
|
||||||
|
if (corners & CR_CORNER_BOTTOMRIGHT)
|
||||||
|
cairo_arc (cr, x+w-radius, y+h-radius, radius, 0, G_PI * 0.5);
|
||||||
|
else
|
||||||
|
cairo_line_to (cr, x+w, y+h);
|
||||||
|
|
||||||
|
if (corners & CR_CORNER_BOTTOMLEFT)
|
||||||
|
cairo_arc (cr, x+radius, y+h-radius, radius, G_PI * 0.5, G_PI);
|
||||||
|
else
|
||||||
|
cairo_line_to (cr, x, y+h);
|
||||||
|
|
||||||
|
if (corners & CR_CORNER_TOPLEFT)
|
||||||
|
cairo_arc (cr, x+radius, y+radius, radius, G_PI, G_PI * 1.5);
|
||||||
|
else
|
||||||
|
cairo_line_to (cr, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ge_cairo_stroke_rectangle.
|
||||||
|
*
|
||||||
|
* A simple function to stroke the rectangle { x, y, w, h}.
|
||||||
|
* (This function only exists because of a cairo performance bug that
|
||||||
|
* has been fixed and it may be a good idea to get rid of it again.)
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ge_cairo_stroke_rectangle (cairo_t *cr, double x, double y, double w, double h)
|
||||||
|
{
|
||||||
|
cairo_rectangle (cr, x, y, w, h);
|
||||||
|
cairo_stroke (cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************
|
||||||
|
* ge_cairo_simple_border -
|
||||||
|
*
|
||||||
|
* A simple routine to draw thin squared
|
||||||
|
* borders with a topleft and bottomright color.
|
||||||
|
*
|
||||||
|
* It originated in Smooth-Engine.
|
||||||
|
***********************************************/
|
||||||
|
void
|
||||||
|
ge_cairo_simple_border (cairo_t *cr,
|
||||||
|
const CairoColor * tl, const CairoColor * br,
|
||||||
|
gint x, gint y, gint width, gint height,
|
||||||
|
gboolean topleft_overlap)
|
||||||
|
{
|
||||||
|
gboolean solid_color;
|
||||||
|
|
||||||
|
g_return_if_fail (cr != NULL);
|
||||||
|
g_return_if_fail (tl != NULL);
|
||||||
|
g_return_if_fail (br != NULL);
|
||||||
|
|
||||||
|
|
||||||
|
solid_color = (tl == br) || ((tl->r == br->r) && (tl->g == br->g) && (tl->b == br->b) && (tl->a == br->a));
|
||||||
|
|
||||||
|
topleft_overlap &= !solid_color;
|
||||||
|
|
||||||
|
cairo_save(cr);
|
||||||
|
|
||||||
|
cairo_set_line_width (cr, 1);
|
||||||
|
|
||||||
|
if (topleft_overlap)
|
||||||
|
{
|
||||||
|
ge_cairo_set_color(cr, br);
|
||||||
|
|
||||||
|
cairo_move_to(cr, x + 0.5, y + height - 0.5);
|
||||||
|
cairo_line_to(cr, x + width - 0.5, y + height - 0.5);
|
||||||
|
cairo_line_to(cr, x + width - 0.5, y + 0.5);
|
||||||
|
|
||||||
|
cairo_stroke (cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
ge_cairo_set_color(cr, tl);
|
||||||
|
|
||||||
|
cairo_move_to(cr, x + 0.5, y + height - 0.5);
|
||||||
|
cairo_line_to(cr, x + 0.5, y + 0.5);
|
||||||
|
cairo_line_to(cr, x + width - 0.5, y + 0.5);
|
||||||
|
|
||||||
|
if (!topleft_overlap)
|
||||||
|
{
|
||||||
|
if (!solid_color)
|
||||||
|
{
|
||||||
|
cairo_stroke(cr);
|
||||||
|
ge_cairo_set_color(cr, br);
|
||||||
|
}
|
||||||
|
|
||||||
|
cairo_move_to(cr, x + 0.5, y + height - 0.5);
|
||||||
|
cairo_line_to(cr, x + width - 0.5, y + height - 0.5);
|
||||||
|
cairo_line_to(cr, x + width - 0.5, y + 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
cairo_stroke(cr);
|
||||||
|
|
||||||
|
cairo_restore(cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ge_cairo_polygon (cairo_t *cr,
|
||||||
|
const CairoColor *color,
|
||||||
|
GdkPoint *points,
|
||||||
|
gint npoints)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
cairo_save(cr);
|
||||||
|
|
||||||
|
ge_cairo_set_color(cr, color);
|
||||||
|
cairo_move_to(cr, points[0].x, points[0].y);
|
||||||
|
|
||||||
|
for (i = 1; i < npoints; i++)
|
||||||
|
{
|
||||||
|
if (!((points[i].x == points[i + 1].x) &&
|
||||||
|
(points[i].y == points[i + 1].y)))
|
||||||
|
{
|
||||||
|
cairo_line_to(cr, points[i].x, points[i].y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((points[npoints-1].x != points[0].y) ||
|
||||||
|
(points[npoints-1].y != points[0].y))
|
||||||
|
{
|
||||||
|
cairo_line_to(cr, points[0].x, points[0].y);
|
||||||
|
}
|
||||||
|
|
||||||
|
cairo_fill(cr);
|
||||||
|
|
||||||
|
cairo_restore(cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ge_cairo_line (cairo_t *cr,
|
||||||
|
const CairoColor *color,
|
||||||
|
gint x1,
|
||||||
|
gint y1,
|
||||||
|
gint x2,
|
||||||
|
gint y2)
|
||||||
|
{
|
||||||
|
cairo_save(cr);
|
||||||
|
|
||||||
|
ge_cairo_set_color(cr, color);
|
||||||
|
cairo_set_line_width (cr, 1);
|
||||||
|
|
||||||
|
cairo_move_to(cr, x1 + 0.5, y1 + 0.5);
|
||||||
|
cairo_line_to(cr, x2 + 0.5, y2 + 0.5);
|
||||||
|
|
||||||
|
cairo_stroke(cr);
|
||||||
|
|
||||||
|
cairo_restore(cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_cairo_mirror (cairo_t *cr,
|
||||||
|
CairoMirror mirror,
|
||||||
|
gint *x,
|
||||||
|
gint *y,
|
||||||
|
gint *width,
|
||||||
|
gint *height)
|
||||||
|
{
|
||||||
|
cairo_matrix_t matrix;
|
||||||
|
|
||||||
|
cairo_matrix_init_identity (&matrix);
|
||||||
|
|
||||||
|
cairo_translate (cr, *x, *y);
|
||||||
|
*x = 0;
|
||||||
|
*y = 0;
|
||||||
|
|
||||||
|
if (mirror & CR_MIRROR_HORIZONTAL)
|
||||||
|
{
|
||||||
|
cairo_matrix_scale (&matrix, -1, 1);
|
||||||
|
*x = -*width;
|
||||||
|
}
|
||||||
|
if (mirror & CR_MIRROR_VERTICAL)
|
||||||
|
{
|
||||||
|
cairo_matrix_scale (&matrix, 1, -1);
|
||||||
|
*y = -*height;
|
||||||
|
}
|
||||||
|
|
||||||
|
cairo_transform (cr, &matrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_cairo_exchange_axis (cairo_t *cr,
|
||||||
|
gint *x,
|
||||||
|
gint *y,
|
||||||
|
gint *width,
|
||||||
|
gint *height)
|
||||||
|
{
|
||||||
|
gint tmp;
|
||||||
|
cairo_matrix_t matrix;
|
||||||
|
|
||||||
|
cairo_translate (cr, *x, *y);
|
||||||
|
cairo_matrix_init (&matrix, 0, 1, 1, 0, 0, 0);
|
||||||
|
|
||||||
|
cairo_transform (cr, &matrix);
|
||||||
|
|
||||||
|
/* swap width/height */
|
||||||
|
tmp = *width;
|
||||||
|
*x = 0;
|
||||||
|
*y = 0;
|
||||||
|
*width = *height;
|
||||||
|
*height = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************
|
||||||
|
* ge_cairo_pattern_fill -
|
||||||
|
*
|
||||||
|
* Fill an area with some pattern
|
||||||
|
* Scaling or tiling if needed
|
||||||
|
***********************************************/
|
||||||
|
void
|
||||||
|
ge_cairo_pattern_fill(cairo_t *canvas,
|
||||||
|
CairoPattern *pattern,
|
||||||
|
gint x,
|
||||||
|
gint y,
|
||||||
|
gint width,
|
||||||
|
gint height)
|
||||||
|
{
|
||||||
|
cairo_matrix_t original_matrix, current_matrix;
|
||||||
|
|
||||||
|
if (pattern->operator == CAIRO_OPERATOR_DEST)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cairo_pattern_get_matrix(pattern->handle, &original_matrix);
|
||||||
|
current_matrix = original_matrix;
|
||||||
|
|
||||||
|
if (pattern->scale != GE_DIRECTION_NONE)
|
||||||
|
{
|
||||||
|
gdouble scale_x = 1.0;
|
||||||
|
gdouble scale_y = 1.0;
|
||||||
|
|
||||||
|
if ((pattern->scale == GE_DIRECTION_VERTICAL) || (pattern->scale == GE_DIRECTION_BOTH))
|
||||||
|
{
|
||||||
|
scale_x = 1.0/width;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((pattern->scale == GE_DIRECTION_HORIZONTAL) || (pattern->scale == GE_DIRECTION_BOTH))
|
||||||
|
{
|
||||||
|
scale_y = 1.0/height;
|
||||||
|
}
|
||||||
|
|
||||||
|
cairo_matrix_scale(¤t_matrix, scale_x, scale_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pattern->translate != GE_DIRECTION_NONE)
|
||||||
|
{
|
||||||
|
gdouble translate_x = 0;
|
||||||
|
gdouble translate_y = 0;
|
||||||
|
|
||||||
|
if ((pattern->translate == GE_DIRECTION_VERTICAL) || (pattern->translate == GE_DIRECTION_BOTH))
|
||||||
|
{
|
||||||
|
translate_x = 0.0-x;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((pattern->translate == GE_DIRECTION_HORIZONTAL) || (pattern->translate == GE_DIRECTION_BOTH))
|
||||||
|
{
|
||||||
|
translate_y = 0.0-y;
|
||||||
|
}
|
||||||
|
|
||||||
|
cairo_matrix_translate(¤t_matrix, translate_x, translate_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
cairo_pattern_set_matrix(pattern->handle, ¤t_matrix);
|
||||||
|
|
||||||
|
cairo_save(canvas);
|
||||||
|
|
||||||
|
cairo_set_source(canvas, pattern->handle);
|
||||||
|
cairo_set_operator(canvas, pattern->operator);
|
||||||
|
cairo_rectangle(canvas, x, y, width, height);
|
||||||
|
|
||||||
|
cairo_fill (canvas);
|
||||||
|
|
||||||
|
cairo_restore(canvas);
|
||||||
|
|
||||||
|
cairo_pattern_set_matrix(pattern->handle, &original_matrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************
|
||||||
|
* ge_cairo_color_pattern -
|
||||||
|
*
|
||||||
|
* Create A Solid Color Pattern
|
||||||
|
***********************************************/
|
||||||
|
CairoPattern*
|
||||||
|
ge_cairo_color_pattern(CairoColor *base)
|
||||||
|
{
|
||||||
|
CairoPattern * result = g_new0(CairoPattern, 1);
|
||||||
|
|
||||||
|
#if ((CAIRO_VERSION_MAJOR < 1) || ((CAIRO_VERSION_MAJOR == 1) && (CAIRO_VERSION_MINOR < 2)))
|
||||||
|
result->type = CAIRO_PATTERN_TYPE_SOLID;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
result->scale = GE_DIRECTION_NONE;
|
||||||
|
result->translate = GE_DIRECTION_NONE;
|
||||||
|
|
||||||
|
result->handle = cairo_pattern_create_rgba(base->r,
|
||||||
|
base->g,
|
||||||
|
base->b,
|
||||||
|
base->a);
|
||||||
|
|
||||||
|
result->operator = CAIRO_OPERATOR_SOURCE;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************
|
||||||
|
* ge_cairo_pixbuf_pattern -
|
||||||
|
*
|
||||||
|
* Create A Tiled Pixbuf Pattern
|
||||||
|
***********************************************/
|
||||||
|
CairoPattern*
|
||||||
|
ge_cairo_pixbuf_pattern(GdkPixbuf *pixbuf)
|
||||||
|
{
|
||||||
|
CairoPattern * result = g_new0(CairoPattern, 1);
|
||||||
|
|
||||||
|
cairo_t *canvas;
|
||||||
|
cairo_surface_t * surface;
|
||||||
|
gint width, height;
|
||||||
|
|
||||||
|
#if ((CAIRO_VERSION_MAJOR < 1) || ((CAIRO_VERSION_MAJOR == 1) && (CAIRO_VERSION_MINOR < 2)))
|
||||||
|
result->type = CAIRO_PATTERN_TYPE_SURFACE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
result->scale = GE_DIRECTION_NONE;
|
||||||
|
result->translate = GE_DIRECTION_BOTH;
|
||||||
|
|
||||||
|
width = gdk_pixbuf_get_width(pixbuf);
|
||||||
|
height = gdk_pixbuf_get_height(pixbuf);
|
||||||
|
|
||||||
|
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
|
||||||
|
|
||||||
|
canvas = cairo_create(surface);
|
||||||
|
|
||||||
|
gdk_cairo_set_source_pixbuf (canvas, pixbuf, 0, 0);
|
||||||
|
cairo_rectangle (canvas, 0, 0, width, height);
|
||||||
|
cairo_fill (canvas);
|
||||||
|
cairo_destroy(canvas);
|
||||||
|
|
||||||
|
result->handle = cairo_pattern_create_for_surface (surface);
|
||||||
|
cairo_surface_destroy(surface);
|
||||||
|
|
||||||
|
cairo_pattern_set_extend (result->handle, CAIRO_EXTEND_REPEAT);
|
||||||
|
|
||||||
|
result->operator = CAIRO_OPERATOR_SOURCE;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************
|
||||||
|
* ge_cairo_pixmap_pattern -
|
||||||
|
*
|
||||||
|
* Create A Tiled Pixmap Pattern
|
||||||
|
***********************************************/
|
||||||
|
CairoPattern*
|
||||||
|
ge_cairo_pixmap_pattern(GdkPixmap *pixmap)
|
||||||
|
{
|
||||||
|
CairoPattern * result = NULL;
|
||||||
|
|
||||||
|
GdkPixbuf * pixbuf;
|
||||||
|
gint width, height;
|
||||||
|
|
||||||
|
gdk_drawable_get_size (GDK_DRAWABLE (pixmap), &width, &height);
|
||||||
|
|
||||||
|
pixbuf = gdk_pixbuf_get_from_drawable(NULL, GDK_DRAWABLE (pixmap),
|
||||||
|
gdk_drawable_get_colormap(GDK_DRAWABLE (pixmap)),
|
||||||
|
0, 0, 0, 0, width, height);
|
||||||
|
|
||||||
|
result = ge_cairo_pixbuf_pattern(pixbuf);
|
||||||
|
|
||||||
|
g_object_unref (pixbuf);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************
|
||||||
|
* ge_cairo_linear_shade_gradient_pattern -
|
||||||
|
*
|
||||||
|
* Create A Linear Shade Gradient Pattern
|
||||||
|
* Aka Smooth Shade Gradient, from/to gradient
|
||||||
|
* With End points defined as shades of the
|
||||||
|
* base color
|
||||||
|
***********************************************/
|
||||||
|
CairoPattern *
|
||||||
|
ge_cairo_linear_shade_gradient_pattern(CairoColor *base,
|
||||||
|
gdouble shade1,
|
||||||
|
gdouble shade2,
|
||||||
|
gboolean vertical)
|
||||||
|
{
|
||||||
|
CairoPattern * result = g_new0(CairoPattern, 1);
|
||||||
|
|
||||||
|
#if ((CAIRO_VERSION_MAJOR < 1) || ((CAIRO_VERSION_MAJOR == 1) && (CAIRO_VERSION_MINOR < 2)))
|
||||||
|
result->type = CAIRO_PATTERN_TYPE_LINEAR;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (vertical)
|
||||||
|
{
|
||||||
|
result->scale = GE_DIRECTION_VERTICAL;
|
||||||
|
|
||||||
|
result->handle = cairo_pattern_create_linear(0, 0, 1, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result->scale = GE_DIRECTION_HORIZONTAL;
|
||||||
|
|
||||||
|
result->handle = cairo_pattern_create_linear(0, 0, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
result->translate = GE_DIRECTION_BOTH;
|
||||||
|
result->operator = CAIRO_OPERATOR_SOURCE;
|
||||||
|
|
||||||
|
ge_cairo_pattern_add_color_stop_shade(result->handle, 0, base, shade1);
|
||||||
|
ge_cairo_pattern_add_color_stop_shade(result->handle, 1, base, shade2);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_cairo_pattern_destroy(CairoPattern *pattern)
|
||||||
|
{
|
||||||
|
if (pattern)
|
||||||
|
{
|
||||||
|
if (pattern->handle)
|
||||||
|
cairo_pattern_destroy(pattern->handle);
|
||||||
|
|
||||||
|
g_free(pattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The following function will be called by GTK+ when the module
|
||||||
|
* is loaded and checks to see if we are compatible with the
|
||||||
|
* version of GTK+ that loads us.
|
||||||
|
*/
|
||||||
|
GE_EXPORT const gchar* g_module_check_init (GModule *module);
|
||||||
|
const gchar*
|
||||||
|
g_module_check_init (GModule *module)
|
||||||
|
{
|
||||||
|
return gtk_check_version (GTK_MAJOR_VERSION,
|
||||||
|
GTK_MINOR_VERSION,
|
||||||
|
GTK_MICRO_VERSION - GTK_INTERFACE_AGE);
|
||||||
|
}
|
||||||
118
libs/clearlooks/cairo-support.h
Normal file
118
libs/clearlooks/cairo-support.h
Normal file
|
|
@ -0,0 +1,118 @@
|
||||||
|
/* Helpful functions when dealing with cairo in gtk engines */
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
gdouble r;
|
||||||
|
gdouble g;
|
||||||
|
gdouble b;
|
||||||
|
gdouble a;
|
||||||
|
} CairoColor;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
CairoColor bg[5];
|
||||||
|
CairoColor fg[5];
|
||||||
|
|
||||||
|
CairoColor dark[5];
|
||||||
|
CairoColor light[5];
|
||||||
|
CairoColor mid[5];
|
||||||
|
|
||||||
|
CairoColor base[5];
|
||||||
|
CairoColor text[5];
|
||||||
|
CairoColor text_aa[5];
|
||||||
|
|
||||||
|
CairoColor black;
|
||||||
|
CairoColor white;
|
||||||
|
} CairoColorCube;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CR_CORNER_NONE = 0,
|
||||||
|
CR_CORNER_TOPLEFT = 1,
|
||||||
|
CR_CORNER_TOPRIGHT = 2,
|
||||||
|
CR_CORNER_BOTTOMLEFT = 4,
|
||||||
|
CR_CORNER_BOTTOMRIGHT = 8,
|
||||||
|
CR_CORNER_ALL = 15
|
||||||
|
} CairoCorners;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CR_MIRROR_NONE = 0,
|
||||||
|
CR_MIRROR_HORIZONTAL = 1 << 0,
|
||||||
|
CR_MIRROR_VERTICAL = 1 << 1
|
||||||
|
} CairoMirror;
|
||||||
|
|
||||||
|
/*****************************/
|
||||||
|
/* Pattern Fills */
|
||||||
|
/*****************************/
|
||||||
|
typedef enum {
|
||||||
|
GE_DIRECTION_VERTICAL,
|
||||||
|
GE_DIRECTION_HORIZONTAL,
|
||||||
|
GE_DIRECTION_BOTH,
|
||||||
|
GE_DIRECTION_NONE
|
||||||
|
} GeDirection;
|
||||||
|
|
||||||
|
#if ((CAIRO_VERSION_MAJOR < 1) || ((CAIRO_VERSION_MAJOR == 1) && (CAIRO_VERSION_MINOR < 2)))
|
||||||
|
typedef enum _cairo_pattern_type {
|
||||||
|
CAIRO_PATTERN_TYPE_SOLID,
|
||||||
|
CAIRO_PATTERN_TYPE_SURFACE,
|
||||||
|
CAIRO_PATTERN_TYPE_LINEAR,
|
||||||
|
CAIRO_PATTERN_TYPE_RADIAL
|
||||||
|
} cairo_pattern_type_t;
|
||||||
|
|
||||||
|
# define CAIRO_PATTERN_TYPE(pattern) pattern->type;
|
||||||
|
#else
|
||||||
|
# define CAIRO_PATTERN_TYPE(pattern) cairo_pattern_get_type (pattern->handle);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
#if ((CAIRO_VERSION_MAJOR < 1) || ((CAIRO_VERSION_MAJOR == 1) && (CAIRO_VERSION_MINOR < 2)))
|
||||||
|
cairo_pattern_type_t type;
|
||||||
|
#endif
|
||||||
|
GeDirection scale;
|
||||||
|
GeDirection translate;
|
||||||
|
|
||||||
|
cairo_pattern_t *handle;
|
||||||
|
cairo_operator_t operator;
|
||||||
|
} CairoPattern;
|
||||||
|
|
||||||
|
GE_INTERNAL void ge_hsb_from_color (const CairoColor *color, gdouble *hue, gdouble *saturation, gdouble *brightness);
|
||||||
|
GE_INTERNAL void ge_color_from_hsb (gdouble hue, gdouble saturation, gdouble brightness, CairoColor *color);
|
||||||
|
|
||||||
|
GE_INTERNAL void ge_gdk_color_to_cairo (const GdkColor * gc, CairoColor * cc);
|
||||||
|
GE_INTERNAL void ge_cairo_color_to_gtk (const CairoColor *cc, GdkColor *c);
|
||||||
|
GE_INTERNAL void ge_gtk_style_to_cairo_color_cube (GtkStyle * style, CairoColorCube *cube);
|
||||||
|
|
||||||
|
GE_INTERNAL void ge_shade_color(const CairoColor *base, gdouble shade_ratio, CairoColor *composite);
|
||||||
|
GE_INTERNAL void ge_saturate_color (const CairoColor * base, gdouble saturate_level, CairoColor *composite);
|
||||||
|
GE_INTERNAL void ge_mix_color (const CairoColor *color1, const CairoColor *color2, gdouble mix_factor, CairoColor *composite);
|
||||||
|
|
||||||
|
GE_INTERNAL cairo_t * ge_gdk_drawable_to_cairo (GdkDrawable *window, GdkRectangle *area);
|
||||||
|
GE_INTERNAL void ge_cairo_set_color (cairo_t *cr, const CairoColor *color);
|
||||||
|
GE_INTERNAL void ge_cairo_set_gdk_color_with_alpha (cairo_t *cr, const GdkColor *color, gdouble alpha);
|
||||||
|
GE_INTERNAL void ge_cairo_pattern_add_color_stop_color (cairo_pattern_t *pattern, gfloat offset, const CairoColor *color);
|
||||||
|
GE_INTERNAL void ge_cairo_pattern_add_color_stop_shade (cairo_pattern_t *pattern, gdouble offset, const CairoColor *color, gdouble shade);
|
||||||
|
|
||||||
|
GE_INTERNAL void ge_cairo_rounded_corner (cairo_t *cr, double x, double y, double radius, CairoCorners corner);
|
||||||
|
GE_INTERNAL void ge_cairo_rounded_rectangle (cairo_t *cr, double x, double y, double w, double h, double radius, CairoCorners corners);
|
||||||
|
|
||||||
|
GE_INTERNAL void ge_cairo_stroke_rectangle (cairo_t *cr, double x, double y, double w, double h);
|
||||||
|
GE_INTERNAL void ge_cairo_simple_border (cairo_t *cr, const CairoColor * tl, const CairoColor * br, gint x, gint y, gint width, gint height, gboolean topleft_overlap);
|
||||||
|
|
||||||
|
GE_INTERNAL void ge_cairo_line (cairo_t *cr, const CairoColor *color, gint x1, gint y1, gint x2, gint y2);
|
||||||
|
GE_INTERNAL void ge_cairo_polygon (cairo_t *cr, const CairoColor *color, GdkPoint *points, gint npoints);
|
||||||
|
|
||||||
|
GE_INTERNAL void ge_cairo_mirror (cairo_t *cr, CairoMirror mirror, gint *x, gint *y, gint *width, gint *height);
|
||||||
|
GE_INTERNAL void ge_cairo_exchange_axis (cairo_t *cr, gint *x, gint *y, gint *width, gint *height);
|
||||||
|
|
||||||
|
GE_INTERNAL void ge_cairo_pattern_fill(cairo_t *canvas, CairoPattern *pattern, gint x, gint y, gint width, gint height);
|
||||||
|
|
||||||
|
GE_INTERNAL CairoPattern *ge_cairo_color_pattern(CairoColor *base);
|
||||||
|
GE_INTERNAL CairoPattern *ge_cairo_pixbuf_pattern(GdkPixbuf *pixbuf);
|
||||||
|
GE_INTERNAL CairoPattern *ge_cairo_pixmap_pattern(GdkPixmap *pixmap);
|
||||||
|
GE_INTERNAL CairoPattern *ge_cairo_linear_shade_gradient_pattern(CairoColor *base, gdouble shade1, gdouble shade2, gboolean vertical);
|
||||||
|
GE_INTERNAL void ge_cairo_pattern_destroy(CairoPattern *pattern);
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,159 +1,17 @@
|
||||||
#ifndef CLEARLOOKS_DRAW_H
|
#ifndef CLEARLOOKS_DRAW_H
|
||||||
#define CLEARLOOKS_DRAW_H
|
#define CLEARLOOKS_DRAW_H
|
||||||
|
|
||||||
|
#include "clearlooks_types.h"
|
||||||
|
#include "clearlooks_style.h"
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk/gdk.h>
|
#include <gdk/gdk.h>
|
||||||
|
|
||||||
typedef struct
|
#include <cairo.h>
|
||||||
{
|
|
||||||
GdkColor *from;
|
|
||||||
GdkColor *to;
|
|
||||||
} CLGradient;
|
|
||||||
|
|
||||||
typedef enum
|
GE_INTERNAL void clearlooks_register_style_classic (ClearlooksStyleFunctions *functions);
|
||||||
{
|
GE_INTERNAL void clearlooks_register_style_glossy (ClearlooksStyleFunctions *functions);
|
||||||
CL_GRADIENT_NONE,
|
GE_INTERNAL void clearlooks_register_style_gummy (ClearlooksStyleFunctions *functions);
|
||||||
CL_GRADIENT_HORIZONTAL,
|
GE_INTERNAL void clearlooks_register_style_inverted (ClearlooksStyleFunctions *functions);
|
||||||
CL_GRADIENT_VERTICAL
|
|
||||||
} CLGradientType;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
CLGradient fill_gradient;
|
|
||||||
CLGradient border_gradient;
|
|
||||||
|
|
||||||
CLGradientType gradient_type;
|
|
||||||
|
|
||||||
GdkGC *bordergc;
|
|
||||||
GdkGC *fillgc;
|
|
||||||
|
|
||||||
guint8 corners[4];
|
|
||||||
|
|
||||||
GdkGC *topleft; /* top + left shadow */
|
|
||||||
GdkGC *bottomright; /* bottom + right shadow */
|
|
||||||
|
|
||||||
GdkColor tmp_color; /* used for gradient */
|
|
||||||
} CLRectangle;
|
|
||||||
|
|
||||||
typedef enum /* DON'T CHANGE THE ORDER! */
|
|
||||||
{
|
|
||||||
CL_CORNER_TOPRIGHT,
|
|
||||||
CL_CORNER_BOTTOMRIGHT,
|
|
||||||
CL_CORNER_BOTTOMLEFT,
|
|
||||||
CL_CORNER_TOPLEFT
|
|
||||||
} CLCornerSide;
|
|
||||||
|
|
||||||
typedef enum /* DON'T CHANGE THE ORDER! */
|
|
||||||
{
|
|
||||||
CL_BORDER_TOP,
|
|
||||||
CL_BORDER_RIGHT,
|
|
||||||
CL_BORDER_BOTTOM,
|
|
||||||
CL_BORDER_LEFT
|
|
||||||
} CLBorderType;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
CL_CORNER_NONE = 0,
|
|
||||||
CL_CORNER_NARROW = 1,
|
|
||||||
CL_CORNER_ROUND = 2
|
|
||||||
} CLCornerSharpness;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLRectangle *cl_rectangle_new(GdkGC *fillgc, GdkGC *bordergc,
|
|
||||||
int tl, int tr, int bl, int br);
|
|
||||||
|
|
||||||
void cl_draw_rectangle (GdkWindow *window, GtkWidget *widget, GtkStyle *style,
|
|
||||||
int x, int y, int width, int height, CLRectangle *r);
|
|
||||||
|
|
||||||
void cl_rectangle_set_color (CLGradient *g, GdkColor *color);
|
|
||||||
void cl_rectangle_set_gradient (CLGradient *g, GdkColor *from, GdkColor *to);
|
|
||||||
|
|
||||||
void cl_rectangle_set_button (CLRectangle *r, GtkStyle *style,
|
|
||||||
GtkStateType state_type, gboolean hasdefault, gboolean has_focus,
|
|
||||||
CLBorderType tl, CLBorderType tr,
|
|
||||||
CLBorderType bl, CLBorderType br);
|
|
||||||
|
|
||||||
void cl_rectangle_set_entry (CLRectangle *r, GtkStyle *style,
|
|
||||||
GtkStateType state_type,
|
|
||||||
CLBorderType tl, CLBorderType tr,
|
|
||||||
CLBorderType bl, CLBorderType br,
|
|
||||||
gboolean has_focus);
|
|
||||||
|
|
||||||
void cl_draw_shadow(GdkWindow *window, GtkWidget *widget, GtkStyle *style,
|
|
||||||
int x, int y, int width, int height, CLRectangle *r);
|
|
||||||
|
|
||||||
void cl_rectangle_set_clip_rectangle (CLRectangle *r, GdkRectangle *area);
|
|
||||||
void cl_rectangle_reset_clip_rectangle (CLRectangle *r);
|
|
||||||
|
|
||||||
void cl_set_corner_sharpness (const gchar *detail, GtkWidget *widget, CLRectangle *r);
|
|
||||||
|
|
||||||
|
|
||||||
void cl_rectangle_set_corners (CLRectangle *r, int tl, int tr, int bl, int br);
|
|
||||||
|
|
||||||
void cl_rectangle_init (CLRectangle *r, GdkGC *fillgc, GdkGC *bordergc,
|
|
||||||
int tl, int tr, int bl, int br);
|
|
||||||
|
|
||||||
void cl_rectangle_reset (CLRectangle *r, GtkStyle *style);
|
|
||||||
|
|
||||||
|
|
||||||
GdkPixmap* cl_progressbar_tile_new (GdkDrawable *drawable, GtkWidget *widget,
|
|
||||||
GtkStyle *style, gint height, gint offset);
|
|
||||||
|
|
||||||
void cl_progressbar_fill (GdkDrawable *drawable, GtkWidget *widget,
|
|
||||||
GtkStyle *style, GdkGC *gc,
|
|
||||||
gint x, gint y, gint width, gint height,
|
|
||||||
guint8 offset, GdkRectangle *area);
|
|
||||||
|
|
||||||
GdkColor cl_gc_set_fg_color_shade (GdkGC *gc, GdkColormap *colormap,
|
|
||||||
GdkColor *from, gfloat s);
|
|
||||||
|
|
||||||
void cl_draw_spinbutton(GtkStyle *style, GdkWindow *window,
|
|
||||||
GtkStateType state_type, GtkShadowType shadow_type,
|
|
||||||
GdkRectangle *area,
|
|
||||||
GtkWidget *widget, const gchar *detail,
|
|
||||||
gint x, gint y, gint width, gint height);
|
|
||||||
|
|
||||||
void cl_draw_button(GtkStyle *style, GdkWindow *window,
|
|
||||||
GtkStateType state_type, GtkShadowType shadow_type,
|
|
||||||
GdkRectangle *area,
|
|
||||||
GtkWidget *widget, const gchar *detail,
|
|
||||||
gint x, gint y, gint width, gint height);
|
|
||||||
|
|
||||||
void cl_draw_entry (GtkStyle *style, GdkWindow *window,
|
|
||||||
GtkStateType state_type, GtkShadowType shadow_type,
|
|
||||||
GdkRectangle *area,
|
|
||||||
GtkWidget *widget, const gchar *detail,
|
|
||||||
gint x, gint y, gint width, gint height);
|
|
||||||
|
|
||||||
void cl_draw_combobox_entry (GtkStyle *style, GdkWindow *window,
|
|
||||||
GtkStateType state_type, GtkShadowType shadow_type,
|
|
||||||
GdkRectangle *area,
|
|
||||||
GtkWidget *widget, const gchar *detail,
|
|
||||||
gint x, gint y, gint width, gint height);
|
|
||||||
|
|
||||||
void cl_draw_combobox_button (GtkStyle *style, GdkWindow *window,
|
|
||||||
GtkStateType state_type, GtkShadowType shadow_type,
|
|
||||||
GdkRectangle *area,
|
|
||||||
GtkWidget *widget, const gchar *detail,
|
|
||||||
gint x, gint y, gint width, gint height);
|
|
||||||
|
|
||||||
void cl_draw_menuitem_button (GdkDrawable *window, GtkWidget *widget, GtkStyle *style,
|
|
||||||
GdkRectangle *area, GtkStateType state_type,
|
|
||||||
int x, int y, int wiidth, int height, CLRectangle *r);
|
|
||||||
|
|
||||||
void cl_draw_menuitem_flat (GdkDrawable *window, GtkWidget *widget, GtkStyle *style,
|
|
||||||
GdkRectangle *area, GtkStateType state_type,
|
|
||||||
int x, int y, int wiidth, int height, CLRectangle *r);
|
|
||||||
|
|
||||||
void cl_draw_menuitem_gradient (GdkDrawable *window, GtkWidget *widget, GtkStyle *style,
|
|
||||||
GdkRectangle *area, GtkStateType state_type,
|
|
||||||
int x, int y, int wiidth, int height, CLRectangle *r);
|
|
||||||
|
|
||||||
void cl_draw_treeview_header (GtkStyle *style, GdkWindow *window,
|
|
||||||
GtkStateType state_type, GtkShadowType shadow_type,
|
|
||||||
GdkRectangle *area,
|
|
||||||
GtkWidget *widget, const gchar *detail,
|
|
||||||
gint x, gint y, gint width, gint height);
|
|
||||||
|
|
||||||
#endif /* CLEARLOOKS_DRAW_H */
|
#endif /* CLEARLOOKS_DRAW_H */
|
||||||
|
|
|
||||||
1422
libs/clearlooks/clearlooks_draw_glossy.c
Normal file
1422
libs/clearlooks/clearlooks_draw_glossy.c
Normal file
File diff suppressed because it is too large
Load diff
1524
libs/clearlooks/clearlooks_draw_gummy.c
Normal file
1524
libs/clearlooks/clearlooks_draw_gummy.c
Normal file
File diff suppressed because it is too large
Load diff
1002
libs/clearlooks/clearlooks_draw_inverted.c
Normal file
1002
libs/clearlooks/clearlooks_draw_inverted.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -19,12 +19,18 @@
|
||||||
* Written by Owen Taylor <otaylor@redhat.com>
|
* Written by Owen Taylor <otaylor@redhat.com>
|
||||||
* and by Alexander Larsson <alexl@redhat.com>
|
* and by Alexander Larsson <alexl@redhat.com>
|
||||||
* Modified by Richard Stellingwerff <remenic@gmail.com>
|
* Modified by Richard Stellingwerff <remenic@gmail.com>
|
||||||
|
* Modified by Kulyk Nazar <schamane@myeburg.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "clearlooks_style.h"
|
#include "clearlooks_style.h"
|
||||||
#include "clearlooks_rc_style.h"
|
#include "clearlooks_rc_style.h"
|
||||||
|
|
||||||
|
#include "animation.h"
|
||||||
|
|
||||||
static void clearlooks_rc_style_init (ClearlooksRcStyle *style);
|
static void clearlooks_rc_style_init (ClearlooksRcStyle *style);
|
||||||
|
#ifdef HAVE_ANIMATION
|
||||||
|
static void clearlooks_rc_style_finalize (GObject *object);
|
||||||
|
#endif
|
||||||
static void clearlooks_rc_style_class_init (ClearlooksRcStyleClass *klass);
|
static void clearlooks_rc_style_class_init (ClearlooksRcStyleClass *klass);
|
||||||
static GtkStyle *clearlooks_rc_style_create_style (GtkRcStyle *rc_style);
|
static GtkStyle *clearlooks_rc_style_create_style (GtkRcStyle *rc_style);
|
||||||
static guint clearlooks_rc_style_parse (GtkRcStyle *rc_style,
|
static guint clearlooks_rc_style_parse (GtkRcStyle *rc_style,
|
||||||
|
|
@ -34,56 +40,82 @@ static void clearlooks_rc_style_merge (GtkRcStyle *dest,
|
||||||
GtkRcStyle *src);
|
GtkRcStyle *src);
|
||||||
|
|
||||||
|
|
||||||
static GtkRcStyleClass *parent_class;
|
static GtkRcStyleClass *clearlooks_parent_rc_class;
|
||||||
|
|
||||||
GType clearlooks_type_rc_style = 0;
|
GType clearlooks_type_rc_style = 0;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
TOKEN_SPOTCOLOR = G_TOKEN_LAST + 1,
|
TOKEN_SCROLLBARCOLOR = G_TOKEN_LAST + 1,
|
||||||
TOKEN_CONTRAST,
|
TOKEN_COLORIZESCROLLBAR,
|
||||||
TOKEN_SUNKENMENU,
|
TOKEN_CONTRAST,
|
||||||
TOKEN_PROGRESSBARSTYLE,
|
TOKEN_SUNKENMENU,
|
||||||
TOKEN_MENUBARSTYLE,
|
TOKEN_PROGRESSBARSTYLE,
|
||||||
TOKEN_MENUITEMSTYLE,
|
TOKEN_MENUBARSTYLE,
|
||||||
TOKEN_LISTVIEWITEMSTYLE
|
TOKEN_TOOLBARSTYLE,
|
||||||
|
TOKEN_MENUITEMSTYLE,
|
||||||
|
TOKEN_LISTVIEWITEMSTYLE,
|
||||||
|
TOKEN_ANIMATION,
|
||||||
|
TOKEN_STYLE,
|
||||||
|
TOKEN_RADIUS,
|
||||||
|
|
||||||
|
TOKEN_CLASSIC,
|
||||||
|
TOKEN_GLOSSY,
|
||||||
|
TOKEN_INVERTED,
|
||||||
|
TOKEN_GUMMY,
|
||||||
|
|
||||||
|
TOKEN_TRUE,
|
||||||
|
TOKEN_FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
|
||||||
const gchar *name;
|
|
||||||
guint token;
|
|
||||||
}
|
|
||||||
theme_symbols[] =
|
|
||||||
{
|
{
|
||||||
{ "spotcolor", TOKEN_SPOTCOLOR },
|
const gchar *name;
|
||||||
{ "contrast", TOKEN_CONTRAST },
|
guint token;
|
||||||
{ "sunkenmenubar", TOKEN_SUNKENMENU },
|
}
|
||||||
{ "progressbarstyle", TOKEN_PROGRESSBARSTYLE },
|
clearlooks_gtk2_rc_symbols[] =
|
||||||
{ "menubarstyle", TOKEN_MENUBARSTYLE },
|
{
|
||||||
{ "menuitemstyle", TOKEN_MENUITEMSTYLE },
|
{ "scrollbar_color", TOKEN_SCROLLBARCOLOR },
|
||||||
{ "listviewitemstyle", TOKEN_LISTVIEWITEMSTYLE }
|
{ "colorize_scrollbar", TOKEN_COLORIZESCROLLBAR },
|
||||||
|
{ "contrast", TOKEN_CONTRAST },
|
||||||
|
{ "sunkenmenubar", TOKEN_SUNKENMENU },
|
||||||
|
{ "progressbarstyle", TOKEN_PROGRESSBARSTYLE },
|
||||||
|
{ "menubarstyle", TOKEN_MENUBARSTYLE },
|
||||||
|
{ "toolbarstyle", TOKEN_TOOLBARSTYLE },
|
||||||
|
{ "menuitemstyle", TOKEN_MENUITEMSTYLE },
|
||||||
|
{ "listviewitemstyle", TOKEN_LISTVIEWITEMSTYLE },
|
||||||
|
{ "animation", TOKEN_ANIMATION },
|
||||||
|
{ "style", TOKEN_STYLE },
|
||||||
|
{ "radius", TOKEN_RADIUS },
|
||||||
|
|
||||||
|
{ "CLASSIC", TOKEN_CLASSIC },
|
||||||
|
{ "GLOSSY", TOKEN_GLOSSY },
|
||||||
|
{ "INVERTED", TOKEN_INVERTED },
|
||||||
|
{ "GUMMY", TOKEN_GUMMY },
|
||||||
|
|
||||||
|
{ "TRUE", TOKEN_TRUE },
|
||||||
|
{ "FALSE", TOKEN_FALSE }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
clearlooks_rc_style_register_type (GTypeModule *module)
|
clearlooks_rc_style_register_type (GTypeModule *module)
|
||||||
{
|
{
|
||||||
static const GTypeInfo object_info =
|
static const GTypeInfo object_info =
|
||||||
{
|
{
|
||||||
sizeof (ClearlooksRcStyleClass),
|
sizeof (ClearlooksRcStyleClass),
|
||||||
(GBaseInitFunc) NULL,
|
(GBaseInitFunc) NULL,
|
||||||
(GBaseFinalizeFunc) NULL,
|
(GBaseFinalizeFunc) NULL,
|
||||||
(GClassInitFunc) clearlooks_rc_style_class_init,
|
(GClassInitFunc) clearlooks_rc_style_class_init,
|
||||||
NULL, /* class_finalize */
|
NULL, /* class_finalize */
|
||||||
NULL, /* class_data */
|
NULL, /* class_data */
|
||||||
sizeof (ClearlooksRcStyle),
|
sizeof (ClearlooksRcStyle),
|
||||||
0, /* n_preallocs */
|
0, /* n_preallocs */
|
||||||
(GInstanceInitFunc) clearlooks_rc_style_init,
|
(GInstanceInitFunc) clearlooks_rc_style_init,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
clearlooks_type_rc_style = g_type_module_register_type (module,
|
clearlooks_type_rc_style = g_type_module_register_type (module,
|
||||||
GTK_TYPE_RC_STYLE,
|
GTK_TYPE_RC_STYLE,
|
||||||
"ClearlooksRcStyle",
|
"ClearlooksRcStyle",
|
||||||
&object_info, 0);
|
&object_info, 0);
|
||||||
|
|
@ -92,266 +124,306 @@ clearlooks_rc_style_register_type (GTypeModule *module)
|
||||||
static void
|
static void
|
||||||
clearlooks_rc_style_init (ClearlooksRcStyle *clearlooks_rc)
|
clearlooks_rc_style_init (ClearlooksRcStyle *clearlooks_rc)
|
||||||
{
|
{
|
||||||
clearlooks_rc->has_spot_color = FALSE;
|
clearlooks_rc->style = CL_STYLE_CLASSIC;
|
||||||
clearlooks_rc->contrast = 1.0;
|
|
||||||
clearlooks_rc->sunkenmenubar = 1;
|
clearlooks_rc->flags = 0;
|
||||||
clearlooks_rc->progressbarstyle = 0;
|
|
||||||
clearlooks_rc->menubarstyle = 0;
|
clearlooks_rc->contrast = 1.0;
|
||||||
clearlooks_rc->menuitemstyle = 1;
|
clearlooks_rc->menubarstyle = 0;
|
||||||
clearlooks_rc->listviewitemstyle = 1;
|
clearlooks_rc->toolbarstyle = 0;
|
||||||
|
clearlooks_rc->animation = FALSE;
|
||||||
|
clearlooks_rc->colorize_scrollbar = FALSE;
|
||||||
|
clearlooks_rc->radius = 3.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_ANIMATION
|
||||||
|
static void
|
||||||
|
clearlooks_rc_style_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
/* cleanup all the animation stuff */
|
||||||
|
clearlooks_animation_cleanup ();
|
||||||
|
|
||||||
|
if (G_OBJECT_CLASS (clearlooks_parent_rc_class)->finalize != NULL)
|
||||||
|
G_OBJECT_CLASS (clearlooks_parent_rc_class)->finalize(object);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clearlooks_rc_style_class_init (ClearlooksRcStyleClass *klass)
|
clearlooks_rc_style_class_init (ClearlooksRcStyleClass *klass)
|
||||||
{
|
{
|
||||||
GtkRcStyleClass *rc_style_class = GTK_RC_STYLE_CLASS (klass);
|
GtkRcStyleClass *rc_style_class = GTK_RC_STYLE_CLASS (klass);
|
||||||
|
#ifdef HAVE_ANIMATION
|
||||||
|
GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
|
||||||
|
#endif
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
clearlooks_parent_rc_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
rc_style_class->parse = clearlooks_rc_style_parse;
|
rc_style_class->parse = clearlooks_rc_style_parse;
|
||||||
rc_style_class->create_style = clearlooks_rc_style_create_style;
|
rc_style_class->create_style = clearlooks_rc_style_create_style;
|
||||||
rc_style_class->merge = clearlooks_rc_style_merge;
|
rc_style_class->merge = clearlooks_rc_style_merge;
|
||||||
|
|
||||||
|
#ifdef HAVE_ANIMATION
|
||||||
|
g_object_class->finalize = clearlooks_rc_style_finalize;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
theme_parse_color(GtkSettings *settings,
|
clearlooks_gtk2_rc_parse_boolean (GtkSettings *settings,
|
||||||
|
GScanner *scanner,
|
||||||
|
gboolean *retval)
|
||||||
|
{
|
||||||
|
guint token;
|
||||||
|
token = g_scanner_get_next_token(scanner);
|
||||||
|
|
||||||
|
token = g_scanner_get_next_token(scanner);
|
||||||
|
if (token != G_TOKEN_EQUAL_SIGN)
|
||||||
|
return G_TOKEN_EQUAL_SIGN;
|
||||||
|
|
||||||
|
token = g_scanner_get_next_token(scanner);
|
||||||
|
if (token == TOKEN_TRUE)
|
||||||
|
*retval = TRUE;
|
||||||
|
else if (token == TOKEN_FALSE)
|
||||||
|
*retval = FALSE;
|
||||||
|
else
|
||||||
|
return TOKEN_TRUE;
|
||||||
|
|
||||||
|
return G_TOKEN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static guint
|
||||||
|
clearlooks_gtk2_rc_parse_color(GtkSettings *settings,
|
||||||
GScanner *scanner,
|
GScanner *scanner,
|
||||||
GdkColor *color)
|
GdkColor *color)
|
||||||
{
|
{
|
||||||
guint token;
|
guint token;
|
||||||
|
|
||||||
/* Skip 'blah_color' */
|
/* Skip 'blah_color' */
|
||||||
token = g_scanner_get_next_token(scanner);
|
token = g_scanner_get_next_token(scanner);
|
||||||
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
token = g_scanner_get_next_token(scanner);
|
||||||
if (token != G_TOKEN_EQUAL_SIGN)
|
if (token != G_TOKEN_EQUAL_SIGN)
|
||||||
return G_TOKEN_EQUAL_SIGN;
|
return G_TOKEN_EQUAL_SIGN;
|
||||||
|
|
||||||
return gtk_rc_parse_color (scanner, color);
|
return gtk_rc_parse_color (scanner, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
theme_parse_contrast(GtkSettings *settings,
|
clearlooks_gtk2_rc_parse_double (GtkSettings *settings,
|
||||||
GScanner *scanner,
|
GScanner *scanner,
|
||||||
double *contrast)
|
gdouble *val)
|
||||||
{
|
{
|
||||||
guint token;
|
guint token;
|
||||||
|
|
||||||
/* Skip 'contrast' */
|
/* Skip 'blah' */
|
||||||
token = g_scanner_get_next_token(scanner);
|
token = g_scanner_get_next_token(scanner);
|
||||||
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
token = g_scanner_get_next_token(scanner);
|
||||||
if (token != G_TOKEN_EQUAL_SIGN)
|
if (token != G_TOKEN_EQUAL_SIGN)
|
||||||
return G_TOKEN_EQUAL_SIGN;
|
return G_TOKEN_EQUAL_SIGN;
|
||||||
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
token = g_scanner_get_next_token(scanner);
|
||||||
if (token != G_TOKEN_FLOAT)
|
if (token != G_TOKEN_FLOAT)
|
||||||
return G_TOKEN_FLOAT;
|
return G_TOKEN_FLOAT;
|
||||||
|
|
||||||
*contrast = scanner->value.v_float;
|
*val = scanner->value.v_float;
|
||||||
|
|
||||||
return G_TOKEN_NONE;
|
return G_TOKEN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
theme_parse_sunkenmenubar(GtkSettings *settings,
|
clearlooks_gtk2_rc_parse_int (GtkSettings *settings,
|
||||||
GScanner *scanner,
|
GScanner *scanner,
|
||||||
guint8 *sunken)
|
guint8 *progressbarstyle)
|
||||||
{
|
{
|
||||||
guint token;
|
guint token;
|
||||||
|
|
||||||
/* Skip 'sunkenmenubar' */
|
/* Skip 'sunkenmenubar' */
|
||||||
token = g_scanner_get_next_token(scanner);
|
token = g_scanner_get_next_token(scanner);
|
||||||
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
token = g_scanner_get_next_token(scanner);
|
||||||
if (token != G_TOKEN_EQUAL_SIGN)
|
if (token != G_TOKEN_EQUAL_SIGN)
|
||||||
return G_TOKEN_EQUAL_SIGN;
|
return G_TOKEN_EQUAL_SIGN;
|
||||||
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
token = g_scanner_get_next_token(scanner);
|
||||||
if (token != G_TOKEN_INT)
|
if (token != G_TOKEN_INT)
|
||||||
return G_TOKEN_INT;
|
return G_TOKEN_INT;
|
||||||
|
|
||||||
*sunken = scanner->value.v_int;
|
*progressbarstyle = scanner->value.v_int;
|
||||||
|
|
||||||
return G_TOKEN_NONE;
|
return G_TOKEN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
theme_parse_progressbarstyle(GtkSettings *settings,
|
clearlooks_gtk2_rc_parse_style (GtkSettings *settings,
|
||||||
GScanner *scanner,
|
GScanner *scanner,
|
||||||
guint8 *progressbarstyle)
|
ClearlooksStyles *style)
|
||||||
{
|
{
|
||||||
guint token;
|
guint token;
|
||||||
|
|
||||||
/* Skip 'sunkenmenubar' */
|
g_assert (CL_NUM_STYLES == CL_STYLE_GUMMY + 1); /* so that people don't forget ;-) */
|
||||||
token = g_scanner_get_next_token(scanner);
|
|
||||||
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
/* Skip 'style' */
|
||||||
if (token != G_TOKEN_EQUAL_SIGN)
|
token = g_scanner_get_next_token (scanner);
|
||||||
return G_TOKEN_EQUAL_SIGN;
|
|
||||||
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
token = g_scanner_get_next_token (scanner);
|
||||||
if (token != G_TOKEN_INT)
|
if (token != G_TOKEN_EQUAL_SIGN)
|
||||||
return G_TOKEN_INT;
|
return G_TOKEN_EQUAL_SIGN;
|
||||||
|
|
||||||
*progressbarstyle = scanner->value.v_int;
|
token = g_scanner_get_next_token (scanner);
|
||||||
|
|
||||||
return G_TOKEN_NONE;
|
switch (token)
|
||||||
|
{
|
||||||
|
case TOKEN_CLASSIC:
|
||||||
|
*style = CL_STYLE_CLASSIC;
|
||||||
|
break;
|
||||||
|
case TOKEN_GLOSSY:
|
||||||
|
*style = CL_STYLE_GLOSSY;
|
||||||
|
break;
|
||||||
|
case TOKEN_INVERTED:
|
||||||
|
*style = CL_STYLE_INVERTED;
|
||||||
|
break;
|
||||||
|
case TOKEN_GUMMY:
|
||||||
|
*style = CL_STYLE_GUMMY;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return TOKEN_CLASSIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
return G_TOKEN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
theme_parse_menubarstyle(GtkSettings *settings,
|
clearlooks_gtk2_rc_parse_dummy (GtkSettings *settings,
|
||||||
GScanner *scanner,
|
GScanner *scanner,
|
||||||
guint8 *menubarstyle)
|
gchar *name)
|
||||||
{
|
{
|
||||||
guint token;
|
guint token;
|
||||||
|
|
||||||
/* Skip 'menubarstyle' */
|
/* Skip option */
|
||||||
token = g_scanner_get_next_token(scanner);
|
token = g_scanner_get_next_token (scanner);
|
||||||
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
/* print a warning. Isn't there a way to get the string from the scanner? */
|
||||||
if (token != G_TOKEN_EQUAL_SIGN)
|
g_scanner_warn (scanner, "Clearlooks configuration option \"%s\" is not supported and will be ignored.", name);
|
||||||
return G_TOKEN_EQUAL_SIGN;
|
|
||||||
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
/* equal sign */
|
||||||
if (token != G_TOKEN_INT)
|
token = g_scanner_get_next_token (scanner);
|
||||||
return G_TOKEN_INT;
|
if (token != G_TOKEN_EQUAL_SIGN)
|
||||||
|
return G_TOKEN_EQUAL_SIGN;
|
||||||
|
|
||||||
*menubarstyle = scanner->value.v_int;
|
/* eat whatever comes next */
|
||||||
|
token = g_scanner_get_next_token (scanner);
|
||||||
return G_TOKEN_NONE;
|
|
||||||
|
return G_TOKEN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
|
||||||
theme_parse_menuitemstyle(GtkSettings *settings,
|
|
||||||
GScanner *scanner,
|
|
||||||
guint8 *menuitemstyle)
|
|
||||||
{
|
|
||||||
guint token;
|
|
||||||
|
|
||||||
/* Skip 'sunkenmenubar' */
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
|
||||||
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
|
||||||
if (token != G_TOKEN_EQUAL_SIGN)
|
|
||||||
return G_TOKEN_EQUAL_SIGN;
|
|
||||||
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
|
||||||
if (token != G_TOKEN_INT)
|
|
||||||
return G_TOKEN_INT;
|
|
||||||
|
|
||||||
*menuitemstyle = scanner->value.v_int;
|
|
||||||
|
|
||||||
return G_TOKEN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static guint
|
|
||||||
theme_parse_listviewitemstyle(GtkSettings *settings,
|
|
||||||
GScanner *scanner,
|
|
||||||
guint8 *listviewitemstyle)
|
|
||||||
{
|
|
||||||
guint token;
|
|
||||||
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
|
||||||
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
|
||||||
|
|
||||||
if (token != G_TOKEN_EQUAL_SIGN)
|
|
||||||
return G_TOKEN_EQUAL_SIGN;
|
|
||||||
|
|
||||||
token = g_scanner_get_next_token(scanner);
|
|
||||||
if (token != G_TOKEN_INT)
|
|
||||||
return G_TOKEN_INT;
|
|
||||||
|
|
||||||
*listviewitemstyle = scanner->value.v_int;
|
|
||||||
|
|
||||||
return G_TOKEN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
clearlooks_rc_style_parse (GtkRcStyle *rc_style,
|
clearlooks_rc_style_parse (GtkRcStyle *rc_style,
|
||||||
GtkSettings *settings,
|
GtkSettings *settings,
|
||||||
GScanner *scanner)
|
GScanner *scanner)
|
||||||
|
|
||||||
{
|
{
|
||||||
static GQuark scope_id = 0;
|
static GQuark scope_id = 0;
|
||||||
ClearlooksRcStyle *clearlooks_style = CLEARLOOKS_RC_STYLE (rc_style);
|
ClearlooksRcStyle *clearlooks_style = CLEARLOOKS_RC_STYLE (rc_style);
|
||||||
|
|
||||||
guint old_scope;
|
guint old_scope;
|
||||||
guint token;
|
guint token;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
/* Set up a new scope in this scanner. */
|
|
||||||
|
|
||||||
if (!scope_id)
|
/* Set up a new scope in this scanner. */
|
||||||
scope_id = g_quark_from_string("clearlooks_theme_engine");
|
|
||||||
|
|
||||||
/* If we bail out due to errors, we *don't* reset the scope, so the
|
if (!scope_id)
|
||||||
* error messaging code can make sense of our tokens.
|
scope_id = g_quark_from_string("clearlooks_theme_engine");
|
||||||
*/
|
|
||||||
old_scope = g_scanner_set_scope(scanner, scope_id);
|
|
||||||
|
|
||||||
/* Now check if we already added our symbols to this scope
|
/* If we bail out due to errors, we *don't* reset the scope, so the
|
||||||
* (in some previous call to clearlooks_rc_style_parse for the
|
* error messaging code can make sense of our tokens.
|
||||||
* same scanner.
|
*/
|
||||||
*/
|
old_scope = g_scanner_set_scope(scanner, scope_id);
|
||||||
|
|
||||||
if (!g_scanner_lookup_symbol(scanner, theme_symbols[0].name))
|
/* Now check if we already added our symbols to this scope
|
||||||
{
|
* (in some previous call to clearlooks_rc_style_parse for the
|
||||||
g_scanner_freeze_symbol_table(scanner);
|
* same scanner.
|
||||||
for (i = 0; i < G_N_ELEMENTS (theme_symbols); i++)
|
*/
|
||||||
g_scanner_scope_add_symbol(scanner, scope_id,
|
|
||||||
theme_symbols[i].name,
|
|
||||||
GINT_TO_POINTER(theme_symbols[i].token));
|
|
||||||
g_scanner_thaw_symbol_table(scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We're ready to go, now parse the top level */
|
if (!g_scanner_lookup_symbol(scanner, clearlooks_gtk2_rc_symbols[0].name))
|
||||||
|
|
||||||
token = g_scanner_peek_next_token(scanner);
|
|
||||||
while (token != G_TOKEN_RIGHT_CURLY)
|
|
||||||
{
|
|
||||||
switch (token)
|
|
||||||
{
|
{
|
||||||
case TOKEN_SPOTCOLOR:
|
for (i = 0; i < G_N_ELEMENTS (clearlooks_gtk2_rc_symbols); i++)
|
||||||
token = theme_parse_color(settings, scanner, &clearlooks_style->spot_color);
|
g_scanner_scope_add_symbol(scanner, scope_id,
|
||||||
clearlooks_style->has_spot_color = TRUE;
|
clearlooks_gtk2_rc_symbols[i].name,
|
||||||
break;
|
GINT_TO_POINTER(clearlooks_gtk2_rc_symbols[i].token));
|
||||||
case TOKEN_CONTRAST:
|
|
||||||
token = theme_parse_contrast(settings, scanner, &clearlooks_style->contrast);
|
|
||||||
break;
|
|
||||||
case TOKEN_SUNKENMENU:
|
|
||||||
token = theme_parse_sunkenmenubar(settings, scanner, &clearlooks_style->sunkenmenubar);
|
|
||||||
break;
|
|
||||||
case TOKEN_PROGRESSBARSTYLE:
|
|
||||||
token = theme_parse_progressbarstyle(settings, scanner, &clearlooks_style->progressbarstyle);
|
|
||||||
break;
|
|
||||||
case TOKEN_MENUBARSTYLE:
|
|
||||||
token = theme_parse_menubarstyle(settings, scanner, &clearlooks_style->menubarstyle);
|
|
||||||
break;
|
|
||||||
case TOKEN_MENUITEMSTYLE:
|
|
||||||
token = theme_parse_menuitemstyle(settings, scanner, &clearlooks_style->menuitemstyle);
|
|
||||||
break;
|
|
||||||
case TOKEN_LISTVIEWITEMSTYLE:
|
|
||||||
token = theme_parse_listviewitemstyle(settings, scanner, &clearlooks_style->listviewitemstyle);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_scanner_get_next_token(scanner);
|
|
||||||
token = G_TOKEN_RIGHT_CURLY;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token != G_TOKEN_NONE)
|
/* We're ready to go, now parse the top level */
|
||||||
return token;
|
|
||||||
|
|
||||||
token = g_scanner_peek_next_token(scanner);
|
token = g_scanner_peek_next_token(scanner);
|
||||||
}
|
while (token != G_TOKEN_RIGHT_CURLY)
|
||||||
|
{
|
||||||
|
switch (token)
|
||||||
|
{
|
||||||
|
case TOKEN_SCROLLBARCOLOR:
|
||||||
|
token = clearlooks_gtk2_rc_parse_color (settings, scanner, &clearlooks_style->scrollbar_color);
|
||||||
|
clearlooks_style->flags |= CL_FLAG_SCROLLBAR_COLOR;
|
||||||
|
break;
|
||||||
|
case TOKEN_COLORIZESCROLLBAR:
|
||||||
|
token = clearlooks_gtk2_rc_parse_boolean (settings, scanner, &clearlooks_style->colorize_scrollbar);
|
||||||
|
clearlooks_style->flags |= CL_FLAG_COLORIZE_SCROLLBAR;
|
||||||
|
break;
|
||||||
|
case TOKEN_CONTRAST:
|
||||||
|
token = clearlooks_gtk2_rc_parse_double (settings, scanner, &clearlooks_style->contrast);
|
||||||
|
clearlooks_style->flags |= CL_FLAG_CONTRAST;
|
||||||
|
break;
|
||||||
|
case TOKEN_MENUBARSTYLE:
|
||||||
|
token = clearlooks_gtk2_rc_parse_int (settings, scanner, &clearlooks_style->menubarstyle);
|
||||||
|
clearlooks_style->flags |= CL_FLAG_MENUBARSTYLE;
|
||||||
|
break;
|
||||||
|
case TOKEN_TOOLBARSTYLE:
|
||||||
|
token = clearlooks_gtk2_rc_parse_int (settings, scanner, &clearlooks_style->toolbarstyle);
|
||||||
|
clearlooks_style->flags |= CL_FLAG_TOOLBARSTYLE;
|
||||||
|
break;
|
||||||
|
case TOKEN_ANIMATION:
|
||||||
|
token = clearlooks_gtk2_rc_parse_boolean (settings, scanner, &clearlooks_style->animation);
|
||||||
|
clearlooks_style->flags |= CL_FLAG_ANIMATION;
|
||||||
|
break;
|
||||||
|
case TOKEN_STYLE:
|
||||||
|
token = clearlooks_gtk2_rc_parse_style (settings, scanner, &clearlooks_style->style);
|
||||||
|
clearlooks_style->flags |= CL_FLAG_STYLE;
|
||||||
|
break;
|
||||||
|
case TOKEN_RADIUS:
|
||||||
|
token = clearlooks_gtk2_rc_parse_double (settings, scanner, &clearlooks_style->radius);
|
||||||
|
clearlooks_style->flags |= CL_FLAG_RADIUS;
|
||||||
|
break;
|
||||||
|
|
||||||
g_scanner_get_next_token(scanner);
|
/* stuff to ignore */
|
||||||
|
case TOKEN_SUNKENMENU:
|
||||||
|
token = clearlooks_gtk2_rc_parse_dummy (settings, scanner, "sunkenmenu");
|
||||||
|
break;
|
||||||
|
case TOKEN_PROGRESSBARSTYLE:
|
||||||
|
token = clearlooks_gtk2_rc_parse_dummy (settings, scanner, "progressbarstyle");
|
||||||
|
break;
|
||||||
|
case TOKEN_MENUITEMSTYLE:
|
||||||
|
token = clearlooks_gtk2_rc_parse_dummy (settings, scanner, "menuitemstyle");
|
||||||
|
break;
|
||||||
|
case TOKEN_LISTVIEWITEMSTYLE:
|
||||||
|
token = clearlooks_gtk2_rc_parse_dummy (settings, scanner, "listviewitemstyle");
|
||||||
|
break;
|
||||||
|
|
||||||
g_scanner_set_scope(scanner, old_scope);
|
default:
|
||||||
|
g_scanner_get_next_token(scanner);
|
||||||
|
token = G_TOKEN_RIGHT_CURLY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return G_TOKEN_NONE;
|
if (token != G_TOKEN_NONE)
|
||||||
|
return token;
|
||||||
|
|
||||||
|
token = g_scanner_peek_next_token(scanner);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_scanner_get_next_token(scanner);
|
||||||
|
|
||||||
|
g_scanner_set_scope(scanner, old_scope);
|
||||||
|
|
||||||
|
return G_TOKEN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -359,27 +431,36 @@ clearlooks_rc_style_merge (GtkRcStyle *dest,
|
||||||
GtkRcStyle *src)
|
GtkRcStyle *src)
|
||||||
{
|
{
|
||||||
ClearlooksRcStyle *dest_w, *src_w;
|
ClearlooksRcStyle *dest_w, *src_w;
|
||||||
|
ClearlooksRcFlags flags;
|
||||||
parent_class->merge (dest, src);
|
|
||||||
|
clearlooks_parent_rc_class->merge (dest, src);
|
||||||
|
|
||||||
if (!CLEARLOOKS_IS_RC_STYLE (src))
|
if (!CLEARLOOKS_IS_RC_STYLE (src))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
src_w = CLEARLOOKS_RC_STYLE (src);
|
src_w = CLEARLOOKS_RC_STYLE (src);
|
||||||
dest_w = CLEARLOOKS_RC_STYLE (dest);
|
dest_w = CLEARLOOKS_RC_STYLE (dest);
|
||||||
|
|
||||||
dest_w->contrast = src_w->contrast;
|
|
||||||
dest_w->sunkenmenubar = src_w->sunkenmenubar;
|
|
||||||
dest_w->progressbarstyle = src_w->progressbarstyle;
|
|
||||||
dest_w->menubarstyle = src_w->menubarstyle;
|
|
||||||
dest_w->menuitemstyle = src_w->menuitemstyle;
|
|
||||||
dest_w->listviewitemstyle = src_w->listviewitemstyle;
|
|
||||||
|
|
||||||
if (src_w->has_spot_color)
|
flags = (~dest_w->flags) & src_w->flags;
|
||||||
{
|
|
||||||
dest_w->has_spot_color = TRUE;
|
if (flags & CL_FLAG_STYLE)
|
||||||
dest_w->spot_color = src_w->spot_color;
|
dest_w->style = src_w->style;
|
||||||
}
|
if (flags & CL_FLAG_CONTRAST)
|
||||||
|
dest_w->contrast = src_w->contrast;
|
||||||
|
if (flags & CL_FLAG_MENUBARSTYLE)
|
||||||
|
dest_w->menubarstyle = src_w->menubarstyle;
|
||||||
|
if (flags & CL_FLAG_TOOLBARSTYLE)
|
||||||
|
dest_w->toolbarstyle = src_w->toolbarstyle;
|
||||||
|
if (flags & CL_FLAG_SCROLLBAR_COLOR)
|
||||||
|
dest_w->scrollbar_color = src_w->scrollbar_color;
|
||||||
|
if (flags & CL_FLAG_COLORIZE_SCROLLBAR)
|
||||||
|
dest_w->colorize_scrollbar = src_w->colorize_scrollbar;
|
||||||
|
if (flags & CL_FLAG_ANIMATION)
|
||||||
|
dest_w->animation = src_w->animation;
|
||||||
|
if (flags & CL_FLAG_RADIUS)
|
||||||
|
dest_w->radius = src_w->radius;
|
||||||
|
|
||||||
|
dest_w->flags |= src_w->flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -388,5 +469,5 @@ clearlooks_rc_style_merge (GtkRcStyle *dest,
|
||||||
static GtkStyle *
|
static GtkStyle *
|
||||||
clearlooks_rc_style_create_style (GtkRcStyle *rc_style)
|
clearlooks_rc_style_create_style (GtkRcStyle *rc_style)
|
||||||
{
|
{
|
||||||
return GTK_STYLE (g_object_new (CLEARLOOKS_TYPE_STYLE, NULL));
|
return GTK_STYLE (g_object_new (CLEARLOOKS_TYPE_STYLE, NULL));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,16 @@
|
||||||
* Written by Owen Taylor <otaylor@redhat.com>
|
* Written by Owen Taylor <otaylor@redhat.com>
|
||||||
* and by Alexander Larsson <alexl@redhat.com>
|
* and by Alexander Larsson <alexl@redhat.com>
|
||||||
* Modified by Richard Stellingwerff <remenic@gmail.com>
|
* Modified by Richard Stellingwerff <remenic@gmail.com>
|
||||||
|
* Modified by Kulyk Nazar <schamane@myeburg.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtk/gtkrc.h>
|
#include <gtk/gtkrc.h>
|
||||||
|
#include "clearlooks_types.h"
|
||||||
|
|
||||||
typedef struct _ClearlooksRcStyle ClearlooksRcStyle;
|
typedef struct _ClearlooksRcStyle ClearlooksRcStyle;
|
||||||
typedef struct _ClearlooksRcStyleClass ClearlooksRcStyleClass;
|
typedef struct _ClearlooksRcStyleClass ClearlooksRcStyleClass;
|
||||||
|
|
||||||
extern GType clearlooks_type_rc_style;
|
GE_INTERNAL extern GType clearlooks_type_rc_style;
|
||||||
|
|
||||||
#define CLEARLOOKS_TYPE_RC_STYLE clearlooks_type_rc_style
|
#define CLEARLOOKS_TYPE_RC_STYLE clearlooks_type_rc_style
|
||||||
#define CLEARLOOKS_RC_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), CLEARLOOKS_TYPE_RC_STYLE, ClearlooksRcStyle))
|
#define CLEARLOOKS_RC_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), CLEARLOOKS_TYPE_RC_STYLE, ClearlooksRcStyle))
|
||||||
|
|
@ -35,18 +37,33 @@ extern GType clearlooks_type_rc_style;
|
||||||
#define CLEARLOOKS_IS_RC_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLEARLOOKS_TYPE_RC_STYLE))
|
#define CLEARLOOKS_IS_RC_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLEARLOOKS_TYPE_RC_STYLE))
|
||||||
#define CLEARLOOKS_RC_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLEARLOOKS_TYPE_RC_STYLE, ClearlooksRcStyleClass))
|
#define CLEARLOOKS_RC_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLEARLOOKS_TYPE_RC_STYLE, ClearlooksRcStyleClass))
|
||||||
|
|
||||||
|
/* XXX: needs fixing! */
|
||||||
|
typedef enum {
|
||||||
|
CL_FLAG_STYLE = 1 << 0,
|
||||||
|
CL_FLAG_SCROLLBAR_COLOR = 1 << 1,
|
||||||
|
CL_FLAG_COLORIZE_SCROLLBAR = 1 << 2,
|
||||||
|
CL_FLAG_CONTRAST = 1 << 3,
|
||||||
|
CL_FLAG_MENUBARSTYLE = 1 << 4,
|
||||||
|
CL_FLAG_TOOLBARSTYLE = 1 << 5,
|
||||||
|
CL_FLAG_ANIMATION = 1 << 6,
|
||||||
|
CL_FLAG_RADIUS = 1 << 7
|
||||||
|
} ClearlooksRcFlags;
|
||||||
|
|
||||||
struct _ClearlooksRcStyle
|
struct _ClearlooksRcStyle
|
||||||
{
|
{
|
||||||
GtkRcStyle parent_instance;
|
GtkRcStyle parent_instance;
|
||||||
|
|
||||||
GdkColor spot_color;
|
ClearlooksRcFlags flags;
|
||||||
gboolean has_spot_color;
|
|
||||||
double contrast;
|
ClearlooksStyles style;
|
||||||
guint8 sunkenmenubar;
|
|
||||||
guint8 progressbarstyle;
|
GdkColor scrollbar_color;
|
||||||
guint8 menubarstyle;
|
gboolean colorize_scrollbar;
|
||||||
guint8 menuitemstyle;
|
double contrast;
|
||||||
guint8 listviewitemstyle;
|
guint8 menubarstyle;
|
||||||
|
guint8 toolbarstyle;
|
||||||
|
gboolean animation;
|
||||||
|
double radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ClearlooksRcStyleClass
|
struct _ClearlooksRcStyleClass
|
||||||
|
|
@ -54,4 +71,4 @@ struct _ClearlooksRcStyleClass
|
||||||
GtkRcStyleClass parent_class;
|
GtkRcStyleClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
void clearlooks_rc_style_register_type (GTypeModule *module);
|
GE_INTERNAL void clearlooks_rc_style_register_type (GTypeModule *module);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,6 @@
|
||||||
/* Clearlooks Engine
|
/* Clearlooks Engine
|
||||||
* Copyright (C) 2005 Richard Stellingwerff.
|
* Copyright (C) 2005 Richard Stellingwerff.
|
||||||
|
* Copyright (C) 2006 Benjamin Berg
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
|
@ -22,12 +23,16 @@
|
||||||
*/
|
*/
|
||||||
#include <gtk/gtkstyle.h>
|
#include <gtk/gtkstyle.h>
|
||||||
|
|
||||||
#include "clearlooks_draw.h"
|
#ifndef CLEARLOOKS_STYLE_H
|
||||||
|
#define CLEARLOOKS_STYLE_H
|
||||||
|
|
||||||
|
#include "animation.h"
|
||||||
|
#include "clearlooks_types.h"
|
||||||
|
|
||||||
typedef struct _ClearlooksStyle ClearlooksStyle;
|
typedef struct _ClearlooksStyle ClearlooksStyle;
|
||||||
typedef struct _ClearlooksStyleClass ClearlooksStyleClass;
|
typedef struct _ClearlooksStyleClass ClearlooksStyleClass;
|
||||||
|
|
||||||
extern GType clearlooks_type_style;
|
GE_INTERNAL extern GType clearlooks_type_style;
|
||||||
|
|
||||||
#define CLEARLOOKS_TYPE_STYLE clearlooks_type_style
|
#define CLEARLOOKS_TYPE_STYLE clearlooks_type_style
|
||||||
#define CLEARLOOKS_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), CLEARLOOKS_TYPE_STYLE, ClearlooksStyle))
|
#define CLEARLOOKS_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), CLEARLOOKS_TYPE_STYLE, ClearlooksStyle))
|
||||||
|
|
@ -36,73 +41,30 @@ extern GType clearlooks_type_style;
|
||||||
#define CLEARLOOKS_IS_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLEARLOOKS_TYPE_STYLE))
|
#define CLEARLOOKS_IS_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLEARLOOKS_TYPE_STYLE))
|
||||||
#define CLEARLOOKS_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLEARLOOKS_TYPE_STYLE, ClearlooksStyleClass))
|
#define CLEARLOOKS_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLEARLOOKS_TYPE_STYLE, ClearlooksStyleClass))
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
CL_BORDER_UPPER = 0,
|
|
||||||
CL_BORDER_LOWER,
|
|
||||||
CL_BORDER_UPPER_ACTIVE,
|
|
||||||
CL_BORDER_LOWER_ACTIVE,
|
|
||||||
CL_BORDER_COUNT
|
|
||||||
} ClBorderColorType;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
CL_SCROLLBUTTON_BEGIN = 0,
|
|
||||||
CL_SCROLLBUTTON_END,
|
|
||||||
CL_SCROLLBUTTON_OTHER
|
|
||||||
} ClScrollButtonType;
|
|
||||||
|
|
||||||
struct _ClearlooksStyle
|
struct _ClearlooksStyle
|
||||||
{
|
{
|
||||||
GtkStyle parent_instance;
|
GtkStyle parent_instance;
|
||||||
|
|
||||||
GdkColor shade[9];
|
|
||||||
|
|
||||||
GdkColor spot_color;
|
|
||||||
GdkColor spot1;
|
|
||||||
GdkColor spot2;
|
|
||||||
GdkColor spot3;
|
|
||||||
|
|
||||||
GdkColor border[CL_BORDER_COUNT];
|
|
||||||
|
|
||||||
/* from light to dark */
|
|
||||||
GdkGC *shade_gc[9];
|
|
||||||
GdkGC *border_gc[CL_BORDER_COUNT];
|
|
||||||
|
|
||||||
GdkGC *spot1_gc;
|
|
||||||
GdkGC *spot2_gc;
|
|
||||||
GdkGC *spot3_gc;
|
|
||||||
|
|
||||||
GdkColor inset_light[5];
|
|
||||||
GdkColor inset_dark[5];
|
|
||||||
|
|
||||||
GdkColor button_g1[5];
|
|
||||||
GdkColor button_g2[5];
|
|
||||||
GdkColor button_g3[5];
|
|
||||||
GdkColor button_g4[5];
|
|
||||||
|
|
||||||
GdkColor listview_bg[5];
|
|
||||||
|
|
||||||
GdkPixmap *radio_pixmap_nonactive[5];
|
ClearlooksColors colors;
|
||||||
GdkPixmap *radio_pixmap_active[5];
|
|
||||||
GdkPixmap *radio_pixmap_inconsistent[5];
|
|
||||||
GdkBitmap *radio_pixmap_mask; /* All masks are the same */
|
|
||||||
|
|
||||||
GdkPixmap *check_pixmap_nonactive[5];
|
|
||||||
GdkPixmap *check_pixmap_active[5];
|
|
||||||
GdkPixmap *check_pixmap_inconsistent[5];
|
|
||||||
|
|
||||||
gboolean sunkenmenubar:1;
|
|
||||||
|
|
||||||
guint8 progressbarstyle;
|
ClearlooksStyles style;
|
||||||
|
|
||||||
guint8 menubarstyle;
|
guint8 menubarstyle;
|
||||||
guint8 menuitemstyle;
|
guint8 toolbarstyle;
|
||||||
guint8 listviewitemstyle;
|
GdkColor scrollbar_color;
|
||||||
|
gboolean colorize_scrollbar;
|
||||||
|
gboolean has_scrollbar_color;
|
||||||
|
gboolean animation;
|
||||||
|
gfloat radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ClearlooksStyleClass
|
struct _ClearlooksStyleClass
|
||||||
{
|
{
|
||||||
GtkStyleClass parent_class;
|
GtkStyleClass parent_class;
|
||||||
|
|
||||||
|
ClearlooksStyleFunctions style_functions[CL_NUM_STYLES];
|
||||||
};
|
};
|
||||||
|
|
||||||
void clearlooks_style_register_type (GTypeModule *module);
|
GE_INTERNAL void clearlooks_style_register_type (GTypeModule *module);
|
||||||
|
|
||||||
|
#endif /* CLEARLOOKS_STYLE_H */
|
||||||
|
|
|
||||||
|
|
@ -4,34 +4,20 @@
|
||||||
#include "clearlooks_style.h"
|
#include "clearlooks_style.h"
|
||||||
#include "clearlooks_rc_style.h"
|
#include "clearlooks_rc_style.h"
|
||||||
|
|
||||||
G_MODULE_EXPORT void
|
GE_EXPORT void
|
||||||
theme_init (GTypeModule *module)
|
theme_init (GTypeModule *module)
|
||||||
{
|
{
|
||||||
clearlooks_rc_style_register_type (module);
|
clearlooks_rc_style_register_type (module);
|
||||||
clearlooks_style_register_type (module);
|
clearlooks_style_register_type (module);
|
||||||
printf("theme_init() called from internal clearlooks engine\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
G_MODULE_EXPORT void
|
GE_EXPORT void
|
||||||
theme_exit (void)
|
theme_exit (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
G_MODULE_EXPORT GtkRcStyle *
|
GE_EXPORT GtkRcStyle *
|
||||||
theme_create_rc_style (void)
|
theme_create_rc_style (void)
|
||||||
{
|
{
|
||||||
return GTK_RC_STYLE (g_object_new (CLEARLOOKS_TYPE_RC_STYLE, NULL));
|
return GTK_RC_STYLE (g_object_new (CLEARLOOKS_TYPE_RC_STYLE, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following function will be called by GTK+ when the module
|
|
||||||
* is loaded and checks to see if we are compatible with the
|
|
||||||
* version of GTK+ that loads us.
|
|
||||||
*/
|
|
||||||
G_MODULE_EXPORT const gchar* g_module_check_init (GModule *module);
|
|
||||||
const gchar*
|
|
||||||
g_module_check_init (GModule *module)
|
|
||||||
{
|
|
||||||
return gtk_check_version (GTK_MAJOR_VERSION,
|
|
||||||
GTK_MINOR_VERSION,
|
|
||||||
GTK_MICRO_VERSION - GTK_INTERFACE_AGE);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
455
libs/clearlooks/clearlooks_types.h
Normal file
455
libs/clearlooks/clearlooks_types.h
Normal file
|
|
@ -0,0 +1,455 @@
|
||||||
|
#ifndef CLEARLOOKS_TYPES_H
|
||||||
|
#define CLEARLOOKS_TYPES_H
|
||||||
|
|
||||||
|
#include <ge-support.h>
|
||||||
|
|
||||||
|
typedef unsigned char boolean;
|
||||||
|
typedef unsigned char uint8;
|
||||||
|
typedef struct _ClearlooksStyleFunctions ClearlooksStyleFunctions;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CL_STYLE_CLASSIC = 0,
|
||||||
|
CL_STYLE_GLOSSY = 1,
|
||||||
|
CL_STYLE_INVERTED = 2,
|
||||||
|
CL_STYLE_GUMMY = 3,
|
||||||
|
CL_NUM_STYLES = 4
|
||||||
|
} ClearlooksStyles;
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CL_STATE_NORMAL,
|
||||||
|
CL_STATE_ACTIVE,
|
||||||
|
CL_STATE_SELECTED,
|
||||||
|
CL_STATE_INSENSITIVE
|
||||||
|
} ClearlooksStateType;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CL_JUNCTION_NONE = 0,
|
||||||
|
CL_JUNCTION_BEGIN = 1,
|
||||||
|
CL_JUNCTION_END = 2
|
||||||
|
} ClearlooksJunction;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CL_STEPPER_UNKNOWN = 0,
|
||||||
|
CL_STEPPER_A = 1,
|
||||||
|
CL_STEPPER_B = 2,
|
||||||
|
CL_STEPPER_C = 4,
|
||||||
|
CL_STEPPER_D = 8
|
||||||
|
} ClearlooksStepper;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CL_ORDER_FIRST,
|
||||||
|
CL_ORDER_MIDDLE,
|
||||||
|
CL_ORDER_LAST
|
||||||
|
} ClearlooksOrder;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CL_ORIENTATION_LEFT_TO_RIGHT,
|
||||||
|
CL_ORIENTATION_RIGHT_TO_LEFT,
|
||||||
|
CL_ORIENTATION_BOTTOM_TO_TOP,
|
||||||
|
CL_ORIENTATION_TOP_TO_BOTTOM
|
||||||
|
} ClearlooksOrientation;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CL_GAP_LEFT,
|
||||||
|
CL_GAP_RIGHT,
|
||||||
|
CL_GAP_TOP,
|
||||||
|
CL_GAP_BOTTOM
|
||||||
|
} ClearlooksGapSide;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CL_SHADOW_NONE,
|
||||||
|
CL_SHADOW_IN,
|
||||||
|
CL_SHADOW_OUT,
|
||||||
|
CL_SHADOW_ETCHED_IN,
|
||||||
|
CL_SHADOW_ETCHED_OUT
|
||||||
|
} ClearlooksShadowType;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CL_HANDLE_TOOLBAR,
|
||||||
|
CL_HANDLE_SPLITTER
|
||||||
|
} ClearlooksHandleType;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CL_ARROW_NORMAL,
|
||||||
|
CL_ARROW_COMBO
|
||||||
|
} ClearlooksArrowType;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CL_DIRECTION_UP,
|
||||||
|
CL_DIRECTION_DOWN,
|
||||||
|
CL_DIRECTION_LEFT,
|
||||||
|
CL_DIRECTION_RIGHT
|
||||||
|
} ClearlooksDirection;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CL_PROGRESSBAR_CONTINUOUS,
|
||||||
|
CL_PROGRESSBAR_DISCRETE
|
||||||
|
} ClearlooksProgressBarStyle;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CL_WINDOW_EDGE_NORTH_WEST,
|
||||||
|
CL_WINDOW_EDGE_NORTH,
|
||||||
|
CL_WINDOW_EDGE_NORTH_EAST,
|
||||||
|
CL_WINDOW_EDGE_WEST,
|
||||||
|
CL_WINDOW_EDGE_EAST,
|
||||||
|
CL_WINDOW_EDGE_SOUTH_WEST,
|
||||||
|
CL_WINDOW_EDGE_SOUTH,
|
||||||
|
CL_WINDOW_EDGE_SOUTH_EAST
|
||||||
|
} ClearlooksWindowEdge;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
double x;
|
||||||
|
double y;
|
||||||
|
double width;
|
||||||
|
double height;
|
||||||
|
} ClearlooksRectangle;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
CairoColor fg[5];
|
||||||
|
CairoColor bg[5];
|
||||||
|
CairoColor base[5];
|
||||||
|
CairoColor text[5];
|
||||||
|
|
||||||
|
CairoColor shade[9];
|
||||||
|
CairoColor spot[3];
|
||||||
|
} ClearlooksColors;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
boolean active;
|
||||||
|
boolean prelight;
|
||||||
|
boolean disabled;
|
||||||
|
boolean focus;
|
||||||
|
boolean is_default;
|
||||||
|
boolean ltr;
|
||||||
|
boolean enable_glow;
|
||||||
|
|
||||||
|
gfloat radius;
|
||||||
|
|
||||||
|
ClearlooksStateType state_type;
|
||||||
|
|
||||||
|
uint8 corners;
|
||||||
|
uint8 xthickness;
|
||||||
|
uint8 ythickness;
|
||||||
|
|
||||||
|
CairoColor parentbg;
|
||||||
|
|
||||||
|
ClearlooksStyleFunctions *style_functions;
|
||||||
|
} WidgetParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
boolean lower;
|
||||||
|
boolean horizontal;
|
||||||
|
boolean fill_level;
|
||||||
|
} SliderParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ClearlooksOrientation orientation;
|
||||||
|
boolean pulsing;
|
||||||
|
float value;
|
||||||
|
} ProgressBarParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int linepos;
|
||||||
|
} OptionMenuParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ClearlooksShadowType shadow;
|
||||||
|
ClearlooksGapSide gap_side;
|
||||||
|
int gap_x;
|
||||||
|
int gap_width;
|
||||||
|
const CairoColor *border; /* maybe changes this to some other hint ... */
|
||||||
|
} FrameParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ClearlooksGapSide gap_side;
|
||||||
|
} TabParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
CairoCorners corners;
|
||||||
|
ClearlooksShadowType shadow;
|
||||||
|
} ShadowParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
boolean horizontal;
|
||||||
|
} SeparatorParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ClearlooksOrder order; /* XXX: rename to position */
|
||||||
|
boolean resizable;
|
||||||
|
} ListViewHeaderParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
CairoColor color;
|
||||||
|
ClearlooksJunction junction; /* On which sides the slider junctions */
|
||||||
|
boolean horizontal;
|
||||||
|
boolean has_color;
|
||||||
|
} ScrollBarParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ClearlooksHandleType type;
|
||||||
|
boolean horizontal;
|
||||||
|
} HandleParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ClearlooksStepper stepper; /* Which stepper to draw */
|
||||||
|
} ScrollBarStepperParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ClearlooksWindowEdge edge;
|
||||||
|
} ResizeGripParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int style;
|
||||||
|
} MenuBarParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ClearlooksShadowType shadow_type;
|
||||||
|
boolean in_cell;
|
||||||
|
boolean in_menu;
|
||||||
|
} CheckboxParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ClearlooksArrowType type;
|
||||||
|
ClearlooksDirection direction;
|
||||||
|
} ArrowParameters;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int style;
|
||||||
|
boolean topmost;
|
||||||
|
} ToolbarParameters;
|
||||||
|
|
||||||
|
struct _ClearlooksStyleFunctions
|
||||||
|
{
|
||||||
|
void (*draw_button) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_scale_trough) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const SliderParameters *slider,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_progressbar_trough) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_progressbar_fill) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const ProgressBarParameters *progressbar,
|
||||||
|
int x, int y, int width, int height, gint offset);
|
||||||
|
|
||||||
|
void (*draw_slider_button) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const SliderParameters *slider,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_entry) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_spinbutton) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_spinbutton_down) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_optionmenu) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const OptionMenuParameters *optionmenu,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_inset) (cairo_t *cr,
|
||||||
|
const CairoColor *bg_color,
|
||||||
|
double x, double y, double w, double h,
|
||||||
|
double radius, uint8 corners);
|
||||||
|
|
||||||
|
void (*draw_menubar) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const MenuBarParameters *menubar,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_tab) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const TabParameters *tab,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_frame) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const FrameParameters *frame,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_separator) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const SeparatorParameters *separator,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_menu_item_separator) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const SeparatorParameters *separator,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_list_view_header) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const ListViewHeaderParameters *header,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_toolbar) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const ToolbarParameters *toolbar,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_menuitem) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_menubaritem) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_selected_cell) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_scrollbar_stepper) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const ScrollBarParameters *scrollbar,
|
||||||
|
const ScrollBarStepperParameters *stepper,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_scrollbar_slider) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const ScrollBarParameters *scrollbar,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_scrollbar_trough) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const ScrollBarParameters *scrollbar,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_statusbar) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_menu_frame) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_tooltip) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_handle) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const HandleParameters *handle,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_resize_grip) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const ResizeGripParameters *grip,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_arrow) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const ArrowParameters *arrow,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_checkbox) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const CheckboxParameters *checkbox,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_radiobutton) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
const CheckboxParameters *checkbox,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
/* Style internal functions */
|
||||||
|
/* XXX: Only used by slider_button, inline it? */
|
||||||
|
void (*draw_shadow) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
gfloat radius,
|
||||||
|
int width, int height);
|
||||||
|
|
||||||
|
void (*draw_slider) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors,
|
||||||
|
const WidgetParameters *widget,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void (*draw_gripdots) (cairo_t *cr,
|
||||||
|
const ClearlooksColors *colors, int x, int y,
|
||||||
|
int width, int height, int xr, int yr,
|
||||||
|
float contrast);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define CLEARLOOKS_RECTANGLE_SET(rect, _x, _y, _w, _h) rect.x = _x; \
|
||||||
|
rect.y = _y; \
|
||||||
|
rect.width = _w; \
|
||||||
|
rect.height = _h;
|
||||||
|
|
||||||
|
#endif /* CLEARLOOKS_TYPES_H */
|
||||||
9
libs/clearlooks/ge-support.h
Normal file
9
libs/clearlooks/ge-support.h
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef GE_SUPPORT_H
|
||||||
|
#define GE_SUPPORT_H
|
||||||
|
|
||||||
|
#include "general-support.h"
|
||||||
|
#include "cairo-support.h"
|
||||||
|
#include "widget-information.h"
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* GE_SUPPORT_H */
|
||||||
39
libs/clearlooks/general-support.h
Normal file
39
libs/clearlooks/general-support.h
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
|
||||||
|
#include <gmodule.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
/* macros to make sure that things are sane ... */
|
||||||
|
|
||||||
|
#define CHECK_DETAIL(detail, value) ((detail) && (!strcmp(value, detail)))
|
||||||
|
|
||||||
|
#define CHECK_ARGS \
|
||||||
|
g_return_if_fail (window != NULL); \
|
||||||
|
g_return_if_fail (style != NULL);
|
||||||
|
|
||||||
|
#define SANITIZE_SIZE \
|
||||||
|
g_return_if_fail (width >= -1); \
|
||||||
|
g_return_if_fail (height >= -1); \
|
||||||
|
\
|
||||||
|
if ((width == -1) && (height == -1)) \
|
||||||
|
gdk_drawable_get_size (window, &width, &height); \
|
||||||
|
else if (width == -1) \
|
||||||
|
gdk_drawable_get_size (window, &width, NULL); \
|
||||||
|
else if (height == -1) \
|
||||||
|
gdk_drawable_get_size (window, NULL, &height);
|
||||||
|
|
||||||
|
#define GE_EXPORT G_MODULE_EXPORT
|
||||||
|
#define GE_INTERNAL G_GNUC_INTERNAL
|
||||||
|
|
||||||
|
/* explicitly export with ggc, G_MODULE_EXPORT does not do this, this should
|
||||||
|
* make it possible to compile with -fvisibility=hidden */
|
||||||
|
#ifdef G_HAVE_GNUC_VISIBILITY
|
||||||
|
# undef GE_EXPORT
|
||||||
|
# define GE_EXPORT __attribute__((__visibility__("default")))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
|
||||||
|
# undef GE_EXPORT
|
||||||
|
# undef GE_INTERNAL
|
||||||
|
# define GE_EXPORT __global
|
||||||
|
# define GE_INTERNAL __hidden
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,110 +1,38 @@
|
||||||
|
#ifndef SUPPORT_H
|
||||||
|
#define SUPPORT_H
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* GTK 2.2 compatibility */
|
#include "clearlooks_types.h"
|
||||||
#ifndef GTK_IS_COMBO_BOX_ENTRY
|
|
||||||
#define GTK_IS_COMBO_BOX_ENTRY(x) 0
|
|
||||||
#endif
|
|
||||||
#ifndef GTK_IS_COMBO_BOX
|
|
||||||
#define GTK_IS_COMBO_BOX(x) 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define RADIO_SIZE 13
|
#define RADIO_SIZE 13
|
||||||
#define CHECK_SIZE 13
|
#define CHECK_SIZE 13
|
||||||
|
|
||||||
GtkTextDirection
|
GE_INTERNAL void clearlooks_treeview_get_header_index (GtkTreeView *tv,
|
||||||
get_direction (GtkWidget *widget);
|
GtkWidget *header,
|
||||||
|
gint *column_index,
|
||||||
|
gint *columns,
|
||||||
|
gboolean *resizable);
|
||||||
|
|
||||||
GdkPixbuf *
|
GE_INTERNAL void clearlooks_clist_get_header_index (GtkCList *clist,
|
||||||
generate_bit (unsigned char alpha[],
|
GtkWidget *button,
|
||||||
GdkColor *color,
|
gint *column_index,
|
||||||
double mult);
|
gint *columns);
|
||||||
|
#ifdef DEVELOPMENT
|
||||||
|
#warning clearlooks_get_parent_bg is a bad hack - find out why its needed, and figure out a better way.
|
||||||
|
#endif
|
||||||
|
|
||||||
GdkPixbuf *
|
GE_INTERNAL void clearlooks_get_parent_bg (const GtkWidget *widget,
|
||||||
colorize_bit (unsigned char *bit,
|
CairoColor *color);
|
||||||
unsigned char *alpha,
|
|
||||||
GdkColor *new_color);
|
|
||||||
|
|
||||||
GdkPixmap *
|
GE_INTERNAL ClearlooksStepper clearlooks_scrollbar_get_stepper (GtkWidget *widget,
|
||||||
pixbuf_to_pixmap (GtkStyle *style,
|
GdkRectangle *stepper);
|
||||||
GdkPixbuf *pixbuf,
|
GE_INTERNAL ClearlooksStepper clearlooks_scrollbar_visible_steppers (GtkWidget *widget);
|
||||||
GdkScreen *screen);
|
GE_INTERNAL ClearlooksJunction clearlooks_scrollbar_get_junction (GtkWidget *widget);
|
||||||
|
|
||||||
gboolean
|
GE_INTERNAL void clearlooks_set_toolbar_parameters (ToolbarParameters *toolbar, GtkWidget *widget, GdkWindow *window, gint x, gint y);
|
||||||
sanitize_size (GdkWindow *window,
|
GE_INTERNAL void clearlooks_get_notebook_tab_position (GtkWidget *widget, gboolean *start, gboolean *end);
|
||||||
gint *width,
|
|
||||||
gint *height);
|
|
||||||
|
|
||||||
void
|
#endif /* SUPPORT_H */
|
||||||
rgb_to_hls (gdouble *r,
|
|
||||||
gdouble *g,
|
|
||||||
gdouble *b);
|
|
||||||
|
|
||||||
void
|
|
||||||
hls_to_rgb (gdouble *h,
|
|
||||||
gdouble *l,
|
|
||||||
gdouble *s);
|
|
||||||
|
|
||||||
void
|
|
||||||
shade (GdkColor * a, GdkColor * b, float k);
|
|
||||||
|
|
||||||
void
|
|
||||||
draw_hgradient (GdkDrawable *drawable, GdkGC *gc, GtkStyle *style,
|
|
||||||
int x, int y, int width, int height,
|
|
||||||
GdkColor *top_color, GdkColor *bottom_color);
|
|
||||||
|
|
||||||
void
|
|
||||||
draw_vgradient (GdkDrawable *drawable, GdkGC *gc, GtkStyle *style,
|
|
||||||
int x, int y, int width, int height,
|
|
||||||
GdkColor *left_color, GdkColor *right_color);
|
|
||||||
|
|
||||||
void
|
|
||||||
arrow_draw_hline (GdkWindow *window,
|
|
||||||
GdkGC *gc,
|
|
||||||
int x1,
|
|
||||||
int x2,
|
|
||||||
int y,
|
|
||||||
gboolean last);
|
|
||||||
|
|
||||||
void
|
|
||||||
arrow_draw_vline (GdkWindow *window,
|
|
||||||
GdkGC *gc,
|
|
||||||
int y1,
|
|
||||||
int y2,
|
|
||||||
int x,
|
|
||||||
gboolean last);
|
|
||||||
|
|
||||||
void
|
|
||||||
draw_arrow (GdkWindow *window,
|
|
||||||
GdkGC *gc,
|
|
||||||
GdkRectangle *area,
|
|
||||||
GtkArrowType arrow_type,
|
|
||||||
gint x,
|
|
||||||
gint y,
|
|
||||||
gint width,
|
|
||||||
gint height);
|
|
||||||
|
|
||||||
void
|
|
||||||
calculate_arrow_geometry (GtkArrowType arrow_type,
|
|
||||||
gint *x,
|
|
||||||
gint *y,
|
|
||||||
gint *width,
|
|
||||||
gint *height);
|
|
||||||
|
|
||||||
GtkWidget *special_get_ancestor(GtkWidget * widget,
|
|
||||||
GType widget_type);
|
|
||||||
|
|
||||||
void blend (GdkColormap *colormap,
|
|
||||||
GdkColor *a, GdkColor *b, GdkColor *c, int alpha);
|
|
||||||
|
|
||||||
GtkWidget *get_parent_window (GtkWidget *widget);
|
|
||||||
|
|
||||||
GdkColor *get_parent_bgcolor (GtkWidget *widget);
|
|
||||||
|
|
||||||
gboolean is_combo_box (GtkWidget * widget);
|
|
||||||
|
|
||||||
GtkWidget *find_combo_box_widget (GtkWidget * widget);
|
|
||||||
|
|
||||||
void gtk_clist_get_header_index (GtkCList *clist, GtkWidget *button,
|
|
||||||
gint *column_index, gint *columns);
|
|
||||||
|
|
|
||||||
312
libs/clearlooks/widget-information.c
Normal file
312
libs/clearlooks/widget-information.c
Normal file
|
|
@ -0,0 +1,312 @@
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "general-support.h"
|
||||||
|
#include "widget-information.h"
|
||||||
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* Widget Type Lookups/Macros
|
||||||
|
|
||||||
|
Based on/modified from functions in
|
||||||
|
Smooth-Engine.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
ge_object_is_a (const GObject * object, const gchar * type_name)
|
||||||
|
{
|
||||||
|
gboolean result = FALSE;
|
||||||
|
|
||||||
|
if ((object))
|
||||||
|
{
|
||||||
|
GType tmp = g_type_from_name (type_name);
|
||||||
|
|
||||||
|
if (tmp)
|
||||||
|
result = g_type_check_instance_is_a ((GTypeInstance *) object, tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ge_is_combo_box_entry (GtkWidget * widget)
|
||||||
|
{
|
||||||
|
gboolean result = FALSE;
|
||||||
|
|
||||||
|
if ((widget) && (widget->parent))
|
||||||
|
{
|
||||||
|
if (GE_IS_COMBO_BOX_ENTRY (widget->parent))
|
||||||
|
result = TRUE;
|
||||||
|
else
|
||||||
|
result = ge_is_combo_box_entry (widget->parent);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
ge_combo_box_is_using_list (GtkWidget * widget)
|
||||||
|
{
|
||||||
|
gboolean result = FALSE;
|
||||||
|
|
||||||
|
if (GE_IS_COMBO_BOX (widget))
|
||||||
|
{
|
||||||
|
gboolean *tmp = NULL;
|
||||||
|
|
||||||
|
gtk_widget_style_get (widget, "appears-as-list", &result, NULL);
|
||||||
|
|
||||||
|
if (tmp)
|
||||||
|
result = *tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ge_is_combo_box (GtkWidget * widget, gboolean as_list)
|
||||||
|
{
|
||||||
|
gboolean result = FALSE;
|
||||||
|
|
||||||
|
if ((widget) && (widget->parent))
|
||||||
|
{
|
||||||
|
if (GE_IS_COMBO_BOX (widget->parent))
|
||||||
|
{
|
||||||
|
if (as_list)
|
||||||
|
result = (ge_combo_box_is_using_list(widget->parent));
|
||||||
|
else
|
||||||
|
result = (!ge_combo_box_is_using_list(widget->parent));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
result = ge_is_combo_box (widget->parent, as_list);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ge_is_combo (GtkWidget * widget)
|
||||||
|
{
|
||||||
|
gboolean result = FALSE;
|
||||||
|
|
||||||
|
if ((widget) && (widget->parent))
|
||||||
|
{
|
||||||
|
if (GE_IS_COMBO (widget->parent))
|
||||||
|
result = TRUE;
|
||||||
|
else
|
||||||
|
result = ge_is_combo (widget->parent);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ge_is_in_combo_box (GtkWidget * widget)
|
||||||
|
{
|
||||||
|
return ((ge_is_combo (widget) || ge_is_combo_box (widget, TRUE) || ge_is_combo_box_entry (widget)));
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ge_is_toolbar_item (GtkWidget * widget)
|
||||||
|
{
|
||||||
|
gboolean result = FALSE;
|
||||||
|
|
||||||
|
if ((widget) && (widget->parent)) {
|
||||||
|
if ((GE_IS_BONOBO_TOOLBAR (widget->parent))
|
||||||
|
|| (GE_IS_BONOBO_DOCK_ITEM (widget->parent))
|
||||||
|
|| (GE_IS_EGG_TOOLBAR (widget->parent))
|
||||||
|
|| (GE_IS_TOOLBAR (widget->parent))
|
||||||
|
|| (GE_IS_HANDLE_BOX (widget->parent)))
|
||||||
|
result = TRUE;
|
||||||
|
else
|
||||||
|
result = ge_is_toolbar_item (widget->parent);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ge_is_panel_widget_item (GtkWidget * widget)
|
||||||
|
{
|
||||||
|
gboolean result = FALSE;
|
||||||
|
|
||||||
|
if ((widget) && (widget->parent))
|
||||||
|
{
|
||||||
|
if (GE_IS_PANEL_WIDGET (widget->parent))
|
||||||
|
result = TRUE;
|
||||||
|
else
|
||||||
|
result = ge_is_panel_widget_item (widget->parent);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ge_is_bonobo_dock_item (GtkWidget * widget)
|
||||||
|
{
|
||||||
|
gboolean result = FALSE;
|
||||||
|
|
||||||
|
if ((widget))
|
||||||
|
{
|
||||||
|
if (GE_IS_BONOBO_DOCK_ITEM(widget) || GE_IS_BONOBO_DOCK_ITEM (widget->parent))
|
||||||
|
result = TRUE;
|
||||||
|
else if (GE_IS_BOX(widget) || GE_IS_BOX(widget->parent))
|
||||||
|
{
|
||||||
|
GtkContainer *box = GE_IS_BOX(widget)?GTK_CONTAINER(widget):GTK_CONTAINER(widget->parent);
|
||||||
|
GList *children = NULL, *child = NULL;
|
||||||
|
|
||||||
|
children = gtk_container_get_children(box);
|
||||||
|
|
||||||
|
for (child = g_list_first(children); child; child = g_list_next(child))
|
||||||
|
{
|
||||||
|
if (GE_IS_BONOBO_DOCK_ITEM_GRIP(child->data))
|
||||||
|
{
|
||||||
|
result = TRUE;
|
||||||
|
child = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (children)
|
||||||
|
g_list_free(children);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
ge_find_combo_box_entry_widget (GtkWidget * widget)
|
||||||
|
{
|
||||||
|
GtkWidget *result = NULL;
|
||||||
|
|
||||||
|
if (widget)
|
||||||
|
{
|
||||||
|
if (GE_IS_COMBO_BOX_ENTRY (widget))
|
||||||
|
result = widget;
|
||||||
|
else
|
||||||
|
result = ge_find_combo_box_entry_widget (widget->parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
ge_find_combo_box_widget (GtkWidget * widget, gboolean as_list)
|
||||||
|
{
|
||||||
|
GtkWidget *result = NULL;
|
||||||
|
|
||||||
|
if (widget)
|
||||||
|
{
|
||||||
|
if (GE_IS_COMBO_BOX (widget))
|
||||||
|
{
|
||||||
|
if (as_list)
|
||||||
|
result = (ge_combo_box_is_using_list(widget))?widget:NULL;
|
||||||
|
else
|
||||||
|
result = (!ge_combo_box_is_using_list(widget))?widget:NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
result = ge_find_combo_box_widget (widget->parent, as_list);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
ge_find_combo_widget (GtkWidget * widget)
|
||||||
|
{
|
||||||
|
GtkWidget *result = NULL;
|
||||||
|
|
||||||
|
if (widget)
|
||||||
|
{
|
||||||
|
if (GE_IS_COMBO (widget))
|
||||||
|
result = widget;
|
||||||
|
else
|
||||||
|
result = ge_find_combo_widget(widget->parent);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget*
|
||||||
|
ge_find_combo_box_widget_parent (GtkWidget * widget)
|
||||||
|
{
|
||||||
|
GtkWidget *result = NULL;
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
result = ge_find_combo_widget(widget);
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
result = ge_find_combo_box_widget(widget, TRUE);
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
result = ge_find_combo_box_entry_widget(widget);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************
|
||||||
|
* option_menu_get_props -
|
||||||
|
*
|
||||||
|
* Find Option Menu Size and Spacing
|
||||||
|
*
|
||||||
|
* Taken from Smooth
|
||||||
|
***********************************************/
|
||||||
|
void
|
||||||
|
ge_option_menu_get_props (GtkWidget * widget,
|
||||||
|
GtkRequisition * indicator_size,
|
||||||
|
GtkBorder * indicator_spacing)
|
||||||
|
{
|
||||||
|
GtkRequisition default_size = { 9, 5 };
|
||||||
|
GtkBorder default_spacing = { 7, 5, 2, 2 };
|
||||||
|
GtkRequisition *tmp_size = NULL;
|
||||||
|
GtkBorder *tmp_spacing = NULL;
|
||||||
|
|
||||||
|
if ((widget) && GE_IS_OPTION_MENU(widget))
|
||||||
|
gtk_widget_style_get (widget,
|
||||||
|
"indicator_size", &tmp_size,
|
||||||
|
"indicator_spacing", &tmp_spacing, NULL);
|
||||||
|
|
||||||
|
if (tmp_size)
|
||||||
|
{
|
||||||
|
*indicator_size = *tmp_size;
|
||||||
|
gtk_requisition_free (tmp_size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*indicator_size = default_size;
|
||||||
|
|
||||||
|
if (tmp_spacing)
|
||||||
|
{
|
||||||
|
*indicator_spacing = *tmp_spacing;
|
||||||
|
gtk_border_free (tmp_spacing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*indicator_spacing = default_spacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ge_button_get_default_border (GtkWidget *widget,
|
||||||
|
GtkBorder *border)
|
||||||
|
{
|
||||||
|
GtkBorder default_border = {1, 1, 1, 1};
|
||||||
|
GtkBorder *tmp_border = NULL;
|
||||||
|
|
||||||
|
if (widget && GE_IS_BUTTON (widget))
|
||||||
|
gtk_widget_style_get (widget, "default-border", &tmp_border, NULL);
|
||||||
|
|
||||||
|
if (tmp_border)
|
||||||
|
{
|
||||||
|
*border = *tmp_border;
|
||||||
|
gtk_border_free (tmp_border);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*border = default_border;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ge_widget_is_ltr (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GtkTextDirection dir = GTK_TEXT_DIR_NONE;
|
||||||
|
|
||||||
|
if (GE_IS_WIDGET (widget))
|
||||||
|
dir = gtk_widget_get_direction (widget);
|
||||||
|
|
||||||
|
if (dir == GTK_TEXT_DIR_NONE)
|
||||||
|
dir = gtk_widget_get_default_direction ();
|
||||||
|
|
||||||
|
if (dir == GTK_TEXT_DIR_RTL)
|
||||||
|
return FALSE;
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
99
libs/clearlooks/widget-information.h
Normal file
99
libs/clearlooks/widget-information.h
Normal file
|
|
@ -0,0 +1,99 @@
|
||||||
|
|
||||||
|
/* Object Type Lookups/Macros
|
||||||
|
|
||||||
|
Based on/modified from functions in
|
||||||
|
Smooth-Engine.
|
||||||
|
*/
|
||||||
|
#define GE_IS_WIDGET(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkWidget"))
|
||||||
|
#define GE_IS_CONTAINER(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkContainer"))
|
||||||
|
#define GE_IS_BIN(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkBin"))
|
||||||
|
|
||||||
|
#define GE_IS_ARROW(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkArrow"))
|
||||||
|
|
||||||
|
#define GE_IS_SEPARATOR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkSeparator"))
|
||||||
|
#define GE_IS_VSEPARATOR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkVSeparator"))
|
||||||
|
#define GE_IS_HSEPARATOR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkHSeparator"))
|
||||||
|
|
||||||
|
#define GE_IS_HANDLE_BOX(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkHandleBox"))
|
||||||
|
#define GE_IS_HANDLE_BOX_ITEM(object) ((object) && GE_IS_HANDLE_BOX(object->parent))
|
||||||
|
#define GE_IS_BONOBO_DOCK_ITEM(object) ((object) && ge_object_is_a ((GObject*)(object), "BonoboDockItem"))
|
||||||
|
#define GE_IS_BONOBO_DOCK_ITEM_GRIP(object) ((object) && ge_object_is_a ((GObject*)(object), "BonoboDockItemGrip"))
|
||||||
|
#define GE_IS_BONOBO_TOOLBAR(object) ((object) && ge_object_is_a ((GObject*)(object), "BonoboUIToolbar"))
|
||||||
|
#define GE_IS_EGG_TOOLBAR(object) ((object) && ge_object_is_a ((GObject*)(object), "Toolbar"))
|
||||||
|
#define GE_IS_TOOLBAR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkToolbar"))
|
||||||
|
#define GE_IS_PANEL_WIDGET(object) ((object) && (ge_object_is_a ((GObject*)(object), "PanelWidget") || ge_object_is_a ((GObject*)(object), "PanelApplet")))
|
||||||
|
|
||||||
|
#define GE_IS_COMBO_BOX_ENTRY(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkComboBoxEntry"))
|
||||||
|
#define GE_IS_COMBO_BOX(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkComboBox"))
|
||||||
|
#define GE_IS_COMBO(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkCombo"))
|
||||||
|
#define GE_IS_OPTION_MENU(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkOptionMenu"))
|
||||||
|
|
||||||
|
#define GE_IS_TOGGLE_BUTTON(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkToggleButton"))
|
||||||
|
#define GE_IS_CHECK_BUTTON(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkCheckButton"))
|
||||||
|
#define GE_IS_SPIN_BUTTON(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkSpinButton"))
|
||||||
|
|
||||||
|
#define GE_IS_STATUSBAR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkStatusbar"))
|
||||||
|
#define GE_IS_PROGRESS_BAR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkProgressBar"))
|
||||||
|
|
||||||
|
#define GE_IS_MENU_SHELL(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkMenuShell"))
|
||||||
|
#define GE_IS_MENU(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkMenu"))
|
||||||
|
#define GE_IS_MENU_BAR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkMenuBar"))
|
||||||
|
#define GE_IS_MENU_ITEM(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkMenuItem"))
|
||||||
|
|
||||||
|
#define GE_IS_CHECK_MENU_ITEM(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkCheckMenuItem"))
|
||||||
|
|
||||||
|
#define GE_IS_RANGE(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkRange"))
|
||||||
|
|
||||||
|
#define GE_IS_SCROLLBAR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkScrollbar"))
|
||||||
|
#define GE_IS_VSCROLLBAR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkVScrollbar"))
|
||||||
|
#define GE_IS_HSCROLLBAR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkHScrollbar"))
|
||||||
|
|
||||||
|
#define GE_IS_SCALE(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkScale"))
|
||||||
|
#define GE_IS_VSCALE(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkVScale"))
|
||||||
|
#define GE_IS_HSCALE(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkHScale"))
|
||||||
|
|
||||||
|
#define GE_IS_PANED(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkPaned"))
|
||||||
|
#define GE_IS_VPANED(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkVPaned"))
|
||||||
|
#define GE_IS_HPANED(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkHPaned"))
|
||||||
|
|
||||||
|
#define GE_IS_BOX(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkBox"))
|
||||||
|
#define GE_IS_VBOX(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkVBox"))
|
||||||
|
#define GE_IS_HBOX(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkHBox"))
|
||||||
|
|
||||||
|
#define GE_IS_CLIST(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkCList"))
|
||||||
|
#define GE_IS_TREE_VIEW(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkTreeView"))
|
||||||
|
#define GE_IS_ENTRY(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkEntry"))
|
||||||
|
#define GE_IS_BUTTON(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkButton"))
|
||||||
|
#define GE_IS_FIXED(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkFixed"))
|
||||||
|
|
||||||
|
#define TOGGLE_BUTTON(object) (GE_IS_TOGGLE_BUTTON(object)?(GtkToggleButton *)object:NULL)
|
||||||
|
|
||||||
|
#define GE_IS_NOTEBOOK(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkNotebook"))
|
||||||
|
#define GE_IS_CELL_RENDERER_TOGGLE(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkCellRendererToggle"))
|
||||||
|
|
||||||
|
#define GE_WIDGET_HAS_DEFAULT(object) ((object) && GE_IS_WIDGET(object) && GTK_WIDGET_HAS_DEFAULT(object))
|
||||||
|
|
||||||
|
GE_INTERNAL gboolean ge_object_is_a (const GObject * object, const gchar * type_name);
|
||||||
|
|
||||||
|
GE_INTERNAL gboolean ge_is_combo_box_entry (GtkWidget * widget);
|
||||||
|
GE_INTERNAL gboolean ge_is_combo_box (GtkWidget * widget, gboolean as_list);
|
||||||
|
GE_INTERNAL gboolean ge_is_combo (GtkWidget * widget);
|
||||||
|
GE_INTERNAL gboolean ge_is_in_combo_box (GtkWidget * widget);
|
||||||
|
|
||||||
|
GE_INTERNAL gboolean ge_is_toolbar_item (GtkWidget * widget);
|
||||||
|
|
||||||
|
GE_INTERNAL gboolean ge_is_panel_widget_item (GtkWidget * widget);
|
||||||
|
|
||||||
|
GE_INTERNAL gboolean ge_is_bonobo_dock_item (GtkWidget * widget);
|
||||||
|
|
||||||
|
GE_INTERNAL GtkWidget *ge_find_combo_box_widget_parent (GtkWidget * widget);
|
||||||
|
|
||||||
|
GE_INTERNAL void ge_option_menu_get_props (GtkWidget * widget,
|
||||||
|
GtkRequisition * indicator_size,
|
||||||
|
GtkBorder * indicator_spacing);
|
||||||
|
|
||||||
|
GE_INTERNAL void ge_button_get_default_border (GtkWidget *widget,
|
||||||
|
GtkBorder *border);
|
||||||
|
|
||||||
|
GE_INTERNAL gboolean ge_widget_is_ltr (GtkWidget *widget);
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue