...
 
Commits (10)
......@@ -167,6 +167,13 @@ LIBS=$GTK_LIBS
AC_CHECK_FUNCS(gtk_print_unix_dialog_new,[have_unix_print=yes]; break,[have_unix_print=no])
AM_CONDITIONAL(HAVE_GTK_UNIX_PRINT, test x"$have_unix_print" = "xyes")
dnl ================================================================
dnl Check for _gtk_widget_class_template_unset_only_for_glade() in gtk+
dnl ================================================================
LIBS=$GTK_LIBS
AC_CHECK_FUNCS(_gtk_widget_class_template_unset_only_for_glade,[have_template_unset=yes]; break,[have_template_unset=no])
AM_CONDITIONAL(HAVE_GTK_TEMPLATE_UNSET, test x"$have_template_unset" = "xyes")
dnl ================================================================
dnl Python for optional python dev libs
dnl ================================================================
......
......@@ -125,6 +125,7 @@ libgladeui_2_la_SOURCES = \
glade-signal-class.c \
glade-signal-editor.c \
glade-signal-model.c \
glade-template.c \
glade-tsort.c \
glade-utils.c \
glade-widget.c \
......
......@@ -45,6 +45,8 @@ struct _GladeCatalog
gchar *name; /* Symbolic catalog name */
gchar *prefix; /* Catalog path prefix */
gchar *dep_catalog; /* Symbolic name of the catalog that
* this catalog depends on */
......@@ -108,6 +110,7 @@ catalog_allocate (void)
catalog->library = NULL;
catalog->name = NULL;
catalog->prefix = NULL;
catalog->dep_catalog = NULL;
catalog->domain = NULL;
catalog->book = NULL;
......@@ -201,6 +204,7 @@ catalog_open (const gchar *filename)
catalog = catalog_allocate ();
catalog->context = context;
catalog->name = name;
catalog->prefix = g_path_get_dirname (filename);
glade_xml_get_property_version (root, GLADE_TAG_VERSION,
&catalog->major_version,
......@@ -726,6 +730,20 @@ glade_catalog_get_name (GladeCatalog *catalog)
return catalog->name;
}
/**
* glade_catalog_get_prefix:
* @catalog: a catalog object
*
* Returns: The catalog path prefix.
*/
G_CONST_RETURN gchar *
glade_catalog_get_prefix (GladeCatalog *catalog)
{
g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
return catalog->prefix;
}
/**
* glade_catalog_get_book:
* @catalog: a catalog object
......
......@@ -59,6 +59,7 @@ const GList *glade_catalog_get_extra_paths (void);
const GList *glade_catalog_load_all (void);
G_CONST_RETURN gchar *glade_catalog_get_name (GladeCatalog *catalog);
G_CONST_RETURN gchar *glade_catalog_get_prefix (GladeCatalog *catalog);
G_CONST_RETURN gchar *glade_catalog_get_icon_prefix(GladeCatalog *catalog);
G_CONST_RETURN gchar *glade_catalog_get_domain (GladeCatalog *catalog);
G_CONST_RETURN gchar *glade_catalog_get_book (GladeCatalog *catalog);
......
......@@ -65,6 +65,7 @@ enum
PROP_SHOW_CLASS_FIELD,
PROP_CLASS_FIELD,
PROP_SHOW_BORDER,
PROP_SIGNAL_EDITOR,
N_PROPERTIES
};
......@@ -199,6 +200,9 @@ glade_editor_get_property (GObject *object,
case PROP_SHOW_BORDER:
g_value_set_boolean (value, gtk_notebook_get_show_border (GTK_NOTEBOOK (editor->priv->notebook)));
break;
case PROP_SIGNAL_EDITOR:
g_value_set_object (value, editor->priv->signal_editor);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -259,12 +263,20 @@ glade_editor_class_init (GladeEditorClass *klass)
_("The class field string"),
NULL,
G_PARAM_READABLE);
properties[PROP_SHOW_BORDER] =
g_param_spec_boolean ("show-boder",
_("Show Border"),
_("Whether the border should be shown"),
TRUE,
G_PARAM_READWRITE);
properties[PROP_SIGNAL_EDITOR] =
g_param_spec_object ("signal-editor",
_("Signal Editor"),
_("The signal editor used to edit signals"),
GLADE_TYPE_SIGNAL_EDITOR,
G_PARAM_READABLE);
/* Install all properties */
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
......
......@@ -5,6 +5,7 @@ VOID:OBJECT
VOID:STRING
VOID:INT,INT
VOID:OBJECT,OBJECT
VOID:OBJECT,OBJECT,OBJECT
VOID:OBJECT,BOOLEAN
VOID:STRING,STRING,STRING
OBJECT:POINTER
......
......@@ -44,6 +44,21 @@ GList *_glade_widget_peek_prop_refs (GladeWidget *widget);
GladeCatalog *_glade_catalog_get_catalog (const gchar *name);
GList *_glade_catalog_tsort (GList *catalogs);
/* glade-project.c */
void
_glade_project_emit_add_signal_handler (GladeWidget *widget,
const GladeSignal *signal);
void
_glade_project_emit_remove_signal_handler (GladeWidget *widget,
const GladeSignal *signal);
void
_glade_project_emit_change_signal_handler (GladeWidget *widget,
const GladeSignal *old_signal,
const GladeSignal *new_signal);
void
_glade_project_emit_activate_signal_handler (GladeWidget *widget,
const GladeSignal *signal);
/* glade-project-properties.c */
void
......@@ -79,6 +94,11 @@ gchar *_glade_util_file_get_relative_path (GFile *target,
void _glade_xml_error_reset_last (void);
gchar *_glade_xml_error_get_last_message (void);
/* glade-template.c */
GType _glade_template_generate_type_from_file (GladeCatalog *catalog,
const gchar *parent,
const gchar *filename);
G_END_DECLS
#endif /* __GLADE_PRIVATE_H__ */
......@@ -180,6 +180,10 @@ enum
TARGETS_CHANGED,
LOAD_PROGRESS,
WIDGET_VISIBILITY_CHANGED,
ADD_SIGNAL_HANDLER,
REMOVE_SIGNAL_HANDLER,
CHANGE_SIGNAL_HANDLER,
ACTIVATE_SIGNAL_HANDLER,
LAST_SIGNAL
};
......@@ -952,6 +956,80 @@ glade_project_class_init (GladeProjectClass *klass)
_glade_marshal_VOID__OBJECT_BOOLEAN,
G_TYPE_NONE, 2, GLADE_TYPE_WIDGET, G_TYPE_BOOLEAN);
/**
* GladeProject::add-signal-handler:
* @gladeproject: the #GladeProject which received the signal.
* @gladewidget: the #GladeWidget
* @signal: the #GladeSignal that was added to @gladewidget.
*/
glade_project_signals[ADD_SIGNAL_HANDLER] =
g_signal_new ("add-signal-handler",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
_glade_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE,
2,
GLADE_TYPE_WIDGET,
GLADE_TYPE_SIGNAL);
/**
* GladeProject::remove-signal-handler:
* @gladeproject: the #GladeProject which received the signal.
* @gladewidget: the #GladeWidget
* @signal: the #GladeSignal that was removed from @gladewidget.
*/
glade_project_signals[REMOVE_SIGNAL_HANDLER] =
g_signal_new ("remove-signal-handler",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
_glade_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE,
2,
GLADE_TYPE_WIDGET,
GLADE_TYPE_SIGNAL);
/**
* GladeProject::change-signal-handler:
* @gladeproject: the #GladeProject which received the signal.
* @gladewidget: the #GladeWidget
* @old_signal: the old #GladeSignal that changed
* @new_signal: the new #GladeSignal
*/
glade_project_signals[CHANGE_SIGNAL_HANDLER] =
g_signal_new ("change-signal-handler",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
_glade_marshal_VOID__OBJECT_OBJECT_OBJECT,
G_TYPE_NONE,
3,
GLADE_TYPE_WIDGET,
GLADE_TYPE_SIGNAL,
GLADE_TYPE_SIGNAL);
/**
* GladeProject::activate-signal-handler:
* @gladeproject: the #GladeProject which received the signal.
* @gladewidget: the #GladeWidget
* @signal: the #GladeSignal that was activated
*/
glade_project_signals[ACTIVATE_SIGNAL_HANDLER] =
g_signal_new ("activate-signal-handler",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
_glade_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE,
2,
GLADE_TYPE_WIDGET,
GLADE_TYPE_SIGNAL);
glade_project_props[PROP_MODIFIED] =
g_param_spec_boolean ("modified",
"Modified",
......@@ -5383,3 +5461,53 @@ glade_project_command_delete (GladeProject *project)
if (widgets)
g_list_free (widgets);
}
/* Private */
void
_glade_project_emit_add_signal_handler (GladeWidget *widget,
const GladeSignal *signal)
{
GladeProject *project = glade_widget_get_project (widget);
if (project)
g_signal_emit (project, glade_project_signals[ADD_SIGNAL_HANDLER], 0,
widget, signal);
}
void
_glade_project_emit_remove_signal_handler (GladeWidget *widget,
const GladeSignal *signal)
{
GladeProject *project = glade_widget_get_project (widget);
if (project)
g_signal_emit (project, glade_project_signals[REMOVE_SIGNAL_HANDLER], 0,
widget, signal);
}
void
_glade_project_emit_change_signal_handler (GladeWidget *widget,
const GladeSignal *old_signal,
const GladeSignal *new_signal)
{
GladeProject *project = glade_widget_get_project (widget);
if (project)
g_signal_emit (project, glade_project_signals[CHANGE_SIGNAL_HANDLER], 0,
widget, old_signal, new_signal);
}
void
_glade_project_emit_activate_signal_handler (GladeWidget *widget,
const GladeSignal *signal)
{
GladeProject *project = glade_widget_get_project (widget);
if (project)
g_signal_emit (project, glade_project_signals[ACTIVATE_SIGNAL_HANDLER], 0,
widget, signal);
}
/*
* glade-template.c:
*
* Copyright (C) 2017-2018 Juan Pablo Ugarte.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Authors:
* Juan Pablo Ugarte <juanpablougarte@gmail.com>
*/
#include "glade-private.h"
#include "glade-utils.h"
#if HAVE_GTK_TEMPLATE_UNSET
extern void
_gtk_widget_class_template_unset_only_for_glade (GtkWidgetClass *widget_class);
#else
#define _gtk_widget_class_template_unset_only_for_glade(void)
#endif
static GHashTable *templates = NULL;
static void
glade_template_instance_init (GTypeInstance *instance, gpointer g_class)
{
/* Reset class template */
_gtk_widget_class_template_unset_only_for_glade (GTK_WIDGET_GET_CLASS (instance));
gtk_widget_class_set_template (GTK_WIDGET_GET_CLASS (instance),
g_hash_table_lookup (templates,
G_OBJECT_TYPE_NAME (instance)));
/* Regular template initialization*/
gtk_widget_init_template ((GtkWidget *)instance);
}
typedef struct {
gchar *class;
gchar *parent;
} ParserData;
static void
start_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values,
gpointer user_data,
GError **error)
{
ParserData *data = user_data;
gint i;
if (!g_str_equal (element_name, "template"))
return;
for (i = 0; attribute_names[i]; i++)
if (g_str_equal (attribute_names[i], "class"))
data->class = g_strdup (attribute_values[i]);
else if (g_str_equal (attribute_names[i], "parent"))
data->parent = g_strdup (attribute_values[i]);
}
GType
_glade_template_generate_type_from_file (GladeCatalog *catalog,
const gchar *name,
const gchar *filename)
{
GMarkupParser parser = { start_element, NULL, };
GMarkupParseContext *context;
ParserData data = { 0, };
GType parent_type;
GTypeQuery query;
GTypeInfo *info;
gchar *template = NULL;
gsize len = 0;
GError *error = NULL;
g_return_val_if_fail (name != NULL, 0);
g_return_val_if_fail (filename != NULL, 0);
if (g_path_is_absolute (filename))
g_file_get_contents (filename, &template, &len, &error);
else
{
gchar *fullpath = g_build_filename (glade_catalog_get_prefix (catalog),
filename, NULL);
g_file_get_contents (fullpath, &template, &len, &error);
g_free (fullpath);
}
if (error)
{
g_warning ("Error loading template file %s for %s class - %s", filename, name, error->message);
return G_TYPE_INVALID;
}
context = g_markup_parse_context_new (&parser, 0, &data, NULL);
g_markup_parse_context_parse (context, template, -1, NULL);
g_markup_parse_context_end_parse (context, NULL);
if (!g_str_equal (name, data.class))
{
g_warning ("Template %s is for class %s, not %s", filename, data.class, name);
return G_TYPE_INVALID;
}
parent_type = glade_util_get_type_from_name (data.parent, FALSE);
g_return_val_if_fail (parent_type != 0, 0);
g_type_query (parent_type, &query);
g_return_val_if_fail (query.type != 0, 0);
if (g_once_init_enter (&templates))
{
GHashTable *table = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_bytes_unref);
g_once_init_leave (&templates, table);
}
/* Add template to global hash table */
g_hash_table_insert (templates, g_strdup (name), g_bytes_new_take (template, len));
info = g_new0 (GTypeInfo, 1);
info->class_size = query.class_size;
info->instance_size = query.instance_size;
info->instance_init = glade_template_instance_init;
g_free (data.class);
g_free (data.parent);
return g_type_register_static (parent_type, name, info, 0);
}
......@@ -2694,7 +2694,7 @@ glade_widget_adaptor_from_catalog (GladeCatalog *catalog,
{
GladeWidgetAdaptor *adaptor = NULL;
gchar *name, *generic_name, *icon_name, *adaptor_icon_name, *adaptor_name,
*func_name;
*func_name, *template;
gchar *title, *translated_title, *parent_name;
GType object_type, adaptor_type, parent_type;
gchar *missing_icon = NULL;
......@@ -2716,6 +2716,7 @@ glade_widget_adaptor_from_catalog (GladeCatalog *catalog,
* - Autosubclassing a specified parent type (a fake widget class)
* - parsing the _get_type() function directly from the catalog
* - deriving foo_bar_get_type() from the name FooBar and loading that.
* - setting a template ui definition
*/
if ((parent_name =
glade_xml_get_property_string (class_node, GLADE_TAG_PARENT)) != NULL)
......@@ -2739,6 +2740,13 @@ glade_widget_adaptor_from_catalog (GladeCatalog *catalog,
object_type = glade_util_get_type_from_name (func_name, TRUE);
g_free (func_name);
}
else if ((template =
glade_xml_get_property_string (class_node,
GLADE_XML_TAG_TEMPLATE)) != NULL)
{
object_type = _glade_template_generate_type_from_file (catalog, name, template);
g_free (template);
}
else
{
GType type_iter;
......
......@@ -342,6 +342,7 @@ glade_widget_add_signal_handler (GladeWidget *widget,
new_signal_handler = glade_signal_clone (signal_handler);
g_ptr_array_add (signals, new_signal_handler);
g_signal_emit (widget, glade_widget_signals[ADD_SIGNAL_HANDLER], 0, new_signal_handler);
_glade_project_emit_add_signal_handler (widget, new_signal_handler);
glade_project_verify_signal (widget, new_signal_handler);
......@@ -388,6 +389,7 @@ glade_widget_remove_signal_handler (GladeWidget *widget,
break;
}
}
_glade_project_emit_remove_signal_handler (widget, signal_handler);
}
/**
......@@ -444,10 +446,12 @@ glade_widget_change_signal_handler (GladeWidget *widget,
g_signal_emit (widget, glade_widget_signals[CHANGE_SIGNAL_HANDLER], 0,
signal_handler_iter);
break;
}
}
_glade_project_emit_change_signal_handler (widget,
old_signal_handler,
new_signal_handler);
}
static gboolean
......@@ -1474,8 +1478,7 @@ glade_widget_class_init (GladeWidgetClass *klass)
/**
* GladeWidget::change-signal-handler:
* @gladewidget: the #GladeWidget which received the signal.
* @arg1: the old #GladeSignal
* @arg2: the new #GladeSignal
* @arg1: the #GladeSignal that changed
*/
glade_widget_signals[CHANGE_SIGNAL_HANDLER] =
g_signal_new ("change-signal-handler",
......
......@@ -185,6 +185,7 @@ typedef struct _GladeProject GladeProject;
#define GLADE_TAG_ICON_NAME "icon-name"
#define GLADE_TAG_IMPORTANT "important"
#define GLADE_TAG_CREATE_TYPE "create-type"
#define GLADE_TAG_TEMPLATE_PREFIX "template-prefix"
/* search child */
......
# Swedish messages for Glade handbook.
# Copyright © 2006-2017 Free Software Foundation, Inc.
# Copyright © 2006-2018 Free Software Foundation, Inc.
# This file is distributed under the same license as the glade package.
# Daniel Nylander <po@danielnylander.se>, 2006.
# Sebastian Rasmussen <sebras@gmail.com>, 2016, 2018.
# Anders Jonsson <anders.jonsson@norsjovallen.se>, 2017.
# Anders Jonsson <anders.jonsson@norsjovallen.se>, 2017, 2018.
#
msgid ""
msgstr ""
"Project-Id-Version: glade3 doc\n"
"POT-Creation-Date: 2018-03-11 09:21+0000\n"
"PO-Revision-Date: 2017-08-03 02:31+0200\n"
"POT-Creation-Date: 2018-09-15 10:42+0000\n"
"PO-Revision-Date: 2018-12-23 21:20+0100\n"
"Last-Translator: Anders Jonsson <anders.jonsson@norsjovallen.se>\n"
"Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n"
"Language: sv\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.2\n"
"X-Generator: Poedit 2.2\n"
#. Put one translator per line, in the form NAME <EMAIL>, YEAR1, YEAR2
msgctxt "_"
......@@ -814,12 +814,13 @@ msgstr ""
#: C/index.docbook:459
msgid ""
"To report a bug or make a suggestion regarding this application or this "
"manual, you can submit them using <ulink url=\"http://bugzilla.gnome.org/"
"enter_bug.cgi?product=glade3\" type=\"http\">bugzilla</ulink>."
"manual, you can submit them using <ulink url=\"https://gitlab.gnome.org/"
"GNOME/glade/issues/\" type=\"http\">our issue tracking system</ulink>."
msgstr ""
"För att rapportera ett fel eller framföra ett förslag angående detta program "
"eller denna manual kan du skicka in dem via <ulink url=\"http://bugzilla."
"gnome.org/enter_bug.cgi?product=glade3\" type=\"http\">bugzilla</ulink>."
"eller denna manual kan du skicka in dem via <ulink url=\"https://gitlab."
"gnome.org/GNOME/glade/issues/\" type=\"http\">vårt felrapporteringssystem</"
"ulink>."
#. (itstool) path: sect1/para
#: C/index.docbook:466
......
......@@ -42,9 +42,41 @@
"*.a"
],
"modules" : [
{
"name" : "gladeui",
"config-opts" : [
"--disable-man-pages",
"--enable-gladeui"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/glade.git",
"branch" : "master"
}
]
},
{
"name" : "libhandy",
"buildsystem" : "meson",
"builddir" : true,
"build-options" : "examples",
"config-opts" : [
"-Dintrospection=false",
"-Dtests=false",
"-Dvapi=false"
],
"sources" : [
{
"type" : "git",
"url" : "https://source.puri.sm/Librem5/libhandy.git"
}
]
},
{
"name" : "glade",
"config-opts" : [
"--disable-gladeui",
"--disable-man-pages"
],
"sources" : [
......
......@@ -17,6 +17,9 @@
<!ELEMENT glade-widget-class (post-create-function?,
get-internal-child-function?,
child-property-applies-function?,
read-widget-function?,
write-widget-function?,
set-property-function?,
properties?,
children?,
packing-defaults?)>
......@@ -39,6 +42,7 @@
<!ELEMENT property (spec?,
type?,
parameter-spec?,
tooltip?,
parameters?,
set-function?,
......@@ -74,6 +78,8 @@
construct-only CDATA #IMPLIED
translatable CDATA #IMPLIED>
<!ELEMENT parameter-spec (type?,
value-type?)>
<!ELEMENT set-function (#PCDATA)>
<!ELEMENT get-function (#PCDATA)>
<!ELEMENT spec (#PCDATA)>
......@@ -87,6 +93,10 @@
<!ATTLIST parameter key CDATA #REQUIRED
value CDATA #REQUIRED>
<!ELEMENT paremter-spec (type,
value-type)>
<!ELEMENT value-type (#PCDATA)>
<!ELEMENT children (child+)>
<!ELEMENT child (type,
......@@ -114,6 +124,10 @@
<!ELEMENT get-internal-child-function (#PCDATA)>
<!ELEMENT child-property-applies-function (#PCDATA)>
<!ELEMENT read-widget-function (#PCDATA)>
<!ELEMENT write-widget-function (#PCDATA)>
<!ELEMENT set-property-function (#PCDATA)>
<!ELEMENT glade-widget-group (default-palette-state?,
glade-widget-class-ref+)>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -244,8 +244,7 @@ find_widget_forall (GtkWidget *widget, gpointer user_data)
if (data->widget)
return;
if (g_strcmp0 (widget_get_name (widget), data->name) == 0 &&
gtk_widget_is_visible (widget))
if (g_strcmp0 (widget_get_name (widget), data->name) == 0)
{
data->widget = widget;
return;
......