X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=gtk-gui.c;h=c78d7e6677feeadabf850c738f2450dfc5132884;hb=abdee5b1b8a97c641bca9bc2ebac9555c3e2ea54;hp=ea3f646e72ba955f68f919851d625722e1aa0780;hpb=28247d3baa9967fa39772c41077e714c4c533c82;p=ext%2Fsubsurface.git diff --git a/gtk-gui.c b/gtk-gui.c index ea3f646..c78d7e6 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -552,7 +552,11 @@ static void about_dialog(GtkWidget *w, gpointer data) GdkPixbuf *logo = NULL; if (need_icon) { +#ifndef WIN32 GtkWidget *image = gtk_image_new_from_file("subsurface.svg"); +#else + GtkWidget *image = gtk_image_new_from_file("subsurface.ico"); +#endif if (image) { logo = gtk_image_get_pixbuf(GTK_IMAGE(image)); @@ -690,23 +694,21 @@ static GtkNotebook *create_new_notebook_window(GtkNotebook *source, return GTK_NOTEBOOK(notebook); } -static void drag_cb(GtkWidget *widget, GdkDragContext *context, +static gboolean drag_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data) { GtkWidget *source; notebook_data_t *nbdp; + gtk_drag_finish(context, TRUE, TRUE, time); source = gtk_drag_get_source_widget(context); if (nbd[0].name && ! strcmp(nbd[0].name,gtk_widget_get_name(source))) nbdp = nbd; else if (nbd[1].name && ! strcmp(nbd[1].name,gtk_widget_get_name(source))) nbdp = nbd + 1; - else - /* HU? */ - return; - - gtk_drag_finish(context, TRUE, TRUE, time); + else /* just on ourselves */ + return TRUE; /* we no longer need the widget - but getting rid of this is hard; * remove the signal handler, remove the notebook from the box @@ -718,31 +720,33 @@ static void drag_cb(GtkWidget *widget, GdkDragContext *context, nbdp->widget = NULL; free(nbdp->name); nbdp->name = NULL; + + return TRUE; } #ifdef WIN32 -static int get_from_registry(const char *key) +static int get_from_registry(HKEY hkey, const char *key) { DWORD value; - DWORD type; DWORD len = 4; LONG success; - success = RegGetValue(HKEY_CURRENT_USER, TEXT("Software\\subsurface"), TEXT(key), - RRF_RT_ANY, &type, &value, &len); + success = RegQueryValueEx(hkey, TEXT(key), NULL, NULL, + (LPBYTE) &value, &len ); if (success != ERROR_SUCCESS) return FALSE; /* that's what happens the first time we start */ return value; } #endif -void init_ui(int argc, char **argv) +void init_ui(int *argcp, char ***argvp) { GtkWidget *win; GtkWidget *notebook; GtkWidget *dive_info; GtkWidget *dive_list; GtkWidget *equipment; + GtkWidget *stats; GtkWidget *menubar; GtkWidget *vbox; GdkScreen *screen; @@ -752,7 +756,7 @@ void init_ui(int argc, char **argv) "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 }; - gtk_init(&argc, &argv); + gtk_init(argcp, argvp); settings = gtk_settings_get_default(); gtk_settings_set_long_property(settings, "gtk_tooltip_timeout", 10, "subsurface setting"); @@ -778,29 +782,34 @@ void init_ui(int argc, char **argv) divelist_font = gconf_client_get_string(gconf, GCONF_NAME(divelist_font), NULL); #else - DWORD type; DWORD len = 4; LONG success; + HKEY hkey; - output_units.length = get_from_registry("feet"); - output_units.pressure = get_from_registry("psi"); - output_units.volume = get_from_registry("cuft"); - output_units.temperature = get_from_registry("fahrenheit"); - visible_cols.temperature = get_from_registry("temperature"); - visible_cols.cylinder = get_from_registry("cylinder"); - visible_cols.nitrox = get_from_registry("nitrox"); - visible_cols.sac = get_from_registry("sac"); - visible_cols.otu = get_from_registry("otu"); + success = RegOpenKeyEx( HKEY_CURRENT_USER, TEXT("Software\\subsurface"), 0, + KEY_QUERY_VALUE, &hkey); + + output_units.length = get_from_registry(hkey, "feet"); + output_units.pressure = get_from_registry(hkey, "psi"); + output_units.volume = get_from_registry(hkey, "cuft"); + output_units.temperature = get_from_registry(hkey, "fahrenheit"); + visible_cols.temperature = get_from_registry(hkey, "temperature"); + visible_cols.cylinder = get_from_registry(hkey, "cylinder"); + visible_cols.nitrox = get_from_registry(hkey, "nitrox"); + visible_cols.sac = get_from_registry(hkey, "sac"); + visible_cols.otu = get_from_registry(hkey, "otu"); divelist_font = malloc(80); len = 80; - success = RegGetValue(HKEY_CURRENT_USER, TEXT("Software\\subsurface"), - TEXT("divelist_font"), RRF_RT_ANY, &type, divelist_font, &len); + success = RegQueryValueEx(hkey, TEXT("divelist_font"), NULL, NULL, + (LPBYTE) divelist_font, &len ); if (success != ERROR_SUCCESS) { /* that's what happens the first time we start - just use the default */ free(divelist_font); divelist_font = NULL; } + RegCloseKey(hkey); + #endif if (!divelist_font) divelist_font = DIVELIST_DEFAULT_FONT; @@ -823,7 +832,7 @@ void init_ui(int argc, char **argv) #ifndef WIN32 gtk_window_set_icon_from_file(GTK_WINDOW(win), "subsurface.svg", NULL); #else - gtk_window_set_icon_from_file(GTK_WINDOW(win), "subsurface.bmp", NULL); + gtk_window_set_icon_from_file(GTK_WINDOW(win), "subsurface.ico", NULL); #endif g_signal_connect(G_OBJECT(win), "delete-event", G_CALLBACK(on_delete), NULL); g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(on_destroy), NULL); @@ -867,6 +876,10 @@ void init_ui(int argc, char **argv) equipment = equipment_widget(); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), equipment, gtk_label_new("Equipment")); + /* Frame for dive statistics */ + stats = stats_widget(); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), stats, gtk_label_new("Info & Stats")); + gtk_widget_set_app_paintable(win, TRUE); gtk_widget_show_all(win);