index 829b06cb6009a88f71c7b07eb007f76c6b4b34c2..2eb30f27cadca86a3906b3ce1931ff0f6f91a46f 100644 (file)
--- a/src/dialogs/swatches.cpp
+++ b/src/dialogs/swatches.cpp
-/*
- * A simple panel for color swatches
- *
- * Authors:
+/** @file
+ * @brief Color swatches dialog
+ */
+/* Authors:
* Jon A. Cruz
+ * John Bintz
*
* Copyright (C) 2005 Jon A. Cruz
+ * Copyright (C) 2008 John Bintz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
#include <errno.h>
#include <glibmm/i18n.h>
#include <gdkmm/pixbuf.h>
#include "inkscape.h"
+#include "desktop.h"
+#include "message-context.h"
#include "document.h"
#include "desktop-handles.h"
#include "extension/db.h"
#include "path-prefix.h"
#include "swatches.h"
#include "sp-item.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "eek-preview.h"
namespace UI {
namespace Dialogs {
-SwatchesPanel* SwatchesPanel::instance = 0;
-
ColorItem::ColorItem( unsigned int r, unsigned int g, unsigned int b, Glib::ustring& name ) :
def( r, g, b, name ),
@@ -238,6 +237,31 @@ static void handleSecondaryClick( GtkWidget* widget, gint arg1, gpointer callbac
}
}
+static gboolean handleEnterNotify( GtkWidget* /*widget*/, GdkEventCrossing* /*event*/, gpointer callback_data ) {
+ ColorItem* item = reinterpret_cast<ColorItem*>(callback_data);
+ if ( item ) {
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ if ( desktop ) {
+ gchar* msg = g_strdup_printf(_("Color: <b>%s</b>; <b>Click</b> to set fill, <b>Shift+click</b> to set stroke"),
+ item->def.descr.c_str());
+ desktop->tipsMessageContext()->set(Inkscape::INFORMATION_MESSAGE, msg);
+ g_free(msg);
+ }
+ }
+ return FALSE;
+}
+
+static gboolean handleLeaveNotify( GtkWidget* /*widget*/, GdkEventCrossing* /*event*/, gpointer callback_data ) {
+ ColorItem* item = reinterpret_cast<ColorItem*>(callback_data);
+ if ( item ) {
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ if ( desktop ) {
+ desktop->tipsMessageContext()->clear();
+ }
+ }
+ return FALSE;
+}
+
static GtkWidget* popupMenu = 0;
static ColorItem* bounceTarget = 0;
@@ -267,14 +291,16 @@ static gboolean handleButtonPress( GtkWidget* widget, GdkEventButton* event, gpo
popupMenu = gtk_menu_new();
GtkWidget* child = 0;
- child = gtk_menu_item_new_with_label("Set fill");
+ //TRANSLATORS: An item in context menu on a colour in the swatches
+ child = gtk_menu_item_new_with_label(_("Set fill"));
g_signal_connect( G_OBJECT(child),
"activate",
G_CALLBACK(redirClick),
user_data);
gtk_menu_shell_append(GTK_MENU_SHELL(popupMenu), child);
- child = gtk_menu_item_new_with_label("Set stroke");
+ //TRANSLATORS: An item in context menu on a colour in the swatches
+ child = gtk_menu_item_new_with_label(_("Set stroke"));
g_signal_connect( G_OBJECT(child),
"activate",
}
-Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Inkscape::IconSize size)
+Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewSize size, guint ratio)
{
Gtk::Widget* widget = 0;
if ( style == PREVIEW_STYLE_BLURB ) {
@@ -511,10 +537,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);
@@ -522,7 +548,7 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Inkscape::
eek_preview_set_color( preview, (def.getR() << 8) | def.getR(), (def.getG() << 8) | def.getG(), (def.getB() << 8) | def.getB());
- eek_preview_set_details( preview, (::PreviewStyle)style, (::ViewType)view, (::GtkIconSize)size );
+ eek_preview_set_details( preview, (::PreviewStyle)style, (::ViewType)view, (::PreviewSize)size, ratio );
eek_preview_set_linked( preview, (LinkType)((_linkSrc ? PREVIEW_LINK_IN:0)
| (_listeners.empty() ? 0:PREVIEW_LINK_OUT)
| (_isLive ? PREVIEW_LINK_OTHER:0)) );
@@ -585,6 +611,16 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Inkscape::
G_CALLBACK(dragBegin),
this );
+ g_signal_connect( G_OBJECT(newBlot->gobj()),
+ "enter-notify-event",
+ G_CALLBACK(handleEnterNotify),
+ this);
+
+ g_signal_connect( G_OBJECT(newBlot->gobj()),
+ "leave-notify-event",
+ G_CALLBACK(handleLeaveNotify),
+ this);
+
// g_signal_connect( G_OBJECT(newBlot->gobj()),
// "drag-drop",
// G_CALLBACK(dragDropColorData),
while ( *ptr == ' ' || *ptr == '\t' ) {
ptr++;
}
- if ( *ptr == 0 ) {
+ if ( (*ptr == 0) || (*ptr == '\r') || (*ptr == '\n') ) {
// blank line. skip it.
} else if ( '0' <= *ptr && *ptr <= '9' ) {
// should be an entry link
while (!sources.empty()) {
gchar *dirname = sources.front();
- if ( Inkscape::IO::file_test( dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) ) ) {
+ if ( Inkscape::IO::file_test( dirname, G_FILE_TEST_EXISTS )
+ && Inkscape::IO::file_test( dirname, G_FILE_TEST_IS_DIR )) {
GError *err = 0;
GDir *directory = g_dir_open(dirname, 0, &err);
if (!directory) {
gchar* lower = g_ascii_strdown( filename, -1 );
// if ( g_str_has_suffix(lower, ".gpl") ) {
gchar* full = g_build_filename(dirname, filename, NULL);
- if ( !Inkscape::IO::file_test( full, (GFileTest)(G_FILE_TEST_IS_DIR ) ) ) {
+ if ( !Inkscape::IO::file_test( full, G_FILE_TEST_IS_DIR ) ) {
_loadPaletteFile(full);
}
g_free(full);
SwatchesPanel& SwatchesPanel::getInstance()
{
- if ( !instance ) {
- instance = new SwatchesPanel();
- }
-
- return *instance;
+ return *new SwatchesPanel();
}
if ( !possible.empty() ) {
JustForNow* first = 0;
- gchar const* targetName = 0;
- if ( _prefs_path ) {
- targetName = prefs_get_string_attribute( _prefs_path, "palette" );
- if ( targetName ) {
+ Glib::ustring targetName;
+ if ( !_prefs_path.empty() ) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ targetName = prefs->getString(_prefs_path + "/palette");
+ if (!targetName.empty()) {
for ( std::vector<JustForNow*>::iterator iter = possible.begin(); iter != possible.end(); ++iter ) {
if ( (*iter)->_name == targetName ) {
first = *iter;
_holder->clear();
JustForNow* curr = possible[itemId];
- if ( _prefs_path ) {
- prefs_set_string_attribute( _prefs_path, "palette", curr->_name.c_str() );
+ if ( !_prefs_path.empty() ) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString(_prefs_path + "/palette", curr->_name);
}
if ( curr->_prefWidth > 0 ) {