Edit window
This commit is contained in:
parent
6628dddb27
commit
10901f7dcb
5 changed files with 174 additions and 0 deletions
|
@ -5,6 +5,7 @@ all:
|
|||
collections.c \
|
||||
interface.c \
|
||||
c-main-window.c \
|
||||
c-edit-window.c \
|
||||
c-new-item-dialog.c \
|
||||
data.c \
|
||||
$(CFLAGS) \
|
||||
|
|
83
src/c-edit-window.c
Normal file
83
src/c-edit-window.c
Normal file
|
@ -0,0 +1,83 @@
|
|||
#include "c-edit-window.h"
|
||||
#include <hildon/hildon.h>
|
||||
#include "data.h"
|
||||
|
||||
G_DEFINE_TYPE(CEditWindow, c_edit_window, HILDON_TYPE_STACKABLE_WINDOW)
|
||||
|
||||
GtkWidget *c_edit_window_new(void)
|
||||
{
|
||||
return g_object_new(C_TYPE_EDIT_WINDOW, NULL);
|
||||
}
|
||||
|
||||
static void c_edit_window_class_init(CEditWindowClass *class)
|
||||
{}
|
||||
|
||||
static void c_edit_window_init(CEditWindow *self)
|
||||
{
|
||||
GtkWidget *pannablearea;
|
||||
GtkWidget *table;
|
||||
GtkWidget *nameclabel;
|
||||
GtkWidget *namelabel;
|
||||
GtkWidget *haveclabel;
|
||||
GtkWidget *havelabel;
|
||||
GtkWidget *totalclabel;
|
||||
GtkWidget *totallabel;
|
||||
GtkWidget *layout;
|
||||
int i;
|
||||
struct collection test = { 0, 3, 10, "Biomega" };
|
||||
|
||||
pannablearea = hildon_pannable_area_new();
|
||||
g_object_set(G_OBJECT(pannablearea),
|
||||
"mov-mode", HILDON_MOVEMENT_MODE_VERT,
|
||||
NULL);
|
||||
gtk_container_add(GTK_CONTAINER(self), pannablearea);
|
||||
|
||||
table = gtk_table_new(4, 2, FALSE);
|
||||
hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(pannablearea),
|
||||
table);
|
||||
|
||||
nameclabel = gtk_label_new("Name:");
|
||||
gtk_misc_set_alignment(GTK_MISC(nameclabel), 0.0, 0.5);
|
||||
gtk_table_attach(GTK_TABLE(table), nameclabel, 0, 1, 0, 1,
|
||||
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
||||
|
||||
namelabel = gtk_label_new(test.name);
|
||||
gtk_misc_set_alignment(GTK_MISC(namelabel), 1.0, 0.5);
|
||||
gtk_table_attach(GTK_TABLE(table), namelabel, 1, 2, 0, 1,
|
||||
GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
||||
|
||||
haveclabel = gtk_label_new("You have:");
|
||||
gtk_misc_set_alignment(GTK_MISC(haveclabel), 0.0, 0.5);
|
||||
gtk_table_attach(GTK_TABLE(table), haveclabel, 0, 1, 1, 2,
|
||||
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
||||
|
||||
havelabel = gtk_label_new(g_strdup_printf("%d", test.current_qty));
|
||||
gtk_misc_set_alignment(GTK_MISC(havelabel), 1.0, 0.5);
|
||||
gtk_table_attach(GTK_TABLE(table), havelabel, 1, 2, 1, 2,
|
||||
GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
||||
|
||||
totalclabel = gtk_label_new("There are:");
|
||||
gtk_misc_set_alignment(GTK_MISC(totalclabel), 0.0, 0.5);
|
||||
gtk_table_attach(GTK_TABLE(table), totalclabel, 0, 1, 2, 3,
|
||||
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
||||
|
||||
totallabel = gtk_label_new((test.total_qty == 0)
|
||||
? "?"
|
||||
: g_strdup_printf("%d", test.total_qty));
|
||||
gtk_misc_set_alignment(GTK_MISC(totallabel), 1.0, 0.5);
|
||||
gtk_table_attach(GTK_TABLE(table), totallabel, 1, 2, 2, 3,
|
||||
GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
||||
|
||||
/*layout = gtk_layout_new(NULL, NULL);
|
||||
gtk_table_attach(GTK_TABLE(table), layout, 0, 2, 3, 4,
|
||||
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
||||
|
||||
for (i = 0; i < test.total_qty; i++) {
|
||||
GtkWidget *button;
|
||||
|
||||
button = hildon_check_button_new(HILDON_SIZE_FINGER_HEIGHT |
|
||||
HILDON_SIZE_AUTO_WIDTH);
|
||||
gtk_button_set_label(GTK_BUTTON(button), g_strdup_printf("%d", i));
|
||||
|
||||
}*/
|
||||
}
|
53
src/c-edit-window.h
Normal file
53
src/c-edit-window.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
#ifndef __C_EDIT_WINDOW_H__
|
||||
#define __C_EDIT_WINDOW_H__
|
||||
|
||||
#include <hildon/hildon-stackable-window.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define C_TYPE_EDIT_WINDOW \
|
||||
(c_edit_window_get_type())
|
||||
|
||||
#define C_EDIT_WINDOW(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
||||
C_TYPE_EDIT_WINDOW, \
|
||||
CEditWindow))
|
||||
|
||||
#define C_EDIT_WINDOW_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
||||
C_TYPE_EDIT_WINDOW, \
|
||||
CEditWindowClass))
|
||||
|
||||
#define C_IS_EDIT_WINDOW(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
||||
C_TYPE_EDIT_WINDOW))
|
||||
|
||||
#define C_IS_EDIT_WINDOW_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
||||
C_TYPE_EDIT_WINDOW))
|
||||
|
||||
#define C_EDIT_WINDOW_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
||||
C_TYPE_EDIT_WINDOW, \
|
||||
CEditWindowClass))
|
||||
|
||||
typedef struct _CEditWindow CEditWindow;
|
||||
typedef struct _CEditWindowClass CEditWindowClass;
|
||||
|
||||
struct _CEditWindowClass
|
||||
{
|
||||
HildonStackableWindowClass parent_class;
|
||||
};
|
||||
|
||||
struct _CEditWindow
|
||||
{
|
||||
HildonStackableWindow parent;
|
||||
};
|
||||
|
||||
GType c_edit_window_get_type(void);
|
||||
|
||||
GtkWidget *c_edit_window_new(void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __C_EDIT_WINDOW_H__ */
|
|
@ -24,6 +24,8 @@ static void c_main_window_on_selection_changed(GtkTreeSelection *selection,
|
|||
static void c_main_window_on_add_clicked(GtkWidget *widget, gpointer user_data);
|
||||
static void c_main_window_on_remove_clicked(GtkWidget *widget,
|
||||
gpointer user_data);
|
||||
static void c_main_window_on_edit_clicked(GtkWidget *widget,
|
||||
gpointer user_data);
|
||||
|
||||
GtkWidget *c_main_window_new(void)
|
||||
{
|
||||
|
@ -175,6 +177,17 @@ static void c_main_window_init(CMainWindow *window)
|
|||
(gpointer)window);
|
||||
gtk_box_pack_start(GTK_BOX(hbuttonbox), window->add_button, FALSE, FALSE, 0);
|
||||
|
||||
window->edit_button =
|
||||
hildon_button_new_with_text(HILDON_SIZE_AUTO_WIDTH |
|
||||
HILDON_SIZE_FINGER_HEIGHT,
|
||||
HILDON_BUTTON_ARRANGEMENT_HORIZONTAL,
|
||||
"Edit",
|
||||
NULL);
|
||||
g_signal_connect(window->edit_button, "clicked",
|
||||
G_CALLBACK(c_main_window_on_edit_clicked),
|
||||
(gpointer)window);
|
||||
gtk_box_pack_start(GTK_BOX(hbuttonbox), window->edit_button, FALSE, FALSE, 0);
|
||||
|
||||
window->remove_button =
|
||||
hildon_button_new_with_text(HILDON_SIZE_AUTO_WIDTH |
|
||||
HILDON_SIZE_FINGER_HEIGHT,
|
||||
|
@ -306,3 +319,14 @@ static void c_main_window_on_remove_clicked(GtkWidget *widget,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void c_main_window_on_edit_clicked(GtkWidget *widget,
|
||||
gpointer user_data)
|
||||
{
|
||||
CMainWindow *self;
|
||||
|
||||
self = (CMainWindow *)user_data;
|
||||
|
||||
/* TODO: Place more code here */
|
||||
interface_show_edit_window();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <hildon/hildon.h>
|
||||
#include "interface.h"
|
||||
#include "c-main-window.h"
|
||||
#include "c-edit-window.h"
|
||||
#include "c-new-item-dialog.h"
|
||||
#include "data.h"
|
||||
|
||||
|
@ -14,6 +15,18 @@ void interface_show_main_window(void)
|
|||
c_main_window_load(C_MAIN_WINDOW(window));
|
||||
}
|
||||
|
||||
void interface_show_edit_window(void)
|
||||
{
|
||||
HildonWindowStack *stack;
|
||||
GtkWidget *window;
|
||||
|
||||
stack = hildon_window_stack_get_default();
|
||||
|
||||
window = c_edit_window_new();
|
||||
hildon_window_stack_push(stack, HILDON_STACKABLE_WINDOW(window), NULL);
|
||||
gtk_widget_show_all(window);
|
||||
}
|
||||
|
||||
GtkWidget *interface_show_new_item_dialog(GtkWindow *window)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
|
Loading…
Reference in a new issue