inspector: Show object title in the css tab
This commit is contained in:
@ -31,7 +31,8 @@
|
|||||||
#include "gtktextview.h"
|
#include "gtktextview.h"
|
||||||
#include "gtkmessagedialog.h"
|
#include "gtkmessagedialog.h"
|
||||||
#include "gtkfilechooserdialog.h"
|
#include "gtkfilechooserdialog.h"
|
||||||
#include "gtktoggletoolbutton.h"
|
#include "gtktogglebutton.h"
|
||||||
|
#include "gtklabel.h"
|
||||||
|
|
||||||
#define GTK_INSPECTOR_CSS_EDITOR_TEXT "inspector-css-editor-text"
|
#define GTK_INSPECTOR_CSS_EDITOR_TEXT "inspector-css-editor-text"
|
||||||
#define GTK_INSPECTOR_CSS_EDITOR_PROVIDER "inspector-css-editor-provider"
|
#define GTK_INSPECTOR_CSS_EDITOR_PROVIDER "inspector-css-editor-provider"
|
||||||
@ -57,13 +58,13 @@ typedef struct
|
|||||||
|
|
||||||
struct _GtkInspectorCssEditorPrivate
|
struct _GtkInspectorCssEditorPrivate
|
||||||
{
|
{
|
||||||
GtkWidget *toolbar;
|
|
||||||
GtkWidget *view;
|
GtkWidget *view;
|
||||||
|
GtkWidget *object_title;
|
||||||
GtkTextBuffer *text;
|
GtkTextBuffer *text;
|
||||||
GtkCssProvider *provider;
|
GtkCssProvider *provider;
|
||||||
gboolean global;
|
gboolean global;
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GtkToggleToolButton *disable_button;
|
GtkToggleButton *disable_button;
|
||||||
guint timeout;
|
guint timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -102,10 +103,10 @@ set_initial_text (GtkInspectorCssEditor *ce)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
disable_toggled (GtkToggleToolButton *button,
|
disable_toggled (GtkToggleButton *button,
|
||||||
GtkInspectorCssEditor *ce)
|
GtkInspectorCssEditor *ce)
|
||||||
{
|
{
|
||||||
if (gtk_toggle_tool_button_get_active (button))
|
if (gtk_toggle_button_get_active (button))
|
||||||
{
|
{
|
||||||
if (ce->priv->global)
|
if (ce->priv->global)
|
||||||
gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (),
|
gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (),
|
||||||
@ -187,7 +188,7 @@ save_response (GtkWidget *dialog,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
save_clicked (GtkToolButton *button,
|
save_clicked (GtkButton *button,
|
||||||
GtkInspectorCssEditor *ce)
|
GtkInspectorCssEditor *ce)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
@ -439,10 +440,10 @@ gtk_inspector_css_editor_class_init (GtkInspectorCssEditorClass *klass)
|
|||||||
TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
|
||||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/css-editor.ui");
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/css-editor.ui");
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssEditor, toolbar);
|
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssEditor, text);
|
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssEditor, text);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssEditor, view);
|
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssEditor, view);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssEditor, disable_button);
|
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssEditor, disable_button);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssEditor, object_title);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, disable_toggled);
|
gtk_widget_class_bind_template_callback (widget_class, disable_toggled);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, save_clicked);
|
gtk_widget_class_bind_template_callback (widget_class, save_clicked);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, text_changed);
|
gtk_widget_class_bind_template_callback (widget_class, text_changed);
|
||||||
@ -463,6 +464,7 @@ gtk_inspector_css_editor_set_object (GtkInspectorCssEditor *ce,
|
|||||||
{
|
{
|
||||||
gchar *text;
|
gchar *text;
|
||||||
GtkCssProvider *provider;
|
GtkCssProvider *provider;
|
||||||
|
const gchar *title;
|
||||||
|
|
||||||
g_return_if_fail (GTK_INSPECTOR_IS_CSS_EDITOR (ce));
|
g_return_if_fail (GTK_INSPECTOR_IS_CSS_EDITOR (ce));
|
||||||
g_return_if_fail (!ce->priv->global);
|
g_return_if_fail (!ce->priv->global);
|
||||||
@ -485,6 +487,9 @@ gtk_inspector_css_editor_set_object (GtkInspectorCssEditor *ce,
|
|||||||
|
|
||||||
gtk_widget_show (GTK_WIDGET (ce));
|
gtk_widget_show (GTK_WIDGET (ce));
|
||||||
|
|
||||||
|
title = (const gchar *)g_object_get_data (object, "gtk-inspector-object-title");
|
||||||
|
gtk_label_set_label (GTK_LABEL (ce->priv->object_title), title);
|
||||||
|
|
||||||
ce->priv->context = gtk_widget_get_style_context (GTK_WIDGET (object));
|
ce->priv->context = gtk_widget_get_style_context (GTK_WIDGET (object));
|
||||||
|
|
||||||
provider = g_object_get_data (G_OBJECT (ce->priv->context), GTK_INSPECTOR_CSS_EDITOR_PROVIDER);
|
provider = g_object_get_data (G_OBJECT (ce->priv->context), GTK_INSPECTOR_CSS_EDITOR_PROVIDER);
|
||||||
|
|||||||
@ -19,29 +19,56 @@
|
|||||||
<template class="GtkInspectorCssEditor" parent="GtkBox">
|
<template class="GtkInspectorCssEditor" parent="GtkBox">
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToolbar" id="toolbar">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="icon-size">small-toolbar</property>
|
<property name="orientation">horizontal</property>
|
||||||
|
<property name="spacing">6</property>
|
||||||
|
<property name="margin">6</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToggleToolButton" id="disable_button">
|
<object class="GtkToggleButton" id="disable_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="icon-name">media-playback-pause-symbolic</property>
|
<property name="relief">none</property>
|
||||||
<property name="tooltip-text" translatable="yes">Disable this custom CSS</property>
|
<property name="tooltip-text" translatable="yes">Disable this custom CSS</property>
|
||||||
<signal name="toggled" handler="disable_toggled"/>
|
<signal name="toggled" handler="disable_toggled"/>
|
||||||
<style>
|
<style>
|
||||||
<class name="image-button"/>
|
<class name="image-button"/>
|
||||||
</style>
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="icon-name">media-playback-pause-symbolic</property>
|
||||||
|
<property name="icon-size">1</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack-type">start</property>
|
||||||
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToolButton" id="save_button">
|
<object class="GtkButton" id="save_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="icon-name">document-save-symbolic</property>
|
<property name="relief">none</property>
|
||||||
<property name="tooltip-text" translatable="yes">Save the current CSS</property>
|
<property name="tooltip-text" translatable="yes">Save the current CSS</property>
|
||||||
<signal name="clicked" handler="save_clicked"/>
|
<signal name="clicked" handler="save_clicked"/>
|
||||||
<style>
|
<style>
|
||||||
<class name="image-button"/>
|
<class name="image-button"/>
|
||||||
</style>
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="icon-name">document-save-symbolic</property>
|
||||||
|
<property name="icon-size">1</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack-type">start</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child type="center">
|
||||||
|
<object class="GtkLabel" id="object_title">
|
||||||
|
<property name="visible">True</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|||||||
Reference in New Issue
Block a user