summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2008-02-18 09:25:27 +0000
committerjoncruz <joncruz@users.sourceforge.net>2008-02-18 09:25:27 +0000
commite2ef39af06a4ad8fdea30809d3ceeda8580e4d7b (patch)
tree92eb8ee65ad6d0dd9b2a4329fbf2978fff912a9e /src
parenta bunch of updates (diff)
downloadinkscape-e2ef39af06a4ad8fdea30809d3ceeda8580e4d7b.tar.gz
inkscape-e2ef39af06a4ad8fdea30809d3ceeda8580e4d7b.zip
Fixing preview/swatch sizes.
(bzr r4765)
Diffstat (limited to 'src')
-rw-r--r--src/dialogs/eek-preview.cpp71
-rw-r--r--src/dialogs/eek-preview.h2
-rw-r--r--src/dialogs/swatches.cpp8
-rw-r--r--src/inkscape-stock.cpp8
-rw-r--r--src/ui/widget/panel.cpp14
-rw-r--r--src/ui/widget/panel.h6
-rw-r--r--src/widgets/icon.cpp10
-rw-r--r--src/widgets/icon.h2
8 files changed, 105 insertions, 16 deletions
diff --git a/src/dialogs/eek-preview.cpp b/src/dialogs/eek-preview.cpp
index 411491777..1716a7cd6 100644
--- a/src/dialogs/eek-preview.cpp
+++ b/src/dialogs/eek-preview.cpp
@@ -90,6 +90,54 @@ GType eek_preview_get_type(void)
return preview_type;
}
+static guint trackCount = 0;
+static guint* trackSizes = 0;
+static GtkIconSize* trackKeys = 0;
+
+void eek_preview_set_size_mappings( guint count, GtkIconSize const* sizes )
+{
+ gint width = 0;
+ gint height = 0;
+ gint smallest = 512;
+ gint largest = 0;
+ guint i = 0;
+ guint delta = 0;
+
+ for ( i = 0; i < count; ++i ) {
+ gboolean worked = gtk_icon_size_lookup( sizes[i], &width, &height );
+ if ( worked ) {
+ if ( width < smallest ) {
+ smallest = width;
+ }
+ if ( width > largest ) {
+ largest = width;
+ }
+ }
+ }
+
+ smallest = (smallest * 3) / 4;
+
+ delta = largest - smallest;
+
+ if ( trackSizes ) {
+ g_free(trackSizes);
+ trackSizes = 0;
+ }
+ if ( trackKeys ) {
+ g_free(trackKeys);
+ trackKeys = 0;
+ }
+
+ trackCount = count;
+ trackSizes = g_new(guint, count);
+ trackKeys = g_new(GtkIconSize, count);
+ for ( i = 0; i < count; ++i ) {
+ guint val = smallest + ( (i * delta) / (count-1) );
+ trackKeys[i] = sizes[i];
+ trackSizes[i] = val;
+ }
+}
+
GtkWidget* eek_preview_area_new(void)
{
return NULL;
@@ -100,10 +148,25 @@ static void eek_preview_size_request( GtkWidget* widget, GtkRequisition* req )
gint width = 0;
gint height = 0;
EekPreview* preview = EEK_PREVIEW(widget);
- gboolean worked = gtk_icon_size_lookup( preview->_size, &width, &height );
- if ( !worked ) {
- width = 16;
- height = 16;
+ gboolean tracked = TRUE;
+ guint i = 0;
+
+ for ( i = 0; i < trackCount; ++i ) {
+ tracked = (trackKeys[i] == preview->_size);
+ if ( tracked ) {
+ width = trackSizes[i];
+ height = width;
+ break;
+ }
+ }
+
+ if ( !tracked ) {
+ gboolean worked = gtk_icon_size_lookup( preview->_size, &width, &height );
+ if ( !worked ) {
+ width = 16;
+ height = 16;
+ g_warning("Size not found [%d]", preview->_size);
+ }
}
if ( preview->_view == VIEW_TYPE_LIST ) {
width *= 3;
diff --git a/src/dialogs/eek-preview.h b/src/dialogs/eek-preview.h
index 114be8742..ff2fb78f3 100644
--- a/src/dialogs/eek-preview.h
+++ b/src/dialogs/eek-preview.h
@@ -117,6 +117,8 @@ LinkType eek_preview_get_linked( EekPreview* splat );
gboolean eek_preview_get_focus_on_click( EekPreview* preview );
void eek_preview_set_focus_on_click( EekPreview* preview, gboolean focus_on_click );
+void eek_preview_set_size_mappings( guint count, GtkIconSize const* sizes );
+
G_END_DECLS
diff --git a/src/dialogs/swatches.cpp b/src/dialogs/swatches.cpp
index 52178e53a..709bce25a 100644
--- a/src/dialogs/swatches.cpp
+++ b/src/dialogs/swatches.cpp
@@ -511,10 +511,10 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Inkscape::
lbl->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
widget = lbl;
} else {
- Glib::ustring blank(" ");
- if ( size == Inkscape::ICON_SIZE_MENU || size == Inkscape::ICON_SIZE_DECORATION ) {
- blank = " ";
- }
+// Glib::ustring blank(" ");
+// if ( size == Inkscape::ICON_SIZE_MENU || size == Inkscape::ICON_SIZE_DECORATION ) {
+// blank = " ";
+// }
GtkWidget* eekWidget = eek_preview_new();
EekPreview * preview = EEK_PREVIEW(eekWidget);
diff --git a/src/inkscape-stock.cpp b/src/inkscape-stock.cpp
index 16bf883d0..107d246b4 100644
--- a/src/inkscape-stock.cpp
+++ b/src/inkscape-stock.cpp
@@ -23,6 +23,8 @@
#include "gtk/gtkiconfactory.h"
+#include "widgets/icon.h"
+#include "ui/widget/panel.h"
void
inkscape_gtk_stock_init() {
@@ -31,6 +33,12 @@ inkscape_gtk_stock_init() {
if (stock_initialized)
return;
+ // Ensure icon internal sizes get set up:
+ sp_icon_get_phys_size(GTK_ICON_SIZE_MENU);
+
+ // And also prepare the swatches.
+ Inkscape::UI::Widget::Panel::prep();
+
GtkIconFactory *icon_factory = gtk_icon_factory_new();
/* todo: Should we simply remove this file now that we're no longer
* calling gtk_icon_factory_add here? */
diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp
index a591e7664..9b9b20530 100644
--- a/src/ui/widget/panel.cpp
+++ b/src/ui/widget/panel.cpp
@@ -27,6 +27,7 @@
#include "prefs-utils.h"
#include "desktop-handles.h"
#include "inkscape.h"
+#include "dialogs/eek-preview.h"
namespace Inkscape {
namespace UI {
@@ -37,6 +38,19 @@ static const int PANEL_SETTING_MODE = 1;
static const int PANEL_SETTING_WRAP = 2;
static const int PANEL_SETTING_NEXTFREE = 3;
+
+void Panel::prep() {
+ GtkIconSize sizes[] = {
+ static_cast<GtkIconSize>(Inkscape::ICON_SIZE_DECORATION),
+ GTK_ICON_SIZE_MENU,
+ GTK_ICON_SIZE_SMALL_TOOLBAR,
+ GTK_ICON_SIZE_BUTTON,
+ GTK_ICON_SIZE_DND, // Not used by options, but included to make the last size larger
+ GTK_ICON_SIZE_DIALOG
+ };
+ eek_preview_set_size_mappings( G_N_ELEMENTS(sizes), sizes );
+}
+
/**
* Construct a Panel
*/
diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h
index 40760a4a2..1062ee58e 100644
--- a/src/ui/widget/panel.h
+++ b/src/ui/widget/panel.h
@@ -38,8 +38,10 @@ namespace Widget {
class Panel : public Gtk::VBox {
public:
+ static void prep();
+
virtual ~Panel();
- Panel(Glib::ustring const &label = "", gchar const *prefs_path = 0,
+ Panel(Glib::ustring const &label = "", gchar const *prefs_path = 0,
int verb_num = 0, Glib::ustring const &apply_label = "",
bool menu_desired = false);
@@ -57,7 +59,7 @@ public:
virtual void setDesktop(SPDesktop *desktop);
SPDesktop *getDesktop() { return _desktop; }
-
+
/** Signal accessors */
virtual sigc::signal<void, int> &signalResponse();
virtual sigc::signal<void> &signalPresent();
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index 03a39acb6..8c582da83 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -59,8 +59,6 @@ static guchar *sp_icon_image_load_svg(gchar const *name, unsigned lsize, unsigne
static guchar *sp_icon_image_load(SPIcon *icon, gchar const *name);
-static int sp_icon_get_phys_size(int size);
-
static void sp_icon_overlay_pixels( guchar *px, int width, int height, int stride,
unsigned r, unsigned g, unsigned b );
@@ -397,7 +395,7 @@ static void injectCustomSize()
}
-static int sp_icon_get_phys_size(int size)
+int sp_icon_get_phys_size(int size)
{
static bool init = false;
static int lastSys[Inkscape::ICON_SIZE_DECORATION + 1];
@@ -542,7 +540,7 @@ static void sp_icon_paint(SPIcon *icon, GdkRectangle const *area)
}
static guchar *
-sp_icon_image_load_pixmap(gchar const *name, unsigned lsize, unsigned psize)
+sp_icon_image_load_pixmap(gchar const *name, unsigned /*lsize*/, unsigned psize)
{
gchar *path;
guchar *px;
@@ -762,7 +760,7 @@ static guchar *get_cached_pixels(Glib::ustring const &key) {
}
static guchar *load_svg_pixels(gchar const *name,
- unsigned lsize, unsigned psize)
+ unsigned /*lsize*/, unsigned psize)
{
SPDocument *doc = NULL;
NRArenaItem *root = NULL;
@@ -949,7 +947,7 @@ static void addPreRender( Inkscape::IconSize lsize, gchar const *name )
pendingRenders.push(preRenderItem(lsize, name));
}
-gboolean icon_prerender_task(gpointer data) {
+gboolean icon_prerender_task(gpointer /*data*/) {
if (!pendingRenders.empty()) {
preRenderItem single=pendingRenders.front();
pendingRenders.pop();
diff --git a/src/widgets/icon.h b/src/widgets/icon.h
index 55112c0ae..45ab82223 100644
--- a/src/widgets/icon.h
+++ b/src/widgets/icon.h
@@ -48,5 +48,7 @@ GtkWidget *sp_icon_new( Inkscape::IconSize size, const gchar *name );
Gtk::Widget *sp_icon_get_icon( const Glib::ustring &oid, Inkscape::IconSize size = Inkscape::ICON_SIZE_BUTTON );
void sp_icon_fetch_pixbuf( SPIcon *icon );
+int sp_icon_get_phys_size(int size);
+
#endif // SEEN_SP_ICON_H