static GdkPixbufAnimation * splash_image_load (gboolean be_verbose) { GdkPixbufAnimation *pixbuf; gchar *filename; filename = gimp_personal_rc_file ("gimp-splash.png"); if (be_verbose) g_printerr ("Trying splash '%s' ... ", filename); pixbuf = gdk_pixbuf_animation_new_from_file (filename, NULL); g_free (filename); if (be_verbose) g_printerr (pixbuf ? "OK\n" : "failed\n"); if (pixbuf) return pixbuf; filename = gimp_personal_rc_file ("splashes"); pixbuf = splash_image_pick_from_dir (filename, be_verbose); g_free (filename); if (pixbuf) return pixbuf; filename = g_build_filename (gimp_data_directory (), "images", "gimp-splash.png", NULL); if (be_verbose) g_printerr ("Trying splash '%s' ... ", filename); pixbuf = gdk_pixbuf_animation_new_from_file (filename, NULL); g_free (filename); if (be_verbose) g_printerr (pixbuf ? "OK\n" : "failed\n"); if (pixbuf) return pixbuf; filename = g_build_filename (gimp_data_directory (), "splashes", NULL); pixbuf = splash_image_pick_from_dir (filename, be_verbose); g_free (filename); return pixbuf; }
static gboolean gimp_ui_manager_entry_load (GimpUIManager *manager, GimpUIManagerUIEntry *entry, GError **error) { gchar *filename = NULL; const gchar *menus_dir_override = g_getenv ("GIMP_TESTING_MENUS_DIR"); /* In order for test cases to be able to run without GIMP being * installed yet, allow them to override the menus directory to the * menus dir in the source root */ if (menus_dir_override) filename = g_build_filename (menus_dir_override, entry->basename, NULL); else filename = g_build_filename (gimp_data_directory (), "menus", entry->basename, NULL); if (manager->gimp->be_verbose) g_print ("loading menu '%s' for %s\n", gimp_filename_to_utf8 (filename), entry->ui_path); entry->merge_id = gtk_ui_manager_add_ui_from_file (GTK_UI_MANAGER (manager), filename, error); g_free (filename); if (! entry->merge_id) return FALSE; return TRUE; }
/* ---------------------------------- * gap_ffpar_getPresetList * ---------------------------------- * returns a list of all available encoder presets. * the list includes presets files found in user specific $GIMPDIR/video_encoder_presets * or in systemwide $GIMPDATADIR/video_encoder_presets. * * Note that Hardcoded presetes are not included in the list * but the presetId is generated as unique value > offset for hardcoded presets. */ GapGveFFMpegValues * gap_ffpar_getPresetList() { GapGveFFMpegValues *epp; GapGveFFMpegValues *eppPrev; char *presetDir; eppPrev = eppRoot; for(epp = eppRoot; epp != NULL; epp = epp->next) { eppPrev = epp; } /* system wide data directory example: /usr/local/share/gimp/2.0 */ presetDir = g_build_filename(gimp_data_directory(), GAP_VIDEO_ENCODER_PRESET_DIR, NULL); p_add_presets_from_directory(eppPrev, presetDir); g_free(presetDir); /* user specific directory example: /home/hof/.gimp-2.6 * (preset names that are already present in previous processed directory * will be overwritten. i.e. user specific variant is preferred) */ presetDir = g_build_filename(gimp_directory(), GAP_VIDEO_ENCODER_PRESET_DIR, NULL); p_add_presets_from_directory(eppPrev, presetDir); g_free(presetDir); return(eppRoot); } /* end gap_ffpar_getPresetList */
/** * gimp_gtkrc: * * Returns the name of GIMP's application-specific gtkrc file. * * The returned string is owned by GIMP and must not be modified or * freed. The returned string is in the encoding used for filenames by * GLib, which isn't necessarily UTF-8. (On Windows it always is * UTF-8.) * * Returns: The name of GIMP's application-specific gtkrc file. **/ const gchar * gimp_gtkrc (void) { static gchar *gimp_gtkrc_filename = NULL; if (! gimp_gtkrc_filename) gimp_gtkrc_filename = g_build_filename (gimp_data_directory (), "themes", "Default", "gtkrc", NULL); return gimp_gtkrc_filename; }
static GdkPixbuf * about_dialog_load_logo (void) { GdkPixbuf *pixbuf; gchar *filename; filename = g_build_filename (gimp_data_directory (), "images", "gimp-logo.png", NULL); pixbuf = gdk_pixbuf_new_from_file (filename, NULL); g_free (filename); return pixbuf; }
gboolean gimp_language_store_parse_iso_codes (GimpLanguageStore *store, GError **error) { #ifdef HAVE_ISO_CODES static const GMarkupParser markup_parser = { iso_codes_parser_start_element, iso_codes_parser_end_element, NULL, /* characters */ NULL, /* passthrough */ NULL /* error */ }; GimpXmlParser *xml_parser; gchar *filename; gboolean success; IsoCodesParser parser = { 0, }; g_return_val_if_fail (GIMP_IS_LANGUAGE_STORE (store), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); iso_codes_parser_init (); parser.store = g_object_ref (store); xml_parser = gimp_xml_parser_new (&markup_parser, &parser); #ifdef G_OS_WIN32 filename = g_build_filename (gimp_data_directory (), "..", "..", "xml", "iso-codes", "iso_639.xml", NULL); #else filename = g_build_filename (ISO_CODES_LOCATION, "iso_639.xml", NULL); #endif success = gimp_xml_parser_parse_file (xml_parser, filename, error); g_free (filename); gimp_xml_parser_free (xml_parser); g_object_unref (parser.store); return success; #endif return TRUE; }
/* * Parse the ISO-639 code list if available on this system, and fill * @base_lang_list with English names of all needed base codes. * * It will also fill the static @all_lang_list. */ static gboolean parse_iso_codes (GHashTable *base_lang_list, GError **error) { gboolean success = TRUE; #ifdef HAVE_ISO_CODES static const GMarkupParser markup_parser = { iso_codes_parser_start_element, iso_codes_parser_end_element, NULL, /* characters */ NULL, /* passthrough */ NULL /* error */ }; GimpXmlParser *xml_parser; gchar *filename; IsoCodesParser parser = { 0, }; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); iso_codes_parser_init (); parser.base_lang_list = g_hash_table_ref (base_lang_list); xml_parser = gimp_xml_parser_new (&markup_parser, &parser); #ifdef G_OS_WIN32 filename = g_build_filename (gimp_data_directory (), "..", "..", "xml", "iso-codes", "iso_639.xml", NULL); #else filename = g_build_filename (ISO_CODES_LOCATION, "iso_639.xml", NULL); #endif success = gimp_xml_parser_parse_file (xml_parser, filename, error); g_free (filename); gimp_xml_parser_free (xml_parser); g_hash_table_unref (parser.base_lang_list); #endif return success; }
static GdkPixbuf * about_dialog_load_logo (void) { GdkPixbuf *pixbuf; gchar *filename; filename = g_build_filename (gimp_data_directory (), "images", #ifdef GIMP_UNSTABLE "gimp-devel-logo.png", #else "gimp-logo.png", #endif NULL); pixbuf = gdk_pixbuf_new_from_file (filename, NULL); g_free (filename); return pixbuf; }
/** * gimp_directory: * * Returns the user-specific GIMP settings directory. If the * environment variable GIMP2_DIRECTORY exists, it is used. If it is * an absolute path, it is used as is. If it is a relative path, it * is taken to be a subdirectory of the home directory. If it is a * relative path, and no home directory can be determined, it is taken * to be a subdirectory of gimp_data_directory(). * * The usual case is that no GIMP2_DIRECTORY environment variable * exists, and then we use the GIMPDIR subdirectory of the home * directory. If no home directory exists, we use a per-user * subdirectory of gimp_data_directory(). In any case, we always * return some non-empty string, whether it corresponds to an existing * directory or not. * * The returned string is owned by GIMP and must not be modified or * freed. The returned string is in the encoding used for filenames by * GLib, which isn't necessarily UTF-8. (On Windows it always is * UTF-8.) * * Returns: The user-specific GIMP settings directory. **/ const gchar * gimp_directory (void) { static gchar *gimp_dir = NULL; const gchar *env_gimp_dir; const gchar *home_dir; if (gimp_dir) return gimp_dir; env_gimp_dir = g_getenv ("GIMP2_DIRECTORY"); home_dir = g_get_home_dir (); if (env_gimp_dir) { if (g_path_is_absolute (env_gimp_dir)) { gimp_dir = g_strdup (env_gimp_dir); } else { if (home_dir) { gimp_dir = g_build_filename (home_dir, env_gimp_dir, NULL); } else { gimp_dir = g_build_filename (gimp_data_directory (), env_gimp_dir, NULL); } } } else { if (home_dir) { gimp_dir = g_build_filename (home_dir, GIMPDIR, NULL); } else { gchar *user_name = g_strdup (g_get_user_name ()); gchar *subdir_name; #ifdef G_OS_WIN32 gchar *p = user_name; while (*p) { /* Replace funny characters in the user name with an * underscore. The code below also replaces some * characters that in fact are legal in file names, but * who cares, as long as the definitely illegal ones are * caught. */ if (!g_ascii_isalnum (*p) && !strchr ("-.,@=", *p)) *p = '_'; p++; } #endif #ifndef G_OS_WIN32 g_message ("warning: no home directory."); #endif subdir_name = g_strconcat (GIMPDIR ".", user_name, NULL); gimp_dir = g_build_filename (gimp_data_directory (), subdir_name, NULL); g_free (user_name); g_free (subdir_name); } } return gimp_dir; }
GtkWidget * tips_dialog_create (Gimp *gimp) { GimpGuiConfig *config; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *button; GtkWidget *image; gint tips_count; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); if (!tips) { GError *error = NULL; gchar *filename; filename = g_build_filename (gimp_data_directory (), "tips", "gimp-tips.xml", NULL); tips = gimp_tips_from_file (filename, &error); if (! tips) { GimpTip *tip; if (! error) { tip = gimp_tip_new (_("The GIMP tips file is empty!"), NULL); } else if (error->code == G_FILE_ERROR_NOENT) { tip = gimp_tip_new (_("The GIMP tips file appears to be " "missing!"), _("There should be a file called '%s'. " "Please check your installation."), gimp_filename_to_utf8 (filename)); } else { tip = gimp_tip_new (_("The GIMP tips file could not be parsed!"), "%s", error->message); } tips = g_list_prepend (tips, tip); } else if (error) { g_printerr ("Error while parsing '%s': %s\n", filename, error->message); } g_clear_error (&error); g_free (filename); } tips_count = g_list_length (tips); config = GIMP_GUI_CONFIG (gimp->config); if (config->last_tip_shown >= tips_count || config->last_tip_shown < 0) config->last_tip_shown = 0; current_tip = g_list_nth (tips, config->last_tip_shown); if (tips_dialog) return tips_dialog; tips_dialog = gimp_dialog_new (_("GIMP Tip of the Day"), "gimp-tip-of-the-day", NULL, 0, NULL, NULL, NULL); button = gtk_dialog_add_button (GTK_DIALOG (tips_dialog), _("_Previous Tip"), RESPONSE_PREVIOUS); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name ("go-previous", GTK_ICON_SIZE_BUTTON)); button = gtk_dialog_add_button (GTK_DIALOG (tips_dialog), _("_Next Tip"), RESPONSE_NEXT); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name ("go-next", GTK_ICON_SIZE_BUTTON)); gtk_dialog_set_response_sensitive (GTK_DIALOG (tips_dialog), RESPONSE_NEXT, tips_count > 1); gtk_dialog_set_response_sensitive (GTK_DIALOG (tips_dialog), RESPONSE_PREVIOUS, tips_count > 1); g_signal_connect (tips_dialog, "response", G_CALLBACK (tips_dialog_response), NULL); g_signal_connect (tips_dialog, "destroy", G_CALLBACK (tips_dialog_destroy), config); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (tips_dialog))), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); gtk_widget_show (hbox); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); image = gtk_image_new_from_icon_name (GIMP_STOCK_INFO, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); gtk_widget_show (image); gtk_container_set_focus_chain (GTK_CONTAINER (hbox), NULL); tip_label = gtk_label_new (NULL); gtk_label_set_selectable (GTK_LABEL (tip_label), TRUE); gtk_label_set_justify (GTK_LABEL (tip_label), GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap (GTK_LABEL (tip_label), TRUE); gtk_misc_set_alignment (GTK_MISC (tip_label), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (vbox), tip_label, TRUE, TRUE, 0); gtk_widget_show (tip_label); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); more_button = gtk_link_button_new_with_label ("http://docs.gimp.org/", /* a link to the related section in the user manual */ _("Learn more")); gtk_widget_show (more_button); gtk_box_pack_start (GTK_BOX (hbox), more_button, FALSE, FALSE, 0); g_signal_connect (more_button, "clicked", G_CALLBACK (more_button_clicked), gimp); tips_dialog_set_tip (current_tip->data); return tips_dialog; }
gboolean gimp_tags_user_install (void) { gchar *filename; GMarkupParser markup_parser; GimpXmlParser *xml_parser; const char *tags_locale; GimpTagsInstaller tags_installer = { 0, }; GError *error = NULL; gboolean result = TRUE; /* This is a special string to specify the language identifier to * look for in the gimp-tags-default.xml file. Please translate the * C in it according to the name of the po file used for * gimp-tags-default.xml. E.g. lithuanian for the translation, * that would be "tags-locale:lt". */ tags_locale = _("tags-locale:C"); if (g_str_has_prefix (tags_locale, "tags-locale:")) { tags_locale += strlen ("tags-locale:"); if (*tags_locale && *tags_locale != 'C') tags_installer.locale = tags_locale; } else { g_warning ("Wrong translation for 'tags-locale:', fix the translation!"); } tags_installer.buf = g_string_new (NULL); g_string_append (tags_installer.buf, "<?xml version='1.0' encoding='UTF-8'?>\n"); g_string_append (tags_installer.buf, "<tags>\n"); filename = g_build_filename (gimp_data_directory (), "tags", "gimp-tags-default.xml", NULL); markup_parser.start_element = gimp_tags_installer_load_start_element; markup_parser.end_element = gimp_tags_installer_load_end_element; markup_parser.text = gimp_tags_installer_load_text; markup_parser.passthrough = NULL; markup_parser.error = NULL; xml_parser = gimp_xml_parser_new (&markup_parser, &tags_installer); result = gimp_xml_parser_parse_file (xml_parser, filename, &error); g_free (filename); gimp_xml_parser_free (xml_parser); if (! result) { g_string_free (tags_installer.buf, TRUE); return FALSE; } g_string_append (tags_installer.buf, "\n</tags>\n"); filename = g_build_filename (gimp_directory (), GIMP_TAGS_FILE, NULL); result = g_file_set_contents (filename, tags_installer.buf->str, tags_installer.buf->len, &error); g_free (filename); g_string_free (tags_installer.buf, TRUE); if (! result) { g_warning ("Error while creating tags.xml: %s\n", error->message); g_error_free (error); return FALSE; } return TRUE; }
/** * gimp_directory: * * Returns the user-specific GIMP settings directory. If the * environment variable GIMP2_DIRECTORY exists, it is used. If it is * an absolute path, it is used as is. If it is a relative path, it * is taken to be a subdirectory of the home directory. If it is a * relative path, and no home directory can be determined, it is taken * to be a subdirectory of gimp_data_directory(). * * The usual case is that no GIMP2_DIRECTORY environment variable * exists, and then we use the GIMPDIR subdirectory of the home * directory. If no home directory exists, we use a per-user * subdirectory of gimp_data_directory(). In any case, we always * return some non-empty string, whether it corresponds to an existing * directory or not. * * The returned string is owned by GIMP and must not be modified or * freed. The returned string is in the encoding used for filenames by * GLib, which isn't necessarily UTF-8. (On Windows it always is * UTF-8.) * * Returns: The user-specific GIMP settings directory. **/ const gchar * gimp_directory (void) { static gchar *gimp_dir = NULL; static gchar *last_env_gimp_dir = NULL; const gchar *env_gimp_dir; const gchar *home_dir; env_gimp_dir = g_getenv ("GIMP2_DIRECTORY"); if (gimp_dir) { gboolean gimp2_directory_changed = FALSE; /* We have constructed the gimp_dir already. We can return * gimp_dir unless some parameter gimp_dir depends on has * changed. For now we just check for changes to GIMP2_DIRECTORY */ gimp2_directory_changed = (env_gimp_dir == NULL && last_env_gimp_dir != NULL) || (env_gimp_dir != NULL && last_env_gimp_dir == NULL) || (env_gimp_dir != NULL && last_env_gimp_dir != NULL && strcmp (env_gimp_dir, last_env_gimp_dir) != 0); if (! gimp2_directory_changed) { return gimp_dir; } else { /* Free the old gimp_dir and go on to update it */ g_free (gimp_dir); gimp_dir = NULL; } } /* Remember the GIMP2_DIRECTORY to next invocation so we can check * if it changes */ g_free (last_env_gimp_dir); last_env_gimp_dir = g_strdup (env_gimp_dir); home_dir = g_get_home_dir (); if (env_gimp_dir) { if (g_path_is_absolute (env_gimp_dir)) { gimp_dir = g_strdup (env_gimp_dir); } else { if (home_dir) { gimp_dir = g_build_filename (home_dir, env_gimp_dir, NULL); } else { gimp_dir = g_build_filename (gimp_data_directory (), env_gimp_dir, NULL); } } } else { if (home_dir) { gimp_dir = g_build_filename (home_dir, GIMPDIR, NULL); } else { gchar *user_name = g_strdup (g_get_user_name ()); gchar *subdir_name; #ifdef G_OS_WIN32 gchar *p = user_name; while (*p) { /* Replace funny characters in the user name with an * underscore. The code below also replaces some * characters that in fact are legal in file names, but * who cares, as long as the definitely illegal ones are * caught. */ if (!g_ascii_isalnum (*p) && !strchr ("-.,@=", *p)) *p = '_'; p++; } #endif #ifndef G_OS_WIN32 g_message ("warning: no home directory."); #endif subdir_name = g_strconcat (GIMPDIR ".", user_name, NULL); gimp_dir = g_build_filename (gimp_data_directory (), subdir_name, NULL); g_free (user_name); g_free (subdir_name); } } return gimp_dir; }