forked from AuroraMiddleware/gtk
parasite: Use template for button path
This commit is contained in:
parent
e43aeb9a1f
commit
3f5d21abec
@ -2,7 +2,21 @@ moduledir = $(libdir)/gtk-3.0/modules
|
||||
|
||||
module_LTLIBRARIES = libgtkparasite.la
|
||||
|
||||
resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/parasite.gresource.xml)
|
||||
resources.h: parasite.gresource.xml
|
||||
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/parasite.gresource.xml \
|
||||
--target=$@ --sourcedir=$(srcdir) --c-name parasite --generate-header --manual-register
|
||||
resources.c: parasite.gresource.xml $(resource_files)
|
||||
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/parasite.gresource.xml \
|
||||
--target=$@ --sourcedir=$(srcdir) --c-name parasite --generate-source --manual-register
|
||||
|
||||
BUILT_SOURCES = \
|
||||
resources.h \
|
||||
resources.c
|
||||
|
||||
libgtkparasite_la_SOURCES = \
|
||||
resources.h \
|
||||
resources.c \
|
||||
inspect-button.c \
|
||||
module.c \
|
||||
parasite.h \
|
||||
@ -49,4 +63,7 @@ libgtkparasite_la_LIBADD = \
|
||||
$(top_builddir)/gtk/libgtk-3.la \
|
||||
$(GTK_DEP_LIBS)
|
||||
|
||||
EXTRA_DIST= \
|
||||
$(resource_files)
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
||||
|
@ -24,63 +24,41 @@
|
||||
|
||||
struct _ParasiteButtonPathPrivate
|
||||
{
|
||||
GtkWidget *sw;
|
||||
GtkWidget *button_box;
|
||||
GtkWidget *sw;
|
||||
GtkWidget *button_box;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (ParasiteButtonPath, parasite_buttonpath, GTK_TYPE_BOX)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (ParasiteButtonPath, parasite_button_path, GTK_TYPE_BOX)
|
||||
|
||||
static void
|
||||
parasite_buttonpath_init (ParasiteButtonPath *bp)
|
||||
parasite_button_path_init (ParasiteButtonPath *bp)
|
||||
{
|
||||
GtkWidget *label;
|
||||
|
||||
bp->priv = parasite_buttonpath_get_instance_private (bp);
|
||||
|
||||
g_object_set (bp,
|
||||
"orientation", GTK_ORIENTATION_HORIZONTAL,
|
||||
NULL);
|
||||
|
||||
bp->priv->sw = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
|
||||
"hscrollbar-policy", GTK_POLICY_AUTOMATIC,
|
||||
"vscrollbar-policy", GTK_POLICY_NEVER,
|
||||
"hexpand", TRUE,
|
||||
NULL);
|
||||
gtk_container_add (GTK_CONTAINER (bp), bp->priv->sw);
|
||||
|
||||
bp->priv->button_box = g_object_new (GTK_TYPE_BOX,
|
||||
"orientation", GTK_ORIENTATION_HORIZONTAL,
|
||||
"hexpand", TRUE,
|
||||
"margin", 6,
|
||||
NULL);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (bp->priv->button_box), "linked");
|
||||
gtk_container_add (GTK_CONTAINER (bp->priv->sw), bp->priv->button_box);
|
||||
|
||||
label = g_object_new (GTK_TYPE_LABEL,
|
||||
"label", "Choose a widget through the inspector",
|
||||
"xalign", 0.5,
|
||||
"hexpand", TRUE,
|
||||
NULL);
|
||||
gtk_container_add (GTK_CONTAINER (bp->priv->button_box), label);
|
||||
bp->priv = parasite_button_path_get_instance_private (bp);
|
||||
gtk_widget_init_template (GTK_WIDGET (bp));
|
||||
}
|
||||
|
||||
static void
|
||||
parasite_buttonpath_class_init(ParasiteButtonPathClass *klass)
|
||||
parasite_button_path_class_init (ParasiteButtonPathClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/parasite/button-path.ui");
|
||||
gtk_widget_class_bind_template_child_private (widget_class, ParasiteButtonPath, sw);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, ParasiteButtonPath, button_box);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
parasite_buttonpath_new ()
|
||||
parasite_button_path_new (void)
|
||||
{
|
||||
return GTK_WIDGET (g_object_new (PARASITE_TYPE_BUTTONPATH, NULL));
|
||||
return GTK_WIDGET (g_object_new (PARASITE_TYPE_BUTTON_PATH, NULL));
|
||||
}
|
||||
|
||||
void
|
||||
parasite_buttonpath_set_widget(ParasiteButtonPath *bp,
|
||||
GtkWidget *widget)
|
||||
parasite_button_path_set_widget (ParasiteButtonPath *bp,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
char *path, **words;
|
||||
int i;
|
||||
gchar *path, **words;
|
||||
gint i;
|
||||
GtkWidget *b;
|
||||
GtkContainer *box = GTK_CONTAINER (bp->priv->button_box);
|
||||
|
||||
@ -100,4 +78,4 @@ parasite_buttonpath_set_widget(ParasiteButtonPath *bp,
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
// vim: set et sw=4 ts=4:
|
||||
// vim: set et sw=2 ts=2:
|
||||
|
@ -19,42 +19,44 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#ifndef _GTKPARASITE_BUTTONPATH_H_
|
||||
#define _GTKPARASITE_BUTTONPATH_H_
|
||||
#ifndef _GTKPARASITE_BUTTON_PATH_H_
|
||||
#define _GTKPARASITE_BUTTON_PATH_H_
|
||||
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define PARASITE_TYPE_BUTTONPATH (parasite_buttonpath_get_type())
|
||||
#define PARASITE_BUTTONPATH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PARASITE_TYPE_BUTTONPATH, ParasiteButtonPath))
|
||||
#define PARASITE_BUTTONPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PARASITE_TYPE_BUTTONPATH, ParasiteButtonPathClass))
|
||||
#define PARASITE_IS_BUTTONPATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PARASITE_TYPE_BUTTONPATH))
|
||||
#define PARASITE_IS_BUTTONPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PARASITE_TYPE_BUTTONPATH))
|
||||
#define PARASITE_BUTTONPATH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PARASITE_TYPE_BUTTONPATH, ParasiteButtonPathClass))
|
||||
#define PARASITE_TYPE_BUTTON_PATH (parasite_button_path_get_type())
|
||||
#define PARASITE_BUTTON_PATH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PARASITE_TYPE_BUTTON_PATH, ParasiteButtonPath))
|
||||
#define PARASITE_BUTTON_PATH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PARASITE_TYPE_BUTTON_PATH, ParasiteButtonPathClass))
|
||||
#define PARASITE_IS_BUTTON_PATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PARASITE_TYPE_BUTTON_PATH))
|
||||
#define PARASITE_IS_BUTTON_PATH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PARASITE_TYPE_BUTTON_PATH))
|
||||
#define PARASITE_BUTTON_PATH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PARASITE_TYPE_BUTTON_PATH, ParasiteButtonPathClass))
|
||||
|
||||
|
||||
typedef struct _ParasiteButtonPathPrivate ParasiteButtonPathPrivate;
|
||||
|
||||
typedef struct _ParasiteButtonPath {
|
||||
GtkBox parent;
|
||||
ParasiteButtonPathPrivate *priv;
|
||||
typedef struct _ParasiteButtonPath
|
||||
{
|
||||
GtkBox parent;
|
||||
ParasiteButtonPathPrivate *priv;
|
||||
} ParasiteButtonPath;
|
||||
|
||||
typedef struct _ParasiteButtonPathClass {
|
||||
GtkBoxClass parent;
|
||||
typedef struct _ParasiteButtonPathClass
|
||||
{
|
||||
GtkBoxClass parent;
|
||||
} ParasiteButtonPathClass;
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GType parasite_buttonpath_get_type ();
|
||||
GtkWidget *parasite_buttonpath_new ();
|
||||
void parasite_buttonpath_set_widget (ParasiteButtonPath *bp,
|
||||
GtkWidget *widget);
|
||||
GType parasite_button_path_get_type (void);
|
||||
GtkWidget *parasite_button_path_new (void);
|
||||
void parasite_button_path_set_widget (ParasiteButtonPath *bp,
|
||||
GtkWidget *widget);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
#endif // _GTKPARASITE_BUTTONPATH_H_
|
||||
#endif // _GTKPARASITE_BUTTON_PATH_H_
|
||||
|
||||
// vim: set et sw=4 ts=4:
|
||||
// vim: set et sw=2 ts=2:
|
||||
|
35
modules/other/parasite/button-path.ui
Normal file
35
modules/other/parasite/button-path.ui
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="ParasiteButtonPath" parent="GtkBox">
|
||||
<property name="orientation">horizontal</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="sw">
|
||||
<property name="visible">True</property>
|
||||
<property name="hscrollbar-policy">automatic</property>
|
||||
<property name="vscrollbar-policy">never</property>
|
||||
<property name="hexpand">True</property>
|
||||
<child>
|
||||
<object class="GtkButtonBox" id="button_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="margin">6</property>
|
||||
<property name="spacing">0</property>
|
||||
<property name="layout-style">start</property>
|
||||
<style>
|
||||
<class name="linked"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="label">Choose a widget through the inspector</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
@ -25,6 +25,7 @@
|
||||
#include "config.h"
|
||||
#include "parasite.h"
|
||||
#include "python-hooks.h"
|
||||
#include "resources.h"
|
||||
|
||||
|
||||
void
|
||||
@ -34,6 +35,8 @@ gtk_module_init(gint *argc, gchar ***argv)
|
||||
parasite_python_init();
|
||||
#endif
|
||||
|
||||
parasite_register_resource ();
|
||||
|
||||
gtkparasite_window_create();
|
||||
}
|
||||
|
||||
|
6
modules/other/parasite/parasite.gresource.xml
Normal file
6
modules/other/parasite/parasite.gresource.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/org/gtk/parasite">
|
||||
<file>button-path.ui</file>
|
||||
</gresource>
|
||||
</gresources>
|
@ -53,7 +53,7 @@ on_widget_tree_selection_changed (ParasiteWidgetTree *widget_tree,
|
||||
GtkWidget *widget = GTK_WIDGET (selected);
|
||||
|
||||
gtkparasite_flash_widget(parasite, widget);
|
||||
parasite_buttonpath_set_widget (PARASITE_BUTTONPATH (parasite->button_path), widget);
|
||||
parasite_button_path_set_widget (PARASITE_BUTTON_PATH (parasite->button_path), widget);
|
||||
parasite_classeslist_set_widget (PARASITE_CLASSESLIST (parasite->classes_list), widget);
|
||||
parasite_csseditor_set_widget (PARASITE_CSSEDITOR (parasite->widget_css_editor), widget);
|
||||
}
|
||||
@ -266,7 +266,7 @@ gtkparasite_window_create()
|
||||
parasite_csseditor_new (TRUE),
|
||||
gtk_label_new ("Custom CSS"));
|
||||
|
||||
window->button_path = parasite_buttonpath_new ();
|
||||
window->button_path = parasite_button_path_new ();
|
||||
gtk_container_add (GTK_CONTAINER (box), window->button_path);
|
||||
|
||||
hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
|
||||
|
Loading…
Reference in New Issue
Block a user