mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Teach the thing to actually track the currently selected dive
.. and repaint the profile when the selection changes. Now, if it just wasn't so ugly, it might even be useful. Except it obviously needs to also show all the other dive information. And allow the user to fill in details. And save the end results. So no, it's not useful. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
23e831a6ed
commit
2044dabc81
4 changed files with 17 additions and 4 deletions
|
@ -5,6 +5,7 @@
|
||||||
#include <gdk/gdk.h>
|
#include <gdk/gdk.h>
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
|
|
||||||
|
extern int selected_dive;
|
||||||
extern GtkWidget *dive_profile_frame(void);
|
extern GtkWidget *dive_profile_frame(void);
|
||||||
extern GtkWidget *create_dive_list(void);
|
extern GtkWidget *create_dive_list(void);
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,9 @@ static void selection_cb(GtkTreeSelection *selection, GtkTreeModel *model)
|
||||||
if (!gtk_tree_selection_get_selected(selection, NULL, &iter))
|
if (!gtk_tree_selection_get_selected(selection, NULL, &iter))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gtk_tree_model_get_value(model, &iter, 0, &value);
|
gtk_tree_model_get_value(model, &iter, 1, &value);
|
||||||
printf("'%s' selected\n", g_value_get_string(&value));
|
selected_dive = g_value_get_int(&value);
|
||||||
|
repaint_dive();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_dive_list(GtkListStore *store)
|
static void fill_dive_list(GtkListStore *store)
|
||||||
|
@ -28,6 +29,7 @@ static void fill_dive_list(GtkListStore *store)
|
||||||
gtk_list_store_append(store, &iter);
|
gtk_list_store_append(store, &iter);
|
||||||
gtk_list_store_set(store, &iter,
|
gtk_list_store_set(store, &iter,
|
||||||
0, dive->name,
|
0, dive->name,
|
||||||
|
1, i,
|
||||||
-1);
|
-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +43,7 @@ GtkWidget *create_dive_list(void)
|
||||||
GtkTreeViewColumn *col;
|
GtkTreeViewColumn *col;
|
||||||
GtkWidget *scroll_window;
|
GtkWidget *scroll_window;
|
||||||
|
|
||||||
model = gtk_list_store_new(1, G_TYPE_STRING);
|
model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
|
||||||
tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
|
tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
|
||||||
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
|
||||||
|
|
||||||
|
|
8
main.c
8
main.c
|
@ -47,6 +47,13 @@ static void on_destroy(GtkWidget* w, gpointer data)
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GtkWidget *dive_profile;
|
||||||
|
|
||||||
|
void repaint_dive(void)
|
||||||
|
{
|
||||||
|
gtk_widget_queue_draw(dive_profile);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -87,6 +94,7 @@ int main(int argc, char **argv)
|
||||||
/* Frame for dive profile */
|
/* Frame for dive profile */
|
||||||
frame = dive_profile_frame();
|
frame = dive_profile_frame();
|
||||||
gtk_container_add(GTK_CONTAINER(vbox), frame);
|
gtk_container_add(GTK_CONTAINER(vbox), frame);
|
||||||
|
dive_profile = frame;
|
||||||
|
|
||||||
gtk_widget_set_app_paintable(win, TRUE);
|
gtk_widget_set_app_paintable(win, TRUE);
|
||||||
gtk_widget_show_all(win);
|
gtk_widget_show_all(win);
|
||||||
|
|
|
@ -5,9 +5,11 @@
|
||||||
#include "dive.h"
|
#include "dive.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
|
int selected_dive = 0;
|
||||||
|
|
||||||
static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
||||||
{
|
{
|
||||||
struct dive *dive = dive_table.dives[0];
|
struct dive *dive = dive_table.dives[selected_dive];
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue