Commit e39561384d5c66388c3a7140204fc4a659c1f089

Thomas de Grivel 2020-01-17T18:20:21

rtbuf-gtk

diff --git a/Makefile.am b/Makefile.am
index 64b7d70..ec241f2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,6 +33,14 @@ include_HEADERS += \
 	data.h
 endif
 
+if ENABLE_GTK3
+bin_PROGRAMS += rtbuf-gtk
+rtbuf_gtk_CFLAGS = ${GTK3_CFLAGS}
+rtbuf_gtk_LDADD = ${GTK3_LIBS} librtbuf.la
+rtbuf_gtk_SOURCES = \
+	rtbuf_gtk.c
+endif # ENABLE_GTK3
+
 if ENABLE_RTBUF
 bin_PROGRAMS += rtbuf
 rtbuf_LDADD = ${RTBUF_LIBS} librtbuf.la
diff --git a/configure.ac b/configure.ac
index a809339..1e47947 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,13 @@ AC_SEARCH_LIBS([cli_init], [cli],
                 fi])
 AM_CONDITIONAL([ENABLE_CLI], [test x"$enable_cli" = x"true"])
 
+PKG_CHECK_MODULES([GTK3], [gtk+-3.0],
+                  [enable_gtk3=true],
+                  [enable_gtk3=false])
+AM_CONDITIONAL([ENABLE_GTK3], [test x"$enable_gtk3" = x"true"])
+AC_SUBST([GTK3_LIBS])
+AC_SUBST([GTK3_CFLAGS])
+
 enable_rtbuf=true
 AM_CONDITIONAL([ENABLE_RTBUF], [test x"$enable_rtbuf" = x"true"])
 
@@ -115,7 +122,8 @@ AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
 
 echo "Building status :"
-echo "  rtbuf  : $enable_rtbuf $RTBUF_LIBS"
-echo "  signal : $enable_signal $SIGNAL_LIBS"
-echo "  sndio  : $enable_sndio $SNDIO_LIBS"
-echo "  glfw3  : $enable_glfw3 $GLFW3_LIBS"
+echo "  rtbuf-gtk : $enable_gtk3 $GTK3_LIBS"
+echo "  rtbuf     : $enable_rtbuf $RTBUF_LIBS"
+echo "  signal    : $enable_signal $SIGNAL_LIBS"
+echo "  sndio     : $enable_sndio $SNDIO_LIBS"
+echo "  glfw3     : $enable_glfw3 $GLFW3_LIBS"
diff --git a/rtbuf.glade b/rtbuf.glade
new file mode 100644
index 0000000..61c13cb
--- /dev/null
+++ b/rtbuf.glade
@@ -0,0 +1,220 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+  <requires lib="gtk+" version="3.20"/>
+  <object class="GtkWindow" id="modular">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkMenuBar">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkMenuItem">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">_File</property>
+                <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkImageMenuItem">
+                        <property name="label">gtk-new</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem">
+                        <property name="label">gtk-open</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem">
+                        <property name="label">gtk-save</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem">
+                        <property name="label">gtk-save-as</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkSeparatorMenuItem">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="quit">
+                        <property name="label">gtk-quit</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkMenuItem">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">_Edit</property>
+                <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkImageMenuItem">
+                        <property name="label">gtk-cut</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem">
+                        <property name="label">gtk-copy</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem">
+                        <property name="label">gtk-paste</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem">
+                        <property name="label">gtk-delete</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkMenuItem">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">_View</property>
+                <property name="use_underline">True</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkMenuItem">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">_Help</property>
+                <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkImageMenuItem">
+                        <property name="label">gtk-about</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkToolbar">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="shadow_type">in</property>
+            <child>
+              <object class="GtkLayout">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <child>
+                  <object class="GtkDrawingArea">
+                    <property name="width_request">454</property>
+                    <property name="height_request">220</property>
+                    <property name="visible">True</property>
+                    <property name="app_paintable">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/rtbuf_gtk.c b/rtbuf_gtk.c
new file mode 100644
index 0000000..7a4ddf2
--- /dev/null
+++ b/rtbuf_gtk.c
@@ -0,0 +1,43 @@
+#include <gtk/gtk.h>
+#include <stdio.h>
+
+void
+rtbuf_gtk_modular_bg_draw (GtkWidget *widget,
+			   cairo_t *cr)
+{
+	(void) widget;
+	(void) cr;
+	printf("draw modular bg\n");
+}
+
+int
+main (int   argc,
+      char *argv[])
+{
+  GtkBuilder *builder;
+  GObject *window;
+  GObject *button;
+  GError *error = NULL;
+
+  gtk_init (&argc, &argv);
+
+  /* Construct a GtkBuilder instance and load our UI description */
+  builder = gtk_builder_new ();
+  if (gtk_builder_add_from_file (builder, "rtbuf.glade", &error) == 0)
+    {
+      g_printerr ("Error loading file: %s\n", error->message);
+      g_clear_error (&error);
+      return 1;
+    }
+
+  /* Connect signal handlers to the constructed widgets. */
+  window = gtk_builder_get_object (builder, "modular");
+  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+
+  button = gtk_builder_get_object (builder, "quit");
+  g_signal_connect (button, "activate", G_CALLBACK (gtk_main_quit), NULL);
+
+  gtk_main ();
+
+  return 0;
+}