summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormuzuiget <muzuiget@gmail.com>2010-08-19 05:40:57 +0800
committerArx Cruz <arxcruz@src.gnome.org>2011-01-04 11:29:49 -0200
commite5467650a641694c82d85cc5d34a5ece28fd51f0 (patch)
treeb87a082b7d8d50a5013bed5c587c53752dd8494f /src
parentef3a33a142620fee850351d14f4a1c191fc6e273 (diff)
Add font and no wrap mode support in text dialog
Diffstat (limited to 'src')
-rw-r--r--src/option.c24
-rw-r--r--src/text.c8
-rw-r--r--src/zenity.h2
3 files changed, 32 insertions, 2 deletions
diff --git a/src/option.c b/src/option.c
index f481345..2d6d8a4 100644
--- a/src/option.c
+++ b/src/option.c
@@ -97,6 +97,7 @@ static gchar *zenity_question_cancel_button;
/* Text Dialog Options */
static gboolean zenity_text_active;
+static gchar *zenity_text_font;
/* Warning Dialog Options */
static gboolean zenity_warning_active;
@@ -716,6 +717,15 @@ static GOptionEntry text_options[] = {
N_("Allow changes to text"),
NULL
},
+ {
+ "font",
+ '\0',
+ 0,
+ G_OPTION_ARG_STRING,
+ &zenity_text_font,
+ N_("Set the text font"),
+ N_("TEXT")
+ },
{
NULL
}
@@ -972,6 +982,9 @@ zenity_option_free (void) {
if (zenity_question_cancel_button)
g_free (zenity_question_cancel_button);
+ if (zenity_text_font)
+ g_free (zenity_text_font);
+
if (zenity_colorsel_color)
g_free (zenity_colorsel_color);
@@ -1163,6 +1176,7 @@ zenity_text_pre_callback (GOptionContext *context,
GError **error)
{
zenity_text_active = FALSE;
+ zenity_text_font = NULL;
return TRUE;
}
@@ -1544,7 +1558,13 @@ zenity_text_post_callback (GOptionContext *context,
if (results->mode == MODE_TEXTINFO) {
results->text_data->uri = zenity_general_uri;
results->text_data->editable = zenity_general_editable;
- }
+ results->text_data->no_wrap = zenity_general_dialog_no_wrap;
+ results->text_data->font = zenity_text_font;
+ } else {
+ if (zenity_text_font)
+ zenity_option_error (zenity_option_get_name (text_options, &zenity_text_font),
+ ERROR_SUPPORT);
+ }
return TRUE;
}
@@ -1895,7 +1915,7 @@ zenity_option_parse (gint argc, gchar **argv)
zenity_option_error (zenity_option_get_name (text_options, &zenity_general_uri), ERROR_SUPPORT);
if (zenity_general_dialog_no_wrap)
- if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING)
+ if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING && results->mode != MODE_TEXTINFO)
zenity_option_error (zenity_option_get_name (text_options, &zenity_general_dialog_no_wrap), ERROR_SUPPORT);
return results;
diff --git a/src/text.c b/src/text.c
index eb5f989..cd31c5f 100644
--- a/src/text.c
+++ b/src/text.c
@@ -134,6 +134,14 @@ zenity_text (ZenityData *data, ZenityTextData *text_data)
gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), text_buffer);
gtk_text_view_set_editable (GTK_TEXT_VIEW(text_view), text_data->editable);
+ if (text_data->no_wrap)
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW(text_view), GTK_WRAP_NONE);
+
+ if (text_data->font) {
+ PangoFontDescription *fontDesc = pango_font_description_from_string (text_data->font);
+ gtk_widget_modify_font(GTK_TEXT_VIEW(text_view), fontDesc);
+ }
+
if (text_data->uri)
zenity_util_fill_file_buffer (text_buffer, text_data->uri);
else
diff --git a/src/zenity.h b/src/zenity.h
index 537f5f0..6414140 100644
--- a/src/zenity.h
+++ b/src/zenity.h
@@ -104,6 +104,8 @@ typedef struct {
typedef struct {
gchar *uri;
gboolean editable;
+ gboolean no_wrap;
+ gchar *font;
GtkTextBuffer *buffer;
} ZenityTextData;