diff options
| author | Alexander Valavanis <valavanisalex@gmail.com> | 2019-02-03 17:36:54 +0000 |
|---|---|---|
| committer | Alexander Valavanis <valavanisalex@gmail.com> | 2019-02-03 17:36:54 +0000 |
| commit | 8308d8432292feea0baa950658d8c1b1eca5248f (patch) | |
| tree | ccf90b6d7709f401eea2aba0eedc2e4d48dd24e8 /src/widgets | |
| parent | TweakToolbar: GtkAction migration (diff) | |
| download | inkscape-8308d8432292feea0baa950658d8c1b1eca5248f.tar.gz inkscape-8308d8432292feea0baa950658d8c1b1eca5248f.zip | |
MeasureToolbar: GtkAction migration
Diffstat (limited to 'src/widgets')
| -rw-r--r-- | src/widgets/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/widgets/ege-output-action.cpp | 259 | ||||
| -rw-r--r-- | src/widgets/ege-output-action.h | 121 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 2 |
4 files changed, 1 insertions, 383 deletions
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index c41fcdb03..0102d1085 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -4,7 +4,6 @@ add_subdirectory(gimp) set(widgets_SRC desktop-widget.cpp ege-adjustment-action.cpp - ege-output-action.cpp ege-paint-def.cpp fill-style.cpp gradient-image.cpp @@ -30,7 +29,6 @@ set(widgets_SRC # Headers desktop-widget.h ege-adjustment-action.h - ege-output-action.h ege-paint-def.h fill-n-stroke-factory.h fill-style.h diff --git a/src/widgets/ege-output-action.cpp b/src/widgets/ege-output-action.cpp deleted file mode 100644 index 773629468..000000000 --- a/src/widgets/ege-output-action.cpp +++ /dev/null @@ -1,259 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MPL-1.1 OR LGPL-2.1-or-later -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is EGE Output Action. - * - * The Initial Developer of the Original Code is - * Jon A. Cruz. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* Note: this file should be kept compilable as both .cpp and .c */ - -#include <cstring> - -#include <gtk/gtk.h> -#include <gtkmm/container.h> -#include <gtkmm/label.h> - -#include "widgets/ege-output-action.h" - - -static void ege_output_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); -static void ege_output_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); -static void fixup_labels( GObject *gobject, GParamSpec *arg1, gpointer user_data ); - -/* static GtkWidget* create_menu_item( GtkAction* action ); */ -static GtkWidget* create_tool_item( GtkAction* action ); - -typedef struct { - gboolean useMarkup; -} EgeOutputActionPrivate; - -#define EGE_OUTPUT_ACTION_GET_PRIVATE( o ) \ - reinterpret_cast<EgeOutputActionPrivate *>(ege_output_action_get_instance_private (o)) - -enum { - PROP_USE_MARKUP = 1, -}; - -G_DEFINE_TYPE_WITH_PRIVATE(EgeOutputAction, ege_output_action, GTK_TYPE_ACTION); - -void ege_output_action_class_init( EgeOutputActionClass* klass ) -{ - if ( klass ) { - GObjectClass* objClass = G_OBJECT_CLASS( klass ); - - objClass->get_property = ege_output_action_get_property; - objClass->set_property = ege_output_action_set_property; - -/* klass->parent_class.create_menu_item = create_menu_item; */ - klass->parent_class.create_tool_item = create_tool_item; - - g_object_class_install_property( objClass, - PROP_USE_MARKUP, - g_param_spec_boolean( "use-markup", - "UseMarkup", - "If markup should be used", - FALSE, - (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) ); - } -} - - -void ege_output_action_init( EgeOutputAction* action ) -{ - auto priv = EGE_OUTPUT_ACTION_GET_PRIVATE( action ); - priv->useMarkup = FALSE; - - g_signal_connect( action, "notify", G_CALLBACK( fixup_labels ), NULL ); -} - -EgeOutputAction* ege_output_action_new( const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *stock_id ) -{ - GObject* obj = (GObject*)g_object_new( EGE_OUTPUT_ACTION_TYPE, - "name", name, - "label", label, - "tooltip", tooltip, - "stock_id", stock_id, - "use-markup", FALSE, - NULL ); - - EgeOutputAction* action = EGE_OUTPUT_ACTION( obj ); - - return action; -} - -gboolean ege_output_action_get_use_markup( EgeOutputAction* action ) -{ - g_return_val_if_fail( IS_EGE_OUTPUT_ACTION(action), FALSE ); - auto priv = EGE_OUTPUT_ACTION_GET_PRIVATE( action ); - - return priv->useMarkup; -} - -void ege_output_action_set_use_markup( EgeOutputAction* action, gboolean setting ) -{ - g_object_set( G_OBJECT(action), "use-markup", setting, NULL ); -} - -void ege_output_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ) -{ - EgeOutputAction* action = EGE_OUTPUT_ACTION( obj ); - auto priv = EGE_OUTPUT_ACTION_GET_PRIVATE( action ); - switch ( propId ) { - case PROP_USE_MARKUP: - g_value_set_boolean( value, priv->useMarkup ); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); - } -} - -void ege_output_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ) -{ - EgeOutputAction* action = EGE_OUTPUT_ACTION( obj ); - auto priv = EGE_OUTPUT_ACTION_GET_PRIVATE( action ); - switch ( propId ) { - case PROP_USE_MARKUP: - { - priv->useMarkup = g_value_get_boolean( value ); - } - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); - } -} - - -/* static GtkWidget* create_menu_item( GtkAction* action ) */ - -GtkWidget* create_tool_item( GtkAction* action ) -{ - GtkWidget* item = nullptr; - - if ( IS_EGE_OUTPUT_ACTION(action) ) - { - auto act = EGE_OUTPUT_ACTION (action); - auto priv = EGE_OUTPUT_ACTION_GET_PRIVATE( act ); - GValue value; - auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - GtkWidget* lbl = nullptr; - memset( &value, 0, sizeof(value) ); - - g_value_init( &value, G_TYPE_STRING ); - g_object_get_property( G_OBJECT(action), "short_label", &value ); - const gchar* sss = g_value_get_string( &value ); - - item = GTK_WIDGET( gtk_tool_item_new() ); - - lbl = gtk_label_new( " " ); - gtk_container_add( GTK_CONTAINER(hb), lbl ); - - if ( priv->useMarkup ) { - lbl = gtk_label_new(nullptr); - gtk_label_set_markup( GTK_LABEL(lbl), sss ? sss : " " ); - } else { - lbl = gtk_label_new( sss ? sss : " " ); - } - gtk_container_add( GTK_CONTAINER(hb), lbl ); - - lbl = gtk_label_new( " " ); - gtk_container_add( GTK_CONTAINER(hb), lbl ); - - gtk_container_add( GTK_CONTAINER(item), hb ); - - gtk_widget_show_all( item ); - - g_value_unset( &value ); - } else { - item = GTK_ACTION_CLASS(ege_output_action_parent_class)->create_tool_item( action ); - } - - return item; -} - -void fixup_labels( GObject *gobject, GParamSpec *arg1, gpointer user_data ) -{ - /* TODO: handle 'use-markup' getting changed also */ - - if ( arg1 && arg1->name && (strcmp("label", arg1->name) == 0) ) { - GSList* proxies = gtk_action_get_proxies( GTK_ACTION(gobject) ); - gchar* str = nullptr; - g_object_get( gobject, "label", &str, NULL ); - Glib::ustring str2(str); - (void)user_data; - while ( proxies ) { - if ( GTK_IS_TOOL_ITEM(proxies->data) ) { - /* Search for the things we built up in create_tool_item() */ - std::vector<Gtk::Widget*> children = Glib::wrap(GTK_CONTAINER(proxies->data))->get_children(); - if ( !children.empty() ) { - if ( GTK_IS_BOX(children[0]->gobj()) ) { - children = dynamic_cast<Gtk::Container *>(children[0])->get_children(); - if ( children.size()>1 ) { - Gtk::Widget *child = children[1]; - if ( GTK_IS_LABEL(child->gobj()) ) { - Gtk::Label* lbl = dynamic_cast<Gtk::Label *>(child); - auto action = EGE_OUTPUT_ACTION(gobject); - auto priv = EGE_OUTPUT_ACTION_GET_PRIVATE( action ); - if ( priv->useMarkup ) { - lbl->set_markup(str2); - } else { - lbl->set_text(str2); - } - } - } - } - } - } - proxies = g_slist_next( proxies ); - } - g_free( str ); - } -} -/* - 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:textwidth=99 : diff --git a/src/widgets/ege-output-action.h b/src/widgets/ege-output-action.h deleted file mode 100644 index 47acad0db..000000000 --- a/src/widgets/ege-output-action.h +++ /dev/null @@ -1,121 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MPL-1.1 OR LGPL-2.1-or-later -#ifndef SEEN_EGE_OUTPUT_ACTION -#define SEEN_EGE_OUTPUT_ACTION -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is EGE Output Action. - * - * The Initial Developer of the Original Code is - * Jon A. Cruz. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/** \file - * GtkAction subclass that represents a string for output. - */ - -/* Note: this file should be kept compilable as both .cpp and .c */ - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - - -#define EGE_OUTPUT_ACTION_TYPE ( ege_output_action_get_type() ) -#define EGE_OUTPUT_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), EGE_OUTPUT_ACTION_TYPE, EgeOutputAction) ) -#define EGE_OUTPUT_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), EGE_OUTPUT_ACTION_TYPE, EgeOutputActionClass) ) -#define IS_EGE_OUTPUT_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), EGE_OUTPUT_ACTION_TYPE) ) -#define IS_EGE_OUTPUT_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), EGE_OUTPUT_ACTION_TYPE) ) -#define EGE_OUTPUT_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), EGE_OUTPUT_ACTION_TYPE, EgeOutputActionClass) ) - -typedef struct _EgeOutputAction EgeOutputAction; -typedef struct _EgeOutputActionClass EgeOutputActionClass; - -/** - * Instance structure of EgeOutputAction. - */ -struct _EgeOutputAction -{ - /** Parent instance structure. */ - GtkAction action; -}; - -/** - * Class structure of EgeOutputAction. - */ -struct _EgeOutputActionClass -{ - /** Parent class structure. */ - GtkActionClass parent_class; -}; - -/** Standard Gtk type function */ -GType ege_output_action_get_type( void ); - -/** - * Creates a new EgeOutputAction instance. - * This is a GtkAction subclass that displays a string. - * - * @param name Functional name for the action. - * @param label Display label for the action. - * @param tooltip Tooltip for the action. - * @param stock_id Icon id to use. - * - * @deprecated GtkActions are deprecated. Use a GtkLabel inside a GtkToolItem instead. - * The Inkscape::UI::Toolbar::Toolbar base class provides an add_label function - * to simplify this. - */ -EgeOutputAction* ege_output_action_new( const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *stock_id ); - -/** - * Return whether or not the displayed text is interpreted as markup. - * - * @param action The action to fetch the markup state for. - * @return True if the text is to be interpreted as markup, false otherwise. - */ -gboolean ege_output_action_get_use_markup( EgeOutputAction* action ); - -/** - * Sets whether or not the displayed text is interpreted as markup. - * - * @param action The action to set the markup state for. - * @param setting True if the text is to be interpreted as markup, false otherwise. - */ -void ege_output_action_set_use_markup( EgeOutputAction* action, gboolean setting ); - -G_END_DECLS - -#endif /* SEEN_EGE_OUTPUT_ACTION */ diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index dda7d2eae..f4ffbbaf0 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -199,7 +199,7 @@ static struct { SP_VERB_INVALID, nullptr, nullptr}, { "/tools/zoom", "zoom_toolbox", Inkscape::UI::Toolbar::ZoomToolbar::create, nullptr, "ZoomToolbar", SP_VERB_INVALID, nullptr, nullptr}, - { "/tools/measure", "measure_toolbox", nullptr, Inkscape::UI::Toolbar::MeasureToolbar::prep, "MeasureToolbar", + { "/tools/measure", "measure_toolbox", Inkscape::UI::Toolbar::MeasureToolbar::create, nullptr, "MeasureToolbar", SP_VERB_INVALID, nullptr, nullptr}, { "/tools/shapes/star", "star_toolbox", Inkscape::UI::Toolbar::StarToolbar::create, nullptr, "StarToolbar", SP_VERB_CONTEXT_STAR_PREFS, "/tools/shapes/star", N_("Style of new stars")}, |
