Code

Add option to align & distribute dialog to treat the selection as a group (closes...
[inkscape.git] / src / ui / dialog / find.cpp
index 4098c4aae68e1d04a5af33f85a566b79862bc19d..f59f2504c062b68fe897841bf84e4a26fc2f44af 100644 (file)
 #include "selection.h"
 #include "desktop-handles.h"
 
-#include "dialog-events.h"
-#include "../prefs-utils.h"
-#include "../verbs.h"
-#include "../interface.h"
-#include "../sp-text.h"
-#include "../sp-flowtext.h"
-#include "../text-editing.h"
-#include "../sp-tspan.h"
-#include "../selection-chemistry.h"
-#include "../sp-defs.h"
-#include "../sp-rect.h"
-#include "../sp-ellipse.h"
-#include "../sp-star.h"
-#include "../sp-spiral.h"
-#include "../sp-path.h"
-#include "../sp-line.h"
-#include "../sp-polyline.h"
-#include "../sp-item-group.h"
-#include "../sp-use.h"
-#include "../sp-image.h"
-#include "../sp-offset.h"
+#include "dialogs/dialog-events.h"
+#include "prefs-utils.h"
+#include "verbs.h"
+#include "interface.h"
+#include "sp-text.h"
+#include "sp-flowtext.h"
+#include "text-editing.h"
+#include "sp-tspan.h"
+#include "sp-tref.h"
+#include "selection-chemistry.h"
+#include "sp-defs.h"
+#include "sp-rect.h"
+#include "sp-ellipse.h"
+#include "sp-star.h"
+#include "sp-spiral.h"
+#include "sp-path.h"
+#include "sp-line.h"
+#include "sp-polyline.h"
+#include "sp-item-group.h"
+#include "sp-use.h"
+#include "sp-image.h"
+#include "sp-offset.h"
 #include <xml/repr.h>
 
 
@@ -55,8 +56,8 @@ namespace Inkscape {
 namespace UI {
 namespace Dialog {
 
-Find::Find() 
-    : Dialog ("dialogs.find", SP_VERB_DIALOG_FIND),
+Find::Find()
+    : UI::Widget::Panel("", "dialogs.find", SP_VERB_DIALOG_FIND),
       _entry_text(_("_Text: "), _("Find objects by their text content (exact or partial match)")),
       _entry_id(_("_ID: "), _("Find objects by the value of the id attribute (exact or partial match)")),
       _entry_style(_("_Style: "), _("Find objects by the value of the style attribute (exact or partial match)")),
@@ -75,42 +76,43 @@ Find::Find()
       _check_paths(_("Paths"), _("Search paths, lines, polylines")),
       _check_texts(_("Texts"), _("Search text objects")),
       _check_groups(_("Groups"), _("Search groups")),
-      _check_clones(_("Clones"), _("Search clones")),
+      _check_clones(
+                 //TRANSLATORS: Translate the word "Clones" only. A noun indicating type of object to find
+                 Q_("find|Clones"), _("Search clones")),
       _check_images(_("Images"), _("Search images")),
       _check_offsets(_("Offsets"), _("Search offset objects")),
     
       _button_clear(_("_Clear"), _("Clear values")),
       _button_find(_("_Find"), _("Select objects matching all of the fields you filled in"))
 {
-    // Top level vbox
-    Gtk::VBox *vbox = get_vbox();
-    vbox->set_spacing(4);
+    Gtk::Box *contents = _getContents();
+    contents->set_spacing(4);
     
-    vbox->pack_start(_entry_text, true, true);
-    vbox->pack_start(_entry_id, true, true);
-    vbox->pack_start(_entry_style, true, true);
-    vbox->pack_start(_entry_attribute, true, true);
-
-    vbox->pack_start(_check_all, true, true);
-    vbox->pack_start(_check_all_shapes, true, true);
-    vbox->pack_start(_check_rects, true, true);
-    vbox->pack_start(_check_ellipses, true, true);
-    vbox->pack_start(_check_stars, true, true);
-    vbox->pack_start(_check_spirals, true, true);
-    vbox->pack_start(_check_paths, true, true);
-    vbox->pack_start(_check_texts, true, true);
-    vbox->pack_start(_check_groups, true, true);
-    vbox->pack_start(_check_clones, true, true);
-    vbox->pack_start(_check_images, true, true);
-    vbox->pack_start(_check_offsets, true, true);
-
-    vbox->pack_start(_check_search_selection, true, true);
-    vbox->pack_start(_check_search_layer, true, true);
-    vbox->pack_start(_check_include_hidden, true, true);
-    vbox->pack_start(_check_include_locked, true, true);
-
-    vbox->pack_start(_button_clear, true, true);
-    vbox->pack_start(_button_find, true, true);
+    contents->pack_start(_entry_text, true, true);
+    contents->pack_start(_entry_id, true, true);
+    contents->pack_start(_entry_style, true, true);
+    contents->pack_start(_entry_attribute, true, true);
+
+    contents->pack_start(_check_all, true, true);
+    contents->pack_start(_check_all_shapes, true, true);
+    contents->pack_start(_check_rects, true, true);
+    contents->pack_start(_check_ellipses, true, true);
+    contents->pack_start(_check_stars, true, true);
+    contents->pack_start(_check_spirals, true, true);
+    contents->pack_start(_check_paths, true, true);
+    contents->pack_start(_check_texts, true, true);
+    contents->pack_start(_check_groups, true, true);
+    contents->pack_start(_check_clones, true, true);
+    contents->pack_start(_check_images, true, true);
+    contents->pack_start(_check_offsets, true, true);
+
+    contents->pack_start(_check_search_selection, true, true);
+    contents->pack_start(_check_search_layer, true, true);
+    contents->pack_start(_check_include_hidden, true, true);
+    contents->pack_start(_check_include_locked, true, true);
+
+    contents->pack_start(_button_clear, true, true);
+    contents->pack_start(_button_find, true, true);
 
     // set signals to handle clicks
     _check_all.signal_clicked().connect(sigc::mem_fun(*this, &Find::onToggleAlltypes));
@@ -119,7 +121,7 @@ Find::Find()
     _button_find.signal_clicked().connect(sigc::mem_fun(*this, &Find::onFind));
 
     _button_find.set_flags(Gtk::CAN_DEFAULT);
-    set_default (_button_find); // activatable by Enter
+    // set_default (_button_find); // activatable by Enter
     _entry_text.getEntry()->grab_focus();
 
     show_all_children();
@@ -275,7 +277,7 @@ Find::filter_fields (GSList *l, bool exact)
 bool
 Find::item_type_match (SPItem *item)
 {
-    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+    SPDesktop *desktop = getDesktop();
 
     if (SP_IS_RECT(item)) {
         return (_check_all_shapes.get_active() || _check_rects.get_active());
@@ -292,7 +294,7 @@ Find::item_type_match (SPItem *item)
     } else if (SP_IS_PATH(item) || SP_IS_LINE(item) || SP_IS_POLYLINE(item)) {
         return (_check_paths.get_active());
 
-    } else if (SP_IS_TEXT(item) || SP_IS_TSPAN(item) || SP_IS_STRING(item)) {
+    } else if (SP_IS_TEXT(item) || SP_IS_TSPAN(item) || SP_IS_TREF(item) || SP_IS_STRING(item)) {
         return (_check_texts.get_active());
 
     } else if (SP_IS_GROUP(item) && !desktop->isLayer(item) ) { // never select layers!
@@ -337,7 +339,7 @@ Find::filter_list (GSList *l, bool exact)
 GSList *
 Find::all_items (SPObject *r, GSList *l, bool hidden, bool locked)
 {
-    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+    SPDesktop *desktop = getDesktop();
 
     if (SP_IS_DEFS(r))
         return l; // we're not interested in items in defs
@@ -359,9 +361,9 @@ Find::all_items (SPObject *r, GSList *l, bool hidden, bool locked)
 GSList *
 Find::all_selection_items (Inkscape::Selection *s, GSList *l, SPObject *ancestor, bool hidden, bool locked)
 {
-    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+    SPDesktop *desktop = getDesktop();
 
-   for (GSList *i = (GSList *) s->itemList(); i != NULL; i = i->next) {
+    for (GSList *i = (GSList *) s->itemList(); i != NULL; i = i->next) {
         if (SP_IS_ITEM (i->data) && !SP_OBJECT_IS_CLONED (i->data) && !desktop->isLayer(SP_ITEM(i->data))) {
             if (!ancestor || ancestor->isAncestorOf(SP_OBJECT (i->data))) {
                 if ((hidden || !desktop->itemIsHidden(SP_ITEM(i->data))) && (locked || !SP_ITEM(i->data)->isLocked())) {
@@ -398,7 +400,7 @@ Find::onClear()
 void
 Find::onFind()
 {   
-    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+    SPDesktop *desktop = getDesktop();
 
     bool hidden = _check_include_hidden.get_active();
     bool locked = _check_include_locked.get_active();