/** * gst_rtsp_message_init_response: * @msg: a #GstRTSPMessage * @code: the status code * @reason: the status reason or #NULL * @request: the request that triggered the response or #NULL * * Initialize @msg with @code and @reason. * * When @reason is #NULL, the default reason for @code will be used. * * When @request is not #NULL, the relevant headers will be copied to the new * response message. * * Returns: a #GstRTSPResult. */ GstRTSPResult gst_rtsp_message_init_response (GstRTSPMessage * msg, GstRTSPStatusCode code, const gchar * reason, const GstRTSPMessage * request) { g_return_val_if_fail (msg != NULL, GST_RTSP_EINVAL); gst_rtsp_message_unset (msg); if (reason == NULL) reason = gst_rtsp_status_as_text (code); msg->type = GST_RTSP_MESSAGE_RESPONSE; msg->type_data.response.code = code; msg->type_data.response.reason = g_strdup (reason); msg->type_data.response.version = GST_RTSP_VERSION_1_0; msg->hdr_fields = g_array_new (FALSE, FALSE, sizeof (RTSPKeyValue)); if (request) { gchar *header; /* copy CSEQ */ if (gst_rtsp_message_get_header (request, GST_RTSP_HDR_CSEQ, &header, 0) == GST_RTSP_OK) { gst_rtsp_message_add_header (msg, GST_RTSP_HDR_CSEQ, header); } /* copy session id */ if (gst_rtsp_message_get_header (request, GST_RTSP_HDR_SESSION, &header, 0) == GST_RTSP_OK) { char *pos; header = g_strdup (header); if ((pos = strchr (header, ';'))) { *pos = '\0'; } g_strchomp (header); gst_rtsp_message_take_header (msg, GST_RTSP_HDR_SESSION, header); } /* FIXME copy more headers? */ } return GST_RTSP_OK; }
static char * get_boot_arguments (void) { #if defined(__linux__) char *contents; gboolean res; contents = NULL; res = g_file_get_contents (LINUX_KERNEL_CMDLINE, &contents, NULL, NULL); if (!res) { g_free (contents); contents = NULL; } else { g_strchomp (contents); } return contents; #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) char kern_name[1024], root[1024], mopts[1024]; char *options; options = NULL; if (kenv(KENV_GET, "kernelname", kern_name, sizeof (kern_name)) == -1) { return options; } if (kenv(KENV_GET, "vfs.root.mountfrom.options", mopts, sizeof (mopts)) == -1) { g_strlcpy (mopts, "ro", sizeof (mopts)); } if (kenv(KENV_GET, "vfs.root.mountfrom", root, sizeof (root)) == -1) { g_strlcpy (root, "/", sizeof (root)); } options = g_strdup_printf ("%s %s root=%s", mopts, kern_name, root); return options; #else return NULL; #endif }
void cmd_delkey(const char *data, SERVER_REC * server, WI_ITEM_REC * item) { GHashTable *optlist; char *target; char contactName[CONTACT_SIZE] = ""; void *free_arg; if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST, "delkey", &optlist, &target)) return; if (item != NULL && IsNULLorEmpty(target)) target = (char *)window_item_get_target(item); if (IsNULLorEmpty(target)) { printtext(server, item != NULL ? window_item_get_target(item) : NULL, MSGLEVEL_CRAP, "\002FiSH:\002 No parameters. Usage: /delkey [-<server tag>] [<nick | #channel>]"); return; } server = cmd_options_get_server("delkey", optlist, server); if (server == NULL || !server->connected) cmd_param_error(CMDERR_NOT_CONNECTED); target = (char *)g_strchomp(target); if (getIniSectionForContact(server, target, contactName) == FALSE) return; if (deleteIniValue(contactName, "key", iniPath) == 1) { printtext(server, item != NULL ? window_item_get_target(item) : NULL, MSGLEVEL_CRAP, "\002FiSH:\002 Key for %s@%s successfully removed!", target, server->tag); } else { printtext(server, item != NULL ? window_item_get_target(item) : NULL, MSGLEVEL_CRAP, "\002FiSH:\002 No key found for %s@%s", target, server->tag); } }
static void haze_debug_print (PurpleDebugLevel level, const char *category, const char *arg_s) { gchar *argh = g_strchomp (g_strdup (arg_s)); gchar *domain = g_strdup_printf ("purple/%s", category); GLogLevelFlags log_level = debug_level_map[level]; /* The default log handler catches g_log. Calling log_to_debug_sender * and g_log duplicates debug messages */ if (flags & HAZE_DEBUG_PURPLE) g_log (domain, log_level, "%s", argh); else log_to_debug_sender (domain, log_level, argh); g_free (domain); g_free(argh); }
static void alarm_save(_Alarm *a, FILE *file) { char buf[STD_ASCTIME_BUF_SIZE]; struct tm tm; gmtime_r(&a->expiry, &tm); asctime_r(&tm, buf); g_strchomp(buf); fprintf(file, "<alarm id='%d' expiry='%ld' calendar='%d'" " key='%s'" " expiry_text='%s'" " serviceName='%s'" " applicationName='%s'/>\n", a->id, a->expiry, a->calendar, a->key, buf, a->serviceName ? : "", a->applicationName ? : ""); }
void rw_cfg_write_string (ConfigFile * cfg, gchar * section, gchar * key, gchar * value) { ConfigSection *sect; ConfigLine *line; cfg->changed = 1; sect = rw_cfg_find_section (cfg, section); if (!sect) sect = rw_cfg_create_section (cfg, section); if ((line = rw_cfg_find_string (sect, key))) { g_free (line->value); line->value = g_strchug (g_strchomp (g_strdup (value))); } else rw_cfg_create_string (sect, key, value); }
static int ReopenLastFonts(void) { char buffer[1024]; char *ffdir = getFontForgeUserDir(Config); FILE *old; int any = 0; if ( ffdir==NULL ) return( false ); sprintf( buffer, "%s/FontsOpenAtLastQuit", ffdir ); old = fopen(buffer,"r"); if ( old==NULL ) return( false ); while ( fgets(buffer,sizeof(buffer),old)!=NULL ) { if ( ViewPostScriptFont(g_strchomp(buffer),0)!=0 ) any = 1; } fclose(old); return( any ); }
static GList * cpufreq_monitor_sysfs_get_available_frequencies (CPUFreqMonitor *monitor) { gchar *path; GList *list = NULL; gchar **frequencies = NULL; gint i; guint cpu; gchar *buffer = NULL; GError *error = NULL; g_object_get (G_OBJECT (monitor), "cpu", &cpu, NULL); path = g_strdup_printf (CPUFREQ_SYSFS_BASE_PATH, cpu, "scaling_available_frequencies"); if (!cpufreq_file_get_contents (path, &buffer, NULL, &error)) { g_warning ("%s", error->message); g_error_free (error); g_free (path); return NULL; } g_free (path); buffer = g_strchomp (buffer); frequencies = g_strsplit (buffer, " ", -1); i = 0; while (frequencies[i]) { if (!g_list_find_custom (list, frequencies[i], compare)) list = g_list_prepend (list, g_strdup (frequencies[i])); i++; } g_strfreev (frequencies); g_free (buffer); return g_list_sort (list, compare); }
static GList * cpufreq_monitor_sysfs_get_available_governors (CPUFreqMonitor *monitor) { gchar *path; GList *list = NULL; gchar **governors = NULL; gint i; guint cpu; gchar *buffer = NULL; GError *error = NULL; g_object_get (G_OBJECT (monitor), "cpu", &cpu, NULL); path = g_strdup_printf (CPUFREQ_SYSFS_BASE_PATH, cpu, "scaling_available_governors"); if (!cpufreq_file_get_contents (path, &buffer, NULL, &error)) { g_warning ("%s", error->message); g_error_free (error); g_free (path); return NULL; } g_free (path); buffer = g_strchomp (buffer); governors = g_strsplit (buffer, " ", -1); i = 0; while (governors[i] != NULL) { list = g_list_prepend (list, g_strdup (governors[i])); i++; } g_strfreev (governors); g_free (buffer); return list; }
void stat_shutdown(struct pk_state *state, gboolean normal) { gchar **stats; gchar **cur; gchar *value; if (normal) { /* Log statistics */ for (stats = cur = stat_list(state); *cur != NULL; cur++) { value = stat_get(state, *cur); g_strchomp(value); pk_log(LOG_STATS, "%s: %s", *cur, value); g_free(value); } g_strfreev(stats); } g_hash_table_destroy(state->fuse->stat_buffers); g_mutex_free(state->fuse->stat_buffer_lock); }
static void audit_read (GvaProcess *process, GvaAuditData *data) { gchar *line; gchar *name; gchar *status; GString *string; gpointer value; line = g_strchomp (gva_process_stdout_read_line (process)); value = GUINT_TO_POINTER (data->output->len); g_ptr_array_add (data->output, g_strdup (line)); if (!gva_mame_verify_parse (line, &name, &status)) goto exit; g_hash_table_insert (data->output_index, g_strdup (name), value); /* Build a quoted, comma-separated list of games. */ string = g_hash_table_lookup (data->status_index, status); if (string != NULL) g_string_append_printf (string, ", \"%s\"", name); else { string = g_string_sized_new (1024); g_string_printf (string, "\"%s\"", name); g_hash_table_insert ( data->status_index, g_strdup (status), string); } gva_process_inc_progress (process); g_free (name); g_free (status); exit: g_free (line); }
GHashTable * ck_unix_pid_get_env_hash (pid_t pid) { GHashTable *hash; char *cmd; char buf[BUFSIZ]; FILE *fp; int i; hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); cmd = g_strdup_printf ("pargs -e %d", pid); fp = popen (cmd, "r"); g_free (cmd); while (fgets (buf, BUFSIZ, fp) != NULL) { g_strchomp (buf); if (g_str_has_prefix (buf, "envp[")) { char *skip_prefix; skip_prefix = strstr (buf, " "); if (skip_prefix != NULL) { char **vals; vals = g_strsplit (skip_prefix + 1, "=", 2); if (vals != NULL) { g_hash_table_insert (hash, g_strdup (vals[0]), g_strdup (vals[1])); g_strfreev (vals); } } } } out: pclose (fp); return hash; }
static void check_xml(GVirConfigDomain *domain, const char *reference_file) { const char *reference_path; GError *error = NULL; char *reference_xml; char *xml; reference_path = g_test_get_filename(G_TEST_DIST, "xml", reference_file, NULL); g_file_get_contents(reference_path, &reference_xml, NULL, &error); g_assert_no_error(error); /* I could not generate text files without a trailing \n with vim or * gedit, workaround this issue by removing trailing whitespace from * the reference file */ g_strchomp(reference_xml); xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(domain)); g_assert_cmpstr(xml, ==, reference_xml); g_free(xml); g_free(reference_xml); }
static char * client_read_line(struct client *client) { const char *p, *newline; size_t length; char *line; p = fifo_buffer_read(client->input, &length); if (p == NULL) return NULL; newline = memchr(p, '\n', length); if (newline == NULL) return NULL; line = g_strndup(p, newline - p); fifo_buffer_consume(client->input, newline - p + 1); return g_strchomp(line); }
static void sylk_parse_sheet (SylkReader *state) { char *buf, *utf8buf; gsize utf8_len; while (!state->finished && (buf = gsf_input_textline_ascii_gets (state->input)) != NULL) { g_strchomp (buf); utf8buf = g_convert_with_iconv (buf, -1, state->converter, NULL, &utf8_len, NULL); state->line_no++; sylk_parse_line (state, utf8buf, utf8_len); g_free (utf8buf); } if (!state->finished) sylk_read_warning (state, _("Missing closing 'E'")); }
void sven_cfg_write_string(ConfigFile * cfg, gchar * section, gchar * key, gchar * value) { ConfigSection *sect; ConfigLine *line; g_return_if_fail(cfg != NULL); g_return_if_fail(section != NULL); g_return_if_fail(key != NULL); sect = sven_cfg_find_section(cfg, section); if (!sect) sect = sven_cfg_create_section(cfg, section); if ((line = sven_cfg_find_string(sect, key))) { g_free(line->value); line->value = g_strchug(g_strchomp(g_strdup(value))); } else sven_cfg_create_string(sect, key, value); }
static GList* restore_or_add_email_address(AddressBookFile *abf, ItemPerson *item, GList *savedList, const gchar *email) { ItemEMail *itemMail = NULL; GList *walk; gboolean found; gchar *addr; if(!email) return savedList; found = FALSE; for (walk = savedList; walk; walk = walk->next) { itemMail = walk->data; if(itemMail && itemMail->address) { addr = g_strchomp(g_strdup(itemMail->address)); if (!strcmp(addr, email)) found = TRUE; g_free(addr); if (found) break; } } if (found) { addritem_person_add_email(item, itemMail); savedList = g_list_delete_link(savedList, walk); } /* something's fishy here */ else { ItemEMail *newEMail; newEMail = addritem_create_item_email(); addritem_email_set_address(newEMail, email); addrcache_id_email(abf->addressCache, newEMail); addritem_person_add_email(item, newEMail); addrbook_set_dirty(abf,TRUE); } return savedList; }
/** * Parse Atom 1.0 text tags of all sorts. * * @param htmlified If set to 1, then HTML is returned. * When set to 0, All HTML tags are removed * * @returns an escaped version of a text construct. */ static gchar * atom10_parse_text_construct (xmlNodePtr cur, gboolean htmlified) { gchar *type, *tmp, *ret = NULL; /* determine encoding mode */ type = xml_get_ns_attribute (cur, "type", NULL); /* not sure what MIME types are necessary... */ /* This that need to be de-encoded and should not contain sub-tags.*/ if (!type || !strcmp(type, "text")) { ret = (gchar *)xmlNodeListGetString (cur->doc, cur->xmlChildrenNode, 1); if (ret) { g_strchug (g_strchomp (ret)); if (htmlified) { tmp = atom10_mark_up_text_content (ret); g_free (ret); ret = tmp; } } } else if (!strcmp(type, "html")) { ret = xhtml_extract (cur, 0, NULL); if (!htmlified) ret = unhtmlize (unxmlize (ret)); } else if (!strcmp (type, "xhtml")) { /* The spec says to show the contents of the div tag that MUST be present */ ret = xhtml_extract (cur, 2, NULL); if (!htmlified) ret = unhtmlize (ret); } else { /* Invalid Atom feed */ ret = g_strdup ("This attribute was invalidly specified in this Atom feed."); } g_free (type); return ret; }
gboolean alter_tblock_data(GtkWidget *widget, gpointer data) { gint index = (GINT)OBJ_GET((widget),"index"); gfloat value = 0.0; gchar * tmpbuf = NULL; GdkColor color; TbField field = (TbField)OBJ_GET(widget,"handler"); if (!GTK_IS_WIDGET(gauge)) return FALSE; switch (field) { case TB_FONT_SCALE: case TB_LAYER: case TB_X_POS: case TB_Y_POS: value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget)); mtx_gauge_face_alter_text_block(MTX_GAUGE_FACE(gauge),index,field,(void *)&value); break; case TB_COLOR_DAY: case TB_COLOR_NITE: gtk_color_button_get_color(GTK_COLOR_BUTTON(widget),&color); mtx_gauge_face_alter_text_block(MTX_GAUGE_FACE(gauge),index,field,(void *)&color); break; case TB_FONT: tmpbuf = g_strdup(gtk_font_button_get_font_name (GTK_FONT_BUTTON(widget))); tmpbuf = g_strchomp(g_strdelimit(tmpbuf,"0123456789",' ')); mtx_gauge_face_alter_text_block(MTX_GAUGE_FACE(gauge),index,field,(void *)tmpbuf); g_free(tmpbuf); break; case TB_TEXT: tmpbuf = g_strdup(gtk_entry_get_text (GTK_ENTRY(widget))); mtx_gauge_face_alter_text_block(MTX_GAUGE_FACE(gauge),index,field,(void *)tmpbuf); g_free(tmpbuf); default: break; } return TRUE; }
static gchar * gcm_edid_parse_string (const guint8 *data) { gchar *text; guint i; guint replaced = 0; /* this is always 12 bytes, but we can't guarantee it's null * terminated or not junk. */ text = g_strndup ((const gchar *) data, 12); /* remove insane newline chars */ g_strdelimit (text, "\n\r", '\0'); /* remove spaces */ g_strchomp (text); /* nothing left? */ if (text[0] == '\0') { g_free (text); text = NULL; goto out; } /* ensure string is printable */ for (i = 0; text[i] != '\0'; i++) { if (!g_ascii_isprint (text[i])) { text[i] = '-'; replaced++; } } /* if the string is junk, ignore the string */ if (replaced > 4) { g_free (text); text = NULL; goto out; } out: return text; }
static gboolean parse_kernel_commandline (OstreeKernelArgs **out_args, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; g_autoptr(GFile) proc_cmdline = g_file_new_for_path ("/proc/cmdline"); g_autofree char *contents = NULL; gsize len; if (!g_file_load_contents (proc_cmdline, cancellable, &contents, &len, NULL, error)) goto out; g_strchomp (contents); ret = TRUE; *out_args = _ostree_kernel_args_from_string (contents); out: return ret; }
void heliotrope_debug_print(PurpleDebugLevel level, const char *category, const char *args) { PyGILState_STATE state = PyGILState_Ensure(); PyObject *result; char *message; message = g_strdup_printf("%s: %s", category, args); // Remove the trailing newline because Python's logging module // already appends a newline by default. message = g_strchomp(message); result = PyObject_CallObject(heliotrope_print_debug_cb, Py_BuildValue("(s)", message)); if (result == NULL) PyErr_Print(); g_free(message); Py_XDECREF(result); PyGILState_Release(state); }
/* * Load list with character strings of label names. Only none blank names * are loaded. */ GList *jpilot_load_custom_label( JPilotFile *pilotFile, GList *labelList ) { gint i; g_return_val_if_fail( pilotFile != NULL, NULL ); if( pilotFile->readMetadata ) { struct AddressAppInfo *ai = & pilotFile->addrInfo; for( i = 0; i < NUM_CUSTOM_LABEL; i++ ) { gchar *labelName = ai->labels[i+IND_CUSTOM_LABEL]; if( labelName ) { g_strchomp( labelName ); g_strchug( labelName ); if( *labelName != '\0' ) { labelName = jpilot_convert_encoding( labelName ); labelList = g_list_append( labelList, labelName ); } } } } return labelList; }
/** * gcr_secret_exchange_send: * @self: a #GcrSecretExchange object * @secret: (allow-none): optionally, a secret to send to the other side * @secret_len: length of @secret, or -1 if null terminated * * Send a reply to the other side of the secret exchange, optionally sending a * secret. * * gcr_secret_exchange_receive() must have been successfully called at least * once on this object. In other words this object must have received data * from the other side of the secret exchange, before we can send a secret. * * Returns: (transfer full): a newly allocated string to be sent to the other * side of the secret exchange */ gchar * gcr_secret_exchange_send (GcrSecretExchange *self, const gchar *secret, gssize secret_len) { GKeyFile *output; gchar *result; g_return_val_if_fail (GCR_IS_SECRET_EXCHANGE (self), NULL); if (!self->pv->derived) { g_warning ("gcr_secret_exchange_receive() must be called " "before calling this function"); return NULL; } output = g_key_file_new (); key_file_set_base64 (output, GCR_SECRET_EXCHANGE_PROTOCOL_1, "public", self->pv->publi, self->pv->n_publi); if (secret != NULL) { if (secret_len < 0) secret_len = strlen (secret); if (!perform_encrypt (self, output, secret, secret_len)) { g_key_file_free (output); return NULL; } } result = g_key_file_to_data (output, NULL, NULL); g_return_val_if_fail (result != NULL, NULL); g_strchomp (result); if (g_str_has_prefix (result, SECRET_EXCHANGE_PROTOCOL_1_PREFIX)) g_warning ("the prepared data does not have the correct protocol prefix"); g_key_file_free (output); return result; }
/** * Test whether we can move off file page. * \return <i>TRUE</i> if OK to move off page. */ static gboolean exp_html_move_file( void ) { gchar *sFile, *msg, *reason; AlertValue aval; sFile = gtk_editable_get_chars( GTK_EDITABLE(exphtml_dlg.entryHtml), 0, -1 ); g_strchug( sFile ); g_strchomp( sFile ); gtk_entry_set_text( GTK_ENTRY(exphtml_dlg.entryHtml), sFile ); exporthtml_parse_filespec( _exportCtl_, sFile ); g_free( sFile ); /* Test for directory */ if( exporthtml_test_dir( _exportCtl_ ) ) { return TRUE; } /* Prompt to create */ msg = g_strdup_printf( _( "HTML Output Directory '%s'\n" \ "does not exist. OK to create new directory?" ), _exportCtl_->dirOutput ); aval = alertpanel( _("Create Directory" ), msg, GTK_STOCK_NO, GTK_STOCK_YES, NULL ); g_free( msg ); if( aval != G_ALERTALTERNATE ) return FALSE; /* Create directory */ if( ! exporthtml_create_dir( _exportCtl_ ) ) { reason = exporthtml_get_create_msg( _exportCtl_ ); msg = g_strdup_printf( _( "Could not create output directory for HTML file:\n%s" ), reason ); aval = alertpanel_full(_("Failed to Create Directory"), msg, GTK_STOCK_CLOSE, NULL, NULL, FALSE, NULL, ALERT_ERROR, G_ALERTDEFAULT); g_free( msg ); return FALSE; } return TRUE; }
gboolean _ostree_kernel_args_append_proc_cmdline (OstreeKernelArgs *kargs, GCancellable *cancellable, GError **error) { gs_unref_object GFile *proc_cmdline_path = g_file_new_for_path ("/proc/cmdline"); gs_free char *proc_cmdline = NULL; gsize proc_cmdline_len = 0; gs_strfreev char **proc_cmdline_args = NULL; if (!g_file_load_contents (proc_cmdline_path, cancellable, &proc_cmdline, &proc_cmdline_len, NULL, error)) return FALSE; g_strchomp (proc_cmdline); proc_cmdline_args = g_strsplit (proc_cmdline, " ", -1); _ostree_kernel_args_append_argv (kargs, proc_cmdline_args); return TRUE; }
static void gdvd_button_new_dialog_callback (GtkWidget *widget, int id, GalDefineViewsDialog *dialog) { gchar *name; GtkTreeIter iter; GalView *view; GalViewCollectionItem *item; GalViewFactory *factory; switch (id) { case GTK_RESPONSE_OK: g_object_get (widget, "name", &name, "factory", &factory, NULL); if (name && factory) { g_strchomp(name); if (*name != '\0') { view = gal_view_factory_new_view (factory, name); gal_view_collection_append(dialog->collection, view); item = dialog->collection->view_data[dialog->collection->view_count-1]; gtk_list_store_append (GTK_LIST_STORE (dialog->model), &iter); gtk_list_store_set (GTK_LIST_STORE (dialog->model), &iter, COL_GALVIEW_NAME, name, COL_GALVIEW_DATA, item, -1); gal_view_edit (view, GTK_WINDOW (dialog)); g_object_unref (view); } } g_object_unref (factory); g_free (name); break; } gtk_widget_destroy (widget); }
TpDebugMessage * _tp_debug_message_new (gdouble timestamp, const gchar *domain, TpDebugLevel level, const gchar *message) { TpDebugMessage *self; GTimeVal tv; g_return_val_if_fail (domain != NULL, NULL); g_return_val_if_fail (message != NULL, NULL); self = g_object_new (TP_TYPE_DEBUG_MESSAGE, NULL); tv.tv_sec = (glong) timestamp; tv.tv_usec = ((timestamp - (int) timestamp) * 1e6); if (g_strrstr (domain, "/")) { gchar **parts = g_strsplit (domain, "/", 2); self->priv->domain = g_strdup (parts[0]); self->priv->category = g_strdup (parts[1]); g_strfreev (parts); } else { self->priv->domain = g_strdup (domain); self->priv->category = NULL; } self->priv->time = g_date_time_new_from_timeval_utc (&tv); self->priv->level = debug_level_to_log_level_flags (level); self->priv->message = g_strdup (message); g_strchomp (self->priv->message); return self; }
static int load_preset (const gchar *fn) { char line[1024] = ""; FILE *f; f = g_fopen (fn, "rt"); if (!f) { g_printerr ("Error opening file \"%s\" for reading!\n", gimp_filename_to_utf8 (fn)); return -1; } fgets (line, 10, f); if (strncmp (line, PRESETMAGIC, 4)) { fclose (f); return load_old_preset (fn); } restore_default_values (); while (!feof (f)) { char *tmps; if (!fgets (line, 1024, f)) break; g_strchomp (line); tmps = strchr (line, '='); if (!tmps) continue; *tmps = '\0'; tmps++; set_values (line, tmps); } fclose (f); return 0; }
EXPORT gboolean change_font(GtkWidget *widget, gpointer data) { gchar * tmpbuf = NULL; MtxGaugeFace *g = NULL; tmpbuf = (gchar *)gtk_font_button_get_font_name (GTK_FONT_BUTTON(widget)); /* Strip out the font size as the gauge lib uses a different scaling * method that scales with the size of the gauge */ tmpbuf = g_strchomp(g_strdelimit(tmpbuf,"0123456789",' ')); if (GTK_IS_WIDGET(gauge)) g = MTX_GAUGE_FACE(gauge); else return FALSE; if (hold_handlers) return TRUE; changed = TRUE; mtx_gauge_face_set_value_font(g, tmpbuf); return TRUE; }