prefs_wrapping.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
  3. * Copyright (C) 2004-2006 Hiroyuki Yamamoto & The Claws Mail Team
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. */
  19. #ifdef HAVE_CONFIG_H
  20. # include "config.h"
  21. #endif
  22. #include "defs.h"
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <glib.h>
  26. #include <glib/gi18n.h>
  27. #include <gtk/gtk.h>
  28. #include <gdk/gdkkeysyms.h>
  29. #include "prefs_common.h"
  30. #include "prefs_gtk.h"
  31. #include "gtk/gtkutils.h"
  32. #include "gtk/prefswindow.h"
  33. #include "manage_window.h"
  34. typedef struct _WrappingPage
  35. {
  36. PrefsPage page;
  37. GtkWidget *window;
  38. GtkWidget *spinbtn_linewrap;
  39. GtkWidget *checkbtn_wrapquote;
  40. GtkWidget *checkbtn_wrappastes;
  41. GtkWidget *checkbtn_autowrap;
  42. } WrappingPage;
  43. void prefs_wrapping_create_widget(PrefsPage *_page, GtkWindow *window,
  44. gpointer data)
  45. {
  46. WrappingPage *prefs_wrapping = (WrappingPage *) _page;
  47. GtkWidget *vbox1;
  48. GtkWidget *vbox2;
  49. GtkWidget *label_linewrap;
  50. GtkObject *spinbtn_linewrap_adj;
  51. GtkWidget *spinbtn_linewrap;
  52. GtkWidget *checkbtn_wrapquote;
  53. GtkWidget *checkbtn_wrappastes;
  54. GtkWidget *checkbtn_autowrap;
  55. GtkWidget *hbox1;
  56. vbox1 = gtk_vbox_new (FALSE, VSPACING);
  57. gtk_widget_show (vbox1);
  58. gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
  59. vbox2 = gtk_vbox_new (FALSE, 0);
  60. gtk_widget_show (vbox2);
  61. gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
  62. PACK_CHECK_BUTTON (vbox2, checkbtn_autowrap, _("Auto wrapping"));
  63. PACK_CHECK_BUTTON (vbox2, checkbtn_wrapquote, _("Wrap quotation"));
  64. PACK_CHECK_BUTTON (vbox2, checkbtn_wrappastes, _("Wrap pasted text"));
  65. hbox1 = gtk_hbox_new (FALSE, 8);
  66. gtk_widget_show (hbox1);
  67. gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
  68. label_linewrap = gtk_label_new (_("Wrap messages at"));
  69. gtk_widget_show (label_linewrap);
  70. gtk_box_pack_start (GTK_BOX (hbox1), label_linewrap, FALSE, FALSE, 4);
  71. spinbtn_linewrap_adj = gtk_adjustment_new (72, 20, 1024, 1, 10, 10);
  72. spinbtn_linewrap = gtk_spin_button_new
  73. (GTK_ADJUSTMENT (spinbtn_linewrap_adj), 1, 0);
  74. gtk_widget_set_size_request (spinbtn_linewrap, 64, -1);
  75. gtk_widget_show (spinbtn_linewrap);
  76. gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_linewrap, FALSE, FALSE, 0);
  77. gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linewrap), TRUE);
  78. label_linewrap = gtk_label_new (_("characters"));
  79. gtk_widget_show (label_linewrap);
  80. gtk_box_pack_start (GTK_BOX (hbox1), label_linewrap, FALSE, FALSE, 0);
  81. gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_autowrap),
  82. prefs_common.autowrap);
  83. gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_wrapquote),
  84. prefs_common.linewrap_quote);
  85. gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_wrappastes),
  86. prefs_common.linewrap_pastes);
  87. gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_linewrap),
  88. prefs_common.linewrap_len);
  89. prefs_wrapping->window = GTK_WIDGET(window);
  90. prefs_wrapping->spinbtn_linewrap = spinbtn_linewrap;
  91. prefs_wrapping->checkbtn_wrapquote = checkbtn_wrapquote;
  92. prefs_wrapping->checkbtn_wrappastes = checkbtn_wrappastes;
  93. prefs_wrapping->checkbtn_autowrap = checkbtn_autowrap;
  94. prefs_wrapping->page.widget = vbox1;
  95. }
  96. void prefs_wrapping_save(PrefsPage *_page)
  97. {
  98. WrappingPage *page = (WrappingPage *) _page;
  99. prefs_common.linewrap_len =
  100. gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page->spinbtn_linewrap));
  101. prefs_common.linewrap_quote =
  102. gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_wrapquote));
  103. prefs_common.linewrap_pastes =
  104. gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_wrappastes));
  105. prefs_common.autowrap =
  106. gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_autowrap));
  107. }
  108. static void prefs_wrapping_destroy_widget(PrefsPage *_page)
  109. {
  110. }
  111. WrappingPage *prefs_wrapping;
  112. void prefs_wrapping_init(void)
  113. {
  114. WrappingPage *page;
  115. static gchar *path[3];
  116. path[0] = _("Compose");
  117. path[1] = _("Wrapping");
  118. path[2] = NULL;
  119. page = g_new0(WrappingPage, 1);
  120. page->page.path = path;
  121. page->page.create_widget = prefs_wrapping_create_widget;
  122. page->page.destroy_widget = prefs_wrapping_destroy_widget;
  123. page->page.save_page = prefs_wrapping_save;
  124. page->page.weight = 182.0;
  125. prefs_gtk_register_page((PrefsPage *) page);
  126. prefs_wrapping = page;
  127. }
  128. void prefs_wrapping_done(void)
  129. {
  130. prefs_gtk_unregister_page((PrefsPage *) prefs_wrapping);
  131. g_free(prefs_wrapping);
  132. }