void meta_prefs_init (void) { GSettings *settings; settings_schemas = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); settings = g_settings_new (SCHEMA_GENERAL); g_signal_connect (settings, "changed", G_CALLBACK (settings_changed), NULL); g_hash_table_insert (settings_schemas, SCHEMA_GENERAL, settings); settings = g_settings_new (SCHEMA_METACITY); g_signal_connect (settings, "changed", G_CALLBACK (settings_changed), NULL); g_hash_table_insert (settings_schemas, SCHEMA_METACITY, settings); /* Individual keys we watch outside of our schemas */ settings = g_settings_new (SCHEMA_INTERFACE); g_signal_connect (settings, "changed::" KEY_GNOME_ACCESSIBILITY, G_CALLBACK (settings_changed), NULL); g_signal_connect (settings, "changed::" KEY_GNOME_ANIMATIONS, G_CALLBACK (settings_changed), NULL); g_signal_connect (settings, "changed::" KEY_GNOME_CURSOR_THEME, G_CALLBACK (settings_changed), NULL); g_signal_connect (settings, "changed::" KEY_GNOME_CURSOR_SIZE, G_CALLBACK (settings_changed), NULL); g_hash_table_insert (settings_schemas, SCHEMA_INTERFACE, settings); /* Bindings have a separate handler, since they are in separate schemas * and work differently */ settings = g_settings_new (SCHEMA_BINDINGS); g_signal_connect (settings, "changed", G_CALLBACK (bindings_changed), NULL); g_hash_table_insert (settings_schemas, SCHEMA_BINDINGS, settings); /* Pick up initial values. */ handle_preference_init_enum (); handle_preference_init_bool (); handle_preference_init_string (); handle_preference_init_int (); init_bindings (); init_workspace_names (); }
void init() { char *home, *realname, *argv[4]; extern char *getlogin(); char buf[MAXPATHLEN]; #if defined(SYSV) && !defined(HPUX) && !defined(IRIX4) extern struct passwd *getpwuid(); /* sys-v forgot this in pwd.h! */ struct utsname ourhost; #else char ourhost[128]; #endif /* SYSV && !HPUX && !IRIX4 */ register char *p; struct passwd *entry; int cnt; #if defined(BSD) || defined(HPUX) || defined(IRIX4) struct hostent *hp; #endif /* BSD || HPUX || IRIX4 */ home = getenv("HOME"); if (realname = getenv("NAME")) { (void) strcpy(buf, realname); } argv[1] = "="; argv[3] = NULL; if (!(entry = getpwuid(getuid()))) if (p = getlogin()) strdup(login, p); else { strdup(login, "unknown"); print("I don't know you, but that's ok.\n"); } else { strdup(login, entry->pw_name); if (!home || !*home) home = entry->pw_dir; if (!realname && (realname = entry->pw_gecos)) { if (p = index(realname, ',')) *p = 0; for (p = buf; *realname; realname++) if (*realname == '&') *p++ = upper(*login), p += Strcpy(p, login+1); else *p++ = *realname; *p = 0; } endpwent(); } if (!home || !*home || Access(home, W_OK)) { if (home && *home) error(home); else print("No home!? "); print_more("Using \"%s\" as home.\n", home = ALTERNATE_HOME); } else { argv[0] = "home"; argv[2] = home; (void) add_option(&set_options, argv); } if (realname && *buf) { /* realname has already been copied to buf */ argv[0] = "realname"; argv[2] = buf; (void) add_option(&set_options, argv); } #ifdef HOMEMAIL strdup(spoolfile, sprintf(buf, "%s/%s", home, MAILFILE)); #else /* HOMEMAIL */ #ifdef ENV_MAIL if ((p = getenv("MAIL")) && *p) strdup(spoolfile, p); else #endif /* ENV_MAIL */ strdup(spoolfile, sprintf(buf, "%s/%s", MAILDIR, login)); #endif /* HOMEMAIL */ mailfile = ""; crt = 24; screen = 18; wrapcolumn = 0; /* Default is no wrap */ escape = DEF_ESCAPE; prompt = DEF_PROMPT; #if defined(BSD) || defined(HPUX) || defined(IRIX4) (void) gethostname(ourhost, sizeof ourhost); if (!(hp = gethostbyname(ourhost))) { if (ourname = (char **)calloc((unsigned)2, sizeof (char *))) strdup(ourname[0], ourhost); } else { int n = -1; cnt = 2; /* 1 for ourhost and 1 for NULL terminator */ for (p = hp->h_name; p && *p; p = hp->h_aliases[++n]) if (strcmp(ourhost, p)) /* if host name is different */ cnt++; if (ourname = (char **)malloc((unsigned)cnt * sizeof (char *))) { n = -1; cnt = 0; ourname[cnt++] = savestr(ourhost); for (p = hp->h_name; p && *p; p = hp->h_aliases[++n]) if (strcmp(ourhost, p)) /* if host name is different */ ourname[cnt++] = savestr(p); ourname[cnt++] = NULL; } } #else #ifdef SYSV if (ourname = (char **)calloc((unsigned)2, sizeof (char *))) { if ((uname (&ourhost) >= 0) && (*ourhost.nodename)) ourname[0] = savestr(ourhost.nodename); else { /* Try to use uuname -l to get host's name if uname didn't work */ char buff[50]; char *p; FILE *F; if (F = popen("exec uuname -l", "r")) { if ((fgets(buff, sizeof buff, F) == buff) && (p = strchr(buff, '\n'))) { *p = '\0'; /* eliminate newline */ ourname[0] = savestr (buff); } (void)pclose(F); } } } #endif /* SYSV */ #endif /* BSD || HPUX || IRIX4 */ if (ourname && ourname[0]) { for (p = buf, cnt = 0; ourname[cnt]; cnt++) { if (cnt) *p++ = ' '; p += Strcpy(p, ourname[cnt]); } argv[0] = "hostname"; argv[2] = buf; (void) add_option(&set_options, argv); } init_bindings(); }