*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <stdarg.h>
#include <sys/stat.h>
+#if HAVE_LIBCOMPFACE
+# include <compface.h>
+#endif
+
#if (HAVE_WCTYPE_H && HAVE_WCHAR_H)
# include <wchar.h>
# include <wctype.h>
#include "menu.h"
#include "prefs_account.h"
#include "prefs_common.h"
+#include "manage_window.h"
gboolean gtkut_get_font_size(GtkWidget *widget,
gint *width, gint *height)
gdk_window_set_icon(widget->window, NULL, xpm, bmp);
}
+GtkWidget *label_window_create(const gchar *str)
+{
+ GtkWidget *window;
+ GtkWidget *label;
+
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_widget_set_size_request(window, 380, 60);
+ gtk_container_set_border_width(GTK_CONTAINER(window), 8);
+ gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
+ gtk_window_set_title(GTK_WINDOW(window), str);
+ gtk_window_set_modal(GTK_WINDOW(window), TRUE);
+ gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
+ manage_window_set_transient(GTK_WINDOW(window));
+
+ label = gtk_label_new(str);
+ gtk_container_add(GTK_CONTAINER(window), label);
+ gtk_widget_show(label);
+
+ gtk_widget_show_now(window);
+
+ return window;
+}
+
GtkWidget *gtkut_account_menu_new(GList *ac_list,
GCallback callback,
gpointer data)
return result;
}
+
+/*!
+ *\brief Create a Browse (file) button based on GTK+ stock
+ */
+GtkWidget *gtkut_get_browse_file_btn(const gchar *button_label)
+{
+ GtkWidget *button;
+
+#if GTK_CHECK_VERSION(2, 6, 0)
+ button = gtk_button_new_with_mnemonic(button_label);
+ gtk_button_set_image((GtkButton*)button,
+ gtk_image_new_from_stock(GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_BUTTON));
+#else
+ GtkWidget* image;
+ GtkWidget* box;
+ GtkWidget* label;
+
+ button = gtk_button_new();
+ box = gtk_hbox_new(FALSE, 0);
+
+ image = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);
+ label = gtk_label_new(NULL);
+ gtk_label_set_text_with_mnemonic(GTK_LABEL(label), button_label);
+ gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
+
+ gtk_box_pack_start((GtkBox*)box, image, FALSE, FALSE, 1);
+ gtk_box_pack_end((GtkBox*)box, label, FALSE, FALSE, 1);
+ gtk_widget_show(label);
+ gtk_widget_show(image);
+ gtk_widget_show(box);
+ gtk_container_add(GTK_CONTAINER(button), box);
+#endif
+ return button;
+}
+
+/*!
+ *\brief Create a Browse (directory) button based on GTK+ stock
+ */
+GtkWidget *gtkut_get_browse_directory_btn(const gchar *button_label)
+{
+ GtkWidget *button;
+
+#if GTK_CHECK_VERSION(2, 6, 0)
+ button = gtk_button_new_with_mnemonic(button_label);
+ gtk_button_set_image((GtkButton*)button,
+ gtk_image_new_from_stock(GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_BUTTON));
+#else
+ GtkWidget* image;
+ GtkWidget* box;
+ GtkWidget* label;
+
+ button = gtk_button_new();
+ box = gtk_hbox_new(FALSE, 0);
+
+ image = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);
+ label = gtk_label_new(NULL);
+ gtk_label_set_text_with_mnemonic(GTK_LABEL(label), button_label);
+ gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
+
+ gtk_box_pack_start((GtkBox*)box, image, FALSE, FALSE, 1);
+ gtk_box_pack_end((GtkBox*)box, label, FALSE, FALSE, 1);
+ gtk_widget_show(label);
+ gtk_widget_show(image);
+ gtk_widget_show(box);
+ gtk_container_add(GTK_CONTAINER(button), box);
+#endif
+ return button;
+}
+
+#if HAVE_LIBCOMPFACE
+gint create_xpm_from_xface(gchar *xpm[], const gchar *xface)
+{
+ static gchar *bit_pattern[] = {
+ "....",
+ "...#",
+ "..#.",
+ "..##",
+ ".#..",
+ ".#.#",
+ ".##.",
+ ".###",
+ "#...",
+ "#..#",
+ "#.#.",
+ "#.##",
+ "##..",
+ "##.#",
+ "###.",
+ "####"
+ };
+
+ static gchar *xface_header = "48 48 2 1";
+ static gchar *xface_black = "# c #000000";
+ static gchar *xface_white = ". c #ffffff";
+
+ gint i, line = 0;
+ const guchar *p;
+ gchar buf[WIDTH * 4 + 1]; /* 4 = strlen("0x0000") */
+
+ p = xface;
+
+ strcpy(xpm[line++], xface_header);
+ strcpy(xpm[line++], xface_black);
+ strcpy(xpm[line++], xface_white);
+
+ for (i = 0; i < HEIGHT; i++) {
+ gint col;
+
+ buf[0] = '\0';
+
+ for (col = 0; col < 3; col++) {
+ gint figure;
+
+ p += 2; /* skip '0x' */
+
+ for (figure = 0; figure < 4; figure++) {
+ gint n = 0;
+
+ if ('0' <= *p && *p <= '9') {
+ n = *p - '0';
+ } else if ('a' <= *p && *p <= 'f') {
+ n = *p - 'a' + 10;
+ } else if ('A' <= *p && *p <= 'F') {
+ n = *p - 'A' + 10;
+ }
+
+ strcat(buf, bit_pattern[n]);
+ p++; /* skip ',' */
+ }
+
+ p++; /* skip '\n' */
+ }
+
+ strcpy(xpm[line++], buf);
+ p++;
+ }
+
+ return 0;
+}
+#endif
+
+gboolean get_tag_range(GtkTextIter *iter,
+ GtkTextTag *tag,
+ GtkTextIter *start_iter,
+ GtkTextIter *end_iter)
+{
+ GtkTextIter _start_iter, _end_iter;
+
+ _end_iter = *iter;
+ if (!gtk_text_iter_forward_to_tag_toggle(&_end_iter, tag)) {
+ debug_print("Can't find end");
+ return FALSE;
+ }
+
+ _start_iter = _end_iter;
+ if (!gtk_text_iter_backward_to_tag_toggle(&_start_iter, tag)) {
+ debug_print("Can't find start.");
+ return FALSE;
+ }
+
+ *start_iter = _start_iter;
+ *end_iter = _end_iter;
+
+ return TRUE;
+}