Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / dialogs / clonetiler.cpp
index e25f2602b70cc6a709cdf03639148b6be2a94a29..8045675b4022ac097f522747e6523d2f60774551 100644 (file)
@@ -4,6 +4,8 @@
 /* Authors:
  *   bulia byak <buliabyak@users.sf.net>
  *   Johan Engelen <goejendaagh@zonnet.nl>
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004-2006 Authors
  * Released under GNU GPL, read the file 'COPYING' for more information
@@ -16,8 +18,6 @@
 #include <gtk/gtk.h>
 #include <glibmm/i18n.h>
 
-#include "application/application.h"
-#include "application/editor.h"
 #include "../desktop.h"
 #include "../desktop-handles.h"
 #include "dialog-events.h"
@@ -47,6 +47,8 @@
 #include "widgets/icon.h"
 #include "xml/repr.h"
 
+using Inkscape::DocumentUndo;
+
 #define MIN_ONSCREEN_DISTANCE 50
 
 static GtkWidget *dlg = NULL;
@@ -83,15 +85,7 @@ static Inkscape::UI::Widget::ColorPicker *color_picker;
 static void
 clonetiler_dialog_destroy( GtkObject */*object*/, gpointer /*data*/ )
 {
-    if (Inkscape::NSApplication::Application::getNewGui())
-    {
-        _shutdown_connection.disconnect();
-        _dialogs_hidden_connection.disconnect();
-        _dialogs_unhidden_connection.disconnect();
-        _desktop_activated_connection.disconnect();
-    } else {
-        sp_signal_disconnect_by_data (INKSCAPE, dlg);
-    }
+    sp_signal_disconnect_by_data (INKSCAPE, dlg);
     _color_changed_connection.disconnect();
 
     delete color_picker;
@@ -120,11 +114,6 @@ clonetiler_dialog_delete (GtkObject */*object*/, GdkEvent * /*event*/, gpointer
 
 }
 
-static void on_delete()
-{
-    (void)clonetiler_dialog_delete (0, 0, NULL);
-}
-
 static void
 on_picker_color_changed (guint rgba)
 {
@@ -849,7 +838,7 @@ clonetiler_trace_hide_tiled_clones_recursively (SPObject *from)
     if (!trace_arena)
         return;
 
-    for (SPObject *o = from->first_child(); o != NULL; o = SP_OBJECT_NEXT(o)) {
+    for (SPObject *o = from->firstChild(); o != NULL; o = o->next) {
         if (SP_IS_ITEM(o) && clonetiler_is_a_clone_of (o, NULL))
             SP_ITEM(o)->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too!
         clonetiler_trace_hide_tiled_clones_recursively (o);
@@ -863,14 +852,14 @@ clonetiler_trace_setup (SPDocument *doc, gdouble zoom, SPItem *original)
     /* Create ArenaItem and set transform */
     trace_visionkey = SPItem::display_key_new(1);
     trace_doc = doc;
-    trace_root = SP_ITEM(SP_DOCUMENT_ROOT (trace_doc))->invoke_show((NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY);
+    trace_root = SP_ITEM(trace_doc->getRoot())->invoke_show((NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY);
 
     // hide the (current) original and any tiled clones, we only want to pick the background
     original->invoke_hide(trace_visionkey);
-    clonetiler_trace_hide_tiled_clones_recursively (SP_OBJECT(SP_DOCUMENT_ROOT (trace_doc)));
+    clonetiler_trace_hide_tiled_clones_recursively(SP_OBJECT(trace_doc->getRoot()));
 
-    sp_document_root (trace_doc)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
-    trace_doc->ensure_up_to_date();
+    trace_doc->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+    trace_doc->ensureUpToDate();
 
     trace_zoom = zoom;
 }
@@ -953,7 +942,7 @@ static void
 clonetiler_trace_finish ()
 {
     if (trace_doc) {
-        SP_ITEM(sp_document_root(trace_doc))->invoke_hide(trace_visionkey);
+        SP_ITEM(trace_doc->getRoot())->invoke_hide(trace_visionkey);
     }
     if (trace_arena) {
         ((NRObject *) trace_arena)->unreference();
@@ -981,20 +970,20 @@ clonetiler_unclump( GtkWidget */*widget*/, void * )
 
     GSList *to_unclump = NULL; // not including the original
 
-    for (SPObject *child = parent->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) {
+    for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
         if (clonetiler_is_a_clone_of (child, obj)) {
             to_unclump = g_slist_prepend (to_unclump, child);
         }
     }
 
-    sp_desktop_document(desktop)->ensure_up_to_date();
+    sp_desktop_document(desktop)->ensureUpToDate();
 
     unclump (to_unclump);
 
     g_slist_free (to_unclump);
 
-    SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER,
-                      _("Unclump tiled clones"));
+    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER,
+                       _("Unclump tiled clones"));
 }
 
 static guint
@@ -1004,7 +993,7 @@ clonetiler_number_of_clones (SPObject *obj)
 
     guint n = 0;
 
-    for (SPObject *child = parent->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) {
+    for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
         if (clonetiler_is_a_clone_of (child, obj)) {
             n ++;
         }
@@ -1033,7 +1022,7 @@ clonetiler_remove( GtkWidget */*widget*/, void *, bool do_undo = true )
 
 // remove old tiling
     GSList *to_delete = NULL;
-    for (SPObject *child = parent->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) {
+    for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
         if (clonetiler_is_a_clone_of (child, obj)) {
             to_delete = g_slist_prepend (to_delete, child);
         }
@@ -1045,9 +1034,10 @@ clonetiler_remove( GtkWidget */*widget*/, void *, bool do_undo = true )
 
     clonetiler_change_selection (NULL, selection, dlg);
 
-    if (do_undo)
-        SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER,
-                          _("Delete tiled clones"));
+    if (do_undo) {
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER,
+                           _("Delete tiled clones"));
+    }
 }
 
 static Geom::Rect
@@ -1480,7 +1470,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
                 double radius = blur * perimeter;
                 // this is necessary for all newly added clones to have correct bboxes,
                 // otherwise filters won't work:
-                sp_desktop_document(desktop)->ensure_up_to_date();
+                sp_desktop_document(desktop)->ensureUpToDate();
                 // it's hard to figure out exact width/height of the tile without having an object
                 // that we can take bbox of; however here we only need a lower bound so that blur
                 // margins are not too small, and the perimeter should work
@@ -1510,8 +1500,8 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
 
     desktop->clearWaitingCursor();
 
-    SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER,
-                     _("Create tiled clones"));
+    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER,
+                       _("Create tiled clones"));
 }
 
 static GtkWidget *
@@ -1859,18 +1849,10 @@ clonetiler_dialog (void)
         gtk_signal_connect ( GTK_OBJECT (dlg), "destroy", G_CALLBACK (clonetiler_dialog_destroy), dlg);
         gtk_signal_connect ( GTK_OBJECT (dlg), "delete_event", G_CALLBACK (clonetiler_dialog_delete), dlg);
 
-        if (Inkscape::NSApplication::Application::getNewGui())
-        {
-            _shutdown_connection = Inkscape::NSApplication::Editor::connectShutdown (&on_delete);
-            _dialogs_hidden_connection = Inkscape::NSApplication::Editor::connectDialogsHidden (sigc::bind (&on_dialog_hide, dlg));
-            _dialogs_unhidden_connection = Inkscape::NSApplication::Editor::connectDialogsUnhidden (sigc::bind (&on_dialog_unhide, dlg));
-            _desktop_activated_connection = Inkscape::NSApplication::Editor::connectDesktopActivated (sigc::bind (&on_transientize, &wd));
-        } else {
-            g_signal_connect   ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (clonetiler_dialog_delete), dlg);
-            g_signal_connect   ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg);
-            g_signal_connect   ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg);
-            g_signal_connect   ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd);
-        }
+        g_signal_connect   ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (clonetiler_dialog_delete), dlg);
+        g_signal_connect   ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg);
+        g_signal_connect   ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg);
+        g_signal_connect   ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd);
 
         GtkTooltips *tt = gtk_tooltips_new();
 
@@ -2643,9 +2625,7 @@ clonetiler_dialog (void)
                     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B);
                 }
                 {
-                    //TRANSLATORS: only translate "string" in "context|string".
-                    // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
-                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|H"));
+                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H"));
                     gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the hue of the color"), NULL);
                     clonetiler_table_attach (table, radio, 0.0, 1, 3);
                     gtk_signal_connect (GTK_OBJECT (radio), "toggled",
@@ -2653,9 +2633,7 @@ clonetiler_dialog (void)
                     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H);
                 }
                 {
-                    //TRANSLATORS: only translate "string" in "context|string".
-                    // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
-                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|S"));
+                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S"));
                     gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the saturation of the color"), NULL);
                     clonetiler_table_attach (table, radio, 0.0, 2, 3);
                     gtk_signal_connect (GTK_OBJECT (radio), "toggled",
@@ -2663,9 +2641,7 @@ clonetiler_dialog (void)
                     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S);
                 }
                 {
-                    //TRANSLATORS: only translate "string" in "context|string".
-                    // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
-                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|L"));
+                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L"));
                     gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the lightness of the color"), NULL);
                     clonetiler_table_attach (table, radio, 0.0, 3, 3);
                     gtk_signal_connect (GTK_OBJECT (radio), "toggled",
@@ -3000,4 +2976,4 @@ clonetiler_dialog (void)
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :