summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7ec336f)
raw | patch | inline | side by side (parent: 7ec336f)
author | joncruz <joncruz@users.sourceforge.net> | |
Fri, 7 Apr 2006 08:55:50 +0000 (08:55 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Fri, 7 Apr 2006 08:55:50 +0000 (08:55 +0000) |
ChangeLog | patch | blob | history | |
src/widgets/desktop-widget.cpp | patch | blob | history | |
src/widgets/icon.cpp | patch | blob | history | |
src/widgets/layer-selector.cpp | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index de6d422555559258e8f4047708660fd2c8ec8bf4..54136d6f5a930d360366a377e395bbb6804e225d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-04-07 Jon A. Cruz <jon@joncruz.org>
+
+ * src/widgets/desktop-widget.cpp, src/widgets/icon.cpp,
+ src/widgets/layer-selector.cpp:
+
+ Added implementation of smaller icon size.
+
2006-04-06 Jon A. Cruz <jon@joncruz.org>
* src/color-profile.cpp, src/sp-image.cpp:
index 7c70b01fa2f2e65ffbe4ec0c41e0e86c94a8a7c1..b80da8aa4e232b860c9d92fff9db0445ecd9235c 100644 (file)
gtk_table_attach (GTK_TABLE (tbl), dtw->hscrollbar, 1, 2, 2, 3, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
/* Vertical scrollbar and the sticky zoom button */
dtw->vscrollbar_box = gtk_vbox_new (FALSE, 0);
- dtw->sticky_zoom = sp_button_new_from_data ( Inkscape::ICON_SIZE_MENU,
+ dtw->sticky_zoom = sp_button_new_from_data ( Inkscape::ICON_SIZE_DECORATION,
SP_BUTTON_TYPE_TOGGLE,
NULL,
"sticky_zoom",
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index 55dab2ba7dbcac32c4704cf7a32549095f1e251e..61c6429895e49a938b328569fe993534a8a06617 100644 (file)
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
static gboolean icon_prerender_task(gpointer data);
-static void addPreRender( GtkIconSize lsize, gchar const *name );
+static void addPreRender( Inkscape::IconSize lsize, gchar const *name );
static void sp_icon_class_init(SPIconClass *klass);
static void sp_icon_init(SPIcon *icon);
static void sp_icon_overlay_pixels( guchar *px, int width, int height, int stride,
unsigned r, unsigned g, unsigned b );
+static void injectCustomSize();
+
static GtkWidgetClass *parent_class;
static bool sizeDirty = true;
+static bool sizeMapDone = false;
+static GtkIconSize iconSizeLookup[] = {
+ GTK_ICON_SIZE_INVALID,
+ GTK_ICON_SIZE_MENU,
+ GTK_ICON_SIZE_SMALL_TOOLBAR,
+ GTK_ICON_SIZE_LARGE_TOOLBAR,
+ GTK_ICON_SIZE_BUTTON,
+ GTK_ICON_SIZE_DND,
+ GTK_ICON_SIZE_DIALOG,
+ GTK_ICON_SIZE_MENU, // for Inkscape::ICON_SIZE_DECORATION
+};
+
GtkType
sp_icon_get_type()
{
static GtkWidget *
-sp_icon_new_full( GtkIconSize lsize, gchar const *name )
+sp_icon_new_full( Inkscape::IconSize lsize, gchar const *name )
{
static gint dump = prefs_get_int_attribute_limited( "debug.icons", "dumpGtk", 0, 0, 1 );
static gint fallback = prefs_get_int_attribute_limited( "debug.icons", "checkNames", 0, 0, 1 );
GtkWidget *widget = 0;
if ( tryLoad ) {
- GtkWidget *img = gtk_image_new_from_stock( name, lsize );
+ gint trySize = CLAMP( static_cast<gint>(lsize), 0, static_cast<gint>(G_N_ELEMENTS(iconSizeLookup) - 1) );
+
+ if ( !sizeMapDone ) {
+ injectCustomSize();
+ }
+
+ GtkWidget *img = gtk_image_new_from_stock( name, iconSizeLookup[trySize] );
if ( img ) {
GtkImageType type = gtk_image_get_storage_type( GTK_IMAGE(img) );
if ( type == GTK_IMAGE_STOCK ) {
if ( !widget ) {
SPIcon *icon = (SPIcon *)g_object_new(SP_TYPE_ICON, NULL);
- icon->lsize = (Inkscape::IconSize)lsize;
+ icon->lsize = lsize;
icon->name = g_strdup(name);
icon->psize = sp_icon_get_phys_size(lsize);
GtkWidget *
sp_icon_new( Inkscape::IconSize lsize, gchar const *name )
{
-// TODO FIX THIS
- return sp_icon_new_full( (GtkIconSize)lsize, name );
+ return sp_icon_new_full( lsize, name );
}
Gtk::Widget *sp_icon_get_icon( Glib::ustring const &oid, Inkscape::IconSize size )
{
Gtk::Widget *result = 0;
- GtkWidget *widget = sp_icon_new_full( (GtkIconSize)size, oid.c_str() );
+ GtkWidget *widget = sp_icon_new_full( size, oid.c_str() );
if ( widget ) {
if ( GTK_IS_IMAGE(widget) ) {
return map[size];
}
+static void injectCustomSize()
+{
+ // TODO - still need to handle the case of theme changes and resize, especially as we can't re-register a string.
+ if ( !sizeMapDone )
+ {
+ gint dump = prefs_get_int_attribute_limited( "debug.icons", "dumpDefault", 0, 0, 1 );
+ gint width = 0;
+ gint height = 0;
+ if ( gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height ) ) {
+ gint newWidth = (width > 18) ? (width / 2) : ((width * 2) / 3);
+ gint newHeight = (height > 18) ? (height / 2) : ((height * 2) / 3);
+ GtkIconSize newSizeEnum = gtk_icon_size_register( "inkscape-decoration", newWidth, newHeight );
+ if ( newSizeEnum ) {
+ if ( dump ) {
+ g_message("Registered (%d, %d) <= (%d, %d) as index %d", newWidth, newHeight, width, height, newSizeEnum);
+ }
+ guint index = static_cast<guint>(Inkscape::ICON_SIZE_DECORATION);
+ if ( index < G_N_ELEMENTS(iconSizeLookup) ) {
+ iconSizeLookup[index] = newSizeEnum;
+ } else if ( dump ) {
+ g_message("size lookup array too small to store entry");
+ }
+ }
+ }
+ sizeMapDone = true;
+ }
+
+}
+
static int sp_icon_get_phys_size(int size)
{
static bool init = false;
- static int lastSys[GTK_ICON_SIZE_DIALOG + 1];
- static int vals[GTK_ICON_SIZE_DIALOG + 1];
+ static int lastSys[Inkscape::ICON_SIZE_DECORATION + 1];
+ static int vals[Inkscape::ICON_SIZE_DECORATION + 1];
- size = CLAMP( size, GTK_ICON_SIZE_MENU, GTK_ICON_SIZE_DIALOG );
+ size = CLAMP( size, GTK_ICON_SIZE_MENU, Inkscape::ICON_SIZE_DECORATION );
+
+ if ( !sizeMapDone ) {
+ injectCustomSize();
+ }
if ( sizeDirty && init ) {
GtkIconSize const gtkSizes[] = {
GTK_ICON_SIZE_LARGE_TOOLBAR,
GTK_ICON_SIZE_BUTTON,
GTK_ICON_SIZE_DND,
- GTK_ICON_SIZE_DIALOG
+ GTK_ICON_SIZE_DIALOG,
+ static_cast<guint>(Inkscape::ICON_SIZE_DECORATION) < G_N_ELEMENTS(iconSizeLookup) ?
+ iconSizeLookup[static_cast<int>(Inkscape::ICON_SIZE_DECORATION)] :
+ GTK_ICON_SIZE_MENU
};
for (unsigned i = 0; i < G_N_ELEMENTS(gtkSizes) && init; ++i) {
unsigned const val_ix(gtkSizes[i]);
if ( !init ) {
sizeDirty = false;
gint dump = prefs_get_int_attribute_limited( "debug.icons", "dumpDefault", 0, 0, 1 );
+
if ( dump ) {
g_message( "Default icon sizes:" );
}
GTK_ICON_SIZE_LARGE_TOOLBAR,
GTK_ICON_SIZE_BUTTON,
GTK_ICON_SIZE_DND,
- GTK_ICON_SIZE_DIALOG
+ GTK_ICON_SIZE_DIALOG,
+ static_cast<guint>(Inkscape::ICON_SIZE_DECORATION) < G_N_ELEMENTS(iconSizeLookup) ?
+ iconSizeLookup[static_cast<int>(Inkscape::ICON_SIZE_DECORATION)] :
+ GTK_ICON_SIZE_MENU
};
gchar const *const names[] = {
"GTK_ICON_SIZE_MENU",
"GTK_ICON_SIZE_LARGE_TOOLBAR",
"GTK_ICON_SIZE_BUTTON",
"GTK_ICON_SIZE_DND",
- "GTK_ICON_SIZE_DIALOG"
+ "GTK_ICON_SIZE_DIALOG",
+ "inkscape-decoration"
};
GtkWidget *icon = (GtkWidget *)g_object_new(SP_TYPE_ICON, NULL);
class preRenderItem
{
public:
- preRenderItem( GtkIconSize lsize, gchar const *name ) :
+ preRenderItem( Inkscape::IconSize lsize, gchar const *name ) :
_lsize( lsize ),
_name( name )
{}
- GtkIconSize _lsize;
+ Inkscape::IconSize _lsize;
Glib::ustring _name;
};
static std::queue<preRenderItem> pendingRenders;
static bool callbackHooked = false;
-static void addPreRender( GtkIconSize lsize, gchar const *name )
+static void addPreRender( Inkscape::IconSize lsize, gchar const *name )
{
if ( !callbackHooked )
index b95005cd9830c65e6ce1f48db5b969d190beb2eb..e0c8286b09b8fe53d4ee8b0ca75d42fe9498db37 100644 (file)
{
AlternateIcons *label;
- label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_MENU, "visible", "hidden"));
+ label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_DECORATION, "visible", "hidden"));
_visibility_toggle.add(*label);
_visibility_toggle.signal_toggled().connect(
sigc::compose(
_tooltips.set_tip(_visibility_toggle, _("Toggle current layer visibility"));
pack_start(_visibility_toggle, Gtk::PACK_EXPAND_PADDING);
- label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_MENU, "lock_unlocked", "width_height_lock"));
+ label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_DECORATION, "lock_unlocked", "width_height_lock"));
_lock_toggle.add(*label);
_lock_toggle.signal_toggled().connect(
sigc::compose(