xsane/xsane-0.995-eula-license-size.patch

422 lines
15 KiB
Diff
Raw Normal View History

diff -up xsane-0.995/src/xsane-front-gtk.c.eula-license-size xsane-0.995/src/xsane-front-gtk.c
--- xsane-0.995/src/xsane-front-gtk.c.eula-license-size 2007-05-17 15:35:06.000000000 +0200
+++ xsane-0.995/src/xsane-front-gtk.c 2007-11-29 16:57:15.000000000 +0100
@@ -1881,6 +1881,73 @@ void xsane_change_working_directory(void
/* ---------------------------------------------------------------------------------------------------------------------- */
+static GtkWidget *xsane_eula_license_textbox (gchar *text)
+{
+ GtkWidget *hbox = gtk_hbox_new(FALSE, 2);
+
+#ifdef HAVE_GTK_TEXT_VIEW_H
+ GtkWidget *scrolled_window, *text_view;
+ GtkTextBuffer *text_buffer;
+
+ /* create a scrolled window to get a vertical scrollbar */
+ scrolled_window = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_container_add(GTK_CONTAINER(hbox), scrolled_window);
+ gtk_widget_show(scrolled_window);
+
+ /* create the gtk_text_view widget */
+ text_view = gtk_text_view_new();
+ gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view), FALSE);
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text_view), GTK_WRAP_WORD);
+ gtk_container_add(GTK_CONTAINER(scrolled_window), text_view);
+ gtk_widget_show(text_view);
+
+ /* get the text_buffer widget and insert the text from file */
+ text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
+
+ gtk_text_buffer_insert_at_cursor(text_buffer, text, strlen (text));
+
+#else /* we do not have gtk_text_view, so we use gtk_text */
+ GtkWidget *text, *vscrollbar;
+
+ /* Create the gtk_text widget */
+ text = gtk_text_new(NULL, NULL);
+ gtk_text_set_editable(GTK_TEXT(text), FALSE); /* text is not editable */
+ gtk_text_set_word_wrap(GTK_TEXT(text), TRUE); /* wrap complete words */
+ gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 0);
+ gtk_widget_show(text);
+
+ /* Add a vertical scrollbar to the GtkText widget */
+ vscrollbar = gtk_vscrollbar_new(GTK_TEXT(text)->vadj);
+ gtk_box_pack_start(GTK_BOX(hbox), vscrollbar, FALSE, FALSE, 0);
+ gtk_widget_show(vscrollbar);
+
+ /* Freeze the text widget, ready for multiple updates */
+ gtk_text_freeze(GTK_TEXT(text));
+
+ gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, text, strlen (text));
+
+ /* Thaw the text widget, allowing the updates to become visible */
+ gtk_text_thaw(GTK_TEXT(text));
+#endif
+
+ return hbox;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void center_pane_callback (GtkWidget *pane, gpointer data)
+{
+ gint max_pos;
+
+ /* Center pane handle */
+ g_object_get (G_OBJECT (pane), "max-position", &max_pos, NULL);
+ gtk_paned_set_position (GTK_PANED (pane), (gint)(max_pos / 2));
+};
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static int eula_accept_flag;
static GtkWidget *eula_dialog = NULL;
@@ -1911,11 +1978,13 @@ static void xsane_eula_button_callback(G
int xsane_display_eula(int ask_for_accept)
/* returns FALSE if accepted, TRUE if not accepted */
{
- GtkWidget *vbox, *hbox, *button, *label, *frame;
+ GtkWidget *vbox, *hbox, *button, *frame, *pane;
GtkAccelGroup *accelerator_group;
char buf[1024];
char filename[PATH_MAX];
FILE *infile;
+ gint width, height;
+ GString *text;
DBG(DBG_proc, "xsane_display_eula(%d)\n", ask_for_accept);
@@ -1925,7 +1994,8 @@ int xsane_display_eula(int ask_for_accep
}
eula_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_size_request(eula_dialog, 550, 580);
+ gdk_window_get_geometry (gdk_get_default_root_window (), NULL, NULL, &width, &height, NULL);
+ gtk_widget_set_size_request(eula_dialog, MIN (550, (int)(0.9 * width)), MIN (580, (int)(0.9 * height)));
gtk_window_set_position(GTK_WINDOW(eula_dialog), GTK_WIN_POS_CENTER);
gtk_window_set_resizable(GTK_WINDOW(eula_dialog), TRUE);
g_signal_connect(GTK_OBJECT(eula_dialog), "delete_event", GTK_SIGNAL_FUNC(xsane_eula_delete_event), (void *) -1); /* -1 = cancel */
@@ -1955,6 +2025,11 @@ int xsane_display_eula(int ask_for_accep
xsane_set_window_icon(eula_dialog, 0);
#endif
+ pane = gtk_vpaned_new ();
+ g_signal_connect_after (G_OBJECT (pane), "realize", (GCallback)center_pane_callback, NULL);
+ gtk_box_pack_start(GTK_BOX(vbox), pane, TRUE, TRUE, 0);
+ gtk_widget_show (pane);
+
/* display XSane copyright message */
snprintf(buf, sizeof(buf), "XSane %s %s\n"
"%s %s\n"
@@ -1968,109 +2043,42 @@ int xsane_display_eula(int ask_for_accep
TEXT_HOMEPAGE, XSANE_HOMEPAGE,
TEXT_EMAIL_ADR, XSANE_EMAIL_ADR);
- label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
- gtk_widget_show(label);
-
- /* add hbox with text and scrollbar to display the eula text */
- hbox = gtk_hbox_new(FALSE, 2);
+ hbox = xsane_eula_license_textbox (buf);
gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+ gtk_paned_add1 (GTK_PANED (pane), hbox);
gtk_widget_show(hbox);
-#ifdef HAVE_GTK_TEXT_VIEW_H
- {
- GtkWidget *scrolled_window, *text_view;
- GtkTextBuffer *text_buffer;
-
- /* create a scrolled window to get a vertical scrollbar */
- scrolled_window = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_container_add(GTK_CONTAINER(hbox), scrolled_window);
- gtk_widget_show(scrolled_window);
-
- /* create the gtk_text_view widget */
- text_view = gtk_text_view_new();
- gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view), FALSE);
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text_view), GTK_WRAP_WORD);
- gtk_container_add(GTK_CONTAINER(scrolled_window), text_view);
- gtk_widget_show(text_view);
-
- /* get the text_buffer widget and insert the text from file */
- text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
-
- xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-eula", 0, ".txt", XSANE_PATH_SYSTEM);
- infile = fopen(filename, "r");
-
- if (infile)
- {
- char buffer[4096];
- int nchars;
-
- while (!feof(infile))
- {
- nchars = fread(buffer, 1, 4096, infile);
- gtk_text_buffer_insert_at_cursor(text_buffer, buffer, nchars);
- }
+ /* Load the EULA text */
+ xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-eula", 0, ".txt", XSANE_PATH_SYSTEM);
+ infile = fopen(filename, "r");
- fclose(infile);
- }
- else
- {
- DBG(DBG_error0, "ERROR: eula text not found. Looks like xsane is not installed correct.\n");
- return TRUE;
- }
-
- }
-#else /* we do not have gtk_text_view, so we use gtk_text */
+ text = g_string_new (NULL);
+ if (infile)
{
- GtkWidget *text, *vscrollbar;
-
- /* Create the gtk_text widget */
- text = gtk_text_new(NULL, NULL);
- gtk_text_set_editable(GTK_TEXT(text), FALSE); /* text is not editable */
- gtk_text_set_word_wrap(GTK_TEXT(text), TRUE); /* wrap complete words */
- gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 0);
- gtk_widget_show(text);
+ char buffer[4096];
+ int nchars;
- /* Add a vertical scrollbar to the GtkText widget */
- vscrollbar = gtk_vscrollbar_new(GTK_TEXT(text)->vadj);
- gtk_box_pack_start(GTK_BOX(hbox), vscrollbar, FALSE, FALSE, 0);
- gtk_widget_show(vscrollbar);
-
- /* Freeze the text widget, ready for multiple updates */
- gtk_text_freeze(GTK_TEXT(text));
-
- /* Load the file text.c into the text window */
- xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-eula", 0, ".txt", XSANE_PATH_SYSTEM);
- infile = fopen(filename, "r");
-
- if (infile)
+ while (!feof(infile))
{
- char buffer[4096];
- int nchars;
-
- while (!feof(infile))
- {
- nchars = fread(buffer, 1, 4096, infile);
- gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, buffer, nchars);
- }
-
- fclose(infile);
- }
- else
- {
- DBG(DBG_error0, "ERROR: eula text not found. Looks like xsane is not installed correct.\n");
- return TRUE;
+ nchars = fread(buffer, 1, 4096, infile);
+ text = g_string_append_len (text, buffer, nchars);
}
- /* Thaw the text widget, allowing the updates to become visible */
- gtk_text_thaw(GTK_TEXT(text));
+ fclose(infile);
+ }
+ else
+ {
+ DBG(DBG_error0, "ERROR: eula text not found. Looks like xsane is not installed correct.\n");
+ g_string_free (text, TRUE);
+ return TRUE;
}
-#endif
-
+ /* add hbox with text and scrollbar to display the eula text */
+ hbox = xsane_eula_license_textbox (text->str);
+ g_string_free (text, TRUE);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
+ gtk_paned_add2 (GTK_PANED (pane), hbox);
+ gtk_widget_show(hbox);
hbox = gtk_hbox_new(FALSE, 2);
gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
@@ -2157,11 +2165,13 @@ static gboolean xsane_license_dialog_del
void xsane_display_gpl(void)
{
- GtkWidget *vbox, *hbox, *button, *label, *frame;
+ GtkWidget *vbox, *hbox, *button, *frame, *pane;
GtkAccelGroup *accelerator_group;
char buf[1024];
char filename[PATH_MAX];
FILE *infile;
+ gint width, height;
+ GString *text;
if (license_dialog) /* make sure the dialog is only opend once */
{
@@ -2169,7 +2179,8 @@ void xsane_display_gpl(void)
}
license_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_size_request(license_dialog, 550, 580);
+ gdk_window_get_geometry (gdk_get_default_root_window (), NULL, NULL, &width, &height, NULL);
+ gtk_widget_set_size_request(license_dialog, MIN (550, (int)(0.9 * width)), MIN (580, (int)(0.9 * height)));
gtk_window_set_position(GTK_WINDOW(license_dialog), GTK_WIN_POS_CENTER);
gtk_window_set_resizable(GTK_WINDOW(license_dialog), TRUE);
g_signal_connect(GTK_OBJECT(license_dialog), "delete_event", GTK_SIGNAL_FUNC(xsane_license_dialog_delete_event), NULL);
@@ -2199,6 +2210,11 @@ void xsane_display_gpl(void)
xsane_set_window_icon(license_dialog, 0);
#endif
+ pane = gtk_vpaned_new ();
+ g_signal_connect_after (G_OBJECT (pane), "realize", (GCallback)center_pane_callback, NULL);
+ gtk_box_pack_start(GTK_BOX(vbox), pane, TRUE, TRUE, 0);
+ gtk_widget_show (pane);
+
/* display XSane copyright message */
snprintf(buf, sizeof(buf), "XSane %s %s\n"
"%s %s\n"
@@ -2212,109 +2228,42 @@ void xsane_display_gpl(void)
TEXT_HOMEPAGE, XSANE_HOMEPAGE,
TEXT_EMAIL_ADR, XSANE_EMAIL_ADR);
- label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
- gtk_widget_show(label);
-
- /* add hbox with text and scrollbar to display the license text */
- hbox = gtk_hbox_new(FALSE, 2);
+ hbox = xsane_eula_license_textbox (buf);
gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+ gtk_paned_add1 (GTK_PANED (pane), hbox);
gtk_widget_show(hbox);
-#ifdef HAVE_GTK_TEXT_VIEW_H
- {
- GtkWidget *scrolled_window, *text_view;
- GtkTextBuffer *text_buffer;
+ /* Load the license text */
+ xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-gpl", 0, ".txt", XSANE_PATH_SYSTEM);
+ infile = fopen(filename, "r");
- /* create a scrolled window to get a vertical scrollbar */
- scrolled_window = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_container_add(GTK_CONTAINER(hbox), scrolled_window);
- gtk_widget_show(scrolled_window);
-
- /* create the gtk_text_view widget */
- text_view = gtk_text_view_new();
- gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view), FALSE);
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text_view), GTK_WRAP_WORD);
- gtk_container_add(GTK_CONTAINER(scrolled_window), text_view);
- gtk_widget_show(text_view);
-
- /* get the text_buffer widget and insert the text from file */
- text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
-
- xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-gpl", 0, ".txt", XSANE_PATH_SYSTEM);
- infile = fopen(filename, "r");
-
- if (infile)
- {
- char buffer[4096];
- int nchars;
-
- while (!feof(infile))
- {
- nchars = fread(buffer, 1, 4096, infile);
- gtk_text_buffer_insert_at_cursor(text_buffer, buffer, nchars);
- }
-
- fclose(infile);
- }
- else
- {
- DBG(DBG_error0, "ERROR: license text not found. Looks like xsane is not installed correct.\n");
- return;
- }
-
- }
-#else /* we do not have gtk_text_view, so we use gtk_text */
+ text = g_string_new (NULL);
+ if (infile)
{
- GtkWidget *text, *vscrollbar;
-
- /* Create the gtk_text widget */
- text = gtk_text_new(NULL, NULL);
- gtk_text_set_editable(GTK_TEXT(text), FALSE); /* text is not editable */
- gtk_text_set_word_wrap(GTK_TEXT(text), TRUE); /* wrap complete words */
- gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 0);
- gtk_widget_show(text);
-
- /* Add a vertical scrollbar to the GtkText widget */
- vscrollbar = gtk_vscrollbar_new(GTK_TEXT(text)->vadj);
- gtk_box_pack_start(GTK_BOX(hbox), vscrollbar, FALSE, FALSE, 0);
- gtk_widget_show(vscrollbar);
-
- /* Freeze the text widget, ready for multiple updates */
- gtk_text_freeze(GTK_TEXT(text));
-
- /* Load the file text.c into the text window */
- xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-gpl", 0, ".txt", XSANE_PATH_SYSTEM);
- infile = fopen(filename, "r");
+ char buffer[4096];
+ int nchars;
- if (infile)
+ while (!feof(infile))
{
- char buffer[4096];
- int nchars;
-
- while (!feof(infile))
- {
- nchars = fread(buffer, 1, 4096, infile);
- gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, buffer, nchars);
- }
-
- fclose(infile);
- }
- else
- {
- DBG(DBG_error0, "ERROR: license text not found. Looks like xsane is not installed correct.\n");
- return;
+ nchars = fread(buffer, 1, 4096, infile);
+ text = g_string_append_len (text, buffer, nchars);
}
- /* Thaw the text widget, allowing the updates to become visible */
- gtk_text_thaw(GTK_TEXT(text));
+ fclose(infile);
+ }
+ else
+ {
+ DBG(DBG_error0, "ERROR: license text not found. Looks like xsane is not installed correct.\n");
+ g_string_free (text, TRUE);
+ return;
}
-#endif
-
+ /* add hbox with text and scrollbar to display the license text */
+ hbox = xsane_eula_license_textbox (text->str);
+ g_string_free (text, TRUE);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
+ gtk_paned_add2 (GTK_PANED (pane), hbox);
+ gtk_widget_show(hbox);
hbox = gtk_hbox_new(FALSE, 2);
gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);