Fixed couple of leaks; made AccelButton use builting glade parser
This commit is contained in:
parent
89ea543339
commit
f077958174
22
moo.kdevelop
22
moo.kdevelop
@ -36,17 +36,17 @@
|
||||
<useconfiguration>debug</useconfiguration>
|
||||
</general>
|
||||
<run>
|
||||
<mainprogram>tests/miniglade</mainprogram>
|
||||
<mainprogram>tests/medit</mainprogram>
|
||||
<directoryradio>executable</directoryradio>
|
||||
<customdirectory>/</customdirectory>
|
||||
<programargs>/usr/share/doc/libglade2-dev/examples/first.glade</programargs>
|
||||
<programargs></programargs>
|
||||
<terminal>false</terminal>
|
||||
<autocompile>false</autocompile>
|
||||
<envvars/>
|
||||
</run>
|
||||
<configurations>
|
||||
<debug>
|
||||
<configargs>--enable-debug=full --enable-all-gcc-warnings=fatal --enable-developer-mode --disable-moo-module --without-python --without-mooterm --without-mooapp --without-mooui --without-mooedit</configargs>
|
||||
<configargs>--enable-debug=full --enable-all-gcc-warnings=fatal --enable-developer-mode --disable-moo-module --without-python --without-mooterm --without-mooapp --without-mooui</configargs>
|
||||
<builddir>build/debug</builddir>
|
||||
<ccompiler>kdevgccoptions</ccompiler>
|
||||
<cxxcompiler>kdevgppoptions</cxxcompiler>
|
||||
@ -54,13 +54,13 @@
|
||||
<cflags>-O0 -g3 -pg</cflags>
|
||||
<cxxflags>-O0 -g3 -pg</cxxflags>
|
||||
<envvars/>
|
||||
<topsourcedir/>
|
||||
<cppflags/>
|
||||
<ldflags/>
|
||||
<ccompilerbinary/>
|
||||
<cxxcompilerbinary/>
|
||||
<f77compilerbinary/>
|
||||
<f77flags/>
|
||||
<topsourcedir></topsourcedir>
|
||||
<cppflags></cppflags>
|
||||
<ldflags></ldflags>
|
||||
<ccompilerbinary></ccompilerbinary>
|
||||
<cxxcompilerbinary></cxxcompilerbinary>
|
||||
<f77compilerbinary></f77compilerbinary>
|
||||
<f77flags></f77flags>
|
||||
</debug>
|
||||
<optimized>
|
||||
<configargs>--enable-all-gcc-warnings=fatal --enable-developer-mode --without-mooapp --without-mooterm --without-python</configargs>
|
||||
@ -165,7 +165,7 @@
|
||||
<kdevdebugger>
|
||||
<general>
|
||||
<dbgshell>libtool</dbgshell>
|
||||
<programargs>--g-fatal-warnings /usr/share/mysql-gui/administrator/backup.glade</programargs>
|
||||
<programargs>--g-fatal-warnings</programargs>
|
||||
<gdbpath></gdbpath>
|
||||
<configGdbScript></configGdbScript>
|
||||
<runShellScript></runShellScript>
|
||||
|
@ -37,7 +37,7 @@ gtksourceview_gettext (const char *msgid)
|
||||
initialized = TRUE;
|
||||
}
|
||||
|
||||
return dgettext (GETTEXT_PACKAGE, msgid);
|
||||
return (char*) dgettext (GETTEXT_PACKAGE, msgid);
|
||||
}
|
||||
|
||||
|
||||
|
@ -156,7 +156,9 @@ static void moo_recent_mgr_set_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_USER_ID:
|
||||
g_free (mgr->priv->user_id);
|
||||
mgr->priv->user_id = g_strdup (g_value_get_string (value));
|
||||
g_object_notify (object, "user-id");
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -192,10 +194,10 @@ moo_recent_mgr_finalize (GObject *object)
|
||||
|
||||
for (l = mgr->priv->files; l != NULL; l = l->next)
|
||||
recent_entry_free (l->data);
|
||||
|
||||
g_slist_free (mgr->priv->files);
|
||||
mgr->priv->files = NULL;
|
||||
g_object_unref (mgr->priv->tooltips);
|
||||
mgr->priv->tooltips = NULL;
|
||||
g_free (mgr->priv->user_id);
|
||||
|
||||
for (l = mgr->priv->menus; l != NULL; l = l->next)
|
||||
{
|
||||
|
@ -159,6 +159,9 @@ moo_text_buffer_finalize (GObject *object)
|
||||
if (buffer->priv->lang)
|
||||
g_object_unref (buffer->priv->lang);
|
||||
|
||||
g_free (buffer->priv->left_brackets);
|
||||
g_free (buffer->priv->right_brackets);
|
||||
|
||||
g_free (buffer->priv);
|
||||
buffer->priv = NULL;
|
||||
|
||||
|
@ -41,6 +41,7 @@ libmooutils_la_SOURCES = \
|
||||
eggregex.h \
|
||||
mooaccelbutton.c \
|
||||
mooaccelbutton.h \
|
||||
mooaccelbutton-glade.h \
|
||||
mooclosure.c \
|
||||
mooclosure.h \
|
||||
moocompat.c \
|
||||
@ -74,7 +75,6 @@ libmooutils_la_SOURCES = \
|
||||
mootypes.h \
|
||||
moowin.c \
|
||||
moowin.h \
|
||||
shortcutdialog-glade.c \
|
||||
stock-about-16.h \
|
||||
stock-about-24.h \
|
||||
stock-moo.h \
|
||||
@ -102,9 +102,9 @@ EXTRA_DIST = \
|
||||
xml2h.sh
|
||||
|
||||
BUILT_SOURCES = \
|
||||
mooaccelbutton-glade.h \
|
||||
moomarshals.h \
|
||||
moomarshals.c \
|
||||
shortcutdialog-glade.c \
|
||||
stock-moo.h
|
||||
|
||||
moomarshals.c: moomarshals.list
|
||||
@ -114,10 +114,9 @@ moomarshals.h: moomarshals.list
|
||||
glib-genmarshal --prefix=_moo_marshal --header \
|
||||
$(srcdir)/moomarshals.list > moomarshals.h
|
||||
|
||||
GLADE = $(srcdir)/glade
|
||||
shortcutdialog-glade.c: $(GLADE)/shortcutdialog.c $(GLADE)/shortcutdialog.sed $(SUPPORT)
|
||||
cat $(GLADE)/shortcutdialog.c | sh $(GLADE)/support.sh | \
|
||||
sed -f $(GLADE)/shortcutdialog.sed > shortcutdialog-glade.c
|
||||
mooaccelbutton-glade.h: $(srcdir)/glade/shortcutdialog.glade $(srcdir)/xml2h.sh
|
||||
sh $(srcdir)/xml2h.sh MOO_ACCEL_BUTTON_GLADE_UI \
|
||||
$(srcdir)/glade/shortcutdialog.glade > mooaccelbutton-glade.h
|
||||
|
||||
PIXMAPS = \
|
||||
$(srcdir)/pixmaps/gap.png \
|
||||
|
@ -3,12 +3,8 @@
|
||||
#
|
||||
|
||||
EXTRA_DIST = \
|
||||
logwindow.gladep \
|
||||
logwindow.glade \
|
||||
shortcutdialog.c \
|
||||
shortcutdialog.gladep \
|
||||
shortcutdialog.glade \
|
||||
shortcutdialog.sed \
|
||||
toolbar.sh \
|
||||
support.sh \
|
||||
toolbar.sh
|
||||
|
@ -1,80 +0,0 @@
|
||||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
|
||||
<widget class="GtkWindow" id="log_window">
|
||||
<property name="title" translatable="yes">GGAP Log</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="default_width">400</property>
|
||||
<property name="default_height">300</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTextView" id="textview">
|
||||
<property name="visible">True</property>
|
||||
<property name="editable">False</property>
|
||||
<property name="overwrite">False</property>
|
||||
<property name="accepts_tab">True</property>
|
||||
<property name="justification">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap_mode">GTK_WRAP_WORD</property>
|
||||
<property name="cursor_visible">True</property>
|
||||
<property name="pixels_above_lines">0</property>
|
||||
<property name="pixels_below_lines">0</property>
|
||||
<property name="pixels_inside_wrap">0</property>
|
||||
<property name="left_margin">0</property>
|
||||
<property name="right_margin">0</property>
|
||||
<property name="indent">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
|
||||
|
||||
<glade-project>
|
||||
<name>logwindow</name>
|
||||
<program_name>logwindow</program_name>
|
||||
<source_directory></source_directory>
|
||||
<pixmaps_directory></pixmaps_directory>
|
||||
<gnome_support>FALSE</gnome_support>
|
||||
<output_main_file>FALSE</output_main_file>
|
||||
<output_support_files>FALSE</output_support_files>
|
||||
<output_build_files>FALSE</output_build_files>
|
||||
<main_source_file>logwindow.c</main_source_file>
|
||||
<main_header_file>logwindow.h</main_header_file>
|
||||
</glade-project>
|
@ -1,149 +0,0 @@
|
||||
/*
|
||||
* DO NOT EDIT THIS FILE - it is generated by Glade.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "callbacks.h"
|
||||
#include "shortcutdialog.h"
|
||||
#include "support.h"
|
||||
|
||||
#define GLADE_HOOKUP_OBJECT(component,widget,name) \
|
||||
g_object_set_data_full (G_OBJECT (component), name, \
|
||||
gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
|
||||
|
||||
#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
|
||||
g_object_set_data (G_OBJECT (component), name, widget)
|
||||
|
||||
GtkWidget*
|
||||
create_dialog (void)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *dialog_vbox1;
|
||||
GtkWidget *eventbox;
|
||||
GtkWidget *frame1;
|
||||
GtkWidget *alignment31;
|
||||
GtkWidget *label;
|
||||
GtkWidget *dialog_action_area1;
|
||||
GtkWidget *cancel;
|
||||
GtkWidget *alignment29;
|
||||
GtkWidget *hbox11;
|
||||
GtkWidget *image1;
|
||||
GtkWidget *label65;
|
||||
GtkWidget *ok;
|
||||
GtkWidget *alignment30;
|
||||
GtkWidget *hbox12;
|
||||
GtkWidget *image2;
|
||||
GtkWidget *label66;
|
||||
|
||||
dialog = gtk_dialog_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (dialog), _("Choose Accelerator"));
|
||||
gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
|
||||
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
|
||||
|
||||
dialog_vbox1 = GTK_DIALOG (dialog)->vbox;
|
||||
gtk_widget_show (dialog_vbox1);
|
||||
|
||||
eventbox = gtk_event_box_new ();
|
||||
gtk_widget_show (eventbox);
|
||||
gtk_box_pack_start (GTK_BOX (dialog_vbox1), eventbox, TRUE, TRUE, 0);
|
||||
GTK_WIDGET_SET_FLAGS (eventbox, GTK_CAN_FOCUS);
|
||||
GTK_WIDGET_SET_FLAGS (eventbox, GTK_CAN_DEFAULT);
|
||||
|
||||
frame1 = gtk_frame_new (NULL);
|
||||
gtk_widget_show (frame1);
|
||||
gtk_container_add (GTK_CONTAINER (eventbox), frame1);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (frame1), 6);
|
||||
|
||||
alignment31 = gtk_alignment_new (0.5, 0.5, 1, 1);
|
||||
gtk_widget_show (alignment31);
|
||||
gtk_container_add (GTK_CONTAINER (frame1), alignment31);
|
||||
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment31), 6, 6, 6, 6);
|
||||
|
||||
label = gtk_label_new (_("\nNew accelerator...\n"));
|
||||
gtk_widget_show (label);
|
||||
gtk_container_add (GTK_CONTAINER (alignment31), label);
|
||||
|
||||
dialog_action_area1 = GTK_DIALOG (dialog)->action_area;
|
||||
gtk_widget_show (dialog_action_area1);
|
||||
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
|
||||
|
||||
cancel = gtk_button_new ();
|
||||
gtk_widget_show (cancel);
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (dialog), cancel, GTK_RESPONSE_CANCEL);
|
||||
GTK_WIDGET_UNSET_FLAGS (cancel, GTK_CAN_FOCUS);
|
||||
gtk_button_set_focus_on_click (GTK_BUTTON (cancel), FALSE);
|
||||
|
||||
alignment29 = gtk_alignment_new (0.5, 0.5, 0, 0);
|
||||
gtk_widget_show (alignment29);
|
||||
gtk_container_add (GTK_CONTAINER (cancel), alignment29);
|
||||
|
||||
hbox11 = gtk_hbox_new (FALSE, 2);
|
||||
gtk_widget_show (hbox11);
|
||||
gtk_container_add (GTK_CONTAINER (alignment29), hbox11);
|
||||
|
||||
image1 = gtk_image_new_from_stock ("gtk-cancel", GTK_ICON_SIZE_BUTTON);
|
||||
gtk_widget_show (image1);
|
||||
gtk_box_pack_start (GTK_BOX (hbox11), image1, FALSE, FALSE, 0);
|
||||
|
||||
label65 = gtk_label_new_with_mnemonic ("Cancel");
|
||||
gtk_widget_show (label65);
|
||||
gtk_box_pack_start (GTK_BOX (hbox11), label65, FALSE, FALSE, 0);
|
||||
|
||||
ok = gtk_button_new ();
|
||||
gtk_widget_show (ok);
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (dialog), ok, GTK_RESPONSE_OK);
|
||||
GTK_WIDGET_UNSET_FLAGS (ok, GTK_CAN_FOCUS);
|
||||
gtk_button_set_focus_on_click (GTK_BUTTON (ok), FALSE);
|
||||
|
||||
alignment30 = gtk_alignment_new (0.5, 0.5, 0, 0);
|
||||
gtk_widget_show (alignment30);
|
||||
gtk_container_add (GTK_CONTAINER (ok), alignment30);
|
||||
|
||||
hbox12 = gtk_hbox_new (FALSE, 2);
|
||||
gtk_widget_show (hbox12);
|
||||
gtk_container_add (GTK_CONTAINER (alignment30), hbox12);
|
||||
|
||||
image2 = gtk_image_new_from_stock ("gtk-ok", GTK_ICON_SIZE_BUTTON);
|
||||
gtk_widget_show (image2);
|
||||
gtk_box_pack_start (GTK_BOX (hbox12), image2, FALSE, FALSE, 0);
|
||||
|
||||
label66 = gtk_label_new_with_mnemonic (_("OK"));
|
||||
gtk_widget_show (label66);
|
||||
gtk_box_pack_start (GTK_BOX (hbox12), label66, FALSE, FALSE, 0);
|
||||
|
||||
/* Store pointers to all widgets, for use by lookup_widget(). */
|
||||
GLADE_HOOKUP_OBJECT_NO_REF (dialog, dialog, "dialog");
|
||||
GLADE_HOOKUP_OBJECT_NO_REF (dialog, dialog_vbox1, "dialog_vbox1");
|
||||
GLADE_HOOKUP_OBJECT (dialog, eventbox, "eventbox");
|
||||
GLADE_HOOKUP_OBJECT (dialog, frame1, "frame1");
|
||||
GLADE_HOOKUP_OBJECT (dialog, alignment31, "alignment31");
|
||||
GLADE_HOOKUP_OBJECT (dialog, label, "label");
|
||||
GLADE_HOOKUP_OBJECT_NO_REF (dialog, dialog_action_area1, "dialog_action_area1");
|
||||
GLADE_HOOKUP_OBJECT (dialog, cancel, "cancel");
|
||||
GLADE_HOOKUP_OBJECT (dialog, alignment29, "alignment29");
|
||||
GLADE_HOOKUP_OBJECT (dialog, hbox11, "hbox11");
|
||||
GLADE_HOOKUP_OBJECT (dialog, image1, "image1");
|
||||
GLADE_HOOKUP_OBJECT (dialog, label65, "label65");
|
||||
GLADE_HOOKUP_OBJECT (dialog, ok, "ok");
|
||||
GLADE_HOOKUP_OBJECT (dialog, alignment30, "alignment30");
|
||||
GLADE_HOOKUP_OBJECT (dialog, hbox12, "hbox12");
|
||||
GLADE_HOOKUP_OBJECT (dialog, image2, "image2");
|
||||
GLADE_HOOKUP_OBJECT (dialog, label66, "label66");
|
||||
|
||||
gtk_widget_grab_focus (eventbox);
|
||||
gtk_widget_grab_default (eventbox);
|
||||
return dialog;
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
s/#include <sys\/types.h>//
|
||||
s/#include <sys\/stat.h>//
|
||||
s/#include <unistd.h>//
|
||||
s/#include <string.h>/#include "mooutils\/moocompat.h"/
|
||||
s/#include <stdio.h>//
|
||||
s/#include "callbacks.h"//
|
||||
s/#include "shortcutdialog.h"//
|
||||
s/create_dialog (void)/_moo_create_accel_dialog (void);\nGtkWidget *_moo_create_accel_dialog (void)/
|
@ -12,6 +12,8 @@
|
||||
*/
|
||||
|
||||
#include "mooutils/mooaccelbutton.h"
|
||||
#include "mooutils/mooaccelbutton-glade.h"
|
||||
#include "mooutils/mooglade.h"
|
||||
#include "mooutils/moocompat.h"
|
||||
#include "mooutils/moomarshals.h"
|
||||
#include <gtk/gtkaccelgroup.h>
|
||||
@ -20,9 +22,6 @@
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
|
||||
GtkWidget *_moo_create_accel_dialog ();
|
||||
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ACCEL,
|
||||
@ -255,11 +254,15 @@ static gboolean key_event (G_GNUC_UNUSED GtkWidget *widget,
|
||||
|
||||
static void moo_accel_button_clicked (MooAccelButton *button)
|
||||
{
|
||||
MooGladeXML *xml;
|
||||
GtkWidget *dialog, *ok_button, *cancel_button, *eventbox, *label;
|
||||
Stuff s = {0, 0, NULL};
|
||||
int response;
|
||||
|
||||
dialog = _moo_create_accel_dialog ();
|
||||
xml = moo_glade_xml_parse_memory (MOO_ACCEL_BUTTON_GLADE_UI, -1, "dialog");
|
||||
g_return_if_fail (xml != NULL);
|
||||
|
||||
dialog = moo_glade_xml_get_widget (xml, "dialog");
|
||||
|
||||
#if GTK_CHECK_VERSION(2,6,0)
|
||||
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
||||
@ -273,10 +276,10 @@ static void moo_accel_button_clicked (MooAccelButton *button)
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog),
|
||||
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))));
|
||||
|
||||
ok_button = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), "ok"));
|
||||
cancel_button = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), "cancel"));
|
||||
eventbox = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), "eventbox"));
|
||||
label = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), "label"));
|
||||
ok_button = moo_glade_xml_get_widget (xml, "ok");
|
||||
cancel_button = moo_glade_xml_get_widget (xml, "cancel");
|
||||
eventbox = moo_glade_xml_get_widget (xml, "eventbox");
|
||||
label = moo_glade_xml_get_widget (xml, "label");
|
||||
|
||||
gtk_button_set_use_underline (GTK_BUTTON (ok_button), FALSE);
|
||||
gtk_button_set_use_underline (GTK_BUTTON (cancel_button), FALSE);
|
||||
@ -286,15 +289,21 @@ static void moo_accel_button_clicked (MooAccelButton *button)
|
||||
g_signal_connect (eventbox, "key-press-event", G_CALLBACK (key_event), &s);
|
||||
|
||||
response = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
if (response == GTK_RESPONSE_OK) {
|
||||
if (s.key || s.mods) {
|
||||
gtk_widget_destroy (dialog);
|
||||
moo_glade_xml_unref (xml);
|
||||
|
||||
if (response == GTK_RESPONSE_OK)
|
||||
{
|
||||
if (s.key || s.mods)
|
||||
{
|
||||
char *accel = gtk_accelerator_name (s.key, s.mods);
|
||||
moo_accel_button_set_accel (button, accel);
|
||||
g_free (accel);
|
||||
}
|
||||
else
|
||||
{
|
||||
moo_accel_button_set_accel (button, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,8 @@ static gboolean parse_property (GParamSpec *param_spec,
|
||||
const char *value,
|
||||
GParameter *param);
|
||||
|
||||
static MooGladeXML *moo_glade_xml_parse_markup (MooMarkupDoc *doc);
|
||||
static MooGladeXML *moo_glade_xml_parse_markup (MooMarkupDoc *doc,
|
||||
const char *root);
|
||||
static MooGladeXML *moo_glade_xml_new (MooMarkupDoc *doc,
|
||||
MooMarkupNode *root);
|
||||
static void moo_glade_xml_free (MooGladeXML *xml);
|
||||
@ -1442,27 +1443,30 @@ moo_glade_xml_unref (MooGladeXML *xml)
|
||||
|
||||
MooGladeXML*
|
||||
moo_glade_xml_parse_file (const char *file,
|
||||
GError **error)
|
||||
const char *root)
|
||||
{
|
||||
GTimer *timer;
|
||||
MooGladeXML *xml;
|
||||
MooMarkupDoc *doc;
|
||||
GError *error = NULL;
|
||||
|
||||
timer = g_timer_new ();
|
||||
doc = moo_markup_parse_file (file, error);
|
||||
g_print ("moo_markup_parse_file: %f\n", g_timer_elapsed (timer, NULL));
|
||||
g_return_val_if_fail (file != NULL, NULL);
|
||||
|
||||
doc = moo_markup_parse_file (file, &error);
|
||||
|
||||
if (!doc)
|
||||
{
|
||||
g_timer_destroy (timer);
|
||||
g_warning ("%s: could not parse file '%s'", G_STRLOC, file);
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_warning ("%s: %s", G_STRLOC, error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_timer_start (timer);
|
||||
xml = moo_glade_xml_parse_markup (doc);
|
||||
g_print ("moo_glade_xml_parse_markup: %f\n", g_timer_elapsed (timer, NULL));
|
||||
|
||||
g_timer_destroy (timer);
|
||||
xml = moo_glade_xml_parse_markup (doc, root);
|
||||
moo_markup_doc_unref (doc);
|
||||
return xml;
|
||||
}
|
||||
@ -1471,34 +1475,74 @@ moo_glade_xml_parse_file (const char *file,
|
||||
MooGladeXML*
|
||||
moo_glade_xml_parse_memory (const char *buffer,
|
||||
int size,
|
||||
GError **error)
|
||||
const char *root)
|
||||
{
|
||||
GTimer *timer;
|
||||
MooGladeXML *xml;
|
||||
MooMarkupDoc *doc;
|
||||
GError *error = NULL;
|
||||
|
||||
timer = g_timer_new ();
|
||||
doc = moo_markup_parse_memory (buffer, size, error);
|
||||
g_print ("moo_markup_parse_memory: %f\n", g_timer_elapsed (timer, NULL));
|
||||
g_return_val_if_fail (buffer != NULL, NULL);
|
||||
|
||||
doc = moo_markup_parse_memory (buffer, size, &error);
|
||||
|
||||
if (!doc)
|
||||
{
|
||||
g_timer_destroy (timer);
|
||||
g_warning ("%s: could not parse buffer", G_STRLOC);
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_warning ("%s: %s", G_STRLOC, error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_timer_start (timer);
|
||||
xml = moo_glade_xml_parse_markup (doc);
|
||||
g_print ("moo_glade_xml_parse_markup: %f\n", g_timer_elapsed (timer, NULL));
|
||||
|
||||
g_timer_destroy (timer);
|
||||
xml = moo_glade_xml_parse_markup (doc, root);
|
||||
moo_markup_doc_unref (doc);
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
||||
static MooMarkupNode*
|
||||
find_widget (MooMarkupNode *node,
|
||||
const char *id)
|
||||
{
|
||||
const char *wid_id;
|
||||
|
||||
g_return_val_if_fail (NODE_IS_WIDGET (node), NULL);
|
||||
|
||||
wid_id = moo_markup_get_prop (node, "id");
|
||||
g_return_val_if_fail (wid_id != NULL, NULL);
|
||||
|
||||
if (!strcmp (wid_id, id))
|
||||
return node;
|
||||
|
||||
FOREACH_ELM_START(node, elm)
|
||||
{
|
||||
if (NODE_IS_CHILD (elm))
|
||||
{
|
||||
FOREACH_ELM_START (elm, child)
|
||||
{
|
||||
if (NODE_IS_WIDGET (child))
|
||||
{
|
||||
MooMarkupNode *wid = find_widget (child, id);
|
||||
if (wid)
|
||||
return wid;
|
||||
}
|
||||
}
|
||||
FOREACH_ELM_END;
|
||||
}
|
||||
}
|
||||
FOREACH_ELM_END;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static MooGladeXML*
|
||||
moo_glade_xml_parse_markup (MooMarkupDoc *doc)
|
||||
moo_glade_xml_parse_markup (MooMarkupDoc *doc,
|
||||
const char *root_id)
|
||||
{
|
||||
MooGladeXML *xml;
|
||||
MooMarkupNode *glade_elm;
|
||||
@ -1512,10 +1556,20 @@ moo_glade_xml_parse_markup (MooMarkupDoc *doc)
|
||||
|
||||
FOREACH_ELM_START(glade_elm, elm)
|
||||
{
|
||||
if (!strcmp (elm->name, "widget"))
|
||||
if (NODE_IS_WIDGET (elm))
|
||||
{
|
||||
root = elm;
|
||||
break;
|
||||
if (root_id)
|
||||
{
|
||||
root = find_widget (elm, root_id);
|
||||
|
||||
if (root)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
root = elm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (!strcmp (elm->name, "requires"))
|
||||
{
|
||||
@ -1530,7 +1584,12 @@ moo_glade_xml_parse_markup (MooMarkupDoc *doc)
|
||||
|
||||
if (!root)
|
||||
{
|
||||
g_warning ("%s: could not find root element", G_STRLOC);
|
||||
if (root_id)
|
||||
g_warning ("%s: could not find root element '%s'",
|
||||
G_STRLOC, root_id);
|
||||
else
|
||||
g_warning ("%s: could not find root element", G_STRLOC);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,10 @@ typedef struct _MooGladeXML MooGladeXML;
|
||||
GType moo_glade_xml_get_type (void);
|
||||
|
||||
MooGladeXML *moo_glade_xml_parse_file (const char *file,
|
||||
GError **error);
|
||||
const char *root);
|
||||
MooGladeXML *moo_glade_xml_parse_memory (const char *buffer,
|
||||
int size,
|
||||
GError **error);
|
||||
const char *root);
|
||||
|
||||
MooGladeXML *moo_glade_xml_ref (MooGladeXML *xml);
|
||||
void moo_glade_xml_unref (MooGladeXML *xml);
|
||||
|
@ -292,6 +292,7 @@ moo_markup_text_node_new (MooMarkupNodeType type,
|
||||
add_node (doc, parent, MOO_MARKUP_NODE (node));
|
||||
|
||||
node->type = type;
|
||||
|
||||
if (type == MOO_MARKUP_TEXT_NODE)
|
||||
node->name = g_strdup ("TEXT");
|
||||
else
|
||||
@ -337,12 +338,13 @@ moo_markup_text_node_add_text (MooMarkupText *node,
|
||||
const char *text,
|
||||
gsize text_len)
|
||||
{
|
||||
char *tmp = (char*)g_memdup (node->text, node->size + text_len + 1);
|
||||
g_memmove (tmp + node->size, text, text_len);
|
||||
tmp[node->size + text_len] = 0;
|
||||
char *tmp = g_new (char, node->size + text_len + 1);
|
||||
memcpy (tmp, node->text, node->size);
|
||||
memcpy (tmp + node->size, text, text_len);
|
||||
g_free (node->text);
|
||||
node->text = tmp;
|
||||
node->size += text_len;
|
||||
node->text[node->size] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user