summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6b464df)
raw | patch | inline | side by side (parent: 6b464df)
author | Jon A. Cruz <jon@joncruz.org> | |
Fri, 10 Sep 2010 08:34:09 +0000 (01:34 -0700) | ||
committer | Jon A. Cruz <jon@joncruz.org> | |
Fri, 10 Sep 2010 08:34:09 +0000 (01:34 -0700) |
src/profile-manager.cpp | patch | blob | history | |
src/shortcuts.cpp | patch | blob | history | |
src/verbs.cpp | patch | blob | history | |
src/verbs.h | patch | blob | history |
index 1cd965e390b526d89318918dd7569dfdaec4a049..b5ac861e13b4665b5ae1bf313fe0b34db5f2d300 100644 (file)
--- a/src/profile-manager.cpp
+++ b/src/profile-manager.cpp
ProfileManager::~ProfileManager()
{
+ _resource_connection.disconnect();
+ _doc = 0;
}
void ProfileManager::_resourcesChanged()
diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp
index d02ef6e4890026610674d396048d9bf565d61898..bf7fb8a4339561725e136fe6f11c09e57fb1f5b5 100644 (file)
--- a/src/shortcuts.cpp
+++ b/src/shortcuts.cpp
return (Inkscape::Verb *)(g_hash_table_lookup(verbs, GINT_TO_POINTER(shortcut)));
}
-unsigned int
-sp_shortcut_get_primary(Inkscape::Verb *verb)
+unsigned int sp_shortcut_get_primary(Inkscape::Verb *verb)
{
- if (!primary_shortcuts) sp_shortcut_init();
- gpointer value;
- if (g_hash_table_lookup_extended(primary_shortcuts, (gpointer)(verb), NULL, &value)) {
- return (unsigned int)GPOINTER_TO_INT(value);
- } else {
- return GDK_VoidSymbol;
+ unsigned int result = GDK_VoidSymbol;
+ if (!primary_shortcuts) {
+ sp_shortcut_init();
}
+ gpointer value = 0;
+ if (g_hash_table_lookup_extended(primary_shortcuts, static_cast<gpointer>(verb), NULL, &value)) {
+ result = static_cast<unsigned int>(GPOINTER_TO_INT(value));
+ }
+ return result;
}
gchar* sp_shortcut_get_label (unsigned int shortcut)
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 67211e38e3087e86f1311354d7ae43cea8cd98fb..eaf16e93f123e0df066f09d68128ece58d93d644 100644 (file)
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
in the \c _verbs hashtable which is indexed by the \c code.
*/
Verb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *image) :
- _actions(NULL), _id(id), _name(name), _tip(tip), _full_tip(0), _image(image)
+ _actions(0),
+ _id(id),
+ _name(name),
+ _tip(tip),
+ _full_tip(0),
+ _shortcut(0),
+ _image(image),
+ _code(0),
+ _default_sensitive(false)
{
static int count = SP_VERB_LAST;
@@ -343,8 +351,6 @@ Verb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *im
_code = count;
_verbs.insert(VerbTable::value_type(count, this));
_verb_ids.insert(VerbIDTable::value_type(_id, this));
-
- return;
}
/** \brief Destroy a verb.
delete _actions;
}
- if (_full_tip) g_free(_full_tip);
-
- return;
+ if (_full_tip) {
+ g_free(_full_tip);
+ _full_tip = 0;
+ }
}
/** \brief Verbs are no good without actions. This is a place holder
}
/** \brief Accessor to get the tooltip for verb as localised string */
-gchar const *
-Verb::get_tip (void)
+gchar const *Verb::get_tip(void)
{
- if (!_tip) return 0;
- unsigned int shortcut = sp_shortcut_get_primary(this);
- if (shortcut!=_shortcut || !_full_tip) {
- if (_full_tip) g_free(_full_tip);
- _shortcut = shortcut;
- gchar* shortcutString = sp_shortcut_get_label(shortcut);
- if (shortcutString) {
- _full_tip = g_strdup_printf("%s (%s)", _(_tip), shortcutString);
- g_free(shortcutString);
- } else {
+ gchar const *result = 0;
+ if (_tip) {
+ unsigned int shortcut = sp_shortcut_get_primary(this);
+ if ( (shortcut != _shortcut) || !_full_tip) {
+ if (_full_tip) {
+ g_free(_full_tip);
+ _full_tip = 0;
+ }
+ _shortcut = shortcut;
+ gchar* shortcutString = sp_shortcut_get_label(shortcut);
+ if (shortcutString) {
+ _full_tip = g_strdup_printf("%s (%s)", _(_tip), shortcutString);
+ g_free(shortcutString);
+ shortcutString = 0;
+ } else {
_full_tip = g_strdup(_(_tip));
+ }
}
+ result = _full_tip;
}
- return _full_tip;
+
+ return result;
}
void
diff --git a/src/verbs.h b/src/verbs.h
index 16d4d795a618d525369d1e5d96d3111a112aad9f..f118014d2d8c51a892d9b5aa7233dadb366cfed8 100644 (file)
--- a/src/verbs.h
+++ b/src/verbs.h
private:
/** \brief An easy to use defition of the table of verbs by code. */
typedef std::map<unsigned int, Inkscape::Verb *> VerbTable;
+
/** \brief A table of all the dynamically created verbs. */
static VerbTable _verbs;
+
/** \brief The table of statically created verbs which are mostly
'base verbs'. */
static Verb * _base_verbs[SP_VERB_LAST + 1];
/* Plus one because there is an entry for SP_VERB_LAST */
+
/** A string comparison function to be used in the Verb ID lookup
to find the different verbs in the hash map. */
struct ltstr {
}
}
};
+
/** \brief An easy to use definition of the table of verbs by ID. */
typedef std::map<gchar const *, Verb *, ltstr> VerbIDTable;
+
/** \brief Quick lookup of verbs by ID */
static VerbIDTable _verb_ids;
/** \brief A unique textual ID for the verb. */
gchar const * _id;
+
/** \brief The full name of the verb. (shown on menu entries) */
gchar const * _name;
+
/** \brief Tooltip for the verb. */
gchar const * _tip;
+
gchar * _full_tip; // includes shortcut
+
unsigned int _shortcut;
+
/** \brief Name of the image that represents the verb. */
gchar const * _image;
+
/** \brief Unique numerical representation of the verb. In most cases
it is a value from the anonymous enum at the top of this
file. */
/** \brief Whether this verb is set to default to sensitive or
insensitive when new actions are created. */
bool _default_sensitive;
+
protected:
/** \brief Allows for preliminary setting of the \c _default_sensitive
value without effecting existing actions
gchar const * name,
gchar const * tip,
gchar const * image) :
- _actions(NULL), _id(id), _name(name), _tip(tip), _full_tip(0), _image(image), _code(code), _default_sensitive(true) {
+ _actions(0),
+ _id(id),
+ _name(name),
+ _tip(tip),
+ _full_tip(0),
+ _shortcut(0),
+ _image(image),
+ _code(code),
+ _default_sensitive(true)
+ {
_verbs.insert(VerbTable::value_type(_code, this));
_verb_ids.insert(VerbIDTable::value_type(_id, this));
}