mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-04 21:12:47 -05:00
Implement reading of X resources, and -name to change the name under
which to look them up. [originally from svn r2084]
This commit is contained in:
@ -5,10 +5,18 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include "putty.h"
|
||||
#include "storage.h"
|
||||
|
||||
/* FIXME. For the moment, we do nothing at all here. */
|
||||
/*
|
||||
* For the moment, the only existing Unix utility is pterm and that
|
||||
* has no GUI configuration at all, so our write routines need do
|
||||
* nothing. Eventually I suppose these will read and write an rc
|
||||
* file somewhere or other.
|
||||
*/
|
||||
|
||||
void *open_settings_w(char *sessionname)
|
||||
{
|
||||
@ -27,19 +35,46 @@ void close_settings_w(void *handle)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Reading settings, for the moment, is done by retrieving X
|
||||
* resources from the X display. When we introduce disk files, I
|
||||
* think what will happen is that the X resources will override
|
||||
* PuTTY's inbuilt defaults, but that the disk files will then
|
||||
* override those. This isn't optimal, but it's the best I can
|
||||
* immediately work out.
|
||||
*/
|
||||
|
||||
static Display *display;
|
||||
|
||||
void *open_settings_r(char *sessionname)
|
||||
{
|
||||
return NULL;
|
||||
static int thing_to_return_an_arbitrary_non_null_pointer_to;
|
||||
display = GDK_DISPLAY();
|
||||
if (!display)
|
||||
return NULL;
|
||||
else
|
||||
return &thing_to_return_an_arbitrary_non_null_pointer_to;
|
||||
}
|
||||
|
||||
char *read_setting_s(void *handle, char *key, char *buffer, int buflen)
|
||||
{
|
||||
return NULL;
|
||||
char *val = XGetDefault(display, app_name, key);
|
||||
if (!val)
|
||||
return NULL;
|
||||
else {
|
||||
strncpy(buffer, val, buflen);
|
||||
buffer[buflen-1] = '\0';
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
int read_setting_i(void *handle, char *key, int defvalue)
|
||||
{
|
||||
return defvalue;
|
||||
char *val = XGetDefault(display, app_name, key);
|
||||
if (!val)
|
||||
return defvalue;
|
||||
else
|
||||
return atoi(val);
|
||||
}
|
||||
|
||||
void close_settings_r(void *handle)
|
||||
|
Reference in New Issue
Block a user