Exemple #1
0
void gui_printtext_window_border(int x, int y)
{
	char *v0, *v1;
	int len;
	if (current_theme != NULL) {
		v1 = theme_format_expand(current_theme, "{window_border} ");
		len = format_real_length(v1, 1);
		v1[len] = '\0';
	}
	else {
		v1 = g_strdup(" ");
	}

	if (*v1 == '\0') {
		g_free(v1);
		v1 = g_strdup(" ");
	}

	if (clrtoeol_info->color != NULL) {
		char *color = g_strdup(clrtoeol_info->color);
		len = format_real_length(color, 0);
		color[len] = '\0';
		v0 = g_strconcat(color, v1, NULL);
		g_free(color);
		g_free(v1);
	} else {
		v0 = v1;
	}

	gui_printtext(x, y, v0);
	g_free(v0);
}
static PyObject *PyTheme_format_expand(PyTheme *self, PyObject *args, PyObject *kwds)
{
    static char *kwlist[] = {"format", "flags", NULL};
    char *format = "";
    int flags = 0;
    char *ret;
    PyObject *pyret;

    RET_NULL_IF_INVALID(self->data);

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|i", kwlist, 
           &format, &flags))
        return NULL;

    if (flags == 0)
        ret = theme_format_expand(self->data, format);
    else {
	theme_rm_col reset;
	strcpy(reset.m, "n");
        ret = theme_format_expand_data(self->data, (const char **)&format,
		reset, reset, NULL, NULL, EXPAND_FLAG_ROOT | flags);
    }

    if (ret)
    {
        pyret = PyString_FromString(ret);
        g_free(ret);
        return pyret;
    }

    Py_RETURN_NONE;
}
Exemple #3
0
static void theme_set_format(THEME_REC *theme, MODULE_THEME_REC *rec,
			     const char *module,
			     const char *key, const char *value)
{
	int num;

        num = format_find_tag(module, key);
	if (num != -1) {
		rec->formats[num] = g_strdup(value);
		rec->expanded_formats[num] = theme_format_expand(theme, value);
	}
}
Exemple #4
0
static void theme_show(THEME_SEARCH_REC *rec, const char *key, const char *value, int reset)
{
	MODULE_THEME_REC *theme;
	FORMAT_REC *formats;
	const char *text, *last_title;
	int n, first;

	formats = g_hash_table_lookup(default_formats, rec->name);
	theme = g_hash_table_lookup(current_theme->modules, rec->name);

	last_title = NULL; first = TRUE;
	for (n = 1; formats[n].def != NULL; n++) {
		text = theme != NULL && theme->formats[n] != NULL ?
			theme->formats[n] : formats[n].def;

		if (formats[n].tag == NULL)
			last_title = text;
		else if ((value != NULL && key != NULL && g_strcasecmp(formats[n].tag, key) == 0) ||
			 (value == NULL && (key == NULL || stristr(formats[n].tag, key) != NULL))) {
			if (first) {
				printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_FORMAT_TITLE, rec->short_name, formats[0].def);
				first = FALSE;
			}
			if (last_title != NULL)
				printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_FORMAT_SUBTITLE, last_title);
			if (reset || value != NULL) {
				theme = theme_module_create(current_theme, rec->name);
                                g_free_not_null(theme->formats[n]);
                                g_free_not_null(theme->expanded_formats[n]);

				text = reset ? formats[n].def : value;
				theme->formats[n] = reset ? NULL : g_strdup(value);
				theme->expanded_formats[n] = theme_format_expand(current_theme, text);
			}
			printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_FORMAT_ITEM, formats[n].tag, text);
			last_title = NULL;
		}
	}
}
Exemple #5
0
static void theme_init_module(THEME_REC *theme, const char *module,
			      CONFIG_REC *config)
{
	MODULE_THEME_REC *rec;
	FORMAT_REC *formats;
	int n;

	formats = g_hash_table_lookup(default_formats, module);
	g_return_if_fail(formats != NULL);

	rec = theme_module_create(theme, module);

	if (config != NULL)
		theme_read_formats(theme, module, config, rec);

	/* expand the remaining formats */
	for (n = 0; n < rec->count; n++) {
		if (rec->expanded_formats[n] == NULL) {
			rec->expanded_formats[n] =
				theme_format_expand(theme, formats[n].def);
		}
	}
}
Exemple #6
0
STATUSBAR_REC *statusbar_create(STATUSBAR_GROUP_REC *group,
                                STATUSBAR_CONFIG_REC *config,
                                MAIN_WINDOW_REC *parent_window)
{
	STATUSBAR_REC *bar;
	THEME_REC *theme;
        GSList *tmp;
	char *name, *value;

        g_return_val_if_fail(group != NULL, NULL);
        g_return_val_if_fail(config != NULL, NULL);
	g_return_val_if_fail(config->type != STATUSBAR_TYPE_WINDOW ||
			     parent_window != NULL, NULL);

	bar = g_new0(STATUSBAR_REC, 1);
	group->bars = g_slist_append(group->bars, bar);

	bar->group = group;

        bar->config = config;
        bar->parent_window = parent_window;

	irssi_set_dirty();
	bar->dirty = TRUE;
        bar->dirty_xpos = 0;

        signal_remove("terminal resized", (SIGNAL_FUNC) sig_terminal_resized);
	signal_remove("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized);
	signal_remove("mainwindow moved", (SIGNAL_FUNC) sig_mainwindow_resized);

	if (config->type == STATUSBAR_TYPE_ROOT) {
		/* top/bottom of the screen */
		mainwindows_reserve_lines(config->placement == STATUSBAR_TOP,
					  config->placement == STATUSBAR_BOTTOM);
                theme = current_theme;
	} else {
		/* top/bottom of the window */
		parent_window->statusbars =
			g_slist_append(parent_window->statusbars, bar);
		mainwindow_set_statusbar_lines(parent_window,
					       config->placement == STATUSBAR_TOP,
					       config->placement == STATUSBAR_BOTTOM);
		theme = parent_window != NULL && parent_window->active != NULL &&
			parent_window->active->theme != NULL ?
			parent_window->active->theme : current_theme;
	}

        signal_add("terminal resized", (SIGNAL_FUNC) sig_terminal_resized);
	signal_add("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized);
	signal_add("mainwindow moved", (SIGNAL_FUNC) sig_mainwindow_resized);

        /* get background color from sb_background abstract */
        name = g_strdup_printf("{sb_%s_bg}", config->name);
	value = theme_format_expand(theme, name);
	g_free(name);

	if (*value == '\0') {
                /* try with the statusbar group name */
		g_free(value);

		name = g_strdup_printf("{sb_%s_bg}", group->name);
		value = theme_format_expand(theme, name);
		g_free(name);

		if (*value == '\0') {
			/* fallback to default statusbar background
			   (also provides backwards compatibility..) */
                        g_free(value);
			value = theme_format_expand(theme, "{sb_background}");
		}
	}

	if (*value == '\0') {
                g_free(value);
		value = g_strdup("%8");
	}
	bar->color = g_strconcat("%n", value, NULL);
	g_free(value);

        statusbars_recalc_ypos(bar);
        signal_emit("statusbar created", 1, bar);

        /* create the items to statusbar */
	for (tmp = config->items; tmp != NULL; tmp = tmp->next) {
		SBAR_ITEM_CONFIG_REC *rec = tmp->data;

                statusbar_item_create(bar, rec);
	}
	return bar;
}
Exemple #7
0
static char *get_activity_list(MAIN_WINDOW_REC *window, int normal, int hilight)
{
        THEME_REC *theme;
	GString *str;
	GList *tmp;
        char *ret, *name, *format, *value;
        int is_det;

	str = g_string_new(NULL);

	theme = window != NULL && window->active != NULL &&
		window->active->theme != NULL ?
		window->active->theme : current_theme;

	for (tmp = activity_list; tmp != NULL; tmp = tmp->next) {
		WINDOW_REC *window = tmp->data;

		is_det = window->data_level >= DATA_LEVEL_HILIGHT;
		if ((!is_det && !normal) || (is_det && !hilight))
                        continue;

                /* comma separator */
		if (str->len > 0) {
			value = theme_format_expand(theme, "{sb_act_sep ,}");
			g_string_append(str, value);
			g_free(value);
		}

		switch (window->data_level) {
		case DATA_LEVEL_NONE:
		case DATA_LEVEL_TEXT:
			name = "{sb_act_text %d}";
			break;
		case DATA_LEVEL_MSG:
			name = "{sb_act_msg %d}";
			break;
		default:
                        if (window->hilight_color == NULL)
				name = "{sb_act_hilight %d}";
			else
                                name = NULL;
			break;
		}

		if (name != NULL)
			format = g_strdup_printf(name, window->refnum);
		else
			format = g_strdup_printf("{sb_act_hilight_color %s %d}",
						 window->hilight_color,
						 window->refnum);

		value = theme_format_expand(theme, format);
		g_string_append(str, value);
                g_free(value);

		g_free(format);
	}

	ret = str->len == 0 ? NULL : str->str;
        g_string_free(str, ret == NULL);
        return ret;
}
Exemple #8
0
static char *get_activity_list(MAIN_WINDOW_REC *window, int normal, int hilight)
{
        THEME_REC *theme;
	GString *str;
	GString *format;
	GList *tmp;
        char *ret, *name, *value;
        int is_det;
	int add_name = settings_get_bool("actlist_names");
	int pref_name = settings_get_bool("actlist_prefer_window_name");

	str = g_string_new(NULL);
	format = g_string_new(NULL);

	theme = window != NULL && window->active != NULL &&
		window->active->theme != NULL ?
		window->active->theme : current_theme;

	for (tmp = activity_list; tmp != NULL; tmp = tmp->next) {
		WINDOW_REC *window = tmp->data;

		is_det = window->data_level >= DATA_LEVEL_HILIGHT;
		if ((!is_det && !normal) || (is_det && !hilight))
                        continue;

                /* comma separator */
		if (str->len > 0) {
			value = theme_format_expand(theme, "{sb_act_sep ,}");
			g_string_append(str, value);
			g_free(value);
		}

		switch (window->data_level) {
		case DATA_LEVEL_NONE:
		case DATA_LEVEL_TEXT:
			name = "{sb_act_text %d";
			break;
		case DATA_LEVEL_MSG:
			name = "{sb_act_msg %d";
			break;
		default:
                        if (window->hilight_color == NULL)
				name = "{sb_act_hilight %d";
			else
                                name = NULL;
			break;
		}

		if (name != NULL)
			g_string_printf(format, name, window->refnum);
		else
			g_string_printf(format, "{sb_act_hilight_color %s %d",
						 window->hilight_color,
						 window->refnum);

		if (add_name && window->active != NULL)
			g_string_append_printf(format, ":%s",
				pref_name == 1 && window->name != NULL ?
				window->name : window->active->visible_name);
		g_string_append_c(format, '}');

		value = theme_format_expand(theme, format->str);
		g_string_append(str, value);
                g_free(value);
	}

	ret = str->len == 0 ? NULL : str->str;
        g_string_free(str, ret == NULL);
	g_string_free(format, TRUE);
        return ret;
}