summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-07-04 14:41:32 +0530
committerPranav Kant <pranavk@collabora.co.uk>2017-07-04 15:08:24 +0530
commit96f3b44deacf63ab7bd5da1c02c7d3d12905b483 (patch)
treeb8f4be9355237cd5a1d613787fc9f2eadf02f6b1
parentc9d7af7d2c63da51896ab0675281e33b05b44b12 (diff)
First cut to modernize gtktliedviewer
Change-Id: I4be0e10d6486aaadf4d061d93b6523cd88cf5f9b
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx87
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx26
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-application.cxx50
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-application.hxx26
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-main.cxx19
5 files changed, 208 insertions, 0 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
new file mode 100644
index 000000000000..6b7793307c02
--- /dev/null
+++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <gtk/gtk.h>
+
+#include <gtv-application-window.hxx>
+
+struct _GtvApplicationWindow
+{
+ GtkApplicationWindow parent_instance;
+};
+
+struct GtvApplicationWindowPrivate
+{
+ GtkWidget* container;
+ GtkWidget* toolbar1;
+ GtkWidget* toolbar2;
+ GtkWidget* btn_saveas;
+ GtkWidget* btn_copy;
+ GtkWidget* btn_paste;
+ GtkWidget* btn_bold;
+ GtkWidget* btn_italics;
+ GtkWidget* btn_underline;
+ GtkWidget* statusbar;
+ GtkWidget* scrolledwindow;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GtvApplicationWindow, gtv_application_window, GTK_TYPE_APPLICATION_WINDOW);
+
+static GtvApplicationWindowPrivate*
+getPrivate(GtvApplicationWindow* win)
+{
+ return static_cast<GtvApplicationWindowPrivate*>(gtv_application_window_get_instance_private(win));
+}
+
+static void
+gtv_application_window_init(GtvApplicationWindow* win)
+{
+ GtkBuilder* builder = gtk_builder_new_from_file("gtv.ui");
+ GtvApplicationWindowPrivate* priv = getPrivate(win);
+
+ // This is the parent GtkBox holding everything
+ priv->container = GTK_WIDGET(gtk_builder_get_object(builder, "container"));
+ // 1st row toolbar
+ priv->toolbar1 = GTK_WIDGET(gtk_builder_get_object(builder, "toolbar1"));
+ // 2nd row toolbar
+ priv->toolbar2 = GTK_WIDGET(gtk_builder_get_object(builder, "toolbar2"));
+ // scrolled window containing the main drawing area
+ priv->scrolledwindow = GTK_WIDGET(gtk_builder_get_object(builder, "scrolledwindow"));
+ // statusbar
+ priv->statusbar = GTK_WIDGET(gtk_builder_get_object(builder, "statusbar"));
+
+ gtk_container_add(GTK_CONTAINER(win), priv->container);
+}
+
+static void
+gtv_application_window_class_init(GtvApplicationWindowClass*)
+{
+ // TODO: Use templates to bind objects maybe ?
+ // But that requires compiling the .ui file into C source requiring
+ // glib-compile-resources (another dependency) as I can't find any gtk
+ // method to set the template from the .ui file directly; can only be set
+ // from gresource
+}
+
+GtvApplicationWindow*
+gtv_application_window_new(GtkApplication* app)
+{
+ g_return_val_if_fail(GTK_IS_APPLICATION(app), nullptr);
+
+ return GTV_APPLICATION_WINDOW(g_object_new(GTV_APPLICATION_WINDOW_TYPE,
+ "application", app,
+ "width-request", 1024,
+ "height-request", 768,
+ "title", "LibreOffice GtkTiledViewer",
+ "window-position", GTK_WIN_POS_CENTER,
+ "show-menubar", false,
+ nullptr));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx
new file mode 100644
index 000000000000..1d67a5a0ab65
--- /dev/null
+++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx
@@ -0,0 +1,26 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef GTV_APPLICATION_WINDOW_H
+#define GTV_APPLICATION_WINDOW_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GTV_APPLICATION_WINDOW_TYPE (gtv_application_window_get_type())
+G_DECLARE_FINAL_TYPE(GtvApplicationWindow, gtv_application_window, GTV, APPLICATION_WINDOW, GtkApplicationWindow);
+
+GtvApplicationWindow* gtv_application_window_new(GtkApplication* application);
+
+G_END_DECLS
+
+#endif /* GTV_APPLICATION_WINDOW_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application.cxx b/libreofficekit/qa/gtktiledviewer/gtv-application.cxx
new file mode 100644
index 000000000000..eab1f08bf938
--- /dev/null
+++ b/libreofficekit/qa/gtktiledviewer/gtv-application.cxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <gtk/gtk.h>
+
+#include <gtv-application.hxx>
+#include <gtv-application-window.hxx>
+
+struct _GtvApplication
+{
+ GtkApplication parent;
+};
+
+G_DEFINE_TYPE(GtvApplication, gtv_application, GTK_TYPE_APPLICATION);
+
+static void
+gtv_application_activate(GApplication* application)
+{
+ GtvApplicationWindow* win = GTV_APPLICATION_WINDOW(gtv_application_window_new(GTK_APPLICATION(application)));
+ gtk_window_present(GTK_WINDOW(win));
+}
+
+//gtv_application_open(GApplication* /*win*/, GFile** /*file*/, gint, const gchar*)
+
+static void
+gtv_application_init(GtvApplication*)
+{
+ // TODO
+}
+
+static void
+gtv_application_class_init(GtvApplicationClass* klass)
+{
+ G_APPLICATION_CLASS(klass)->activate = gtv_application_activate;
+}
+
+GtvApplication* gtv_application_new()
+{
+ return GTV_APPLICATION(g_object_new(GTV_APPLICATION_TYPE,
+ "application-id", "org.libreoffice.gtktiledviewer",
+ nullptr));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application.hxx b/libreofficekit/qa/gtktiledviewer/gtv-application.hxx
new file mode 100644
index 000000000000..57bacca0fb71
--- /dev/null
+++ b/libreofficekit/qa/gtktiledviewer/gtv-application.hxx
@@ -0,0 +1,26 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef GTV_APPLICATION_H
+#define GTV_APPLICATION_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GTV_APPLICATION_TYPE (gtv_application_get_type())
+G_DECLARE_FINAL_TYPE(GtvApplication, gtv_application, GTV, APPLICATION, GtkApplication);
+
+GtvApplication* gtv_application_new();
+
+G_END_DECLS
+
+#endif /* GTV_APPLICATION_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-main.cxx b/libreofficekit/qa/gtktiledviewer/gtv-main.cxx
new file mode 100644
index 000000000000..c35e6cb73abd
--- /dev/null
+++ b/libreofficekit/qa/gtktiledviewer/gtv-main.cxx
@@ -0,0 +1,19 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <gtk/gtk.h>
+
+#include <gtv-application.hxx>
+
+int main(int argc, char* argv[])
+{
+ return g_application_run(G_APPLICATION(gtv_application_new()), argc, argv);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */