Commit 2b07b6c0 authored by Matthias Clasen's avatar Matthias Clasen

inspector: Add a magnifier

Add a magnifier that shows the selected widget up to 5 times
enlarged.
parent 52b3b420
......@@ -10,6 +10,7 @@ inspector_c_sources = \
inspector/graphdata.c \
inspector/init.c \
inspector/inspect-button.c \
inspector/magnifier.c \
inspector/menu.c \
inspector/misc-info.c \
inspector/object-hierarchy.c \
......@@ -37,6 +38,7 @@ inspector_h_sources = \
inspector/gestures.h \
inspector/graphdata.h \
inspector/init.h \
inspector/magnifier.h \
inspector/menu.h \
inspector/misc-info.h \
inspector/object-hierarchy.h \
......@@ -59,6 +61,7 @@ inspector_templates = \
inspector/css-editor.ui \
inspector/data-list.ui \
inspector/general.ui \
inspector/magnifier.ui \
inspector/menu.ui \
inspector/misc-info.ui \
inspector/object-hierarchy.ui \
......
......@@ -32,6 +32,7 @@
#include "general.h"
#include "gestures.h"
#include "graphdata.h"
#include "magnifier.h"
#include "menu.h"
#include "misc-info.h"
#include "object-hierarchy.h"
......@@ -46,6 +47,8 @@
#include "visual.h"
#include "window.h"
#include "gtkmagnifierprivate.h"
#include "gtkmodulesprivate.h"
void
......@@ -61,6 +64,8 @@ gtk_inspector_init (void)
g_type_ensure (GTK_TYPE_INSPECTOR_DATA_LIST);
g_type_ensure (GTK_TYPE_INSPECTOR_GENERAL);
g_type_ensure (GTK_TYPE_INSPECTOR_GESTURES);
g_type_ensure (GTK_TYPE_MAGNIFIER);
g_type_ensure (GTK_TYPE_INSPECTOR_MAGNIFIER);
g_type_ensure (GTK_TYPE_INSPECTOR_MENU);
g_type_ensure (GTK_TYPE_INSPECTOR_MISC_INFO);
g_type_ensure (GTK_TYPE_INSPECTOR_OBJECT_HIERARCHY);
......
/*
* 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 "config.h"
#include <glib/gi18n-lib.h>
#include "magnifier.h"
#include "gtkmagnifierprivate.h"
#include "gtklabel.h"
struct _GtkInspectorMagnifierPrivate
{
GtkWidget *object;
GtkWidget *magnifier;
GtkWidget *object_title;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorMagnifier, gtk_inspector_magnifier, GTK_TYPE_BOX)
static void
gtk_inspector_magnifier_init (GtkInspectorMagnifier *sl)
{
sl->priv = gtk_inspector_magnifier_get_instance_private (sl);
gtk_widget_init_template (GTK_WIDGET (sl));
}
void
gtk_inspector_magnifier_set_object (GtkInspectorMagnifier *sl,
GObject *object)
{
const gchar *title;
sl->priv->object = NULL;
if (!GTK_IS_WIDGET (object))
{
gtk_widget_hide (GTK_WIDGET (sl));
_gtk_magnifier_set_inspected (GTK_MAGNIFIER (sl->priv->magnifier), NULL);
return;
}
title = (const gchar *)g_object_get_data (object, "gtk-inspector-object-title");
gtk_label_set_label (GTK_LABEL (sl->priv->object_title), title);
gtk_widget_show (GTK_WIDGET (sl));
sl->priv->object = GTK_WIDGET (object);
_gtk_magnifier_set_inspected (GTK_MAGNIFIER (sl->priv->magnifier), GTK_WIDGET (object));
_gtk_magnifier_set_coords (GTK_MAGNIFIER (sl->priv->magnifier), 0, 0);
}
static void
gtk_inspector_magnifier_class_init (GtkInspectorMagnifierClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/magnifier.ui");
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMagnifier, magnifier);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMagnifier, object_title);
}
// vim: set et sw=2 ts=2:
/*
* 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_MAGNIFIER_H_
#define _GTK_INSPECTOR_MAGNIFIER_H_
#include <gtk/gtkbox.h>
#define GTK_TYPE_INSPECTOR_MAGNIFIER (gtk_inspector_magnifier_get_type())
#define GTK_INSPECTOR_MAGNIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_MAGNIFIER, GtkInspectorMagnifier))
#define GTK_INSPECTOR_MAGNIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_MAGNIFIER, GtkInspectorMagnifierClass))
#define GTK_INSPECTOR_IS_MAGNIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_MAGNIFIER))
#define GTK_INSPECTOR_IS_MAGNIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_MAGNIFIER))
#define GTK_INSPECTOR_MAGNIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_MAGNIFIER, GtkInspectorMagnifierClass))
typedef struct _GtkInspectorMagnifierPrivate GtkInspectorMagnifierPrivate;
typedef struct _GtkInspectorMagnifier
{
GtkBox parent;
GtkInspectorMagnifierPrivate *priv;
} GtkInspectorMagnifier;
typedef struct _GtkInspectorMagnifierClass
{
GtkBoxClass parent;
} GtkInspectorMagnifierClass;
G_BEGIN_DECLS
GType gtk_inspector_magnifier_get_type (void);
void gtk_inspector_magnifier_set_object (GtkInspectorMagnifier *sl,
GObject *object);
G_END_DECLS
#endif // _GTK_INSPECTOR_MAGNIFIER_H_
// vim: set et sw=2 ts=2:
......@@ -42,6 +42,7 @@
#include "menu.h"
#include "misc-info.h"
#include "gestures.h"
#include "magnifier.h"
#include "gtklabel.h"
#include "gtkbutton.h"
......@@ -75,6 +76,7 @@ set_selected_object (GtkInspectorWindow *iw,
gtk_inspector_actions_set_object (GTK_INSPECTOR_ACTIONS (iw->actions), selected);
gtk_inspector_menu_set_object (GTK_INSPECTOR_MENU (iw->menu), selected);
gtk_inspector_gestures_set_object (GTK_INSPECTOR_GESTURES (iw->gestures), selected);
gtk_inspector_magnifier_set_object (GTK_INSPECTOR_MAGNIFIER (iw->magnifier), selected);
for (l = iw->extra_pages; l != NULL; l = l->next)
g_object_set (l->data, "object", selected, NULL);
......@@ -234,6 +236,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, menu);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, misc_info);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, gestures);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, magnifier);
gtk_widget_class_bind_template_callback (widget_class, gtk_inspector_on_inspect);
gtk_widget_class_bind_template_callback (widget_class, on_object_activated);
......
......@@ -64,6 +64,7 @@ typedef struct
GtkWidget *menu;
GtkWidget *misc_info;
GtkWidget *gestures;
GtkWidget *magnifier;
GtkWidget *invisible;
GtkWidget *selected_widget;
......@@ -99,7 +100,6 @@ void gtk_inspector_on_inspect (GtkWidget *widget,
void gtk_inspector_window_select_widget_under_pointer (GtkInspectorWindow *iw);
G_END_DECLS
......
......@@ -365,6 +365,14 @@
<property name="title" translatable="yes">Gestures</property>
</packing>
</child>
<child>
<object class="GtkInspectorMagnifier" id="magnifier">
</object>
<packing>
<property name="name">magnifier</property>
<property name="title" translatable="yes">Magnifier</property>
</packing>
</child>
</object>
</child>
</object>
......
......@@ -18,6 +18,7 @@ N_("Data");
N_("Actions");
N_("Menu");
N_("Gestures");
N_("Magnifier");
N_("Objects");
N_("Statistics");
N_("Resources");
......
......@@ -292,6 +292,7 @@ gtk/inspector/general.ui.h
gtk/inspector/gestures.c
gtk/inspector/inspect-button.c
gtk/inspector/menu.c
gtk/inspector/magnifier.ui.h
gtk/inspector/menu.ui.h
gtk/inspector/misc-info.c
gtk/inspector/misc-info.ui.h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment