static gboolean try_load (struct pixdata_context *context, GError **error) { GdkPixbuf *pixbuf; G_GNUC_BEGIN_IGNORE_DEPRECATIONS if (context->got_pixbuf) return TRUE; if (!gdk_pixdata_deserialize (&context->pixdata, context->data->len, (guchar *)context->data->str, error)) return FALSE; pixbuf = gdk_pixbuf_from_pixdata (&context->pixdata, TRUE, error); if (pixbuf == NULL) return FALSE; context->got_pixbuf = TRUE; if (context->prepared_func) (* context->prepared_func) (pixbuf, NULL, context->user_data); if (context->updated_func) (* context->updated_func) (pixbuf, 0, 0, pixbuf->width, pixbuf->height, context->user_data); return TRUE; G_GNUC_END_IGNORE_DEPRECATIONS }
GdkPixbuf *vik_layer_load_icon ( VikLayerTypeEnum type ) { g_assert ( type < VIK_LAYER_NUM_TYPES ); if ( vik_layer_interfaces[type]->icon ) return gdk_pixbuf_from_pixdata ( vik_layer_interfaces[type]->icon, FALSE, NULL ); return NULL; }
static GdkCursor *nsgtk_create_menu_cursor(void) { GdkCursor *cursor = NULL; GdkPixbuf *pixbuf; pixbuf = gdk_pixbuf_from_pixdata(&menu_cursor_pixdata, FALSE, NULL); cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pixbuf, 0, 3); g_object_unref (pixbuf); return cursor; }
GdkPixbuf * ma_deserialize_pixdata (const guint8 *bytes, gint size) { GdkPixdata pixdata; if (gdk_pixdata_deserialize (&pixdata, size, bytes, NULL)) { return gdk_pixbuf_from_pixdata (&pixdata, TRUE, NULL); } else { return NULL; } }
/** * Convertit une chaine codée en base 64 en pixbuf * * \param str_base64 * * return a new pixbuf * */ GdkPixbuf *gsb_select_icon_create_pixbuf_from_chaine_base64 ( gchar *str_base64 ) { guchar *data; gsize longueur; GdkPixdata pixdata; GdkPixbuf *pixbuf = NULL; data = g_base64_decode ( str_base64, &longueur ); gdk_pixdata_deserialize ( &pixdata, longueur, data, NULL ); pixbuf = gdk_pixbuf_from_pixdata ( &pixdata, TRUE, NULL ); g_free ( data ); return pixbuf; }
GdkCursor * gl_view_ellipse_get_create_cursor (void) { GdkCursor *cursor = NULL; GdkPixbuf *pixbuf; gl_debug (DEBUG_VIEW, "START"); pixbuf = gdk_pixbuf_from_pixdata (&cursor_ellipse_pixdata, FALSE, NULL); cursor = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), pixbuf, X_HOTSPOT, Y_HOTSPOT); g_object_unref (pixbuf); gl_debug (DEBUG_VIEW, "END"); return cursor; }
/** * gdk_pixbuf_new_from_inline: * @data_length: Length in bytes of the @data argument or -1 to * disable length checks * @data: (array length=data_length): Byte data containing a * serialized #GdkPixdata structure * @copy_pixels: Whether to copy the pixel data, or use direct pointers * @data for the resulting pixbuf * @error: #GError return location, may be %NULL to ignore errors * * Create a #GdkPixbuf from a flat representation that is suitable for * storing as inline data in a program. This is useful if you want to * ship a program with images, but don't want to depend on any * external files. * * gdk-pixbuf ships with a program called [gdk-pixbuf-csource][gdk-pixbuf-csource], * which allows for conversion of #GdkPixbufs into such a inline representation. * In almost all cases, you should pass the `--raw` option to * `gdk-pixbuf-csource`. A sample invocation would be: * * |[ * gdk-pixbuf-csource --raw --name=myimage_inline myimage.png * ]| * * For the typical case where the inline pixbuf is read-only static data, * you don't need to copy the pixel data unless you intend to write to * it, so you can pass %FALSE for @copy_pixels. (If you pass `--rle` to * `gdk-pixbuf-csource`, a copy will be made even if @copy_pixels is %FALSE, * so using this option is generally a bad idea.) * * If you create a pixbuf from const inline data compiled into your * program, it's probably safe to ignore errors and disable length checks, * since things will always succeed: * |[ * pixbuf = gdk_pixbuf_new_from_inline (-1, myimage_inline, FALSE, NULL); * ]| * * For non-const inline data, you could get out of memory. For untrusted * inline data located at runtime, you could have corrupt inline data in * addition. * * Return value: A newly-created #GdkPixbuf structure with a reference, * count of 1, or %NULL if an error occurred. * * Deprecated: 2.32: Use #GResource instead. **/ GdkPixbuf* gdk_pixbuf_new_from_inline (gint data_length, const guint8 *data, gboolean copy_pixels, GError **error) { GdkPixdata pixdata; if (data_length != -1) g_return_val_if_fail (data_length > GDK_PIXDATA_HEADER_LENGTH, NULL); g_return_val_if_fail (data != NULL, NULL); if (!gdk_pixdata_deserialize (&pixdata, data_length, data, error)) return NULL; return gdk_pixbuf_from_pixdata (&pixdata, copy_pixels, error); }
void ctk_main(ParsedAttribute *p, ConfigProperties *conf, CtrlHandles *h, const char *page) { int i, has_nv_control = FALSE; GList *list = NULL; GtkWidget *window; list = g_list_append (list, gdk_pixbuf_from_pixdata(&nvidia_icon_pixdata, TRUE, NULL)); gtk_window_set_default_icon_list(list); window = ctk_window_new(p, conf, h); for (i = 0; i < h->targets[X_SCREEN_TARGET].n; i++) { if (h->targets[X_SCREEN_TARGET].t[i].h) { has_nv_control = TRUE; break; } } if (!has_nv_control) { GtkWidget *dlg; dlg = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "You do not appear to be using the NVIDIA " "X driver. Please edit your X configuration " "file (just run `nvidia-xconfig` " "as root), and restart the X server."); gtk_dialog_run(GTK_DIALOG(dlg)); gtk_widget_destroy (dlg); } ctk_window_set_active_page(CTK_WINDOW(window), page); gtk_main(); }
static GdkPixbuf * load_raw_pixbuf (const gchar * file) { GError *err = NULL; GdkPixbuf *pixbuf; if (strcmp (file, "<default-check>") == 0) pixbuf = gdk_pixbuf_from_pixdata (&check_img, TRUE, &err); else if (strcmp (file, "<default-uncheck>") == 0) pixbuf = gdk_pixbuf_from_pixdata (&uncheck_img, TRUE, &err); else if (strcmp (file, "<default-incheck>") == 0) pixbuf = gdk_pixbuf_from_pixdata (&incheck_img, TRUE, &err); else if (strcmp (file, "<default-radio>") == 0) pixbuf = gdk_pixbuf_from_pixdata (&radio_img, TRUE, &err); else if (strcmp (file, "<default-unradio>") == 0) pixbuf = gdk_pixbuf_from_pixdata (&unradio_img, TRUE, &err); else if (strcmp (file, "<default-inradio>") == 0) pixbuf = gdk_pixbuf_from_pixdata (&inradio_img, TRUE, &err); else pixbuf = gdk_pixbuf_new_from_file (file, &err); if (err != NULL) g_warning ("Unable to load \"%s\" (%s).", file, err->message); return pixbuf; }
static GdkPixbuf *load_banner(void) { return gdk_pixbuf_from_pixdata((GdkPixdata *)&startbanner_pixdata, FALSE, NULL); }
bool RunLinuxDialog() { GtkWidget *dialog; GtkWidget *main_box, *central_box, *advance_box, *res_box, *hw_box, *sw_box, *shader_box; GtkWidget *native_box, *fsaa_box, *resxy_box, *renderer_box, *interlace_box, *threads_box, *filter_box; GtkWidget *hw_table, *shader_table, *res_frame, *hw_frame, *sw_frame, *shader_frame; GtkWidget *interlace_combo_box, *threads_spin; GtkWidget *interlace_label, *threads_label, *native_label, *fsaa_label, *rexy_label, *render_label, *filter_label; GtkWidget *hack_table, *hack_skipdraw_label, *hack_box, *hack_frame; GtkWidget *hack_alpha_check, *hack_date_check, *hack_offset_check, *hack_skipdraw_spin, *hack_msaa_check, *hack_sprite_check, * hack_wild_check, *hack_enble_check, *hack_logz_check; GtkWidget *hack_tco_label, *hack_tco_entry; GtkWidget *gl_box, *gl_frame, *gl_table; GtkWidget *notebook, *page_label[2]; int return_value; GdkPixbuf* logo_pixmap; GtkWidget *logo_image; /* Create the widgets */ dialog = gtk_dialog_new_with_buttons ( "GSdx Config", NULL, /* parent window*/ (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); // The main area for the whole dialog box. main_box = gtk_vbox_new(false, 5); central_box = gtk_vbox_new(false, 5); advance_box = gtk_vbox_new(false, 5); // The Internal resolution frame and container. res_box = gtk_vbox_new(false, 5); res_frame = gtk_frame_new ("OpenGL Internal Resolution (can cause glitches)"); gtk_container_add(GTK_CONTAINER(res_frame), res_box); // The extra shader setting frame/container/table shader_box = gtk_vbox_new(false, 5); shader_frame = gtk_frame_new("Custom Shader Settings"); gtk_container_add(GTK_CONTAINER(shader_frame), shader_box); shader_table = gtk_table_new(5,2, false); gtk_container_add(GTK_CONTAINER(shader_box), shader_table); // The hardware mode frame, container, and table. hw_box = gtk_vbox_new(false, 5); hw_frame = gtk_frame_new ("Hardware Mode Settings"); gtk_container_add(GTK_CONTAINER(hw_frame), hw_box); hw_table = gtk_table_new(5,2, false); gtk_container_add(GTK_CONTAINER(hw_box), hw_table); // The software mode frame and container. (It doesn't have enough in it for a table.) sw_box = gtk_vbox_new(false, 5); sw_frame = gtk_frame_new ("Software Mode Settings"); gtk_container_add(GTK_CONTAINER(sw_frame), sw_box); // The hack frame and container. hack_box = gtk_hbox_new(false, 5); hack_frame = gtk_frame_new ("Hacks"); gtk_container_add(GTK_CONTAINER(hack_frame), hack_box); hack_table = gtk_table_new(3,3, false); gtk_container_add(GTK_CONTAINER(hack_box), hack_table); // Grab a logo, to make things look nice. logo_pixmap = gdk_pixbuf_from_pixdata(&gsdx_ogl_logo, false, NULL); logo_image = gtk_image_new_from_pixbuf(logo_pixmap); gtk_box_pack_start(GTK_BOX(main_box), logo_image, true, true, 0); // Create the renderer combo box and label, and stash them in a box. render_label = gtk_label_new ("Renderer:"); render_combo_box = CreateRenderComboBox(); renderer_box = gtk_hbox_new(false, 5); // Use gtk_box_pack_start instead of gtk_container_add so it lines up nicely. gtk_box_pack_start(GTK_BOX(renderer_box), render_label, false, false, 5); gtk_box_pack_start(GTK_BOX(renderer_box), render_combo_box, false, false, 5); // Create the interlace combo box and label, and stash them in a box. interlace_label = gtk_label_new ("Interlacing (F5):"); interlace_combo_box = CreateInterlaceComboBox(); interlace_box = gtk_hbox_new(false, 5); gtk_box_pack_start(GTK_BOX(interlace_box), interlace_label, false, false, 5); gtk_box_pack_start(GTK_BOX(interlace_box), interlace_combo_box, false, false, 5); // Create the filter combo box. filter_label = gtk_label_new ("Texture Filtering:"); filter_combo_box = CreateFilterComboBox(); filter_box = gtk_hbox_new(false, 5); gtk_box_pack_start(GTK_BOX(filter_box), filter_label, false, false, 5); gtk_box_pack_start(GTK_BOX(filter_box), filter_combo_box, false, false, 0); // Create the threading spin box and label, and stash them in a box. (Yes, we do a lot of that.) threads_label = gtk_label_new("Extra rendering threads:"); threads_spin = gtk_spin_button_new_with_range(0,100,1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(threads_spin), theApp.GetConfig("extrathreads", 0)); threads_box = gtk_hbox_new(false, 0); gtk_box_pack_start(GTK_BOX(threads_box), threads_label, false, false, 5); gtk_box_pack_start(GTK_BOX(threads_box), threads_spin, false, false, 5); // A bit of funkiness for the resolution box. native_label = gtk_label_new("Original PS2 Resolution: "); native_res_check = gtk_check_button_new_with_label("Native"); native_box = gtk_hbox_new(false, 5); gtk_box_pack_start(GTK_BOX(native_box), native_label, false, false, 5); gtk_box_pack_start(GTK_BOX(native_box), native_res_check, false, false, 5); fsaa_label = gtk_label_new("Or Use Scaling:"); fsaa_combo_box = CreateMsaaComboBox(); fsaa_box = gtk_hbox_new(false, 5); gtk_box_pack_start(GTK_BOX(fsaa_box), fsaa_label, false, false, 5); gtk_box_pack_start(GTK_BOX(fsaa_box), fsaa_combo_box, false, false, 5); rexy_label = gtk_label_new("Custom Resolution:"); resx_spin = gtk_spin_button_new_with_range(256,8192,1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(resx_spin), theApp.GetConfig("resx", 1024)); resy_spin = gtk_spin_button_new_with_range(256,8192,1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(resy_spin), theApp.GetConfig("resy", 1024)); resxy_box = gtk_hbox_new(false, 5); gtk_box_pack_start(GTK_BOX(resxy_box), rexy_label, false, false, 5); gtk_box_pack_start(GTK_BOX(resxy_box), resx_spin, false, false, 5); gtk_box_pack_start(GTK_BOX(resxy_box), resy_spin, false, false, 5); // Create our hack settings. hack_alpha_check = gtk_check_button_new_with_label("Alpha Hack"); hack_date_check = gtk_check_button_new_with_label("Date Hack"); hack_offset_check = gtk_check_button_new_with_label("Offset Hack"); hack_skipdraw_label = gtk_label_new("Skipdraw:"); hack_skipdraw_spin = gtk_spin_button_new_with_range(0,1000,1); hack_enble_check = gtk_check_button_new_with_label("Enable User Hacks"); hack_wild_check = gtk_check_button_new_with_label("Wild arm Hack"); hack_sprite_check = gtk_check_button_new_with_label("Sprite Hack"); hack_msaa_check = gtk_check_button_new_with_label("Msaa Hack"); hack_tco_label = gtk_label_new("Texture Offset: 0x"); hack_tco_entry = gtk_entry_new(); hack_logz_check = gtk_check_button_new_with_label("Log Depth Hack"); gtk_spin_button_set_value(GTK_SPIN_BUTTON(hack_skipdraw_spin), theApp.GetConfig("UserHacks_SkipDraw", 0)); set_hex_entry(hack_tco_entry, theApp.GetConfig("UserHacks_TCOffset", 0)); // Tables are strange. The numbers are for their position: left, right, top, bottom. gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_alpha_check, 0, 1, 0, 1); gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_offset_check, 1, 2, 0, 1); gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_sprite_check, 0, 1, 1, 2); gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_wild_check, 1, 2, 1, 2); gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_logz_check, 0, 1, 2, 3); gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_date_check, 1, 2, 2, 3); // Note: MSAA is not implemented yet. I disable it to make the table square //gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_msaa_check, 2, 3, 1, 2); gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_skipdraw_label, 0, 1, 3, 4); gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_skipdraw_spin, 1, 2, 3, 4); gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_tco_label, 0, 1, 4, 5); gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_tco_entry, 1, 2, 4, 5); // Create our checkboxes. shadeboost_check = gtk_check_button_new_with_label("Shade boost"); paltex_check = gtk_check_button_new_with_label("Allow 8 bits textures"); fba_check = gtk_check_button_new_with_label("Alpha correction (FBA)"); aa_check = gtk_check_button_new_with_label("Edge anti-aliasing (AA1)"); fxaa_check = gtk_check_button_new_with_label("Fxaa shader"); // Set the checkboxes. gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shadeboost_check), theApp.GetConfig("shadeboost", 1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(paltex_check), theApp.GetConfig("paltex", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fba_check), theApp.GetConfig("fba", 1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(aa_check), theApp.GetConfig("aa1", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fxaa_check), theApp.GetConfig("fxaa", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(native_res_check), theApp.GetConfig("nativeres", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_alpha_check), theApp.GetConfig("UserHacks_AlphaHack", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_offset_check), theApp.GetConfig("UserHacks_HalfPixelOffset", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_date_check), theApp.GetConfig("UserHacks_DateGL4", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_enble_check), theApp.GetConfig("UserHacks", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_msaa_check), theApp.GetConfig("UserHacks_MSAA", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_wild_check), theApp.GetConfig("UserHacks_WildHack", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_sprite_check), theApp.GetConfig("UserHacks_SpriteHack", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_logz_check), theApp.GetConfig("logz", 1)); // Shadeboost scale sb_brightness = gtk_hscale_new_with_range(0, 200, 10); GtkWidget* sb_brightness_label = gtk_label_new("Shade Boost Brightness"); gtk_scale_set_value_pos(GTK_SCALE(sb_brightness), GTK_POS_RIGHT); gtk_range_set_value(GTK_RANGE(sb_brightness), theApp.GetConfig("ShadeBoost_Brightness", 50)); sb_contrast = gtk_hscale_new_with_range(0, 200, 10); GtkWidget* sb_contrast_label = gtk_label_new("Shade Boost Contrast"); gtk_scale_set_value_pos(GTK_SCALE(sb_contrast), GTK_POS_RIGHT); gtk_range_set_value(GTK_RANGE(sb_contrast), theApp.GetConfig("ShadeBoost_Contrast", 50)); sb_saturation = gtk_hscale_new_with_range(0, 200, 10); GtkWidget* sb_saturation_label = gtk_label_new("Shade Boost Saturation"); gtk_scale_set_value_pos(GTK_SCALE(sb_saturation), GTK_POS_RIGHT); gtk_range_set_value(GTK_RANGE(sb_saturation), theApp.GetConfig("ShadeBoost_Saturation", 50)); // Populate all those boxes we created earlier with widgets. gtk_container_add(GTK_CONTAINER(res_box), native_box); gtk_container_add(GTK_CONTAINER(res_box), fsaa_box); gtk_container_add(GTK_CONTAINER(res_box), resxy_box); gtk_container_add(GTK_CONTAINER(sw_box), threads_box); gtk_container_add(GTK_CONTAINER(sw_box), aa_check); // Tables are strange. The numbers are for their position: left, right, top, bottom. gtk_table_attach_defaults(GTK_TABLE(shader_table), fxaa_check, 0, 1, 0, 1); gtk_table_attach_defaults(GTK_TABLE(shader_table), shadeboost_check, 1, 2, 0, 1); gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_brightness_label, 0, 1, 1, 2); gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_brightness, 1, 2, 1, 2); gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_contrast_label, 0, 1, 2, 3); gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_contrast, 1, 2, 2, 3); gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_saturation_label, 0, 1, 3, 4); gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_saturation, 1, 2, 3, 4); // Tables are strange. The numbers are for their position: left, right, top, bottom. gtk_table_attach_defaults(GTK_TABLE(hw_table), filter_box, 0, 1, 0, 1); gtk_table_attach_defaults(GTK_TABLE(hw_table), paltex_check, 0, 1, 1, 2); gtk_table_attach_defaults(GTK_TABLE(hw_table), fba_check, 1, 2, 1, 2); // The GL advance options gl_box = gtk_vbox_new(false, 5); gl_frame = gtk_frame_new ("OpenGL Very Advanced Custom Settings"); gtk_container_add(GTK_CONTAINER(gl_frame), gl_box); gl_table = gtk_table_new(10, 2, false); gtk_container_add(GTK_CONTAINER(gl_box), gl_table); GtkWidget* gl_bs_label = gtk_label_new("Buffer Storage:"); GtkWidget* gl_bs_combo = CreateGlComboBox("override_GL_ARB_buffer_storage"); GtkWidget* gl_bt_label = gtk_label_new("Bindless Texture:"); GtkWidget* gl_bt_combo = CreateGlComboBox("override_GL_ARB_bindless_texture"); GtkWidget* gl_sso_label = gtk_label_new("Separate Shader:"); GtkWidget* gl_sso_combo = CreateGlComboBox("override_GL_ARB_separate_shader_objects"); GtkWidget* gl_ss_label = gtk_label_new("Shader Subroutine:"); GtkWidget* gl_ss_combo = CreateGlComboBox("override_GL_ARB_shader_subroutine"); GtkWidget* gl_gs_label = gtk_label_new("Geometry Shader:"); GtkWidget* gl_gs_combo = CreateGlComboBox("override_geometry_shader"); GtkWidget* gl_ils_label = gtk_label_new("Image Load Store:"); GtkWidget* gl_ils_combo = CreateGlComboBox("override_GL_ARB_shader_image_load_store"); GtkWidget* gl_cc_label = gtk_label_new("Clip Control (depth accuracy):"); GtkWidget* gl_cc_combo = CreateGlComboBox("override_GL_ARB_clip_control"); GtkWidget* gl_ct_label = gtk_label_new("Clear Texture:"); GtkWidget* gl_ct_combo = CreateGlComboBox("override_GL_ARB_clear_texture"); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_gs_label, 0, 1, 0, 1); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_gs_combo, 1, 2, 0, 1); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bs_label, 0, 1, 1, 2); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bs_combo, 1, 2, 1, 2); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bt_label, 0, 1, 2, 3); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bt_combo, 1, 2, 2, 3); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_sso_label, 0, 1, 3, 4); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_sso_combo, 1, 2, 3, 4); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ss_label, 0, 1, 4, 5); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ss_combo, 1, 2, 4, 5); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ils_label, 0, 1, 5, 6); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ils_combo, 1, 2, 5, 6); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_cc_label, 0, 1, 6, 7); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_cc_combo, 1, 2, 6, 7); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ct_label, 0, 1, 7, 8); gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ct_combo, 1, 2, 7, 8); // those one are properly detected so no need a gui #if 0 override_GL_ARB_copy_image = -1 override_GL_ARB_explicit_uniform_location = -1 override_GL_ARB_gpu_shader5 = -1 override_GL_ARB_shading_language_420pack = -1 #endif // Handle some nice tab notebook = gtk_notebook_new(); page_label[0] = gtk_label_new("Global Setting"); page_label[1] = gtk_label_new("Advance Setting"); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), central_box, page_label[0]); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), advance_box, page_label[1]); // Put everything in the big box. gtk_container_add(GTK_CONTAINER(main_box), renderer_box); gtk_container_add(GTK_CONTAINER(main_box), interlace_box); gtk_container_add(GTK_CONTAINER(main_box), notebook); gtk_container_add(GTK_CONTAINER(central_box), res_frame); gtk_container_add(GTK_CONTAINER(central_box), shader_frame); gtk_container_add(GTK_CONTAINER(central_box), hw_frame); gtk_container_add(GTK_CONTAINER(central_box), sw_frame); gtk_container_add(GTK_CONTAINER(advance_box), hack_frame); gtk_container_add(GTK_CONTAINER(advance_box), gl_frame); // Put the box in the dialog and show it to the world. gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_box); gtk_widget_show_all (dialog); return_value = gtk_dialog_run (GTK_DIALOG (dialog)); if (return_value == GTK_RESPONSE_ACCEPT) { int mode_height = 0, mode_width = 0; mode_width = theApp.GetConfig("ModeWidth", 640); mode_height = theApp.GetConfig("ModeHeight", 480); theApp.SetConfig("ModeHeight", mode_height); theApp.SetConfig("ModeWidth", mode_width); // Get all the settings from the dialog box. if (gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box)) != -1) { // Note the value are based on m_gs_renderers vector on GSdx.cpp switch (gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box))) { case 2: theApp.SetConfig("renderer", 10); break; case 3: theApp.SetConfig("renderer", 11); break; case 4: theApp.SetConfig("renderer", 12); break; case 5: theApp.SetConfig("renderer", 13); break; // Fallback to SW opengl default: theApp.SetConfig("renderer", 13); break; } } if (gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)) != -1) theApp.SetConfig( "interlace", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box))); theApp.SetConfig("extrathreads", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(threads_spin))); theApp.SetConfig("filter", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(filter_combo_box))); theApp.SetConfig("shadeboost", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(shadeboost_check))); theApp.SetConfig("paltex", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(paltex_check))); theApp.SetConfig("fba", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fba_check))); theApp.SetConfig("aa1", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(aa_check))); theApp.SetConfig("fxaa", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fxaa_check))); theApp.SetConfig("nativeres", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(native_res_check))); theApp.SetConfig("ShadeBoost_Saturation", (int)gtk_range_get_value(GTK_RANGE(sb_saturation))); theApp.SetConfig("ShadeBoost_Brightness", (int)gtk_range_get_value(GTK_RANGE(sb_brightness))); theApp.SetConfig("ShadeBoost_Contrast", (int)gtk_range_get_value(GTK_RANGE(sb_contrast))); theApp.SetConfig("upscale_multiplier", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(fsaa_combo_box))+1); theApp.SetConfig("resx", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resx_spin))); theApp.SetConfig("resy", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resy_spin))); theApp.SetConfig("UserHacks_SkipDraw", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(hack_skipdraw_spin))); theApp.SetConfig("UserHacks_HalfPixelOffset", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_offset_check))); theApp.SetConfig("UserHacks_AlphaHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_alpha_check))); theApp.SetConfig("logz", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_logz_check))); theApp.SetConfig("UserHacks_DateGL4", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_date_check))); theApp.SetConfig("UserHacks_MSAA", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_msaa_check))); theApp.SetConfig("UserHacks_WildHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_wild_check))); theApp.SetConfig("UserHacks_SpriteHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_sprite_check))); theApp.SetConfig("UserHacks", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_enble_check))); theApp.SetConfig("UserHacks_TCOffset", get_hex_entry(hack_tco_entry)); theApp.SetConfig("override_GL_ARB_clear_texture", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_ct_combo)) - 1); theApp.SetConfig("override_GL_ARB_bindless_texture", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_bt_combo)) - 1); theApp.SetConfig("override_GL_ARB_buffer_storage", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_bs_combo)) - 1); theApp.SetConfig("override_GL_ARB_separate_shader_objects", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_sso_combo)) - 1); theApp.SetConfig("override_GL_ARB_shader_subroutine", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_ss_combo)) - 1); theApp.SetConfig("override_geometry_shader", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_gs_combo)) - 1); theApp.SetConfig("override_GL_ARB_shader_image_load_store", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_ils_combo)) - 1); theApp.SetConfig("override_GL_ARB_clip_control", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_cc_combo)) - 1); // NOT supported yet theApp.SetConfig("msaa", 0); // Let's just be windowed for the moment. theApp.SetConfig("windowed", 1); gtk_widget_destroy (dialog); return true; } gtk_widget_destroy (dialog); return false; }
GtkWidget* bimp_watermark_gui_new(watermark_settings settings) { GtkWidget *gui, *hbox_text_entry, *hbox_text_font, *hbox_text_color, *hbox_opacity, *frame_position, *table_position; GtkWidget *align_radio_text, *align_radio_image; GtkWidget *label_text, *label_font, *label_color, *label_opacity, *label_percent; gui = gtk_vbox_new(FALSE, 5); align_radio_text = gtk_alignment_new(0, 0, 0, 0); gtk_alignment_set_padding(GTK_ALIGNMENT(align_radio_text), 0, 5, 10, 0); radio_text = gtk_radio_button_new_with_label(NULL, _("Text watermark")); vbox_text = gtk_vbox_new(FALSE, 5); hbox_text_entry = gtk_hbox_new(FALSE, 5); label_text = gtk_label_new(g_strconcat(_("Text"), ":", NULL)); gtk_widget_set_size_request (label_text, LABEL_W, LABEL_H); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_text), settings->mode); entry_text = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(entry_text), 50); gtk_entry_set_text(GTK_ENTRY(entry_text), settings->text); gtk_widget_set_size_request (entry_text, INPUT_W, INPUT_H); hbox_text_font = gtk_hbox_new(FALSE, 5); label_font = gtk_label_new(g_strconcat(_("Font"), ":", NULL)); gtk_widget_set_size_request (label_font, LABEL_W, LABEL_H); chooser_font = gtk_font_button_new_with_font(pango_font_description_to_string(settings->font)); gtk_widget_set_size_request (chooser_font, INPUT_W, INPUT_H); hbox_text_color = gtk_hbox_new(FALSE, 5); label_color = gtk_label_new(g_strconcat(_("Color"), ":", NULL)); gtk_widget_set_size_request (label_color, LABEL_W, LABEL_H); chooser_color = gtk_color_button_new_with_color(&(settings->color)); gtk_widget_set_size_request (chooser_color, INPUT_W, INPUT_H); align_radio_image = gtk_alignment_new(0, 0, 0, 0); gtk_alignment_set_padding(GTK_ALIGNMENT(align_radio_image), 0, 5, 10, 0); radio_image = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON(radio_text), _("Image watermark")); vbox_image = gtk_vbox_new(FALSE, 5); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_image), !settings->mode); chooser_image = gtk_file_chooser_button_new(_("Select image"), GTK_FILE_CHOOSER_ACTION_OPEN); /* set image chooser's filters */ GtkFileFilter *filter_all, *supported[5]; filter_all = gtk_file_filter_new(); gtk_file_filter_set_name(filter_all, _("All supported types")); supported[0] = gtk_file_filter_new(); gtk_file_filter_set_name(supported[0], "Bitmap (*.bmp)"); gtk_file_filter_add_pattern (supported[0], "*.bmp"); gtk_file_filter_add_pattern (filter_all, "*.bmp"); supported[1] = gtk_file_filter_new(); gtk_file_filter_set_name(supported[1], "JPEG (*.jpg, *.jpeg, *jpe)"); gtk_file_filter_add_pattern (supported[1], "*.jpg"); gtk_file_filter_add_pattern (supported[1], "*.jpeg"); gtk_file_filter_add_pattern (supported[1], "*.jpe"); gtk_file_filter_add_pattern (filter_all, "*.jpg"); gtk_file_filter_add_pattern (filter_all, "*.jpeg"); gtk_file_filter_add_pattern (filter_all, "*.jpe"); supported[2] = gtk_file_filter_new(); gtk_file_filter_set_name(supported[2], "GIF (*.gif)"); gtk_file_filter_add_pattern (supported[2], "*.gif"); gtk_file_filter_add_pattern (filter_all, "*.gif"); supported[3] = gtk_file_filter_new(); gtk_file_filter_set_name(supported[3], "PNG (*.png)"); gtk_file_filter_add_pattern (supported[3], "*.png"); gtk_file_filter_add_pattern (filter_all, "*.png"); supported[4] = gtk_file_filter_new(); gtk_file_filter_set_name(supported[4], "TIFF (*tif, *.tiff)"); gtk_file_filter_add_pattern (supported[4], "*.tiff"); gtk_file_filter_add_pattern (supported[4], "*.tif"); gtk_file_filter_add_pattern (filter_all, "*.tiff"); gtk_file_filter_add_pattern (filter_all, "*.tif"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser_image), filter_all); int i; for(i = 0; i < 5; i++) { gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser_image), supported[i]); } if (settings->image_file != NULL) { gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser_image), settings->image_file); } gtk_widget_set_size_request (chooser_image, INPUT_W, INPUT_H); hbox_opacity = gtk_hbox_new(FALSE, 5); label_opacity = gtk_label_new(g_strconcat(_("Opacity"), ":", NULL)); gtk_widget_set_size_request (label_opacity, LABEL_TRANSP_W, LABEL_TRANSP_H); gtk_misc_set_alignment(GTK_MISC(label_opacity), 0.5, 0.8); scale_opacity = gtk_hscale_new_with_range(1, 100, 1); gtk_range_set_value(GTK_RANGE(scale_opacity), settings->opacity); gtk_widget_set_size_request (scale_opacity, SCALE_TRANSP_W, SCALE_TRANSP_H); label_percent = gtk_label_new("%"); gtk_widget_set_size_request (label_percent, LABEL_PERCENT_W, LABEL_PERCENT_H); gtk_misc_set_alignment(GTK_MISC(label_percent), 0.5, 0.8); frame_position = gtk_frame_new(g_strconcat(_("Position on the image"), ":", NULL)); gtk_widget_set_size_request (frame_position, FRAME_POSITION_W, FRAME_POSITION_H); table_position = gtk_table_new(3, 3, TRUE); button_tl = gtk_radio_button_new (NULL); gtk_button_set_image(GTK_BUTTON(button_tl), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_postl, TRUE, NULL))); gtk_widget_set_tooltip_text (button_tl, watermark_pos_get_string(WM_POS_TL)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_tl), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_tl), settings->position == WM_POS_TL); gtk_widget_set_size_request (button_tl, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_tl, 0, 1, 0, 1, GTK_EXPAND, GTK_EXPAND, 0, 0); button_tc = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_tc), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_postc, TRUE, NULL))); gtk_widget_set_tooltip_text (button_tc, watermark_pos_get_string(WM_POS_TC)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_tc), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_tc), settings->position == WM_POS_TC); gtk_widget_set_size_request (button_tc, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_tc, 1, 2, 0, 1, GTK_EXPAND, GTK_EXPAND, 0, 0); button_tr = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_tr), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_postr, TRUE, NULL))); gtk_widget_set_tooltip_text (button_tr, watermark_pos_get_string(WM_POS_TR)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_tr), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_tr), settings->position == WM_POS_TR); gtk_widget_set_size_request (button_tr, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_tr, 2, 3, 0, 1, GTK_EXPAND, GTK_EXPAND, 0, 0); button_cl = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_cl), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_poscl, TRUE, NULL))); gtk_widget_set_tooltip_text (button_cl, watermark_pos_get_string(WM_POS_CL)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_cl), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_cl), settings->position == WM_POS_CL); gtk_widget_set_size_request (button_cl, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_cl, 0, 1, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0); button_cc = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_cc), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_poscc, TRUE, NULL))); gtk_widget_set_tooltip_text (button_cc, watermark_pos_get_string(WM_POS_CC)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_cc), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_cc), settings->position == WM_POS_CC); gtk_widget_set_size_request (button_cc, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_cc, 1, 2, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0); button_cr = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_cr), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_poscr, TRUE, NULL))); gtk_widget_set_tooltip_text (button_cr, watermark_pos_get_string(WM_POS_CR)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_cr), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_cr), settings->position == WM_POS_CR); gtk_widget_set_size_request (button_cr, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_cr, 2, 3, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0); button_bl = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_bl), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_posbl, TRUE, NULL))); gtk_widget_set_tooltip_text (button_bl, watermark_pos_get_string(WM_POS_BL)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_bl), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_bl), settings->position == WM_POS_BL); gtk_widget_set_size_request (button_bl, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_bl, 0, 1, 2, 3, GTK_EXPAND, GTK_EXPAND, 0, 0); button_bc = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_bc), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_posbc, TRUE, NULL))); gtk_widget_set_tooltip_text (button_bc, watermark_pos_get_string(WM_POS_BC)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_bc), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_bc), settings->position == WM_POS_BC); gtk_widget_set_size_request (button_bc, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_bc, 1, 2, 2, 3, GTK_EXPAND, GTK_EXPAND, 0, 0); button_br = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_br), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_posbr, TRUE, NULL))); gtk_widget_set_tooltip_text (button_br, watermark_pos_get_string(WM_POS_BR)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_br), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_br), settings->position == WM_POS_BR); gtk_widget_set_size_request (button_br, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_br, 2, 3, 2, 3, GTK_EXPAND, GTK_EXPAND, 0, 0); gtk_box_pack_start(GTK_BOX(gui), radio_text, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_text_entry), label_text, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_text_entry), entry_text, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_text_font), label_font, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_text_font), chooser_font, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_text_color), label_color, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_text_color), chooser_color, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox_text), hbox_text_entry, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox_text), hbox_text_font, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox_text), hbox_text_color, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(align_radio_text), vbox_text); gtk_box_pack_start(GTK_BOX(gui), align_radio_text, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(gui), radio_image, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox_image), chooser_image, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(align_radio_image), vbox_image); gtk_box_pack_start(GTK_BOX(gui), align_radio_image, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_opacity), label_opacity, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_opacity), scale_opacity, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_opacity), label_percent, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(gui), hbox_opacity, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(frame_position), table_position); gtk_box_pack_start(GTK_BOX(gui), frame_position, FALSE, FALSE, 0); toggle_group(NULL, NULL); g_signal_connect(G_OBJECT(radio_text), "toggled", G_CALLBACK(toggle_group), NULL); return gui; }
static GdkPixbuf *load_banner(void) { extern const GdkPixdata startbanner_pixdata; return gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL); }
GtkWidget* ctk_banner_new(BannerArtworkType artwork) { GObject *object; CtkBanner *ctk_banner; const GdkPixdata *pixdata; int tall, pad_x; if (!select_artwork(artwork, &tall, &pad_x, &pixdata)) { return NULL; } object = g_object_new(CTK_TYPE_BANNER, NULL); ctk_banner = CTK_BANNER(object); ctk_banner->back.pixbuf = NULL; ctk_banner->artwork.pixbuf = NULL; ctk_banner->artwork_pad_x = pad_x; /* load the global images */ if (!Background.pixbuf) { Background.pixbuf = gdk_pixbuf_from_pixdata(&background_pixdata, TRUE, NULL); Background.w = gdk_pixbuf_get_width(Background.pixbuf); Background.h = gdk_pixbuf_get_height(Background.pixbuf); } g_object_ref(Background.pixbuf); if (!TallBackground.pixbuf) { TallBackground.pixbuf = gdk_pixbuf_from_pixdata(&background_tall_pixdata, TRUE, NULL); TallBackground.w = gdk_pixbuf_get_width(TallBackground.pixbuf); TallBackground.h = gdk_pixbuf_get_height(TallBackground.pixbuf); } g_object_ref(TallBackground.pixbuf); if (!Logo.pixbuf) { Logo.pixbuf = gdk_pixbuf_from_pixdata(&logo_pixdata, TRUE, NULL); Logo.w = gdk_pixbuf_get_width(Logo.pixbuf); Logo.h = gdk_pixbuf_get_height(Logo.pixbuf); } g_object_ref(Logo.pixbuf); if (!TallLogo.pixbuf) { TallLogo.pixbuf = gdk_pixbuf_from_pixdata(&logo_tall_pixdata, TRUE, NULL); TallLogo.w = gdk_pixbuf_get_width(TallLogo.pixbuf); TallLogo.h = gdk_pixbuf_get_height(TallLogo.pixbuf); } g_object_ref(TallLogo.pixbuf); /* * assign fields based on whether the artwork is tall; XXX these * may need to be tweaked */ if (tall) { ctk_banner->logo_pad_x = 11; ctk_banner->logo_pad_y = 0; ctk_banner->background = &TallBackground; ctk_banner->logo = &TallLogo; } else { ctk_banner->logo_pad_x = 10; ctk_banner->logo_pad_y = 10; ctk_banner->background = &Background; ctk_banner->logo = &Logo; } /* load the artwork pixbuf */ ctk_banner->artwork.pixbuf = gdk_pixbuf_from_pixdata(pixdata, TRUE, NULL); ctk_banner->artwork.w = gdk_pixbuf_get_width(ctk_banner->artwork.pixbuf); ctk_banner->artwork.h = gdk_pixbuf_get_height(ctk_banner->artwork.pixbuf); return GTK_WIDGET(object); }
int main( int argc, char *argv[] ) { VikWindow *first_window; GdkPixbuf *main_icon; gboolean dashdash_already = FALSE; int i = 0; GError *error = NULL; gboolean gui_initialized; bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #if ! GLIB_CHECK_VERSION (2, 32, 0) g_thread_init ( NULL ); #endif gdk_threads_init (); gui_initialized = gtk_init_with_args (&argc, &argv, "files+", entries, NULL, &error); if (!gui_initialized) { /* check if we have an error message */ if (error == NULL) { /* no error message, the GUI initialization failed */ const gchar *display_name = gdk_get_display_arg_name (); (void)g_fprintf (stderr, "Failed to open display: %s\n", (display_name != NULL) ? display_name : " "); } else { /* yep, there's an error, so print it */ (void)g_fprintf (stderr, "Parsing command line options failed: %s\n", error->message); g_error_free (error); (void)g_fprintf (stderr, "Run \"%s --help\" to see the list of recognized options.\n",argv[0]); } return EXIT_FAILURE; } if (vik_version) { (void)g_printf ("%s %s\nCopyright (c) 2003-2008 Evan Battaglia\nCopyright (c) 2008-"THEYEAR" Viking's contributors\n", PACKAGE_NAME, PACKAGE_VERSION); return EXIT_SUCCESS; } #if GLIB_CHECK_VERSION (2, 32, 0) if (vik_debug) g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, log_debug, NULL); #else if (!vik_debug) g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, mute_log, NULL); #endif #if HAVE_X11_XLIB_H XSetErrorHandler(myXErrorHandler); #endif // Discover if this is the very first run a_vik_very_first_run (); a_settings_init (); a_preferences_init (); /* * First stage initialization * * Should not use a_preferences_get() yet * * Since the first time a_preferences_get() is called it loads any preferences values from disk, * but of course for preferences not registered yet it can't actually understand them * so subsequent initial attempts to get those preferences return the default value, until the values have changed */ a_vik_preferences_init (); a_layer_defaults_init (); a_download_init(); curl_download_init(); a_babel_init (); /* Init modules/plugins */ modules_init(); vik_georef_layer_init (); maps_layer_init (); a_mapcache_init (); a_background_init (); a_toolbar_init(); vik_routing_prefs_init(); /* * Second stage initialization * * Can now use a_preferences_get() */ a_background_post_init (); a_babel_post_init (); modules_post_init (); // May need to initialize the Positonal TimeZone lookup if ( a_vik_get_time_ref_frame() == VIK_TIME_REF_WORLD ) vu_setup_lat_lon_tz_lookup(); /* Set the icon */ main_icon = gdk_pixbuf_from_pixdata(&viking_pixbuf, FALSE, NULL); gtk_window_set_default_icon(main_icon); gdk_threads_enter (); // Ask for confirmation of default settings on first run vu_set_auto_features_on_first_run (); /* Create the first window */ first_window = vik_window_new_window(); vu_check_latest_version ( GTK_WINDOW(first_window) ); // Load startup file first so that subsequent files are loaded on top // Especially so that new tracks+waypoints will be above any maps in a startup file if ( a_vik_get_startup_method () == VIK_STARTUP_METHOD_SPECIFIED_FILE ) { gboolean load_startup_file = TRUE; // When a viking file is to be loaded via the command line // then we'll skip loading any startup file int jj = 0; while ( ++jj < argc ) { if ( check_file_magic_vik(argv[jj]) ) load_startup_file = FALSE; } if ( load_startup_file ) vik_window_open_file ( first_window, a_vik_get_startup_file(), TRUE ); } while ( ++i < argc ) { if ( strcmp(argv[i],"--") == 0 && !dashdash_already ) dashdash_already = TRUE; /* hack to open '-' */ else { VikWindow *newvw = first_window; gboolean change_filename = (i == 1); // Open any subsequent .vik files in their own window if ( i > 1 && check_file_magic_vik ( argv[i] ) ) { newvw = vik_window_new_window (); change_filename = TRUE; } vik_window_open_file ( newvw, argv[i], change_filename ); } } vik_window_new_window_finish ( first_window ); vu_command_line ( first_window, latitude, longitude, zoom_level_osm, map_id ); gtk_main (); gdk_threads_leave (); a_babel_uninit (); a_toolbar_uninit (); a_background_uninit (); a_mapcache_uninit (); a_dems_uninit (); a_layer_defaults_uninit (); a_preferences_uninit (); a_settings_uninit (); modules_uninit(); curl_download_uninit(); vu_finalize_lat_lon_tz_lookup (); // Clean up any temporary files util_remove_all_in_deletion_list (); return 0; }
bool RunLinuxDialog() { GtkWidget *dialog; int return_value; /* Create the widgets */ dialog = gtk_dialog_new_with_buttons ( "GSdx Config", NULL, /* parent window*/ (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), "OK", GTK_RESPONSE_ACCEPT, // "Cancel", GTK_RESPONSE_REJECT, // Drop because it is too annoying to support call back this way NULL); // The main area for the whole dialog box. GtkWidget* main_box = gtk_vbox_new(false, 5); GtkWidget* central_box = gtk_vbox_new(false, 5); GtkWidget* advance_box = gtk_vbox_new(false, 5); GtkWidget* debug_box = gtk_vbox_new(false, 5); // Grab a logo, to make things look nice. GdkPixbuf* logo_pixmap = gdk_pixbuf_from_pixdata(&gsdx_ogl_logo, false, NULL); GtkWidget* logo_image = gtk_image_new_from_pixbuf(logo_pixmap); gtk_box_pack_start(GTK_BOX(main_box), logo_image, true, true, 0); GtkWidget* main_table = CreateTableInBox(main_box , NULL , 2 , 2); GtkWidget* res_table = CreateTableInBox(central_box , "OpenGL Internal Resolution" , 3 , 3); GtkWidget* shader_table = CreateTableInBox(central_box , "Custom Shader Settings" , 8 , 2); GtkWidget* hw_table = CreateTableInBox(central_box , "Hardware Mode Settings" , 5 , 2); GtkWidget* sw_table = CreateTableInBox(central_box , "Software Mode Settings" , 3 , 2); GtkWidget* hack_table = CreateTableInBox(advance_box , "Hacks" , 9 , 2); GtkWidget* gl_table = CreateTableInBox(advance_box , "OpenGL Very Advanced Custom Settings" , 8 , 2); GtkWidget* record_table = CreateTableInBox(debug_box , "Recording Settings" , 3 , 3); GtkWidget* debug_table = CreateTableInBox(debug_box , "OpenGL / GSdx Debug Settings" , 5 , 3); // Populate all the tables populate_main_table(main_table); populate_res_table(res_table); populate_shader_table(shader_table); populate_hw_table(hw_table); populate_sw_table(sw_table); populate_hack_table(hack_table); populate_gl_table(gl_table); populate_debug_table(debug_table); populate_record_table(record_table); // Handle some nice tab GtkWidget* notebook = gtk_notebook_new(); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), central_box, gtk_label_new("Global Setting")); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), advance_box, gtk_label_new("Advance Setting")); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), debug_box , gtk_label_new("Debug/Recording Setting")); // Put everything in the big box. gtk_container_add(GTK_CONTAINER(main_box), notebook); // Put the box in the dialog and show it to the world. gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_box); gtk_widget_show_all (dialog); return_value = gtk_dialog_run (GTK_DIALOG (dialog)); // Compatibility & not supported option int mode_width = theApp.GetConfig("ModeWidth", 640); int mode_height = theApp.GetConfig("ModeHeight", 480); theApp.SetConfig("ModeHeight", mode_height); theApp.SetConfig("ModeWidth", mode_width); theApp.SetConfig("msaa", 0); theApp.SetConfig("windowed", 1); // Anisotropic is disabled when it is 1x, no need of an extra check box theApp.SetConfig("AnisotropicFiltering", 1); gtk_widget_destroy (dialog); return (return_value == GTK_RESPONSE_ACCEPT); }
void mysql__add_row_to_model(MYSQL_ROW row, unsigned long* lengths) { GdkPixbuf* iconbuf = NULL; char length[64]; char keywords[256]; char name[256]; float samplerate; char samplerate_s[32]; unsigned channels, colour; gboolean online = FALSE; GtkTreeIter iter; //db__iter_to_result(result); //deserialise the pixbuf field: GdkPixdata pixdata; GdkPixbuf* pixbuf = NULL; if(row[MYSQL_PIXBUF]){ if(gdk_pixdata_deserialize(&pixdata, lengths[MYSQL_PIXBUF], (guint8*)row[MYSQL_PIXBUF], NULL)){ pixbuf = gdk_pixbuf_from_pixdata(&pixdata, TRUE, NULL); } } format_time(length, row[MYSQL_LENGTH]); if(row[MYSQL_KEYWORDS]) snprintf(keywords, 256, "%s", row[MYSQL_KEYWORDS]); else keywords[0] = 0; if(!row[MYSQL_SAMPLERATE]) samplerate = 0; else samplerate = atoi(row[MYSQL_SAMPLERATE]); samplerate_format(samplerate_s, samplerate); if(row[7]==NULL) channels = 0; else channels = atoi(row[7]); if(row[MYSQL_ONLINE]==NULL) online = 0; else online = atoi(row[MYSQL_ONLINE]); if(row[MYSQL_COLOUR]==NULL) colour = 0; else colour = atoi(row[MYSQL_COLOUR]); strncpy(name, row[MYSQL_NAME], 255); //TODO markup should be set in cellrenderer, not model! #if 0 if(GTK_WIDGET_REALIZED(app.view)){ //check colours dont clash: long c_num = strtol(app.config.colour[colour], NULL, 16); dbg(2, "rowcolour=%s", app.config.colour[colour]); GdkColor row_colour; color_rgba_to_gdk(&row_colour, c_num << 8); if(is_similar(&row_colour, &app.fg_colour, 0x60)){ snprintf(name, 255, "%s%s%s", "<span foreground=\"blue\">", row[MYSQL_NAME], "</span>"); } } #endif #ifdef USE_AYYI //is the file loaded in the current Ayyi song? if(ayyi.got_song){ gchar* fullpath = g_build_filename(row[MYSQL_DIR], name, NULL); if(pool__file_exists(fullpath)) dbg(0, "exists"); else dbg(0, "doesnt exist"); g_free(fullpath); } #endif //icon (only shown if the sound file is currently available): if(online){ MIME_type* mime_type = mime_type_lookup(row[MYSQL_MIMETYPE]); type_to_icon(mime_type); if ( ! mime_type->image ) dbg(0, "no icon."); iconbuf = mime_type->image->sm_pixbuf; } else iconbuf = NULL; #if 0 //strip the homedir from the dir string: char* path = strstr(row[MYSQL_DIR], g_get_home_dir()); path = path ? path + strlen(g_get_home_dir()) + 1 : row[MYSQL_DIR]; #endif gtk_list_store_append(app.store, &iter); gtk_list_store_set(app.store, &iter, COL_ICON, iconbuf, #ifdef USE_AYYI COL_AYYI_ICON, ayyi_icon, #endif COL_IDX, atoi(row[MYSQL_ID]), COL_NAME, name, COL_FNAME, row[MYSQL_DIR], COL_KEYWORDS, keywords, COL_OVERVIEW, pixbuf, COL_LENGTH, length, COL_SAMPLERATE, samplerate_s, COL_CHANNELS, channels, COL_MIMETYPE, row[MYSQL_MIMETYPE], COL_NOTES, row[MYSQL_NOTES], COL_COLOUR, colour, -1); if(pixbuf) g_object_unref(pixbuf); #if 0 if(app.no_gui){ printf(" %s\n", name); } #endif }
void doppelganger_set_image (Doppelganger *dg, GdkPixbuf *pixbuf) { GdkPixbuf *scaled = NULL; GdkPixdata black_arrow_data; GdkPixbuf *black_arrow; GdkPixbuf *cursor_image; gboolean preexisting = dg->cursor!=NULL; if (!gdk_pixdata_deserialize (&black_arrow_data, -1, black_cursor, NULL) || black_cursor == NULL) { /* This won't happen in practice, so it can be fatal */ g_error ("Failed to deseralise pointer."); } black_arrow = gdk_pixbuf_from_pixdata (&black_arrow_data, TRUE, NULL); if (pixbuf) { scaled = gdk_pixbuf_scale_simple (pixbuf, 64, 64, GDK_INTERP_BILINEAR); /* * Composite a black arrow onto the top left-hand * corner. */ gdk_pixbuf_composite (black_arrow, scaled, 0, 0, 13, 21, 0.0, 0.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255); gdk_pixbuf_unref (black_arrow); cursor_image = scaled; } else { cursor_image = black_arrow; } if (preexisting) { gdk_cursor_unref (dg->cursor); } dg->cursor = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), cursor_image, 1, 1); gdk_pixbuf_unref (cursor_image); #if 0 if (preexisting) { XIEventMask mask = { dg->mpx, 0, "" }; if (XIUngrabDevice (gdk_x11_get_default_xdisplay (), dg->mpx, CurrentTime) != GrabSuccess) { g_warning ("Ungrab failed."); } if (XIGrabDevice (gdk_x11_get_default_xdisplay (), dg->mpx, GDK_ROOT_WINDOW(), CurrentTime, gdk_x11_cursor_get_xcursor (dg->cursor), GrabModeAsync, GrabModeAsync, True, &mask) != GrabSuccess) { g_warning ("Grab failed."); } } #endif }
/* Main entry point */ int main(int argc, char** argv) { GtkWidget *window; GtkAccelGroup *group; struct eid_vwr_ui_callbacks* cb; pthread_t thread; GdkPixbuf *logo; GError* err = NULL; /* The GNU implementation of setlocale() ignores whatever we * specify if the LANGUAGE environment variable has a value, so * ensure that it doesn't */ putenv("LANGUAGE="); bindtextdomain("eid-viewer", DATAROOTDIR "/locale"); textdomain("eid-viewer"); eid_vwr_convert_set_lang(langfromenv()); gtk_init(&argc, &argv); builder = gtk_builder_new(); if(gtk_builder_add_from_string(builder, VIEWER_GLADE_STRING, strlen(VIEWER_GLADE_STRING), &err) == 0) { g_critical("Could not parse Glade XML: %s", err->message); exit(EXIT_FAILURE); } window = GTK_WIDGET(gtk_builder_get_object(builder, "mainwin")); group = gtk_accel_group_new(); gtk_window_add_accel_group(GTK_WINDOW(window), group); touched_labels = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); bindata_init(); connect_signals(window); setup_treeview(); certs_init(); cb = eid_vwr_cbstruct(); cb->newsrc = newsrc; cb->newstringdata = newstringdata; cb->newbindata = newbindata; cb->logv = ui_log_init(); cb->newstate = newstate; cb->pinop_result = pinop_result; cb->readers_changed = readers_changed; eid_vwr_createcallbacks(cb); pthread_create(&thread, NULL, threadmain, NULL); G_GNUC_BEGIN_IGNORE_DEPRECATIONS logo = gdk_pixbuf_from_pixdata(&logo_128, FALSE, NULL); G_GNUC_END_IGNORE_DEPRECATIONS gtk_window_set_default_icon(logo); gtk_widget_show(window); if(argc > 1) { eid_vwr_be_deserialize(argv[1]); } gtk_main(); return 0; }
void create_startwin(void) { GtkWidget *banner, *label, *content, *scroll; GtkWidget *hbox1, *fixed1; GdkPixbuf *startbanner_pixbuf; startwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (startwin), apptitle); gtk_window_set_position (GTK_WINDOW (startwin), GTK_WIN_POS_CENTER); gtk_window_set_resizable (GTK_WINDOW (startwin), FALSE); gtk_window_set_type_hint (GTK_WINDOW (startwin), GDK_WINDOW_TYPE_HINT_DIALOG); hbox1 = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox1); gtk_container_add (GTK_CONTAINER (startwin), hbox1); startbanner_pixbuf = gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL); banner = gtk_image_new_from_pixbuf(startbanner_pixbuf); g_object_unref((gpointer)startbanner_pixbuf); gtk_widget_show (banner); gtk_box_pack_start (GTK_BOX (hbox1), banner, FALSE, FALSE, 0); fixed1 = gtk_fixed_new (); gtk_widget_show (fixed1); gtk_box_pack_start (GTK_BOX (hbox1), fixed1, TRUE, TRUE, 0); gtk_widget_set_size_request (fixed1, 390, -1); label = gtk_label_new (startwin_labeltext); gtk_widget_show (label); gtk_fixed_put (GTK_FIXED (fixed1), label, 6, 6); gtk_widget_set_size_request (label, 378, 16); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER); scroll = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scroll); gtk_fixed_put (GTK_FIXED (fixed1), scroll, 6, 28); gtk_widget_set_size_request (scroll, 378, 248); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); content = gtk_text_view_new (); gtk_widget_show (content); gtk_container_add (GTK_CONTAINER(scroll), content); //gtk_fixed_put (GTK_FIXED (fixed1), content, 6, 28); gtk_widget_set_size_request (content, 378, 248); gtk_text_view_set_editable (GTK_TEXT_VIEW (content), FALSE); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (content), GTK_WRAP_WORD); gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (content), FALSE); g_signal_connect ((gpointer) startwin, "delete_event", G_CALLBACK (on_startwin_delete_event), NULL); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (startwin, startwin, "startwin"); GLADE_HOOKUP_OBJECT (startwin, banner, "banner"); GLADE_HOOKUP_OBJECT (startwin, label, "label"); GLADE_HOOKUP_OBJECT (startwin, scroll, "scroll"); GLADE_HOOKUP_OBJECT (startwin, content, "content"); g_signal_connect((gpointer)startwin, "destroy", G_CALLBACK(gtk_widget_destroyed), (gpointer)&startwin); gtk_widget_show (startwin); gtk_main_iteration_do (FALSE); }
int main( int argc, char *argv[] ) { VikWindow *first_window; GdkPixbuf *main_icon; gboolean dashdash_already = FALSE; int i = 0; GError *error = NULL; gboolean gui_initialized; bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); g_thread_init ( NULL ); gdk_threads_init (); gui_initialized = gtk_init_with_args (&argc, &argv, "files+", entries, NULL, &error); if (!gui_initialized) { /* check if we have an error message */ if (error == NULL) { /* no error message, the GUI initialization failed */ const gchar *display_name = gdk_get_display_arg_name (); g_fprintf (stderr, "Failed to open display: %s\n", (display_name != NULL) ? display_name : " "); } else { /* yep, there's an error, so print it */ g_fprintf (stderr, "Parsing command line options failed: %s\n", error->message); g_error_free (error); g_fprintf (stderr, "Run \"%s --help\" to see the list of recognized options.\n",argv[0]); } return EXIT_FAILURE; } if (vik_version) { g_printf ("%s %s, Copyright (c) 2003-2007 Evan Battaglia\n", PACKAGE_NAME, PACKAGE_VERSION); return EXIT_SUCCESS; } if (!vik_debug) g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, mute_log, NULL); curl_download_init(); a_preferences_init (); a_vik_preferences_init (); /* Init modules/plugins */ modules_init(); a_mapcache_init (); a_background_init (); #ifdef VIK_CONFIG_GEOCACHES a_datasource_gc_init(); #endif /* Set the icon */ main_icon = gdk_pixbuf_from_pixdata(&viking_pixbuf, FALSE, NULL); gtk_window_set_default_icon(main_icon); /* Create the first window */ first_window = new_window(); gdk_threads_enter (); while ( ++i < argc ) { if ( strcmp(argv[i],"--") == 0 && !dashdash_already ) dashdash_already = TRUE; /* hack to open '-' */ else vik_window_open_file ( first_window, argv[i], argc == 2 ); } gtk_main (); gdk_threads_leave (); a_background_uninit (); a_mapcache_uninit (); a_dems_uninit (); a_preferences_uninit (); return 0; }
int main( int argc, char *argv[] ) { VikWindow *first_window; GdkPixbuf *main_icon; gboolean dashdash_already = FALSE; int i = 0; GError *error = NULL; gboolean gui_initialized; bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #if ! GLIB_CHECK_VERSION (2, 32, 0) g_thread_init ( NULL ); #endif gdk_threads_init (); gui_initialized = gtk_init_with_args (&argc, &argv, "files+", entries, NULL, &error); if (!gui_initialized) { /* check if we have an error message */ if (error == NULL) { /* no error message, the GUI initialization failed */ const gchar *display_name = gdk_get_display_arg_name (); g_fprintf (stderr, "Failed to open display: %s\n", (display_name != NULL) ? display_name : " "); } else { /* yep, there's an error, so print it */ g_fprintf (stderr, "Parsing command line options failed: %s\n", error->message); g_error_free (error); g_fprintf (stderr, "Run \"%s --help\" to see the list of recognized options.\n",argv[0]); } return EXIT_FAILURE; } if (vik_version) { g_printf ("%s %s\nCopyright (c) 2003-2008 Evan Battaglia\nCopyright (c) 2008-2012 Viking's contributors\n", PACKAGE_NAME, PACKAGE_VERSION); return EXIT_SUCCESS; } #if GLIB_CHECK_VERSION (2, 32, 0) if (vik_debug) g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, log_debug, NULL); #else if (!vik_debug) g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, mute_log, NULL); #endif #if HAVE_X11_XLIB_H XSetErrorHandler(myXErrorHandler); #endif // Discover if this is the very first run a_vik_very_first_run (); a_settings_init (); a_preferences_init (); a_vik_preferences_init (); a_layer_defaults_init (); a_download_init(); curl_download_init(); a_babel_init (); /* Init modules/plugins */ modules_init(); maps_layer_init (); a_mapcache_init (); a_background_init (); #ifdef VIK_CONFIG_GEOCACHES a_datasource_gc_init(); #endif vik_routing_prefs_init(); /* Set the icon */ main_icon = gdk_pixbuf_from_pixdata(&viking_pixbuf, FALSE, NULL); gtk_window_set_default_icon(main_icon); gdk_threads_enter (); // Ask for confirmation of default settings on first run set_auto_features_on_first_run (); /* Create the first window */ first_window = vik_window_new_window(); check_latest_version ( GTK_WINDOW(first_window) ); while ( ++i < argc ) { if ( strcmp(argv[i],"--") == 0 && !dashdash_already ) dashdash_already = TRUE; /* hack to open '-' */ else { VikWindow *newvw = first_window; gboolean change_filename = (i == 1); // Open any subsequent .vik files in their own window if ( i > 1 && check_file_magic_vik ( argv[i] ) ) { newvw = vik_window_new_window (); change_filename = TRUE; } vik_window_open_file ( newvw, argv[i], change_filename ); } } vik_window_new_window_finish ( first_window ); gtk_main (); gdk_threads_leave (); a_babel_uninit (); a_background_uninit (); a_mapcache_uninit (); a_dems_uninit (); a_layer_defaults_uninit (); a_preferences_uninit (); a_settings_uninit (); curl_download_uninit(); return 0; }