aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2014-01-28 16:50:47 +0100
committerJavier <dev.git@javispedro.com>2014-01-28 16:50:47 +0100
commitc2d6d46b9ca89cb1c0729ee599c3566d3d1e7cf7 (patch)
tree7e1e2285437816c06ac884d68284d854413cf41e /test
downloadtopmenu-gtk-c2d6d46b9ca89cb1c0729ee599c3566d3d1e7cf7.tar.gz
topmenu-gtk-c2d6d46b9ca89cb1c0729ee599c3566d3d1e7cf7.zip
initial import
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am12
-rw-r--r--test/client.c79
-rw-r--r--test/server.c40
3 files changed, 131 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..4455221
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,12 @@
+noinst_PROGRAMS = client server
+
+AM_CPPFLAGS = $(GTK_CFLAGS)
+AM_LDFLAGS = $(GTK_LIBS)
+
+client_SOURCES = client.c
+client_CPPFLAGS = $(GTK_CFLAGS)
+client_LDADD = $(GTK_LIBS) ../libtopmenu-client/libtopmenu-client.la
+
+server_SOURCES = server.c
+server_CPPFLAGS = $(GTK_CFLAGS)
+server_LDADD = $(GTK_LIBS) ../libtopmenu-server/libtopmenu-server.la
diff --git a/test/client.c b/test/client.c
new file mode 100644
index 0000000..08312e6
--- /dev/null
+++ b/test/client.c
@@ -0,0 +1,79 @@
+#include <stdlib.h>
+
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
+
+#include "../libtopmenu-client/topmenu-client.h"
+#include "../libtopmenu-client/topmenu-monitor.h"
+
+static GtkWindow *mainwin;
+
+static GtkWidget * create_menu_bar(void)
+{
+ GtkMenuBar *bar = GTK_MENU_BAR(gtk_menu_bar_new());
+ GtkMenuItem *app = GTK_MENU_ITEM(gtk_menu_item_new_with_label("Client"));
+ GtkMenuItem *file = GTK_MENU_ITEM(gtk_menu_item_new_with_mnemonic("_File"));
+ GtkMenuItem *edit = GTK_MENU_ITEM(gtk_menu_item_new_with_mnemonic("_Edit"));
+ GtkMenuItem *help = GTK_MENU_ITEM(gtk_menu_item_new_with_mnemonic("_Help"));
+
+ GtkLabel *app_label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(app)));
+ gtk_label_set_markup(app_label, "<b>Client</b>");
+
+ gtk_menu_bar_append(bar, GTK_WIDGET(app));
+ gtk_menu_bar_append(bar, GTK_WIDGET(file));
+ gtk_menu_bar_append(bar, GTK_WIDGET(edit));
+ gtk_menu_bar_append(bar, GTK_WIDGET(help));
+
+ GtkMenu *app_menu = GTK_MENU(gtk_menu_new());
+ GtkMenuItem *quit = GTK_MENU_ITEM(gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL));
+ gtk_menu_append(app_menu, GTK_WIDGET(quit));
+ gtk_menu_item_set_submenu(app, GTK_WIDGET(app_menu));
+
+ GtkMenu *file_menu = GTK_MENU(gtk_menu_new());
+ GtkMenuItem *new = GTK_MENU_ITEM(gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, NULL));
+ gtk_menu_append(file_menu, GTK_WIDGET(new));
+ GtkMenuItem *open = GTK_MENU_ITEM(gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, NULL));
+ gtk_menu_append(file_menu, GTK_WIDGET(open));
+ GtkMenuItem *close = GTK_MENU_ITEM(gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, NULL));
+ gtk_menu_append(file_menu, GTK_WIDGET(close));
+ gtk_menu_item_set_submenu(file, GTK_WIDGET(file_menu));
+
+ return GTK_WIDGET(bar);
+}
+
+GtkWindow * create_main_window()
+{
+ GtkWindow *win = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
+ GtkVBox *box = GTK_VBOX(gtk_vbox_new(FALSE, 0));
+ GtkLabel *label = GTK_LABEL(gtk_label_new("Hello World"));
+
+ GtkWidget *bar = create_menu_bar();
+
+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(bar), FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(label), TRUE, TRUE, 0);
+ gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(box));
+
+ return win;
+}
+
+int main(int argc, char **argv)
+{
+ gtk_set_locale();
+ gtk_init(&argc, &argv);
+
+ mainwin = create_main_window();
+ topmenu_monitor_get_instance();
+
+ g_signal_connect(mainwin, "destroy", G_CALLBACK(gtk_main_quit), NULL);
+
+ gtk_widget_realize(GTK_WIDGET(mainwin));
+
+ topmenu_client_connect_window_widget(gtk_widget_get_window(GTK_WIDGET(mainwin)),
+ create_menu_bar());
+
+ gtk_widget_show_all(GTK_WIDGET(mainwin));
+
+ gtk_main();
+
+ return EXIT_SUCCESS;
+}
diff --git a/test/server.c b/test/server.c
new file mode 100644
index 0000000..d0b9135
--- /dev/null
+++ b/test/server.c
@@ -0,0 +1,40 @@
+#include <stdlib.h>
+
+#include <gtk/gtk.h>
+
+#include "../libtopmenu-server/topmenu-widget.h"
+
+static GtkWindow *mainwin;
+static TopMenuWidget *topmenu;
+
+static gboolean handle_button_press(GtkWidget *widget, GdkEvent *event, gpointer user_data)
+{
+ g_debug("Mainwin: button press");
+ return FALSE;
+}
+
+static void construct_main_window()
+{
+ mainwin = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
+ topmenu = TOPMENU_WIDGET(topmenu_widget_new());
+ gtk_container_add(GTK_CONTAINER(mainwin), GTK_WIDGET(topmenu));
+}
+
+int main(int argc, char **argv)
+{
+ gtk_set_locale();
+ gtk_init(&argc, &argv);
+
+ construct_main_window();
+
+ g_signal_connect(mainwin, "destroy", G_CALLBACK(gtk_main_quit), NULL);
+ g_signal_connect(mainwin, "button-press-event", G_CALLBACK(handle_button_press), NULL);
+
+ gtk_window_set_keep_above(mainwin, TRUE);
+ gtk_window_set_accept_focus(mainwin, FALSE);
+ gtk_widget_show_all(GTK_WIDGET(mainwin));
+
+ gtk_main();
+
+ return EXIT_SUCCESS;
+}