inspector: Add a general information tab
It is useful to see the GTK+ version, and the various paths that affect GTK+ operation at runtime.
This commit is contained in:
@ -25,6 +25,8 @@ libgtkinspector_la_SOURCES = \
|
||||
css-editor.c \
|
||||
data-list.h \
|
||||
data-list.c \
|
||||
general.h \
|
||||
general.c \
|
||||
init.h \
|
||||
init.c \
|
||||
inspect-button.c \
|
||||
|
||||
170
gtk/inspector/general.c
Normal file
170
gtk/inspector/general.c
Normal file
@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "general.h"
|
||||
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include "x11/gdkx.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_WIN32
|
||||
#include "win32/gdkwin32.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#include "quartz/gdkquartz.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
#include "wayland/gdkwayland.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_BROADWAY
|
||||
#include "broadway/gdkbroadway.h"
|
||||
#endif
|
||||
|
||||
|
||||
struct _GtkInspectorGeneralPrivate
|
||||
{
|
||||
GtkWidget *gtk_version;
|
||||
GtkWidget *gdk_backend;
|
||||
|
||||
GtkWidget *prefix;
|
||||
GtkWidget *xdg_data_home;
|
||||
GtkWidget *xdg_data_dirs;
|
||||
GtkWidget *gtk_path;
|
||||
GtkWidget *gtk_exe_prefix;
|
||||
GtkWidget *gtk_data_prefix;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorGeneral, gtk_inspector_general, GTK_TYPE_BOX)
|
||||
|
||||
static void
|
||||
init_version (GtkInspectorGeneral *gen)
|
||||
{
|
||||
const gchar *backend;
|
||||
GdkDisplay *display;
|
||||
|
||||
display = gtk_widget_get_display (GTK_WIDGET (gen));
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
if (GDK_IS_X11_DISPLAY (display))
|
||||
backend = "X11";
|
||||
else
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
if (GDK_IS_WAYLAND_DISPLAY (display))
|
||||
backend = "Wayland";
|
||||
else
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_BROADWAY
|
||||
if (GDK_IS_BROADWAY_DISPLAY (display))
|
||||
backend = "Broadway";
|
||||
else
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WIN32
|
||||
if (GDK_IS_WIN32_DISPLAY (display))
|
||||
backend = "Windows";
|
||||
else
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
if (GDK_IS_QUARTZ_DISPLAY (display))
|
||||
backend = "Quartz";
|
||||
else
|
||||
#endif
|
||||
backend = "Unknown";
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (gen->priv->gtk_version), GTK_VERSION);
|
||||
gtk_label_set_text (GTK_LABEL (gen->priv->gdk_backend), backend);
|
||||
}
|
||||
|
||||
static void
|
||||
set_monospace_font (GtkWidget *w)
|
||||
{
|
||||
PangoFontDescription *font_desc;
|
||||
font_desc = pango_font_description_from_string ("monospace");
|
||||
gtk_widget_override_font (w, font_desc);
|
||||
pango_font_description_free (font_desc);
|
||||
}
|
||||
|
||||
static void
|
||||
set_path_label (GtkWidget *w,
|
||||
const gchar *var)
|
||||
{
|
||||
const gchar *v;
|
||||
|
||||
v = g_getenv (var);
|
||||
g_print ("%s %s\n", var, v);
|
||||
if (v)
|
||||
{
|
||||
set_monospace_font (w);
|
||||
gtk_label_set_text (GTK_LABEL (w), v);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *r;
|
||||
r = gtk_widget_get_ancestor (w, GTK_TYPE_LIST_BOX_ROW);
|
||||
gtk_widget_hide (r);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
init_env (GtkInspectorGeneral *gen)
|
||||
{
|
||||
set_monospace_font (gen->priv->prefix);
|
||||
gtk_label_set_text (GTK_LABEL (gen->priv->prefix), _gtk_get_data_prefix ());
|
||||
set_path_label (gen->priv->xdg_data_home, "XDG_DATA_HOME");
|
||||
set_path_label (gen->priv->xdg_data_dirs, "XDG_DATA_DIRS");
|
||||
set_path_label (gen->priv->gtk_path, "GTK_PATH");
|
||||
set_path_label (gen->priv->gtk_exe_prefix, "GTK_EXE_PREFIX");
|
||||
set_path_label (gen->priv->gtk_data_prefix, "GTK_DATA_PREFIX");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_general_init (GtkInspectorGeneral *gen)
|
||||
{
|
||||
gen->priv = gtk_inspector_general_get_instance_private (gen);
|
||||
gtk_widget_init_template (GTK_WIDGET (gen));
|
||||
init_version (gen);
|
||||
init_env (gen);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_general_class_init (GtkInspectorGeneralClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/general.ui");
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gtk_version);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gdk_backend);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, prefix);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, xdg_data_home);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, xdg_data_dirs);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gtk_path);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gtk_exe_prefix);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gtk_data_prefix);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_inspector_general_new (void)
|
||||
{
|
||||
return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_GENERAL, NULL));
|
||||
}
|
||||
|
||||
// vim: set et sw=2 ts=2:
|
||||
53
gtk/inspector/general.h
Normal file
53
gtk/inspector/general.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _GTK_INSPECTOR_GENERAL_H_
|
||||
#define _GTK_INSPECTOR_GENERAL_H_
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define GTK_TYPE_INSPECTOR_GENERAL (gtk_inspector_general_get_type())
|
||||
#define GTK_INSPECTOR_GENERAL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_GENERAL, GtkInspectorGeneral))
|
||||
#define GTK_INSPECTOR_GENERAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_GENERAL, GtkInspectorGeneralClass))
|
||||
#define GTK_INSPECTOR_IS_GENERAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_GENERAL))
|
||||
#define GTK_INSPECTOR_IS_GENERAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_GENERAL))
|
||||
#define GTK_INSPECTOR_GENERAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_GENERAL, GtkInspectorGeneralClass))
|
||||
|
||||
|
||||
typedef struct _GtkInspectorGeneralPrivate GtkInspectorGeneralPrivate;
|
||||
|
||||
typedef struct _GtkInspectorGeneral
|
||||
{
|
||||
GtkBox parent;
|
||||
GtkInspectorGeneralPrivate *priv;
|
||||
} GtkInspectorGeneral;
|
||||
|
||||
typedef struct _GtkInspectorGeneralClass
|
||||
{
|
||||
GtkBoxClass parent;
|
||||
} GtkInspectorGeneralClass;
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GType gtk_inspector_general_get_type (void);
|
||||
GtkWidget *gtk_inspector_general_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif // _GTK_INSPECTOR_GENERAL_H_
|
||||
|
||||
// vim: set et sw=2 ts=2:
|
||||
269
gtk/inspector/general.ui
Normal file
269
gtk/inspector/general.ui
Normal file
@ -0,0 +1,269 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface domain="gtk30">
|
||||
<template class="GtkInspectorGeneral" parent="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="margin">60</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkFrame" id="version_frame">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">center</property>
|
||||
<child>
|
||||
<object class="GtkListBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="selection-mode">none</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">40</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="gtk_version_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">GTK+ Version</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="xalign">0.0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="gtk_version">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">baseline</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">40</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="gdk_backend_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">GDK Backend</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="xalign">0.0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="gdk_backend">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">baseline</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame" id="env_frame">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">center</property>
|
||||
<child>
|
||||
<object class="GtkListBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="selection-mode">none</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">40</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="prefix_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Prefix</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="xalign">0.0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="prefix">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">baseline</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">40</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="xdg_data_home_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">XDG_DATA_HOME</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="xalign">0.0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="xdg_data_home">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">baseline</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">40</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="xdg_data_dirs_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">XDG_DATA_DIRS</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="xalign">0.0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="xdg_data_dirs">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">baseline</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">40</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="gtk_path_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">GTK_PATH</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="xalign">0.0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="gtk_path">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">baseline</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">40</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="gtk_exe_prefix_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">GTK_EXE_PREFIX</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="xalign">0.0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="gtk_exe_prefix">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">baseline</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">40</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="gtk_data_prefix_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">GTK_DATA_PREFIX</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="xalign">0.0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="gtk_data_prefix">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">baseline</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
<object class="GtkSizeGroup">
|
||||
<property name="mode">horizontal</property>
|
||||
<widgets>
|
||||
<widget name="gtk_version_label"/>
|
||||
<widget name="gdk_backend_label"/>
|
||||
<widget name="prefix_label"/>
|
||||
<widget name="xdg_data_home_label"/>
|
||||
<widget name="xdg_data_dirs_label"/>
|
||||
<widget name="gtk_path_label"/>
|
||||
<widget name="gtk_exe_prefix_label"/>
|
||||
<widget name="gtk_data_prefix_label"/>
|
||||
</widgets>
|
||||
</object>
|
||||
<object class="GtkSizeGroup">
|
||||
<property name="mode">horizontal</property>
|
||||
<widgets>
|
||||
<widget name="version_frame"/>
|
||||
<widget name="env_frame"/>
|
||||
</widgets>
|
||||
</object>
|
||||
-->
|
||||
</interface>
|
||||
@ -27,6 +27,7 @@
|
||||
#include "classes-list.h"
|
||||
#include "css-editor.h"
|
||||
#include "data-list.h"
|
||||
#include "general.h"
|
||||
#include "object-hierarchy.h"
|
||||
#include "property-cell-renderer.h"
|
||||
#include "prop-list.h"
|
||||
@ -52,6 +53,7 @@ gtk_inspector_init (void)
|
||||
g_type_ensure (GTK_TYPE_INSPECTOR_CLASSES_LIST);
|
||||
g_type_ensure (GTK_TYPE_INSPECTOR_CSS_EDITOR);
|
||||
g_type_ensure (GTK_TYPE_INSPECTOR_DATA_LIST);
|
||||
g_type_ensure (GTK_TYPE_INSPECTOR_GENERAL);
|
||||
g_type_ensure (GTK_TYPE_INSPECTOR_OBJECT_HIERARCHY);
|
||||
g_type_ensure (GTK_TYPE_INSPECTOR_PROPERTY_CELL_RENDERER);
|
||||
g_type_ensure (GTK_TYPE_INSPECTOR_PROP_LIST);
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
<file>classes-list.ui</file>
|
||||
<file>css-editor.ui</file>
|
||||
<file>data-list.ui</file>
|
||||
<file>general.ui</file>
|
||||
<file>object-hierarchy.ui</file>
|
||||
<file>prop-list.ui</file>
|
||||
<file>signals-list.ui</file>
|
||||
|
||||
@ -231,6 +231,17 @@
|
||||
<property name="label" translatable="yes">Custom CSS</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkInspectorGeneral">
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="tab">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">General</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
|
||||
@ -275,6 +275,7 @@ gtk/inspector/classes-list.ui.h
|
||||
gtk/inspector/css-editor.c
|
||||
gtk/inspector/css-editor.ui.h
|
||||
gtk/inspector/data-list.ui.h
|
||||
gtk/inspector/general.ui.h
|
||||
gtk/inspector/inspect-button.c
|
||||
gtk/inspector/object-hierarchy.ui.h
|
||||
gtk/inspector/prop-list.ui.h
|
||||
|
||||
Reference in New Issue
Block a user