/* ----------------------------------------- * gap_base_get_gimprc_gdouble_value * ----------------------------------------- * get gdouble configuration value for the keyname gimprc_option_name from the gimprc file. * returns the configure value in constraint to the specified range * (between min_value and max_value) * the specified default_value is returned in case the gimprc * has no entry for the specified gimprc_option_name. */ gdouble gap_base_get_gimprc_gdouble_value (const char *gimprc_option_name , gdouble default_value, gdouble min_value, gdouble max_value) { char *value_string; gdouble value; value = default_value; value_string = gimp_gimprc_query(gimprc_option_name); if(value_string) { gchar *endptr; gchar *nptr; gdouble val; nptr = value_string; val = g_ascii_strtod(nptr, &endptr); if(nptr != endptr) { value = val; } g_free(value_string); } return (CLAMP(value, min_value, max_value)); } /* end gap_base_get_gimprc_gdouble_value */
static GList * script_fu_search_path (void) { gchar *path_str; GList *path = NULL; path_str = gimp_gimprc_query ("script-fu-path"); if (path_str) { GError *error = NULL; path = gimp_config_path_expand_to_files (path_str, &error); g_free (path_str); if (! path) { g_warning ("Can't convert script-fu-path to filesystem encoding: %s", error->message); g_clear_error (&error); } } return path; }
static gchar * script_fu_search_path (void) { gchar *path_str; gchar *path = NULL; path_str = gimp_gimprc_query ("script-fu-path"); if (path_str) { GError *error = NULL; path = g_filename_from_utf8 (path_str, -1, NULL, NULL, &error); g_free (path_str); if (! path) { g_warning ("Can't convert script-fu-path to filesystem encoding: %s", error->message); g_error_free (error); } } return path; }
/* -------------------------------- * gap_gve_sox_init_config * -------------------------------- */ void gap_gve_sox_init_config(GapGveCommonValues *cval) { char *value_string; gap_gve_sox_init_default(cval); value_string = gimp_gimprc_query("video_encode_com_util_sox"); if(value_string) { g_snprintf(cval->util_sox, sizeof(cval->util_sox), "%s", value_string); g_free(value_string); } value_string = gimp_gimprc_query("video_encode_com_util_sox_options"); if(value_string) { g_snprintf(cval->util_sox_options, sizeof(cval->util_sox_options), "%s", value_string); g_free(value_string); } } /* end gap_gve_sox_init_config */
/* ------------------------------------ * p_build_gvaidx_filename * ------------------------------------ * internal variante using track numbers starting at 0 */ static char * p_build_gvaidx_filename(const char *filename, gint32 track, const char *decoder_name , const char *suffix) { static gchar name[40]; gchar *vindex_file; gchar *filename_part; gchar *uri; gchar *gvaindexes_dir; uri = GVA_filename_to_uri(filename); if(uri) { GVA_md5_string(name, uri); } else { return (NULL); } filename_part = g_strdup_printf("%s.%d.%s.%s" , name , (int)track , decoder_name , suffix ); gvaindexes_dir = gimp_gimprc_query("video-index-dir"); if(gvaindexes_dir) { vindex_file = g_build_filename(gvaindexes_dir, filename_part, NULL); g_free(gvaindexes_dir); } else { /* nothing configured. in that case we use a default directory */ //vindex_file = g_build_filename(g_get_home_dir(), "gvaindexes", filename_part, NULL); vindex_file = g_build_filename(gimp_directory(), "gvaindexes", filename_part, NULL); } if(gap_debug) { printf("VIDINDEX: filename_part: %s\n", filename_part); printf("VIDINDEX: vindex_file: %s\n", vindex_file); } g_free(filename_part); return(vindex_file); } /* end p_build_gvaidx_filename */
/* ------------------------------------ * gap_player_cache_get_gimprc_bytesize * ------------------------------------ */ gint32 gap_player_cache_get_gimprc_bytesize(void) { gint32 bytesize; gchar *value_string; value_string = gimp_gimprc_query("video_playback_cache"); if(value_string) { char *ptr; bytesize = atol(value_string); for(ptr=value_string; *ptr != '\0'; ptr++) { if ((*ptr == 'M') || (*ptr == 'm')) { bytesize *= (1024 * 1024); break; } if ((*ptr == 'K') || (*ptr == 'k')) { bytesize *= 1024; break; } } if (bytesize < GAP_PLAYER_CACHE_FRAME_SZIE) { /* turns OFF the cache */ bytesize = 0; } g_free(value_string); } else { /* nothing configured in gimprc file * use cache with default size. */ bytesize = GAP_PLAYER_CACHE_DEFAULT_MAX_BYTESIZE; } return (bytesize); } /* end gap_player_cache_get_gimprc_bytesize */
/* ----------------------------------------- * gap_base_get_gimprc_int_value * ----------------------------------------- * get integer configuration value for the keyname gimprc_option_name from the gimprc file. * returns the configure value in constraint to the specified range * (between min_value and max_value) * the specified default_value is returned in case the gimprc * has no entry for the specified gimprc_option_name. */ gint32 gap_base_get_gimprc_int_value (const char *gimprc_option_name , gint32 default_value, gint32 min_value, gint32 max_value) { char *value_string; gint32 value; value = default_value; value_string = gimp_gimprc_query(gimprc_option_name); if(value_string) { value = atol(value_string); g_free(value_string); } return (CLAMP(value, min_value, max_value)); } /* end p_get_gimprc_int_value */
/* ---------------------------------- * GVA_build_video_toc_filename * ---------------------------------- */ char * GVA_build_video_toc_filename(const char *filename, const char *decoder_name) { static gchar name[40]; gchar *toc_file; gchar *filename_part; gchar *uri; gchar *gvaindexes_dir; uri = GVA_filename_to_uri(filename); if(uri) { GVA_md5_string(name, uri); } else { printf("TOC-NAME: uri is NULL filename:%s\n", filename); return (NULL); } filename_part = g_strdup_printf("%s.%s.toc", name, decoder_name); gvaindexes_dir = gimp_gimprc_query("video-index-dir"); if(gvaindexes_dir) { toc_file = g_build_filename(gvaindexes_dir, filename_part, NULL); g_free(gvaindexes_dir); } else { /* nothing configured. in that case we use a default directory */ //toc_file = g_build_filename(g_get_home_dir(), "gvaindexes", filename_part, NULL); toc_file = g_build_filename(gimp_directory(), "gvaindexes", filename_part, NULL); } if(gap_debug) { printf("TOC-NAME: filename_part: %s\n", filename_part); printf("TOC-NAME: toc_file: %s\n", toc_file); } g_free(filename_part); return(toc_file); } /* end GVA_build_video_toc_filename */
static void gimp_ensure_modules (void) { static GimpModuleDB *module_db = NULL; if (! module_db) { gchar *load_inhibit = gimp_get_module_load_inhibit (); gchar *module_path = gimp_gimprc_query ("module-path"); module_db = gimp_module_db_new (FALSE); gimp_module_db_set_load_inhibit (module_db, load_inhibit); gimp_module_db_load (module_db, module_path); g_free (module_path); g_free (load_inhibit); } }
/* -------------------------------- * gap_base_check_tooltips * -------------------------------- * check and enable/disable tooltips according to global gimprc settings */ gboolean gap_base_check_tooltips(gboolean *old_state) { char *value_string; gboolean new_state; gboolean changed; new_state = TRUE; changed = TRUE; value_string = gimp_gimprc_query("show-tooltips"); if(value_string != NULL) { if (strcmp(value_string, "no") == 0) { new_state = FALSE; } } if (old_state != NULL) { if(*old_state == new_state) { changed = FALSE; } } if (changed == TRUE) { if(new_state == TRUE) { gimp_help_enable_tooltips (); } else { gimp_help_disable_tooltips (); } } return (new_state); } /* end gap_base_check_tooltips */
/* This function is memoized. Once it finds the value it permanently * caches it * */ GList * parsepath (void) { gchar *rc_path, *path; if (parsepath_cached_path) return parsepath_cached_path; path = gimp_gimprc_query ("gimpressionist-path"); if (path) { rc_path = g_filename_from_utf8 (path, -1, NULL, NULL, NULL); g_free (path); } else { gchar *gimprc = gimp_personal_rc_file ("gimprc"); gchar *full_path = gimp_config_build_data_path ("gimpressionist"); gchar *esc_path = g_strescape (full_path, NULL); g_message (_("No %s in gimprc:\n" "You need to add an entry like\n" "(%s \"%s\")\n" "to your %s file."), "gflare-path", "gflare-path", esc_path, gimp_filename_to_utf8 (gimprc)); g_free (gimprc); g_free (esc_path); rc_path = gimp_config_path_expand (full_path, TRUE, NULL); g_free (full_path); } parsepath_cached_path = gimp_path_parse (rc_path, 16, FALSE, NULL); g_free (rc_path); return parsepath_cached_path; }
/* ----------------------------------------- * gap_base_get_gimprc_gboolean_value * ----------------------------------------- */ gboolean gap_base_get_gimprc_gboolean_value (const char *gimprc_option_name , gboolean default_value) { char *value_string; gboolean value; value = default_value; value_string = gimp_gimprc_query(gimprc_option_name); if(value_string) { value = FALSE; if((*value_string == 'y') || (*value_string == 'Y')) { value = TRUE; } g_free(value_string); } return (value); } /* end gap_base_get_gimprc_gboolean_value */
static gboolean save_dialog (void) { GtkWidget *dlg; GtkWidget *main_vbox; GtkWidget *entry; GtkWidget *table; GtkWidget *scrolled_window; GtkWidget *text_view; GtkTextBuffer *text_buffer; gchar *gump_from; gint row = 0; gboolean run; gimp_ui_init (PLUG_IN_BINARY, FALSE); /* check gimprc for a preferred "From:" address */ gump_from = gimp_gimprc_query ("gump-from"); if (gump_from) { g_strlcpy (mail_info.from, gump_from, BUFFER_SIZE); g_free (gump_from); } dlg = gimp_dialog_new (_("Send by Email"), PLUG_IN_ROLE, NULL, 0, gimp_standard_help_func, PLUG_IN_PROC, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("_Send"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dlg), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gimp_window_set_transient (GTK_WINDOW (dlg)); main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), main_vbox, TRUE, TRUE, 0); gtk_widget_show (main_vbox); /* table */ table = gtk_table_new (5, 2, FALSE); gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacing (GTK_TABLE (table), 0, 12); gtk_table_set_col_spacings (GTK_TABLE (table), 6); /* Filename entry */ entry = gtk_entry_new (); gtk_widget_set_size_request (entry, 200, -1); gtk_entry_set_max_length (GTK_ENTRY (entry), BUFFER_SIZE - 1); gtk_entry_set_text (GTK_ENTRY (entry), mail_info.filename); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("_Filename:"), 0.0, 0.5, entry, 1, FALSE); g_signal_connect (entry, "changed", G_CALLBACK (mail_entry_callback), mail_info.filename); /* To entry */ entry = gtk_entry_new (); gtk_widget_set_size_request (entry, 200, -1); gtk_entry_set_max_length (GTK_ENTRY (entry), BUFFER_SIZE - 1); gtk_entry_set_text (GTK_ENTRY (entry), mail_info.receipt); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, C_("email-address", "_To:"), 0.0, 0.5, entry, 1, FALSE); g_signal_connect (entry, "changed", G_CALLBACK (mail_entry_callback), mail_info.receipt); gtk_widget_grab_focus (entry); /* From entry */ entry = gtk_entry_new (); gtk_widget_set_size_request (entry, 200, -1); gtk_entry_set_max_length (GTK_ENTRY (entry), BUFFER_SIZE - 1); gtk_entry_set_text (GTK_ENTRY (entry), mail_info.from); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, C_("email-address", "_From:"), 0.0, 0.5, entry, 1, FALSE); g_signal_connect (entry, "changed", G_CALLBACK (mail_entry_callback), mail_info.from); /* Subject entry */ entry = gtk_entry_new (); gtk_widget_set_size_request (entry, 200, -1); gtk_entry_set_max_length (GTK_ENTRY (entry), BUFFER_SIZE - 1); gtk_entry_set_text (GTK_ENTRY (entry), mail_info.subject); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("S_ubject:"), 0.0, 0.5, entry, 1, FALSE); g_signal_connect (entry, "changed", G_CALLBACK (mail_entry_callback), mail_info.subject); /* Body */ scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start (GTK_BOX (main_vbox), scrolled_window, TRUE, TRUE, 0); gtk_widget_show (scrolled_window); text_buffer = gtk_text_buffer_new (NULL); g_signal_connect (text_buffer, "changed", G_CALLBACK (mesg_body_callback), NULL); gtk_text_buffer_set_text (text_buffer, mail_info.comment, -1); text_view = gtk_text_view_new_with_buffer (text_buffer); g_object_unref (text_buffer); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD); gtk_container_add (GTK_CONTAINER (scrolled_window), text_view); gtk_widget_show (text_view); gtk_widget_show (dlg); run = (gimp_dialog_run (GIMP_DIALOG (dlg)) == GTK_RESPONSE_OK); gtk_widget_destroy (dlg); return run; }
void fontsel_configure (GtkWidget *fontsel, gboolean init) { gchar *path; GList *list; GList *dirs; GtkWidget *parent; GtkWidget *clist; ProgressData *pdata; g_return_if_fail (fontsel != NULL); parent = gtk_widget_get_toplevel (fontsel); path = gimp_gimprc_query (FONTPATH_TOKEN); if (init) { if (path == NULL || !*path) { path = g_strdup (DEFAULT_FONTPATH); fontsel_directories_dialog (parent, _("You seem to be running the FreeType plug-in for the " "first time. You need to specify a list of folders " "where font files can be found on your system."), &path); } } else { init = fontsel_directories_dialog (parent, NULL, &path); } if (init) { pdata = g_object_get_data (G_OBJECT (fontsel), "progress_data"); start_progress (pdata); if (families) { g_tree_foreach (families, (GTraverseFunc) fontsel_remove_family, NULL); g_tree_destroy (families); } families = g_tree_new ((GCompareFunc)strcmp); dirs = gimp_path_parse (path, 128, TRUE, NULL); for (list = dirs; list; list = g_list_next (list)) fontsel_scan_directory (list->data); clist = g_object_get_data (G_OBJECT (fontsel), "family_list"); gtk_clist_freeze (GTK_CLIST (clist)); gtk_clist_clear (GTK_CLIST (clist)); g_tree_foreach (families, (GTraverseFunc) fontsel_family_list_insert, clist); gtk_clist_thaw (GTK_CLIST (clist)); stop_progress (pdata); } }
static GimpPDBStatusType run_pspi_settings (gint n_params, const GimpParam *param) { GimpRunMode run_mode = param[0].data.d_int32; GString *sp; int i; switch (run_mode) { case GIMP_RUN_NONINTERACTIVE: if (n_params != pspi_settings_nargs) return GIMP_PDB_CALLING_ERROR; if (param[1].data.d_int32 <= 0 || param[1].data.d_int32 > 10) return GIMP_PDB_CALLING_ERROR; sp = g_string_new (""); for (i = 0; i < param[1].data.d_int32; i++) { if (sp->len > 0) g_string_append_c (sp, G_SEARCHPATH_SEPARATOR); g_string_append (sp, param[2].data.d_stringarray[i]); search_path = sp->str; } break; case GIMP_RUN_INTERACTIVE: /* Possibly retrieve data */ i = gimp_get_data_size (PSPI_PATH_TOKEN); if (i > 0) { search_path = g_malloc (i); gimp_get_data (PSPI_PATH_TOKEN, search_path); } else { search_path = gimp_gimprc_query (PSPI_PATH_TOKEN); if (search_path == NULL) search_path = g_strdup (""); } if (! pspi_settings_dialog (&search_path)) return GIMP_PDB_CANCEL; gimp_message (_("The new search path will be used next time GIMP is started")); break; case GIMP_RUN_WITH_LAST_VALS: break; default: break; } if (search_path == NULL) search_path = g_strdup (""); gimp_set_data (PSPI_PATH_TOKEN, search_path, strlen (search_path) + 1); gimp_gimprc_set (PSPI_PATH_TOKEN, search_path); return GIMP_PDB_SUCCESS; }
static void init (void) { GimpMessageHandlerType old_handler; gimp_plugin_domain_register (PLUGIN_NAME, NULL); setup_debug_mask (); old_handler = gimp_message_get_handler (); if (old_handler == GIMP_CONSOLE) gimp_message_set_handler (GIMP_MESSAGE_BOX); search_path = gimp_gimprc_query (PSPI_PATH_TOKEN); if (search_path == NULL) search_path = g_strdup (""); get_saved_plugin_data (); pspirc_values_modified = FALSE; scan_search_path (); /* Forget those PS plug-ins that weren't around any longer. */ g_hash_table_foreach_remove (plug_in_hash, check_present, NULL); /* Rewrite the pspirc file if necessary */ if (pspirc_values_modified) { gchar *pspirc_name = gimp_personal_rc_file (PSPIRC); gchar *temp_name = g_strconcat (pspirc_name, ".new", NULL); gchar *bak_name = g_strconcat (pspirc_name, ".bak", NULL); FILE *pspirc = fopen (temp_name, "w"); if (pspirc == NULL) g_message (_("Could not open %s for writing"), temp_name); else { PSPI_DEBUG (PSPIRC, g_print ("Saving pspirc file\n")); fprintf (pspirc, "<pspi-settings>\n"); g_hash_table_foreach (plug_in_hash, save_pspirc_entry, pspirc); fprintf (pspirc, "</pspi-settings>\n"); PSPI_DEBUG (PSPIRC, g_print ("\n")); fclose (pspirc); remove (bak_name); if (g_file_test (pspirc_name, G_FILE_TEST_EXISTS) && rename (pspirc_name, bak_name) != 0) g_message (_("Could not rename %s to %s"), pspirc_name, bak_name); else { if (rename (temp_name, pspirc_name) != 0) { g_message (_("Could not rename %s to %s"), temp_name, pspirc_name); if (rename (bak_name, pspirc_name) != 0) g_message (_("Could not rename %s to %s"), bak_name, pspirc_name); } else remove (bak_name); } } g_free (pspirc_name); g_free (temp_name); g_free (bak_name); } if (old_handler == GIMP_CONSOLE) gimp_message_set_handler (GIMP_CONSOLE); }