[gtk+] inspector: Add a magnifier
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Add a magnifier
- Date: Sun, 21 Dec 2014 00:25:09 +0000 (UTC)
commit 2b07b6c069297abdeed1b41c91fde1d47058ce97
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 20 19:24:08 2014 -0500
inspector: Add a magnifier
Add a magnifier that shows the selected widget up to 5 times
enlarged.
gtk/inspector/Makefile.inc | 3 ++
gtk/inspector/init.c | 5 +++
gtk/inspector/magnifier.c | 80 ++++++++++++++++++++++++++++++++++++++++++
gtk/inspector/magnifier.h | 54 ++++++++++++++++++++++++++++
gtk/inspector/window.c | 3 ++
gtk/inspector/window.h | 2 +-
gtk/inspector/window.ui | 8 ++++
gtk/inspector/window.ui.h | 1 +
po/POTFILES.in | 1 +
9 files changed, 156 insertions(+), 1 deletions(-)
---
diff --git a/gtk/inspector/Makefile.inc b/gtk/inspector/Makefile.inc
index 5c966df..464e809 100644
--- a/gtk/inspector/Makefile.inc
+++ b/gtk/inspector/Makefile.inc
@@ -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 \
diff --git a/gtk/inspector/init.c b/gtk/inspector/init.c
index c930948..14acd8e 100644
--- a/gtk/inspector/init.c
+++ b/gtk/inspector/init.c
@@ -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);
diff --git a/gtk/inspector/magnifier.c b/gtk/inspector/magnifier.c
new file mode 100644
index 0000000..c7b4a5b
--- /dev/null
+++ b/gtk/inspector/magnifier.c
@@ -0,0 +1,80 @@
+/*
+ * 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:
diff --git a/gtk/inspector/magnifier.h b/gtk/inspector/magnifier.h
new file mode 100644
index 0000000..2dcac6f
--- /dev/null
+++ b/gtk/inspector/magnifier.h
@@ -0,0 +1,54 @@
+/*
+ * 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:
diff --git a/gtk/inspector/magnifier.ui.h b/gtk/inspector/magnifier.ui.h
new file mode 100644
index 0000000..e69de29
diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c
index 1e7223b..3846ecd 100644
--- a/gtk/inspector/window.c
+++ b/gtk/inspector/window.c
@@ -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);
diff --git a/gtk/inspector/window.h b/gtk/inspector/window.h
index 8560e0c..07a469d 100644
--- a/gtk/inspector/window.h
+++ b/gtk/inspector/window.h
@@ -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
diff --git a/gtk/inspector/window.ui b/gtk/inspector/window.ui
index 366d179..6046618 100644
--- a/gtk/inspector/window.ui
+++ b/gtk/inspector/window.ui
@@ -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>
diff --git a/gtk/inspector/window.ui.h b/gtk/inspector/window.ui.h
index 498011c..05c6b21 100644
--- a/gtk/inspector/window.ui.h
+++ b/gtk/inspector/window.ui.h
@@ -18,6 +18,7 @@ N_("Data");
N_("Actions");
N_("Menu");
N_("Gestures");
+N_("Magnifier");
N_("Objects");
N_("Statistics");
N_("Resources");
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 2bac9c0..62aef23 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]