summaryrefslogtreecommitdiffstats
path: root/src/helper
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-08-18 20:19:55 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-08-18 20:19:55 +0000
commitdce3466274e04364e25c47b0b71007a65c9cf9dd (patch)
tree37d21bcfbc010d83221de713fb83d6e15e1546cf /src/helper
parentFix accidental regression in previous commit (diff)
downloadinkscape-dce3466274e04364e25c47b0b71007a65c9cf9dd.tar.gz
inkscape-dce3466274e04364e25c47b0b71007a65c9cf9dd.zip
Code cleanup.
(bzr r13341.1.145)
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/gnome-utils.cpp148
-rw-r--r--src/helper/gnome-utils.h14
-rw-r--r--src/helper/window.cpp62
-rw-r--r--src/helper/window.h19
4 files changed, 124 insertions, 119 deletions
diff --git a/src/helper/gnome-utils.cpp b/src/helper/gnome-utils.cpp
index 957b7ea5e..3d2b333a2 100644
--- a/src/helper/gnome-utils.cpp
+++ b/src/helper/gnome-utils.cpp
@@ -1,9 +1,7 @@
-#define __GNOME_UTILS_C__
-
-/*
+/**
* Helpers
*
- * Author:
+ * Authors:
* Mitsuru Oka
* Lauris Kaplinski <lauris@kaplinski.com>
*
@@ -25,49 +23,48 @@
* Returns a GList containing strings allocated with g_malloc
* that have been splitted from @uri-list.
*/
-GList*
-gnome_uri_list_extract_uris (const gchar* uri_list)
+GList *gnome_uri_list_extract_uris(const gchar *uri_list)
{
- const gchar *p, *q;
- gchar *retval;
- GList *result = NULL;
-
- g_return_val_if_fail (uri_list != NULL, NULL);
-
- p = uri_list;
-
- /* We don't actually try to validate the URI according to RFC
- * 2396, or even check for allowed characters - we just ignore
- * comments and trim whitespace off the ends. We also
- * allow LF delimination as well as the specified CRLF.
- */
- while (p) {
- if (*p != '#') {
- while (isspace(*p))
- p++;
-
- q = p;
- while (*q && (*q != '\n') && (*q != '\r'))
- q++;
-
- if (q > p) {
- q--;
- while (q > p && isspace(*q))
- q--;
-
- retval = (gchar*)g_malloc (q - p + 2);
- strncpy (retval, p, q - p + 1);
- retval[q - p + 1] = '\0';
-
- result = g_list_prepend (result, retval);
- }
- }
- p = strchr (p, '\n');
- if (p)
- p++;
- }
-
- return g_list_reverse (result);
+ const gchar *p, *q;
+ gchar *retval;
+ GList *result = NULL;
+
+ g_return_val_if_fail(uri_list != NULL, NULL);
+
+ p = uri_list;
+
+ /* We don't actually try to validate the URI according to RFC
+ * 2396, or even check for allowed characters - we just ignore
+ * comments and trim whitespace off the ends. We also
+ * allow LF delimination as well as the specified CRLF.
+ */
+ while (p) {
+ if (*p != '#') {
+ while (isspace(*p))
+ p++;
+
+ q = p;
+ while (*q && (*q != '\n') && (*q != '\r'))
+ q++;
+
+ if (q > p) {
+ q--;
+ while (q > p && isspace(*q))
+ q--;
+
+ retval = (gchar *)g_malloc(q - p + 2);
+ strncpy(retval, p, q - p + 1);
+ retval[q - p + 1] = '\0';
+
+ result = g_list_prepend(result, retval);
+ }
+ }
+ p = strchr(p, '\n');
+ if (p)
+ p++;
+ }
+
+ return g_list_reverse(result);
}
/**
@@ -80,29 +77,40 @@ gnome_uri_list_extract_uris (const gchar* uri_list)
* Note that unlike gnome_uri_list_extract_uris() function, this
* will discard any non-file uri from the result value.
*/
-GList*
-gnome_uri_list_extract_filenames (const gchar* uri_list)
+GList *gnome_uri_list_extract_filenames(const gchar *uri_list)
{
- g_return_val_if_fail (uri_list != NULL, NULL);
-
- GList *result = gnome_uri_list_extract_uris (uri_list);
-
- GList *tmp_list = result;
- while (tmp_list) {
- gchar *s = (gchar*)tmp_list->data;
-
- GList *node = tmp_list;
- tmp_list = tmp_list->next;
-
- if (!strncmp (s, "file:", 5)) {
- node->data = g_filename_from_uri (s, NULL, NULL);
- /* not sure if this fallback is useful at all */
- if (!node->data) node->data = g_strdup (s+5);
- } else {
- result = g_list_remove_link(result, node);
- g_list_free_1 (node);
- }
- g_free (s);
- }
- return result;
+ g_return_val_if_fail(uri_list != NULL, NULL);
+
+ GList *result = gnome_uri_list_extract_uris(uri_list);
+
+ GList *tmp_list = result;
+ while (tmp_list) {
+ gchar *s = (gchar *)tmp_list->data;
+
+ GList *node = tmp_list;
+ tmp_list = tmp_list->next;
+
+ if (!strncmp(s, "file:", 5)) {
+ node->data = g_filename_from_uri(s, NULL, NULL);
+ /* not sure if this fallback is useful at all */
+ if (!node->data)
+ node->data = g_strdup(s + 5);
+ } else {
+ result = g_list_remove_link(result, node);
+ g_list_free_1(node);
+ }
+ g_free(s);
+ }
+ return result;
}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
diff --git a/src/helper/gnome-utils.h b/src/helper/gnome-utils.h
index 3502b28df..6f2f28223 100644
--- a/src/helper/gnome-utils.h
+++ b/src/helper/gnome-utils.h
@@ -1,7 +1,7 @@
-/*
+/**
* GNOME Utils - Migration helper
*
- * Author:
+ * Authors:
* GNOME Developer
* Mitsuru Oka <oka326@parkcity.ne.jp>
* Lauris Kaplinski <lauris@ximian.com>
@@ -11,17 +11,15 @@
* Released under GNU GPL
*/
-
-#ifndef __GNOME_UTILS_H__
-#define __GNOME_UTILS_H__
+#ifndef SEEN_GNOME_UTILS_H
+#define SEEN_GNOME_UTILS_H
#include <glib.h>
GList *gnome_uri_list_extract_uris(gchar const *uri_list);
-
GList *gnome_uri_list_extract_filenames(gchar const *uri_list);
-#endif /* __GNOME_UTILS_H__ */
+#endif // !SEEN_GNOME_UTILS_H
/*
Local Variables:
@@ -32,4 +30,4 @@ GList *gnome_uri_list_extract_filenames(gchar const *uri_list);
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
diff --git a/src/helper/window.cpp b/src/helper/window.cpp
index 98fbef170..98e886a38 100644
--- a/src/helper/window.cpp
+++ b/src/helper/window.cpp
@@ -1,6 +1,4 @@
-#define __SP_WINDOW_C__
-
-/*
+/**
* Generic window implementation
*
* Author:
@@ -9,61 +7,61 @@
* This code is in public domain
*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
+#include <glibmm.h>
#include <gtkmm/window.h>
+#include "desktop.h"
#include "inkscape.h"
#include "shortcuts.h"
-#include "desktop.h"
#include "ui/tools/tool-base.h"
#include "window.h"
-#include <gtk/gtk.h>
static bool on_window_key_press(GdkEventKey* event)
{
- unsigned int shortcut;
- shortcut = Inkscape::UI::Tools::get_group0_keyval (event) |
+ unsigned shortcut = 0;
+ // FIXME why?
+ shortcut = Inkscape::UI::Tools::get_group0_keyval (event) |
( event->state & GDK_SHIFT_MASK ?
SP_SHORTCUT_SHIFT_MASK : 0 ) |
( event->state & GDK_CONTROL_MASK ?
SP_SHORTCUT_CONTROL_MASK : 0 ) |
( event->state & GDK_MOD1_MASK ?
SP_SHORTCUT_ALT_MASK : 0 );
- return sp_shortcut_invoke (shortcut, SP_ACTIVE_DESKTOP);
+ return sp_shortcut_invoke (shortcut, SP_ACTIVE_DESKTOP);
}
-Gtk::Window *
-Inkscape::UI::window_new (const gchar *title, unsigned int resizeable)
+Gtk::Window * Inkscape::UI::window_new (const gchar *title, unsigned int resizeable)
{
- Gtk::Window *window = new Gtk::Window(Gtk::WINDOW_TOPLEVEL);
- window->set_title (title);
- window->set_resizable (resizeable);
- window->signal_key_press_event().connect(sigc::ptr_fun(&on_window_key_press));
+ Gtk::Window *window = new Gtk::Window(Gtk::WINDOW_TOPLEVEL);
+ window->set_title (title);
+ window->set_resizable (resizeable);
+ window->signal_key_press_event().connect(sigc::ptr_fun(&on_window_key_press));
- return window;
+ return window;
}
-static gboolean
-sp_window_key_press(GtkWidget */*widget*/, GdkEventKey *event)
+static gboolean sp_window_key_press(GtkWidget *, GdkEventKey *event)
{
return on_window_key_press(event);
}
-GtkWidget *
-sp_window_new (const gchar *title, unsigned int resizeable)
+GtkWidget * sp_window_new (const gchar *title, unsigned int resizeable)
{
- GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title ((GtkWindow *) window, title);
- gtk_window_set_resizable ((GtkWindow *) window, resizeable);
- g_signal_connect_after ((GObject *) window, "key_press_event", (GCallback) sp_window_key_press, NULL);
+ GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title ((GtkWindow *) window, title);
+ gtk_window_set_resizable ((GtkWindow *) window, resizeable);
+ g_signal_connect_after ((GObject *) window, "key_press_event", (GCallback) sp_window_key_press, NULL);
- return window;
+ return window;
}
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
diff --git a/src/helper/window.h b/src/helper/window.h
index c6807f9e5..a0efcd292 100644
--- a/src/helper/window.h
+++ b/src/helper/window.h
@@ -1,7 +1,7 @@
-#ifndef __SP_WINDOW_H__
-#define __SP_WINDOW_H__
+#ifndef SEEN_SP_WINDOW_H
+#define SEEN_SP_WINDOW_H
-/*
+/**
* Generic window implementation
*
* Author:
@@ -17,10 +17,11 @@ namespace Gtk {
class Window;
}
-/*
- * This function is deprecated. Use Inkscape::UI::window_new instead.
- */
-GtkWidget *sp_window_new (const gchar *title, unsigned int resizeable);
+// Can we just get rid of this altogether?
+#if defined(GCC_VERSION) || defined(__clang__)
+__attribute__((deprecated))
+#endif
+GtkWidget * sp_window_new (const gchar *title, unsigned int resizeable);
namespace Inkscape {
namespace UI {
@@ -30,7 +31,7 @@ Gtk::Window *window_new (const gchar *title, unsigned int resizeable);
}
}
-#endif
+#endif // !SEEN_SP_WINDOW_H
/*
Local Variables:
@@ -41,4 +42,4 @@ Gtk::Window *window_new (const gchar *title, unsigned int resizeable);
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :