X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=gtk-gui.c;h=ee99f01eb48167e29aef0e339d13f59ee2fd32e9;hb=7b5874ead7c9115f8e20025ad29733d9e4293d70;hp=e740357cd587a2bd4450a60fb5a4ca3333ba5b2f;hpb=cb2114f263d7b23b8b2471cdf2037a0877eec50d;p=ext%2Fsubsurface.git diff --git a/gtk-gui.c b/gtk-gui.c index e740357..ee99f01 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -8,15 +8,6 @@ #include #include -#if defined __linux__ -#include -#elif defined WIN32 -#include -#elif defined __APPLE__ -#include -static CFURLRef fileURL; -#endif - #include "dive.h" #include "divelist.h" #include "display.h" @@ -28,16 +19,11 @@ GtkWidget *main_window; GtkWidget *main_vbox; GtkWidget *error_info_bar; GtkWidget *error_label; +GtkWidget *vpane, *hpane; int error_count; -#define DIVELIST_DEFAULT_FONT "Sans 8" const char *divelist_font; -#ifdef __linux__ -GConfClient *gconf; -#define GCONF_NAME(x) "/apps/subsurface/" #x -#endif - struct units output_units; static GtkWidget *dive_profile; @@ -120,9 +106,9 @@ static void file_open(GtkWidget *w, gpointer data) gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { - GSList *filenames; + GSList *filenames, *fn_glist; char *filename; - filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); + filenames = fn_glist = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); GError *error = NULL; while(filenames != NULL) { @@ -138,7 +124,7 @@ static void file_open(GtkWidget *w, gpointer data) g_free(filename); filenames = g_slist_next(filenames); } - g_slist_free(filenames); + g_slist_free(fn_glist); report_dives(FALSE); } gtk_widget_destroy(dialog); @@ -175,7 +161,7 @@ static void ask_save_changes() dialog = gtk_dialog_new_with_buttons("Save Changes?", GTK_WINDOW(main_window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_NO, GTK_RESPONSE_NO, NULL); content = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); label = gtk_label_new ("You have unsaved changes\nWould you like to save those before exiting the program?"); @@ -215,17 +201,25 @@ static void quit(GtkWidget *w, gpointer data) } GtkTreeViewColumn *tree_view_column(GtkWidget *tree_view, int index, const char *title, - data_func_t data_func, PangoAlignment align, gboolean visible) + data_func_t data_func, unsigned int flags) { GtkCellRenderer *renderer; GtkTreeViewColumn *col; double xalign = 0.0; /* left as default */ + PangoAlignment align; + gboolean visible; + + align = (flags & ALIGN_LEFT) ? PANGO_ALIGN_LEFT : + (flags & ALIGN_RIGHT) ? PANGO_ALIGN_RIGHT : + PANGO_ALIGN_CENTER; + visible = !(flags & INVISIBLE); renderer = gtk_cell_renderer_text_new(); col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(col, title); - gtk_tree_view_column_set_sort_column_id(col, index); + if (!(flags & UNSORTABLE)) + gtk_tree_view_column_set_sort_column_id(col, index); gtk_tree_view_column_set_resizable(col, TRUE); gtk_tree_view_column_pack_start(col, renderer, TRUE); if (data_func) @@ -409,74 +403,18 @@ static void preferences_dialog(GtkWidget *w, gpointer data) update_dive_list_units(); repaint_dive(); update_dive_list_col_visibility(); -#ifdef __linux__ - gconf_client_set_bool(gconf, GCONF_NAME(feet), output_units.length == FEET, NULL); - gconf_client_set_bool(gconf, GCONF_NAME(psi), output_units.pressure == PSI, NULL); - gconf_client_set_bool(gconf, GCONF_NAME(cuft), output_units.volume == CUFT, NULL); - gconf_client_set_bool(gconf, GCONF_NAME(fahrenheit), output_units.temperature == FAHRENHEIT, NULL); - gconf_client_set_bool(gconf, GCONF_NAME(TEMPERATURE), visible_cols.temperature, NULL); - gconf_client_set_bool(gconf, GCONF_NAME(CYLINDER), visible_cols.cylinder, NULL); - gconf_client_set_bool(gconf, GCONF_NAME(NITROX), visible_cols.nitrox, NULL); - gconf_client_set_bool(gconf, GCONF_NAME(SAC), visible_cols.sac, NULL); - gconf_client_set_bool(gconf, GCONF_NAME(OTU), visible_cols.otu, NULL); - gconf_client_set_string(gconf, GCONF_NAME(divelist_font), divelist_font, NULL); -#elif defined __APPLE__ -#define STRING_BOOL(_cond) (_cond) ? CFSTR("1") : CFSTR("0") - - CFPropertyListRef propertyList; - CFMutableDictionaryRef dict; - CFDataRef xmlData; - CFStringRef cf_divelist_font; - Boolean status; - SInt32 errorCode; - - dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - CFDictionarySetValue(dict, CFSTR("feet"), STRING_BOOL(output_units.length == FEET)); - CFDictionarySetValue(dict, CFSTR("psi"), STRING_BOOL(output_units.pressure == PSI)); - CFDictionarySetValue(dict, CFSTR("cuft"), STRING_BOOL(output_units.volume == CUFT)); - CFDictionarySetValue(dict, CFSTR("fahrenheit"), STRING_BOOL(output_units.temperature == FAHRENHEIT)); - CFDictionarySetValue(dict, CFSTR("TEMPERATURE"), STRING_BOOL(visible_cols.temperature)); - CFDictionarySetValue(dict, CFSTR("CYLINDER"), STRING_BOOL(visible_cols.cylinder)); - CFDictionarySetValue(dict, CFSTR("NITROX"), STRING_BOOL(visible_cols.nitrox)); - CFDictionarySetValue(dict, CFSTR("SAC"), STRING_BOOL(visible_cols.sac)); - CFDictionarySetValue(dict, CFSTR("OTU"), STRING_BOOL(visible_cols.otu)); - cf_divelist_font = CFStringCreateWithCString(kCFAllocatorDefault, divelist_font, 1); - CFDictionarySetValue(dict, CFSTR("divelist_font"), cf_divelist_font); - propertyList = dict; - xmlData = CFPropertyListCreateXMLData(kCFAllocatorDefault, propertyList); - status = CFURLWriteDataAndPropertiesToResource (fileURL, xmlData, NULL, &errorCode); - // some error handling - CFRelease(xmlData); - CFRelease(propertyList); -#elif defined WIN32 - HKEY hkey; - LONG success = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\subsurface"), - 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, - NULL, &hkey, NULL); - if (success != ERROR_SUCCESS) - printf("CreateKey Software\\subsurface failed %ld\n", success); - DWORD value; - -#define StoreInReg(_key, _val) { \ - value = (_val) ; \ - RegSetValueEx(hkey, TEXT(_key), 0, REG_DWORD, &value, 4); \ - } - StoreInReg("feet", output_units.length == FEET); - StoreInReg("psi", output_units.pressure == PSI); - StoreInReg("cuft", output_units.volume == CUFT); - StoreInReg("fahrenheit", output_units.temperature == FAHRENHEIT); - StoreInReg("temperature", visible_cols.temperature); - StoreInReg("cylinder", visible_cols.cylinder); - StoreInReg("nitrox", visible_cols.nitrox); - StoreInReg("sac", visible_cols.sac); - StoreInReg("otu", visible_cols.otu); - RegSetValueEx(hkey, TEXT("divelist_font"), 0, REG_SZ, divelist_font, strlen(divelist_font)); - if (RegFlushKey(hkey) != ERROR_SUCCESS) - printf("RegFlushKey failed %ld\n"); - RegCloseKey(hkey); -#endif + subsurface_set_conf("feet", PREF_BOOL, BOOL_TO_PTR(output_units.length == FEET)); + subsurface_set_conf("psi", PREF_BOOL, BOOL_TO_PTR(output_units.pressure == PSI)); + subsurface_set_conf("cuft", PREF_BOOL, BOOL_TO_PTR(output_units.volume == CUFT)); + subsurface_set_conf("fahrenheit", PREF_BOOL, BOOL_TO_PTR(output_units.temperature == FAHRENHEIT)); + subsurface_set_conf("TEMPERATURE", PREF_BOOL, BOOL_TO_PTR(visible_cols.temperature)); + subsurface_set_conf("CYLINDER", PREF_BOOL, BOOL_TO_PTR(visible_cols.cylinder)); + subsurface_set_conf("NITROX", PREF_BOOL, BOOL_TO_PTR(visible_cols.nitrox)); + subsurface_set_conf("SAC", PREF_BOOL, BOOL_TO_PTR(visible_cols.sac)); + subsurface_set_conf("OTU", PREF_BOOL, BOOL_TO_PTR(visible_cols.otu)); + subsurface_set_conf("divelist_font", PREF_STRING, divelist_font); + subsurface_close_conf(); } gtk_widget_destroy(dialog); } @@ -584,11 +522,7 @@ static void about_dialog(GtkWidget *w, gpointer data) GdkPixbuf *logo = NULL; if (need_icon) { -#if defined __linux__ || defined __APPLE__ - GtkWidget *image = gtk_image_new_from_file("subsurface.svg"); -#elif defined WIN32 - GtkWidget *image = gtk_image_new_from_file("subsurface.ico"); -#endif + GtkWidget *image = gtk_image_new_from_file(subsurface_icon_name()); if (image) { logo = gtk_image_get_pixbuf(GTK_IMAGE(image)); @@ -608,9 +542,34 @@ static void about_dialog(GtkWidget *w, gpointer data) NULL); } +static void view_list(GtkWidget *w, gpointer data) +{ + gtk_paned_set_position(GTK_PANED(vpane), 0); +} + +static void view_profile(GtkWidget *w, gpointer data) +{ + gtk_paned_set_position(GTK_PANED(hpane), 0); + gtk_paned_set_position(GTK_PANED(vpane), 65535); +} + +static void view_info(GtkWidget *w, gpointer data) +{ + gtk_paned_set_position(GTK_PANED(vpane), 65535); + gtk_paned_set_position(GTK_PANED(hpane), 65535); +} + +/* Ooh. I don't know how to get the half-way size. So I'm just using random numbers */ +static void view_three(GtkWidget *w, gpointer data) +{ + gtk_paned_set_position(GTK_PANED(hpane), 400); + gtk_paned_set_position(GTK_PANED(vpane), 200); +} + static GtkActionEntry menu_items[] = { { "FileMenuAction", GTK_STOCK_FILE, "File", NULL, NULL, NULL}, { "LogMenuAction", GTK_STOCK_FILE, "Log", NULL, NULL, NULL}, + { "ViewMenuAction", GTK_STOCK_FILE, "View", NULL, NULL, NULL}, { "FilterMenuAction", GTK_STOCK_FILE, "Filter", NULL, NULL, NULL}, { "HelpMenuAction", GTK_STOCK_HELP, "Help", NULL, NULL, NULL}, { "OpenFile", GTK_STOCK_OPEN, NULL, "O", NULL, G_CALLBACK(file_open) }, @@ -622,6 +581,10 @@ static GtkActionEntry menu_items[] = { { "SelectEvents", NULL, "SelectEvents", NULL, NULL, G_CALLBACK(selectevents_dialog) }, { "Quit", GTK_STOCK_QUIT, NULL, "Q", NULL, G_CALLBACK(quit) }, { "About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK(about_dialog) }, + { "ViewList", NULL, "List", "1", NULL, G_CALLBACK(view_list) }, + { "ViewProfile", NULL, "Profile", "2", NULL, G_CALLBACK(view_profile) }, + { "ViewInfo", NULL, "Info", "3", NULL, G_CALLBACK(view_info) }, + { "ViewThree", NULL, "Three", "4", NULL, G_CALLBACK(view_three) }, }; static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]); @@ -641,6 +604,12 @@ static const gchar* ui_string = " \ \ \ \ + \ + \ + \ + \ + \ + \ \ \ \ @@ -673,104 +642,6 @@ static void switch_page(GtkNotebook *notebook, gint arg1, gpointer user_data) repaint_dive(); } -static const char notebook_group[] = "123"; -#define GRP_ID ((void *)notebook_group) -typedef struct { - char *name; - GtkWidget *widget; - GtkWidget *box; - gulong delete_handler; - gulong destroy_handler; -} notebook_data_t; - -static notebook_data_t nbd[2]; /* we rip at most two notebook pages off */ - -static GtkNotebook *create_new_notebook_window(GtkNotebook *source, - GtkWidget *page, - gint x, gint y, gpointer data) -{ - GtkWidget *win, *notebook, *vbox; - notebook_data_t *nbdp; - GtkAllocation allocation; - - /* pick the right notebook page data and return if both are detached */ - if (nbd[0].widget == NULL) - nbdp = nbd; - else if (nbd[1].widget == NULL) - nbdp = nbd + 1; - else - return NULL; - - nbdp->name = strdup(gtk_widget_get_name(page)); - nbdp->widget = win = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(win), nbdp->name); - gtk_window_move(GTK_WINDOW(win), x, y); - - /* Destroying the dive list will kill the application */ - nbdp->delete_handler = g_signal_connect(G_OBJECT(win), "delete-event", G_CALLBACK(on_delete), NULL); - nbdp->destroy_handler = g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(on_destroy), NULL); - - nbdp->box = vbox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(win), vbox); - - notebook = gtk_notebook_new(); - gtk_notebook_set_group(GTK_NOTEBOOK(notebook), GRP_ID); - gtk_widget_set_name(notebook, nbdp->name); - /* disallow drop events */ - gtk_drag_dest_set(notebook, 0, NULL, 0, 0); - gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 6); - gtk_widget_get_allocation(page, &allocation); - gtk_window_set_default_size(GTK_WINDOW(win), allocation.width, allocation.height); - - gtk_widget_show_all(win); - return GTK_NOTEBOOK(notebook); -} - -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 /* 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 - * then destroy the widget (and clear out our data structure) */ - g_signal_handler_disconnect(nbdp->widget,nbdp->delete_handler); - g_signal_handler_disconnect(nbdp->widget,nbdp->destroy_handler); - gtk_container_remove(GTK_CONTAINER(nbdp->box), source); - gtk_widget_destroy(nbdp->widget); - nbdp->widget = NULL; - free(nbdp->name); - nbdp->name = NULL; - - return TRUE; -} - -#if defined WIN32 -static int get_from_registry(HKEY hkey, const char *key) -{ - DWORD value; - DWORD len = 4; - LONG success; - - 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 *argcp, char ***argvp) { GtkWidget *win; @@ -781,13 +652,9 @@ void init_ui(int *argcp, char ***argvp) GtkWidget *stats; GtkWidget *menubar; GtkWidget *vbox; - GtkWidget *hpane, *vpane; GdkScreen *screen; GtkIconTheme *icon_theme=NULL; GtkSettings *settings; - static const GtkTargetEntry notebook_target = { - "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 - }; gtk_init(argcp, argvp); settings = gtk_settings_get_default(); @@ -795,88 +662,23 @@ void init_ui(int *argcp, char ***argvp) g_type_init(); -#ifdef __linux__ - gconf = gconf_client_get_default(); - - if (gconf_client_get_bool(gconf, GCONF_NAME(feet), NULL)) + subsurface_open_conf(); + if (subsurface_get_conf("feet", PREF_BOOL)) output_units.length = FEET; - if (gconf_client_get_bool(gconf, GCONF_NAME(psi), NULL)) + if (subsurface_get_conf("psi", PREF_BOOL)) output_units.pressure = PSI; - if (gconf_client_get_bool(gconf, GCONF_NAME(cuft), NULL)) + if (subsurface_get_conf("cuft", PREF_BOOL)) output_units.volume = CUFT; - if (gconf_client_get_bool(gconf, GCONF_NAME(fahrenheit), NULL)) + if (subsurface_get_conf("fahrenheit", PREF_BOOL)) output_units.temperature = FAHRENHEIT; /* an unset key is FALSE - all these are hidden by default */ - visible_cols.cylinder = gconf_client_get_bool(gconf, GCONF_NAME(CYLINDER), NULL); - visible_cols.temperature = gconf_client_get_bool(gconf, GCONF_NAME(TEMPERATURE), NULL); - visible_cols.nitrox = gconf_client_get_bool(gconf, GCONF_NAME(NITROX), NULL); - visible_cols.otu = gconf_client_get_bool(gconf, GCONF_NAME(OTU), NULL); - visible_cols.sac = gconf_client_get_bool(gconf, GCONF_NAME(SAC), NULL); - - divelist_font = gconf_client_get_string(gconf, GCONF_NAME(divelist_font), NULL); -#elif defined WIN32 - DWORD len = 4; - LONG success; - HKEY hkey; - - 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 = 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); -#elif defined __APPLE__ -#define BOOL_FROM_CFSTRING(_pl,_key) \ - strcmp("0", CFStringGetCStringPtr(CFDictionaryGetValue(_pl, CFSTR(_key)), 0) ? : "") - - CFPropertyListRef propertyList; - CFStringRef errorString; - CFDataRef resourceData; - Boolean status; - SInt32 errorCode; - - fileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, - CFSTR("subsurface.pref"),// file path name - kCFURLPOSIXPathStyle, // interpret as POSIX path - false ); // is it a directory? - - status = CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, - fileURL, &resourceData, - NULL, NULL, &errorCode); - propertyList = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, - resourceData, kCFPropertyListImmutable, - &errorString); - CFRelease(resourceData); - output_units.length = BOOL_FROM_CFSTRING(propertyList, "feet") ? FEET : METERS; - output_units.pressure = BOOL_FROM_CFSTRING(propertyList, "psi") ? PSI : BAR; - output_units.volume = BOOL_FROM_CFSTRING(propertyList, "cuft") ? CUFT : LITER; - output_units.temperature = BOOL_FROM_CFSTRING(propertyList, "fahrenheit") ? FAHRENHEIT : CELSIUS; - visible_cols.temperature = BOOL_FROM_CFSTRING(propertyList, "TEMPERATURE"); - visible_cols.cylinder = BOOL_FROM_CFSTRING(propertyList, "CYLINDER"); - visible_cols.nitrox = BOOL_FROM_CFSTRING(propertyList, "NITROX"); - visible_cols.sac = BOOL_FROM_CFSTRING(propertyList, "SAC"); - visible_cols.otu = BOOL_FROM_CFSTRING(propertyList, "OTU"); - CFRelease(propertyList); -#endif - if (!divelist_font) - divelist_font = DIVELIST_DEFAULT_FONT; + visible_cols.cylinder = PTR_TO_BOOL(subsurface_get_conf("CYLINDER", PREF_BOOL)); + visible_cols.temperature = PTR_TO_BOOL(subsurface_get_conf("TEMPERATURE", PREF_BOOL)); + visible_cols.nitrox = PTR_TO_BOOL(subsurface_get_conf("NITROX", PREF_BOOL)); + visible_cols.otu = PTR_TO_BOOL(subsurface_get_conf("OTU", PREF_BOOL)); + visible_cols.sac = PTR_TO_BOOL(subsurface_get_conf("SAC", PREF_BOOL)); + + divelist_font = subsurface_get_conf("divelist_font", PREF_STRING); error_info_bar = NULL; win = gtk_window_new(GTK_WINDOW_TOPLEVEL); @@ -892,12 +694,11 @@ void init_ui(int *argcp, char ***argvp) gtk_window_set_default_icon_name ("subsurface"); } } - if (need_icon) -#if defined __linux__ || defined __APPLE__ - gtk_window_set_icon_from_file(GTK_WINDOW(win), "subsurface.svg", NULL); -#elif defined WIN32 - gtk_window_set_icon_from_file(GTK_WINDOW(win), "subsurface.ico", NULL); -#endif + if (need_icon) { + const char *icon_name = subsurface_icon_name(); + if (!access(icon_name, R_OK)) + gtk_window_set_icon_from_file(GTK_WINDOW(win), icon_name, NULL); + } 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); main_window = win; @@ -907,7 +708,8 @@ void init_ui(int *argcp, char ***argvp) main_vbox = vbox; menubar = get_menubar_menu(win); - gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0); + + subsurface_ui_setup(settings, menubar, vbox); vpane = gtk_vpaned_new(); gtk_box_pack_start(GTK_BOX(vbox), vpane, TRUE, TRUE, 3); @@ -918,10 +720,6 @@ void init_ui(int *argcp, char ***argvp) /* Notebook for dive info vs profile vs .. */ notebook = gtk_notebook_new(); gtk_paned_add1(GTK_PANED(hpane), notebook); - gtk_notebook_set_group(GTK_NOTEBOOK(notebook), GRP_ID); - g_signal_connect(notebook, "create-window", G_CALLBACK(create_new_notebook_window), NULL); - gtk_drag_dest_set(notebook, GTK_DEST_DEFAULT_ALL, ¬ebook_target, 1, GDK_ACTION_MOVE); - g_signal_connect(notebook, "drag-drop", G_CALLBACK(drag_cb), notebook); g_signal_connect(notebook, "switch-page", G_CALLBACK(switch_page), NULL); /* Create the actual divelist */ @@ -1015,7 +813,7 @@ static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer gc.cr = gdk_cairo_create(widget->window); g_object_set(widget, "has-tooltip", TRUE, NULL); g_signal_connect(widget, "query-tooltip", G_CALLBACK(profile_tooltip), &drawing_area); - set_source_rgb(&gc, 0, 0, 0); + init_profile_background(&gc); cairo_paint(gc.cr); if (dive) { @@ -1052,7 +850,7 @@ int process_ui_events(void) break; } } - return(ret); + return ret; } @@ -1107,7 +905,7 @@ static GtkEntry *dive_computer_device(GtkWidget *vbox) entry = gtk_entry_new(); gtk_container_add(GTK_CONTAINER(frame), entry); - gtk_entry_set_text(GTK_ENTRY(entry), "/dev/ttyUSB0"); + gtk_entry_set_text(GTK_ENTRY(entry), subsurface_USB_name()); return GTK_ENTRY(entry); }