parasite: Don't open a window upon load

Instead, we want to let GTK+ open a window whose life-cycle
it can control. We just ensure that all our types are registered
when the module is loaded, so GTK+ can find them.
This commit is contained in:
Matthias Clasen 2014-05-06 22:02:08 -04:00
parent 38bbde200e
commit 87e3484aa7
3 changed files with 21 additions and 28 deletions

View File

@ -22,10 +22,18 @@
*/
#include <glib.h>
#include "window.h"
#include "button-path.h"
#include "classes-list.h"
#include "css-editor.h"
#include "object-hierarchy.h"
#include "property-cell-renderer.h"
#include "prop-list.h"
#include "python-hooks.h"
#include "python-shell.h"
#include "resources.h"
#include "themes.h"
#include "widget-tree.h"
#include "window.h"
void
gtk_module_init (gint *argc, gchar ***argv)
@ -36,7 +44,17 @@ gtk_module_init (gint *argc, gchar ***argv)
parasite_register_resource ();
gtk_window_present (GTK_WINDOW (parasite_window_new ()));
g_type_ensure (PARASITE_TYPE_THEMES);
g_type_ensure (PARASITE_TYPE_CSS_EDITOR);
g_type_ensure (PARASITE_TYPE_BUTTON_PATH);
g_type_ensure (PARASITE_TYPE_WIDGET_TREE);
g_type_ensure (PARASITE_TYPE_PROP_LIST);
g_type_ensure (PARASITE_TYPE_OBJECT_HIERARCHY);
g_type_ensure (PARASITE_TYPE_CLASSES_LIST);
g_type_ensure (PARASITE_TYPE_PYTHON_SHELL);
g_type_ensure (PARASITE_TYPE_PROPERTY_CELL_RENDERER);
g_type_ensure (PARASITE_TYPE_WINDOW);
}
// vim: set et sw=2 ts=2:

View File

@ -37,19 +37,6 @@
G_DEFINE_TYPE (ParasiteWindow, parasite_window, GTK_TYPE_WINDOW)
static void
delete_window (GtkWidget *widget)
{
GApplication *app = g_application_get_default ();
gtk_widget_hide (widget);
if (app)
g_application_quit (app);
else
exit (0);
}
extern void on_inspect (GtkWidget *button, ParasiteWindow *pw);
static void
@ -161,7 +148,6 @@ parasite_window_class_init (ParasiteWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, ParasiteWindow, python_shell);
gtk_widget_class_bind_template_child (widget_class, ParasiteWindow, widget_popup);
gtk_widget_class_bind_template_callback (widget_class, delete_window);
gtk_widget_class_bind_template_callback (widget_class, on_inspect);
gtk_widget_class_bind_template_callback (widget_class, on_graphic_updates_toggled);
gtk_widget_class_bind_template_callback (widget_class, on_widget_tree_selection_changed);
@ -171,16 +157,6 @@ parasite_window_class_init (ParasiteWindowClass *klass)
GtkWidget *
parasite_window_new (void)
{
g_type_ensure (PARASITE_TYPE_THEMES);
g_type_ensure (PARASITE_TYPE_CSS_EDITOR);
g_type_ensure (PARASITE_TYPE_BUTTON_PATH);
g_type_ensure (PARASITE_TYPE_WIDGET_TREE);
g_type_ensure (PARASITE_TYPE_PROP_LIST);
g_type_ensure (PARASITE_TYPE_OBJECT_HIERARCHY);
g_type_ensure (PARASITE_TYPE_CLASSES_LIST);
g_type_ensure (PARASITE_TYPE_PYTHON_SHELL);
g_type_ensure (PARASITE_TYPE_PROPERTY_CELL_RENDERER);
return GTK_WIDGET (g_object_new (PARASITE_TYPE_WINDOW, NULL));
}

View File

@ -23,7 +23,6 @@
<template class="ParasiteWindow" parent="GtkWindow">
<property name="default-height">500</property>
<property name="default-width">1000</property>
<signal name="delete-event" handler="delete_window"/>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>