Code

Changed objects to only get linked to "linkable" colors.
authorjoncruz <joncruz@users.sourceforge.net>
Tue, 28 Mar 2006 17:14:27 +0000 (17:14 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Tue, 28 Mar 2006 17:14:27 +0000 (17:14 +0000)
ChangeLog
src/dialogs/eek-preview.cpp
src/dialogs/eek-preview.h
src/dialogs/swatches.cpp
src/dialogs/swatches.h
src/interface.cpp

index 8f85a016ebde242a0122cab5aa80d94ef7d218c3..b17a68f4a8d609fe3c7972f7a539e75c85cf528b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-03-28  Jon A. Cruz  <jon@joncruz.org>
+
+       * src/interface.cpp, src/dialogs/eek-color-def.h,
+         src/dialogs/eek-preview.h, src/dialogs/eek-preview.cpp,
+         src/dialogs/swatches.h, src/dialogs/swatches.cpp:
+
+         Changed objects to only get liked to "linkable" colors.
+       
 2006-03-28  Jon A. Cruz  <jon@joncruz.org>
 
        * src/interface.cpp, src/dialogs/swatches.cpp:
index d2ac8db5de4cc3242c6f4cccb560d520363b2da5..0108d47775bacf0908ce496a021e6c43101a03c7 100644 (file)
@@ -210,11 +210,12 @@ gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* event )
                                  );
             }
 
-            if ( area.height < possible.height ) {
-                area.y = possible.y + (possible.height - area.height);
-            }
-
             if ( preview->_linked & PREVIEW_LINK_OUT ) {
+                GdkRectangle otherArea = {area.x, area.y, area.width, area.height};
+                if ( otherArea.height < possible.height ) {
+                    otherArea.y = possible.y + (possible.height - otherArea.height);
+                }
+
                 gtk_paint_arrow( style,
                                  widget->window,
                                  (GtkStateType)widget->state,
@@ -224,8 +225,28 @@ gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* event )
                                  NULL, /* detail */
                                  GTK_ARROW_UP,
                                  FALSE,
-                                 area.x, area.y,
-                                 area.width, area.height
+                                 otherArea.x, otherArea.y,
+                                 otherArea.width, otherArea.height
+                                 );
+            }
+
+            if ( preview->_linked & PREVIEW_LINK_OTHER ) {
+                GdkRectangle otherArea = {insetX, area.y, area.width, area.height};
+                if ( otherArea.height < possible.height ) {
+                    otherArea.y = possible.y + (possible.height - otherArea.height) / 2;
+                }
+
+                gtk_paint_arrow( style,
+                                 widget->window,
+                                 (GtkStateType)widget->state,
+                                 GTK_SHADOW_ETCHED_OUT,
+                                 NULL, /* clip area.  &area, */
+                                 widget, /* may be NULL */
+                                 NULL, /* detail */
+                                 GTK_ARROW_LEFT,
+                                 FALSE,
+                                 otherArea.x, otherArea.y,
+                                 otherArea.width, otherArea.height
                                  );
             }
         }
@@ -485,7 +506,7 @@ static void eek_preview_class_init( EekPreviewClass *klass )
 
 void eek_preview_set_linked( EekPreview* splat, LinkType link )
 {
-    link = (LinkType)(link & PREVIEW_LINK_BOTH);
+    link = (LinkType)(link & PREVIEW_LINK_ALL);
     if ( link != (LinkType)splat->_linked ) {
         splat->_linked = link;
 
index 736d7105890dc5d08e315311d0715c2ea9be365b..114be8742a65171b1634a9920b1014c06a5f38ab 100644 (file)
@@ -71,7 +71,8 @@ typedef enum {
   PREVIEW_LINK_NONE = 0,
   PREVIEW_LINK_IN = 1,
   PREVIEW_LINK_OUT = 2,
-  PREVIEW_LINK_BOTH = 3
+  PREVIEW_LINK_OTHER = 4,
+  PREVIEW_LINK_ALL = 7
 } LinkType;
 
 typedef struct _EekPreview       EekPreview;
index 1d429603d571fb168f86c6f9b00cb6a8e709beee..8d81c3b99a6e843cfe56f5741706b081d4e1ccfd 100644 (file)
@@ -42,6 +42,7 @@ SwatchesPanel* SwatchesPanel::instance = 0;
 
 ColorItem::ColorItem( unsigned int r, unsigned int g, unsigned int b, Glib::ustring& name ) :
     def( r, g, b, name ),
+    _isLive(false),
     _linkIsTone(false),
     _linkPercent(0),
     _linkGray(0),
@@ -102,12 +103,12 @@ static const GtkTargetEntry sourceColorEntries[] = {
     {"text/plain", 0, TEXT_DATA},
 };
 
-static void dragGetColorData( GtkWidget *widget,
-                              GdkDragContext *drag_context,
-                              GtkSelectionData *data,
-                              guint info,
-                              guint time,
-                              gpointer user_data)
+void ColorItem::_dragGetColorData( GtkWidget *widget,
+                                   GdkDragContext *drag_context,
+                                   GtkSelectionData *data,
+                                   guint info,
+                                   guint time,
+                                   gpointer user_data)
 {
     static GdkAtom typeXColor = gdk_atom_intern("application/x-color", FALSE);
     static GdkAtom typeText = gdk_atom_intern("text/plain", FALSE);
@@ -148,19 +149,19 @@ static void dragGetColorData( GtkWidget *widget,
 //         } else {
 //             g_message("Unable to find the color");
 //         }
-        int itemCount = 4 + 1 + 1 + paletteName.length();
+        int itemCount = 4 + 2 + 1 + paletteName.length();
 
-        guint16* tmp = new guint16[itemCount]
-;
+        guint16* tmp = new guint16[itemCount];
         tmp[0] = (item->def.getR() << 8) | item->def.getR();
         tmp[1] = (item->def.getG() << 8) | item->def.getG();
         tmp[2] = (item->def.getB() << 8) | item->def.getB();
         tmp[3] = 0xffff;
+        tmp[4] = (item->_isLive || !item->_listeners.empty() || (item->_linkSrc != 0) ) ? 1 : 0;
 
-        tmp[4] = index;
-        tmp[5] = paletteName.length();
+        tmp[5] = index;
+        tmp[6] = paletteName.length();
         for ( unsigned int i = 0; i < paletteName.length(); i++ ) {
-            tmp[6 + i] = paletteName[i];
+            tmp[7 + i] = paletteName[i];
         }
         gtk_selection_data_set( data,
                                 typeXColor,
@@ -351,7 +352,9 @@ void ColorItem::_colorDefChanged(void* data)
                                        (item->def.getG() << 8) | item->def.getG(),
                                        (item->def.getB() << 8) | item->def.getB() );
 
-                eek_preview_set_linked( preview, (LinkType)((item->_linkSrc ? PREVIEW_LINK_IN:0) | (item->_listeners.empty() ? 0:PREVIEW_LINK_OUT)) );
+                eek_preview_set_linked( preview, (LinkType)((item->_linkSrc ? PREVIEW_LINK_IN:0)
+                                                            | (item->_listeners.empty() ? 0:PREVIEW_LINK_OUT)
+                                                            | (item->_isLive ? PREVIEW_LINK_OTHER:0)) );
 
                 widget->queue_draw();
             }
@@ -439,7 +442,9 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Gtk::Built
         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_linked( preview, (LinkType)((_linkSrc ? PREVIEW_LINK_IN:0) | (_listeners.empty() ? 0:PREVIEW_LINK_OUT)) );
+        eek_preview_set_linked( preview, (LinkType)((_linkSrc ? PREVIEW_LINK_IN:0)
+                                                    | (_listeners.empty() ? 0:PREVIEW_LINK_OUT)
+                                                    | (_isLive ? PREVIEW_LINK_OTHER:0)) );
 
         def.addCallback( _colorDefChanged, this );
 
@@ -485,7 +490,7 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Gtk::Built
 
         g_signal_connect( G_OBJECT(newBlot->gobj()),
                           "drag-data-get",
-                          G_CALLBACK(dragGetColorData),
+                          G_CALLBACK(ColorItem::_dragGetColorData),
                           this);
 
         g_signal_connect( G_OBJECT(newBlot->gobj()),
@@ -645,10 +650,14 @@ void ColorItem::_wireMagicColors( void* p )
 
                     if ( subby.find('E') != std::string::npos )
                     {
-                        //g_message("                   HOT!");
                         (*it)->def.setEditable( true );
                     }
 
+                    if ( subby.find('L') != std::string::npos )
+                    {
+                        (*it)->_isLive = true;
+                    }
+
                     std::string part;
                     // Tint. index + 1 more val.
                     if ( getBlock( part, 'T', subby ) ) {
index b6f28f18201be089257b122264f72d92ee867d3a..965c32240f77c8b4a373770c5df9f0967be3e1a2 100644 (file)
@@ -57,6 +57,13 @@ private:
                              guint event_time,
                              gpointer user_data);
 
+    static void _dragGetColorData( GtkWidget *widget,
+                                   GdkDragContext *drag_context,
+                                   GtkSelectionData *data,
+                                   guint info,
+                                   guint time,
+                                   gpointer user_data);
+
     static void _wireMagicColors( void* p );
     static void _colorDefChanged(void* data);
 
@@ -66,6 +73,7 @@ private:
     Gtk::Tooltips tips;
     std::vector<Gtk::Widget*> _previews;
 
+    bool _isLive;
     bool _linkIsTone;
     int _linkPercent;
     int _linkGray;
index 5de76aff170a9bfc6dacf880730887e0e9c825d0..c913d1122c44e85f68b770f363de208f73a14137 100644 (file)
@@ -1005,16 +1005,18 @@ sp_ui_drag_data_received(GtkWidget *widget,
                     sp_desktop_apply_css_recursive( item, css, true );
                     item->updateRepr();
 
-                    if ( data->length > 12 ) {
+                    if ( data->length > 14 ) {
+                        int flags = dataVals[4];
+
                         // piggie-backed palette entry info
-                        int index = dataVals[4];
+                        int index = dataVals[5];
                         Glib::ustring palName;
-                        for ( int i = 0; i < dataVals[5]; i++ ) {
-                            palName += (gunichar)dataVals[6+i];
+                        for ( int i = 0; i < dataVals[6]; i++ ) {
+                            palName += (gunichar)dataVals[7+i];
                         }
 
                         // Now hook in a magic tag of some sort.
-                        if ( !palName.empty() ) {
+                        if ( !palName.empty() && (flags & 1) ) {
                             gchar* str = g_strdup_printf("%d|", index);
                             palName.insert( 0, str );
                             g_free(str);