Selection

The main window now actually looks and works like it should as defined by the style guides
This commit is contained in:
Tom Willemsen 2010-11-18 00:23:41 +01:00
parent ce6f28bf35
commit dd7b20b120
4 changed files with 34 additions and 134 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
eye-on-manga
debian/files

1
debian/files vendored
View file

@ -1 +0,0 @@
eye-on-manga_0.0.1-1_i386.deb user/other optional

View file

@ -19,17 +19,17 @@ enum {
static void eom_main_window_add_menu(EomMainWindow *window);
static void eom_main_window_on_new(GtkWidget *widget, GtkWindow *window);
static void eom_main_window_on_selection_changed(GtkTreeSelection *selection,
gpointer user_data);
static void eom_main_window_on_add_clicked(GtkWidget *widget,
gpointer user_data);
static void eom_main_window_on_remove_clicked(GtkWidget *widget,
gpointer user_data);
static void eom_main_window_on_edit_clicked(GtkWidget *widget,
gpointer user_data);
static gboolean eom_main_window_on_edit_closed(GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
static void eom_main_window_on_row_activated(GtkWidget *treeview,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer user_data);
GtkWidget *eom_main_window_new(void)
{
@ -72,18 +72,6 @@ void eom_main_window_add_line(EomMainWindow *window,
-1);
}
void eom_main_window_set_no_select(EomMainWindow *self)
{
if (GTK_IS_WIDGET(self->edit_button))
gtk_widget_set_sensitive(GTK_WIDGET(self->edit_button), FALSE);
}
void eom_main_window_set_has_select(EomMainWindow *self)
{
if (GTK_IS_WIDGET(self->edit_button))
gtk_widget_set_sensitive(GTK_WIDGET(self->edit_button), TRUE);
}
static void eom_main_window_class_init(EomMainWindowClass *class)
{}
@ -91,10 +79,9 @@ static void eom_main_window_init(EomMainWindow *window)
{
GtkCellRenderer *renderer;
GtkWidget *view;
GtkWidget *vbox;
GtkWidget *hbuttonbox;
GtkWidget *pannablearea;
GtkTreeViewColumn *current_column;
GtkTreeSelection *selection;
int index;
index = -1;
@ -110,22 +97,19 @@ static void eom_main_window_init(EomMainWindow *window)
G_TYPE_INT,
G_TYPE_INT);
vbox = gtk_vbox_new(FALSE, 0);
pannablearea = hildon_pannable_area_new();
g_object_set(G_OBJECT(pannablearea),
"mov-mode", HILDON_MOVEMENT_MODE_VERT,
NULL);
gtk_box_pack_start(GTK_BOX(vbox), pannablearea, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(window), pannablearea);
view = gtk_tree_view_new();
hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(pannablearea),
view);
view = hildon_gtk_tree_view_new(HILDON_UI_MODE_NORMAL);
g_signal_connect(view, "row-activated",
G_CALLBACK(eom_main_window_on_row_activated), window);
gtk_container_add(GTK_CONTAINER(pannablearea), view);
window->selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
g_signal_connect(window->selection, "changed",
G_CALLBACK(eom_main_window_on_selection_changed),
(gpointer)window);
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
@ -164,25 +148,6 @@ static void eom_main_window_init(EomMainWindow *window)
gtk_tree_view_set_model(GTK_TREE_VIEW(view),
GTK_TREE_MODEL(window->store));
g_object_unref(window->store);
hbuttonbox = gtk_hbutton_box_new();
gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox), GTK_BUTTONBOX_END);
gtk_box_pack_start(GTK_BOX(vbox), hbuttonbox, FALSE, TRUE, 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(eom_main_window_on_edit_clicked),
(gpointer)window);
gtk_box_pack_start(GTK_BOX(hbuttonbox), window->edit_button, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(window), vbox);
eom_main_window_set_no_select(window);
}
static void eom_main_window_add_menu(EomMainWindow *window)
@ -236,87 +201,6 @@ static void eom_main_window_on_new(GtkWidget *widget, GtkWindow *window)
}
}
static void eom_main_window_on_selection_changed(GtkTreeSelection *selection,
gpointer user_data)
{
gint count;
EomMainWindow *self = (EomMainWindow *)user_data;
count = gtk_tree_selection_count_selected_rows(selection);
if (count == 0)
eom_main_window_set_no_select(self);
else
eom_main_window_set_has_select(self);
}
/*static void eom_main_window_on_add_clicked(GtkWidget *widget, gpointer user_data)
{
EomMainWindow *self;
gint count;
self = (EomMainWindow *)user_data;
count = gtk_tree_selection_count_selected_rows(self->selection);
if (count > 0) {
GtkTreeModel *model;
if (gtk_tree_selection_get_selected(self->selection, &model, &self->iter)) {
gint id;
gint current_count;
gtk_tree_model_get(model, &self->iter, COL_ID, &id, -1);
gtk_tree_model_get(model, &self->iter, COL_CURRENT, &current_count, -1);
if (data_add_to_manga(id, 1))
gtk_list_store_set(GTK_LIST_STORE(self->store), &self->iter,
COL_CURRENT, current_count + 1, -1);
}
}
}*/
/*static void eom_main_window_on_remove_clicked(GtkWidget *widget,
gpointer user_data)
{
EomMainWindow *self;
gint count;
self = (EomMainWindow *)user_data;
count = gtk_tree_selection_count_selected_rows(self->selection);
if (count > 0) {
GtkTreeModel *model;
if (gtk_tree_selection_get_selected(self->selection, &model, &self->iter)) {
gint id;
gint current_count;
gtk_tree_model_get(model, &self->iter, COL_ID, &id, -1);
gtk_tree_model_get(model, &self->iter, COL_CURRENT, &current_count, -1);
if (current_count > 0 && data_add_to_manga(id, -1))
gtk_list_store_set(GTK_LIST_STORE(self->store), &self->iter,
COL_CURRENT, current_count - 1, -1);
}
}
}*/
static void eom_main_window_on_edit_clicked(GtkWidget *widget,
gpointer user_data)
{
EomMainWindow *self = user_data;
GtkTreeModel *model;
gint id;
GtkWidget *window;
if (gtk_tree_selection_get_selected(self->selection, &model, &self->iter)) {
gtk_tree_model_get(model, &self->iter, COL_ID, &id, -1);
window = interface_show_edit_window(id);
g_signal_connect(window, "delete-event",
G_CALLBACK(eom_main_window_on_edit_closed), self);
}
}
static gboolean eom_main_window_on_edit_closed(GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
@ -327,3 +211,24 @@ static gboolean eom_main_window_on_edit_closed(GtkWidget *widget,
return FALSE;
}
static void eom_main_window_on_row_activated(GtkWidget *treeview,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer user_data)
{
EomMainWindow *self = user_data;
GtkTreeIter iter;
GtkTreeModel *model;
gint id;
GtkWidget *window;
model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
if (!gtk_tree_model_get_iter(model, &iter, path))
return;
gtk_tree_model_get(model, &iter, COL_ID, &id, -1);
window = interface_show_edit_window(id);
g_signal_connect(window, "delete-event",
G_CALLBACK(eom_main_window_on_edit_closed), self);
}

View file

@ -45,9 +45,6 @@ struct _EomMainWindow
GtkTreeIter iter;
GtkListStore *store;
GtkTreeSelection *selection;
GtkWidget *edit_button;
};
GType eom_main_window_get_type(void);
@ -60,8 +57,6 @@ void eom_main_window_add_line(EomMainWindow *window,
const gchar *name,
gint current_qty,
gint total_qty);
void eom_main_window_set_no_select(EomMainWindow *self);
void eom_main_window_set_has_select(EomMainWindow *self);
G_END_DECLS