Compare commits
2 Commits
040d74b8c4
...
c7dbe01c22
Author | SHA1 | Date | |
---|---|---|---|
c7dbe01c22 | |||
795bc1a4e5 |
@ -163,6 +163,10 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="margin_left">4</property>
|
||||
<property name="margin_right">4</property>
|
||||
<property name="margin_top">4</property>
|
||||
<property name="margin_bottom">4</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
</object>
|
||||
@ -179,6 +183,10 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="margin_left">4</property>
|
||||
<property name="margin_right">4</property>
|
||||
<property name="margin_top">4</property>
|
||||
<property name="margin_bottom">4</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
</object>
|
||||
|
31
src/main.c
31
src/main.c
@ -1,27 +1,46 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include "main_window.h"
|
||||
#include "scanner.h"
|
||||
|
||||
// TODO: For testing only
|
||||
#include "cart_item.h"
|
||||
|
||||
struct app_state {
|
||||
struct mainWindow *mainWindow;
|
||||
};
|
||||
|
||||
static void newtag(YacosScanner *scanner, struct mainWindow *mainWindow)
|
||||
{
|
||||
// TODO: For testing only
|
||||
gtk_stack_set_visible_child(mainWindow->stack_main, mainWindow->page_cart.box);
|
||||
GtkWidget *le = yacos_cart_item_new();
|
||||
gtk_list_box_insert(mainWindow->page_cart.list, le, -1);
|
||||
gtk_widget_show(le);
|
||||
}
|
||||
|
||||
static void activate(GtkApplication* app, gpointer user_data)
|
||||
{
|
||||
struct app_state *app_state = user_data;
|
||||
struct mainWindow **mainWindow = &(app_state->mainWindow);
|
||||
|
||||
YacosScanner *scanner;
|
||||
|
||||
*mainWindow = mainWindow_new(app);
|
||||
if (*mainWindow) {
|
||||
if (!(*mainWindow)) {
|
||||
g_error("Error initializing mainWindow.");
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_application_add_window(GTK_APPLICATION(app), GTK_WINDOW((*mainWindow)->main_window));
|
||||
gtk_widget_show_all((*mainWindow)->main_window);
|
||||
|
||||
// For testing only
|
||||
gtk_stack_set_visible_child((*mainWindow)->stack_main, (*mainWindow)->page_cart.box);
|
||||
GtkWidget *le = yacos_cart_item_new();
|
||||
gtk_list_box_insert((*mainWindow)->page_cart.list, le, -1);
|
||||
gtk_widget_show(le);
|
||||
scanner = yacos_scanner_new();
|
||||
if (!scanner) {
|
||||
g_error("Error initializing scanner.");
|
||||
}
|
||||
|
||||
g_signal_connect(scanner, "newtag",
|
||||
(GCallback) newtag, (*mainWindow));
|
||||
}
|
||||
|
||||
|
||||
|
60
src/scanner.c
Normal file
60
src/scanner.c
Normal file
@ -0,0 +1,60 @@
|
||||
#include "scanner.h"
|
||||
|
||||
struct _YacosScanner {
|
||||
GObject parent_instance;
|
||||
|
||||
// TODO: Private data goes here
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(YacosScanner, yacos_scanner, G_TYPE_OBJECT)
|
||||
|
||||
enum {
|
||||
SIGNAL_NEWTAG = 0,
|
||||
SIGNAL_COUNT
|
||||
};
|
||||
guint yacos_scanner_signals[SIGNAL_COUNT];
|
||||
|
||||
static gboolean *yacos_scanner_read (gpointer user_data)
|
||||
{
|
||||
YacosScanner *self = YACOS_SCANNER(user_data);
|
||||
|
||||
// TODO: Scan for tags
|
||||
g_signal_emit(self, yacos_scanner_signals[SIGNAL_NEWTAG], 0);
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
static void yacos_scanner_finalize(GObject *gobject)
|
||||
{
|
||||
YacosScanner *obj = yacos_scanner_get_instance_private(YACOS_SCANNER(gobject));
|
||||
|
||||
// TODO: clean up
|
||||
|
||||
G_OBJECT_CLASS(yacos_scanner_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void yacos_scanner_class_init(YacosScannerClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
yacos_scanner_signals[SIGNAL_NEWTAG] =
|
||||
g_signal_newv("newtag",
|
||||
G_TYPE_FROM_CLASS(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
|
||||
NULL, NULL, NULL, NULL,
|
||||
G_TYPE_NONE,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
object_class->finalize = yacos_scanner_finalize;
|
||||
}
|
||||
|
||||
static void yacos_scanner_init(YacosScanner *self)
|
||||
{
|
||||
g_timeout_add(1000, G_SOURCE_FUNC(yacos_scanner_read), self);
|
||||
}
|
||||
|
||||
YacosScanner *yacos_scanner_new(void)
|
||||
{
|
||||
return g_object_new(YACOS_TYPE_SCANNER, 0);
|
||||
}
|
15
src/scanner.h
Normal file
15
src/scanner.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef SCANNER_H
|
||||
#define SCANNER_H
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define YACOS_TYPE_SCANNER yacos_scanner_get_type()
|
||||
G_DECLARE_FINAL_TYPE(YacosScanner, yacos_scanner, YACOS, SCANNER, GObject)
|
||||
|
||||
YacosScanner *yacos_scanner_new(void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif // SCANNER_H
|
Loading…
Reference in New Issue
Block a user