Do apply terminal settings when they are changed

master
Yevgen Muntyan 2006-04-08 21:09:02 -05:00
parent e9a83d008c
commit 58a319710e
6 changed files with 77 additions and 26 deletions

View File

@ -29,8 +29,6 @@
#include <string.h>
#define MOO_TERM_PREFS_PREFIX "Terminal"
#define NEW_KEY_BOOL(s__,v__) moo_prefs_new_key_bool (MOO_TERM_PREFS_PREFIX "/" s__, v__)
#define NEW_KEY_INT(s__,v__) moo_prefs_new_key_int (MOO_TERM_PREFS_PREFIX "/" s__, v__)
#define NEW_KEY_STRING(s__,v__) moo_prefs_new_key_string (MOO_TERM_PREFS_PREFIX "/" s__, v__)
@ -49,7 +47,8 @@
#endif /* ! __WIN32__ */
static void set_defaults (void)
void
_moo_term_init_settings (void)
{
GtkSettings *settings;
GtkStyle *style;
@ -78,10 +77,13 @@ static void set_defaults (void)
void
_moo_term_apply_settings (MooTerm *term)
{
set_defaults ();
moo_term_set_font_from_string (term, GET_STRING (MOO_TERM_PREFS_FONT));
gtk_widget_modify_text (GTK_WIDGET (term), GTK_STATE_NORMAL,
GET_COLOR (MOO_TERM_PREFS_FOREGROUND));
gtk_widget_modify_base (GTK_WIDGET (term), GTK_STATE_NORMAL,
GET_COLOR (MOO_TERM_PREFS_BACKGROUND));
if (GET_BOOL (MOO_TERM_PREFS_CURSOR_BLINKS))
{
int t = GET_INT (MOO_TERM_PREFS_CURSOR_BLINK_TIME);
@ -116,7 +118,7 @@ GtkWidget *moo_term_prefs_page_new (void)
"page",
MOO_TERM_PREFS_PREFIX);
set_defaults ();
_moo_term_init_settings ();
return page;
}

View File

@ -20,11 +20,10 @@ G_BEGIN_DECLS
GtkWidget *moo_term_prefs_page_new (void);
void moo_term_set_prefs_prefix (const char *prefix);
const char *moo_term_get_prefs_prefix (void);
const char *moo_term_setting (const char *setting_name);
/* keep in sync with list in mooterm-prefs.c */
#define MOO_TERM_PREFS_PREFIX "Terminal"
#define MOO_TERM_PREFS_FONT "font"
#define MOO_TERM_PREFS_FOREGROUND "foreground"
@ -32,8 +31,6 @@ const char *moo_term_setting (const char *setting_name);
#define MOO_TERM_PREFS_CURSOR_BLINKS "cursor_blinks"
#define MOO_TERM_PREFS_CURSOR_BLINK_TIME "cursor_blink_time"
#define MOO_TERM_PREFS_SAVE_SELECTION_DIR "save_selection_dir"
G_END_DECLS

View File

@ -181,6 +181,7 @@ struct _MooTermPrivate {
buf_scrollback ((term)->priv->buffer))
void _moo_term_apply_settings (MooTerm *term);
void _moo_term_init_settings (void);
void _moo_term_set_window_title (MooTerm *term,
const char *title);
void _moo_term_set_icon_name (MooTerm *term,

View File

@ -351,6 +351,8 @@ moo_term_init (MooTerm *term)
"feed-child",
G_CALLBACK (moo_term_feed_child),
term);
_moo_term_init_settings ();
}
@ -533,8 +535,6 @@ moo_term_realize (GtkWidget *widget)
_moo_term_update_palette (term);
_moo_term_size_changed (term);
_moo_term_apply_settings (term);
term->priv->im = gtk_im_multicontext_new ();
gtk_im_context_set_client_window (term->priv->im, widget->window);
gtk_im_context_set_use_preedit (term->priv->im, FALSE);

View File

@ -11,8 +11,10 @@
* See COPYING file that comes with this distribution.
*/
#define MOOTERM_COMPILATION
#include "mooterm/mootermwindow.h"
#include "mooterm/mooterm-prefs.h"
#include "mooterm/mooterm-private.h"
#include "mooutils/moocompat.h"
#include "mooutils/moodialogs.h"
#include "mooutils/mooutils-fs.h"
@ -25,10 +27,15 @@ static void moo_term_window_init (MooTermWindow *win
static GObject *moo_term_window_constructor (GType type,
guint n_props,
GObjectConstructParam *props);
static void moo_term_window_destroy (GtkObject *object);
static void copy_clipboard (MooTerm *term);
static void paste_clipboard (MooTerm *term);
static void prefs_notify (const char *key,
const GValue *newval,
MooTermWindow *window);
/* MOO_TYPE_TERM_WINDOW */
G_DEFINE_TYPE (MooTermWindow, moo_term_window, MOO_TYPE_WINDOW)
@ -40,6 +47,7 @@ static void moo_term_window_class_init (MooTermWindowClass *klass)
MooWindowClass *window_class = MOO_WINDOW_CLASS (klass);
gobject_class->constructor = moo_term_window_constructor;
GTK_OBJECT_CLASS(klass)->destroy = moo_term_window_destroy;
moo_window_class_set_id (window_class, "Terminal", "Terminal");
@ -137,6 +145,14 @@ static GObject *moo_term_window_constructor (GType
window->terminal = MOO_TERM (terminal);
gtk_widget_show (MOO_WINDOW(window)->vbox);
_moo_term_apply_settings (window->terminal);
window->prefs_notify_id =
moo_prefs_notify_connect (MOO_TERM_PREFS_PREFIX,
MOO_PREFS_MATCH_PREFIX,
(MooPrefsNotify) prefs_notify,
window, NULL);
#if 0
TODO TODO
// GtkWidget *popup =
@ -151,20 +167,54 @@ TODO TODO
}
void moo_term_window_apply_settings (MooTermWindow *window)
static void
moo_term_window_destroy (GtkObject *object)
{
MooTermWindow *window = MOO_TERM_WINDOW (object);
if (window->prefs_notify_id)
moo_prefs_notify_disconnect (window->prefs_notify_id);
if (window->apply_prefs_idle)
g_source_remove (window->apply_prefs_idle);
window->prefs_notify_id = 0;
window->apply_prefs_idle = 0;
GTK_OBJECT_CLASS (moo_term_window_parent_class)->destroy (object);
}
static gboolean
apply_prefs (MooTermWindow *window)
{
window->apply_prefs_idle = 0;
_moo_term_apply_settings (window->terminal);
return FALSE;
}
static void
prefs_notify (G_GNUC_UNUSED const char *key,
G_GNUC_UNUSED const GValue *newval,
MooTermWindow *window)
{
g_return_if_fail (MOO_IS_TERM_WINDOW (window));
g_signal_emit_by_name (window->terminal, "apply_settings", NULL);
if (!window->apply_prefs_idle)
window->apply_prefs_idle =
g_idle_add ((GSourceFunc) apply_prefs, window);
}
GtkWidget *moo_term_window_new (void)
GtkWidget *
moo_term_window_new (void)
{
return GTK_WIDGET (g_object_new (MOO_TYPE_TERM_WINDOW, NULL));
return g_object_new (MOO_TYPE_TERM_WINDOW, NULL);
}
MooTerm *moo_term_window_get_term (MooTermWindow *window)
MooTerm *
moo_term_window_get_term (MooTermWindow *window)
{
g_return_val_if_fail (MOO_IS_TERM_WINDOW (window), NULL);
return window->terminal;

View File

@ -35,9 +35,10 @@ typedef struct _MooTermWindowClass MooTermWindowClass;
struct _MooTermWindow
{
MooWindow parent;
GType term_type;
MooTerm *terminal;
guint prefs_notify_id;
guint apply_prefs_idle;
};
struct _MooTermWindowClass