annotate src/audacious/ui_skinned_textbox.c @ 4269:2a4954d14bfb

removed debugging stuff...
author Eugene Zagidullin <e.asphyx@gmail.com>
date Sun, 10 Feb 2008 15:54:47 +0300
parents 977877bb212f
children de33c83aa06f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1 /*
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
2 * Audacious - a cross-platform multimedia player
3840
46591501603e Add my name in few places
Tomasz Mon <desowin@gmail.com>
parents: 3358
diff changeset
3 * Copyright (c) 2007 Tomasz Moń
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
4 *
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
5 * Based on:
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
6 * BMP - Cross-platform multimedia player
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
7 * Copyright (C) 2003-2004 BMP development team.
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
8 * XMMS:
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
9 * Copyright (C) 1998-2003 XMMS development team.
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
10 *
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3105
diff changeset
13 * the Free Software Foundation; under version 3 of the License.
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
14 *
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
19 *
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3105
diff changeset
21 * along with this program. If not, see <http://www.gnu.org/licenses>.
3123
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
22 *
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
23 * The Audacious team does not consider modular code linking to
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
24 * Audacious or using our public API to be a derived work.
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
25 */
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
26
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
27 #include "ui_skinned_textbox.h"
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
28 #include "main.h"
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
29 #include "util.h"
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
30 #include "strings.h"
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
31 #include <string.h>
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
32
3105
1912eba1004b cleaning
Tomasz Mon <desowin@gmail.com>
parents: 3103
diff changeset
33 #define UI_SKINNED_TEXTBOX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ui_skinned_textbox_get_type(), UiSkinnedTextboxPrivate))
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
34 typedef struct _UiSkinnedTextboxPrivate UiSkinnedTextboxPrivate;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
35
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
36 #define TEXTBOX_SCROLL_SMOOTH_TIMEOUT 30
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
37 #define TEXTBOX_SCROLL_WAIT 80
2965
f84d09bada0f correct _move_relative() and _resize_relative()
Tomasz Mon <desowin@gmail.com>
parents: 2962
diff changeset
38
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
39 enum {
2942
1a59a0ced6a8 make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents: 2920
diff changeset
40 CLICKED,
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
41 DOUBLE_CLICKED,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
42 RIGHT_CLICKED,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
43 DOUBLED,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
44 REDRAW,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
45 LAST_SIGNAL
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
46 };
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
47
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
48 struct _UiSkinnedTextboxPrivate {
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
49 SkinPixmapId skin_index;
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
50 gboolean scaled;
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
51 gboolean scroll_back;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
52 gint nominal_y, nominal_height;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
53 gint scroll_timeout;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
54 gint font_ascent, font_descent;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
55 PangoFontDescription *font;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
56 gchar *fontname;
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
57 gchar *pixbuf_text;
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
58 gint skin_id;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
59 gint drag_x, drag_off, offset;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
60 gboolean is_scrollable, is_dragging;
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
61 gint pixbuf_width;
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
62 GdkPixbuf *pixbuf;
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
63 gboolean scroll_allowed, scroll_enabled;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
64 gint scroll_dummy;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
65 gint move_x, move_y;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
66 };
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
67
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
68 static void ui_skinned_textbox_class_init (UiSkinnedTextboxClass *klass);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
69 static void ui_skinned_textbox_init (UiSkinnedTextbox *textbox);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
70 static void ui_skinned_textbox_destroy (GtkObject *object);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
71 static void ui_skinned_textbox_realize (GtkWidget *widget);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
72 static void ui_skinned_textbox_size_request (GtkWidget *widget, GtkRequisition *requisition);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
73 static void ui_skinned_textbox_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
74 static gboolean ui_skinned_textbox_expose (GtkWidget *widget, GdkEventExpose *event);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
75 static gboolean ui_skinned_textbox_button_press (GtkWidget *widget, GdkEventButton *event);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
76 static gboolean ui_skinned_textbox_button_release (GtkWidget *widget, GdkEventButton *event);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
77 static gboolean ui_skinned_textbox_motion_notify (GtkWidget *widget, GdkEventMotion *event);
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
78 static void ui_skinned_textbox_toggle_scaled (UiSkinnedTextbox *textbox);
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
79 static void ui_skinned_textbox_redraw (UiSkinnedTextbox *textbox);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
80 static gboolean ui_skinned_textbox_should_scroll (UiSkinnedTextbox *textbox);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
81 static void textbox_generate_xfont_pixmap (UiSkinnedTextbox *textbox, const gchar *pixmaptext);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
82 static gboolean textbox_scroll (gpointer data);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
83 static void textbox_generate_pixmap (UiSkinnedTextbox *textbox);
3038
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
84 static void textbox_handle_special_char (gchar *c, gint * x, gint * y);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
86 static GtkWidgetClass *parent_class = NULL;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
87 static guint textbox_signals[LAST_SIGNAL] = { 0 };
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
88
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
89 GType ui_skinned_textbox_get_type() {
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
90 static GType textbox_type = 0;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
91 if (!textbox_type) {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
92 static const GTypeInfo textbox_info = {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
93 sizeof (UiSkinnedTextboxClass),
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
94 NULL,
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
95 NULL,
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
96 (GClassInitFunc) ui_skinned_textbox_class_init,
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
97 NULL,
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
98 NULL,
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
99 sizeof (UiSkinnedTextbox),
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
100 0,
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
101 (GInstanceInitFunc) ui_skinned_textbox_init,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
102 };
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
103 textbox_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedTextbox", &textbox_info, 0);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
104 }
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
105
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
106 return textbox_type;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
107 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
108
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
109 static void ui_skinned_textbox_class_init(UiSkinnedTextboxClass *klass) {
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
110 GObjectClass *gobject_class;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
111 GtkObjectClass *object_class;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112 GtkWidgetClass *widget_class;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
113
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
114 gobject_class = G_OBJECT_CLASS(klass);
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
115 object_class = (GtkObjectClass*) klass;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
116 widget_class = (GtkWidgetClass*) klass;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
117 parent_class = gtk_type_class (gtk_widget_get_type ());
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
118
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119 object_class->destroy = ui_skinned_textbox_destroy;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
120
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121 widget_class->realize = ui_skinned_textbox_realize;
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
122 widget_class->expose_event = ui_skinned_textbox_expose;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
123 widget_class->size_request = ui_skinned_textbox_size_request;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
124 widget_class->size_allocate = ui_skinned_textbox_size_allocate;
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
125 widget_class->button_press_event = ui_skinned_textbox_button_press;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
126 widget_class->button_release_event = ui_skinned_textbox_button_release;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127 widget_class->motion_notify_event = ui_skinned_textbox_motion_notify;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
128
2942
1a59a0ced6a8 make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents: 2920
diff changeset
129 klass->clicked = NULL;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
130 klass->double_clicked = NULL;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
131 klass->right_clicked = NULL;
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
132 klass->scaled = ui_skinned_textbox_toggle_scaled;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133 klass->redraw = ui_skinned_textbox_redraw;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134
2942
1a59a0ced6a8 make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents: 2920
diff changeset
135 textbox_signals[CLICKED] =
1a59a0ced6a8 make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents: 2920
diff changeset
136 g_signal_new ("clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
1a59a0ced6a8 make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents: 2920
diff changeset
137 G_STRUCT_OFFSET (UiSkinnedTextboxClass, clicked), NULL, NULL,
1a59a0ced6a8 make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents: 2920
diff changeset
138 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
1a59a0ced6a8 make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents: 2920
diff changeset
139
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 textbox_signals[DOUBLE_CLICKED] =
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
141 g_signal_new ("double-clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142 G_STRUCT_OFFSET (UiSkinnedTextboxClass, double_clicked), NULL, NULL,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
143 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
144
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
145 textbox_signals[RIGHT_CLICKED] =
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
146 g_signal_new ("right-clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
147 G_STRUCT_OFFSET (UiSkinnedTextboxClass, right_clicked), NULL, NULL,
4135
07c1639b110b the less calls to gdk_window_get_pointer the better
Tomasz Mon <desowin@gmail.com>
parents: 4119
diff changeset
148 gtk_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
149
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150 textbox_signals[DOUBLED] =
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
151 g_signal_new ("toggle-scaled", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
152 G_STRUCT_OFFSET (UiSkinnedTextboxClass, scaled), NULL, NULL,
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
153 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
154
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
155 textbox_signals[REDRAW] =
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
156 g_signal_new ("redraw", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
157 G_STRUCT_OFFSET (UiSkinnedTextboxClass, redraw), NULL, NULL,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
158 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
159
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
160 g_type_class_add_private (gobject_class, sizeof (UiSkinnedTextboxPrivate));
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
161 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
162
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
163 static void ui_skinned_textbox_init(UiSkinnedTextbox *textbox) {
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
164 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
165 priv->move_x = 0;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
166 priv->move_y = 0;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
167 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
168
3005
3db40ad79fd9 request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents: 2998
diff changeset
169 GtkWidget* ui_skinned_textbox_new(GtkWidget *fixed, gint x, gint y, gint w, gboolean allow_scroll, SkinPixmapId si) {
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
170 UiSkinnedTextbox *textbox = g_object_new (ui_skinned_textbox_get_type (), NULL);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
171 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
172
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
173 textbox->height = bmp_active_skin->properties.textbox_bitmap_font_height;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
174 textbox->x = x;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
175 textbox->y = y;
2957
c859aa1a1a4e don't update text if it haven't changed
Tomasz Mon <desowin@gmail.com>
parents: 2956
diff changeset
176 textbox->text = g_strdup("");
2947
13591e28d89e cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2945
diff changeset
177 textbox->width = w;
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
178 priv->scroll_allowed = allow_scroll;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
179 priv->scroll_enabled = TRUE;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
180 priv->skin_index = si;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
181 priv->nominal_y = y;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
182 priv->nominal_height = textbox->height;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
183 priv->scroll_timeout = 0;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
184 priv->scroll_dummy = 0;
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
185
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
186 priv->scaled = FALSE;
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
187
3939
d46d60247826 we don't need to store GtkFixed pointer, do we?
Tomasz Mon <desowin@gmail.com>
parents: 3933
diff changeset
188 gtk_fixed_put(GTK_FIXED(fixed), GTK_WIDGET(textbox), textbox->x, textbox->y);
2982
b5efea796fe8 correct gtk_fixed_put()'s
Tomasz Mon <desowin@gmail.com>
parents: 2981
diff changeset
189
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
190 return GTK_WIDGET(textbox);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
191 }
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
192
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
193 static void ui_skinned_textbox_destroy(GtkObject *object) {
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
194 UiSkinnedTextbox *textbox;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
195
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
196 g_return_if_fail (object != NULL);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
197 g_return_if_fail (UI_SKINNED_IS_TEXTBOX (object));
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
198
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
199 textbox = UI_SKINNED_TEXTBOX (object);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
200
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
201 if (GTK_OBJECT_CLASS (parent_class)->destroy)
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
202 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
203 }
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
204
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
205 static void ui_skinned_textbox_realize(GtkWidget *widget) {
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
206 UiSkinnedTextbox *textbox;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
207 GdkWindowAttr attributes;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
208 gint attributes_mask;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
209
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
210 g_return_if_fail (widget != NULL);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
211 g_return_if_fail (UI_SKINNED_IS_TEXTBOX(widget));
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
212
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
213 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
214 textbox = UI_SKINNED_TEXTBOX(widget);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
215
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
216 attributes.x = widget->allocation.x;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
217 attributes.y = widget->allocation.y;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
218 attributes.width = widget->allocation.width;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
219 attributes.height = widget->allocation.height;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
220 attributes.wclass = GDK_INPUT_OUTPUT;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
221 attributes.window_type = GDK_WINDOW_CHILD;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
222 attributes.event_mask = gtk_widget_get_events(widget);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
223 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK |
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
224 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK |
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
225 GDK_POINTER_MOTION_HINT_MASK;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
226 attributes.visual = gtk_widget_get_visual(widget);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
227 attributes.colormap = gtk_widget_get_colormap(widget);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
228
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
229 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
230 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
231
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
232 widget->style = gtk_style_attach(widget->style, widget->window);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
233
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
234 gdk_window_set_user_data(widget->window, widget);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
235 }
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
236
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
237 static void ui_skinned_textbox_size_request(GtkWidget *widget, GtkRequisition *requisition) {
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
238 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX(widget);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
239 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
240
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
241 requisition->width = textbox->width*(priv->scaled ? cfg.scale_factor : 1);
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
242 requisition->height = textbox->height*(priv->scaled ? cfg.scale_factor : 1 );
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
243 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
244
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
245 static void ui_skinned_textbox_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
246 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX (widget);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
247 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
248
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
249 widget->allocation = *allocation;
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
250 widget->allocation.x *= (priv->scaled ? cfg.scale_factor : 1);
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
251 widget->allocation.y *= (priv->scaled ? cfg.scale_factor : 1);
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
252 if (GTK_WIDGET_REALIZED (widget))
3011
99865f696f13 don't use gtk_widget_set_uposition()
Tomasz Mon <desowin@gmail.com>
parents: 3005
diff changeset
253 gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
254
4222
977877bb212f fixed the textboxes
Cristi Magherusan <majeru@atheme.org>
parents: 4217
diff changeset
255 if (textbox->x + priv->move_x - widget->allocation.x/(priv->scaled ? cfg.scale_factor : 1) <3);
3137
19908efce4e5 one mutex is enough for resizing
Tomasz Mon <desowin@gmail.com>
parents: 3123
diff changeset
256 priv->move_x = 0;
4222
977877bb212f fixed the textboxes
Cristi Magherusan <majeru@atheme.org>
parents: 4217
diff changeset
257 if (textbox->y + priv->move_y - widget->allocation.y/(priv->scaled ? cfg.scale_factor : 1) <3);
3137
19908efce4e5 one mutex is enough for resizing
Tomasz Mon <desowin@gmail.com>
parents: 3123
diff changeset
258 priv->move_y = 0;
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
259 textbox->x = widget->allocation.x/(priv->scaled ? cfg.scale_factor : 1);
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
260 textbox->y = widget->allocation.y/(priv->scaled ? cfg.scale_factor : 1);
2919
2abf3bb3e63d fix textbox resize
Tomasz Mon <desowin@gmail.com>
parents: 2918
diff changeset
261
4222
977877bb212f fixed the textboxes
Cristi Magherusan <majeru@atheme.org>
parents: 4217
diff changeset
262 if (textbox->width - (guint) (widget->allocation.width / (priv->scaled ? cfg.scale_factor : 1)) > 2) {
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
263 textbox->width = (guint) (widget->allocation.width / (priv->scaled ? cfg.scale_factor : 1));
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
264 if (priv->pixbuf_text) g_free(priv->pixbuf_text);
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
265 priv->pixbuf_text = NULL;
3222
bb7f5adc1677 I hope textbox_resize_relative is now working propertly
Tomasz Mon <desowin@gmail.com>
parents: 3137
diff changeset
266 priv->offset = 0;
bb7f5adc1677 I hope textbox_resize_relative is now working propertly
Tomasz Mon <desowin@gmail.com>
parents: 3137
diff changeset
267 gtk_widget_set_size_request(widget, textbox->width, textbox->height);
bb7f5adc1677 I hope textbox_resize_relative is now working propertly
Tomasz Mon <desowin@gmail.com>
parents: 3137
diff changeset
268 gtk_widget_queue_draw(GTK_WIDGET(textbox));
2919
2abf3bb3e63d fix textbox resize
Tomasz Mon <desowin@gmail.com>
parents: 2918
diff changeset
269 }
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
270 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
271
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
272 static gboolean ui_skinned_textbox_expose(GtkWidget *widget, GdkEventExpose *event) {
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
273 g_return_val_if_fail (widget != NULL, FALSE);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
274 g_return_val_if_fail (UI_SKINNED_IS_TEXTBOX (widget), FALSE);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
275 g_return_val_if_fail (event != NULL, FALSE);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
276
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
277 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX (widget);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
278 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
4119
9d4b5cdae3ba oops, fix previous commit
Tomasz Mon <desowin@gmail.com>
parents: 4118
diff changeset
279 g_return_val_if_fail (textbox->width > 0 && textbox->height > 0, FALSE);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
280
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
281 GdkPixbuf *obj = NULL;
2998
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
282 gint cw;
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
283
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
284 if (textbox->text && (!priv->pixbuf_text || strcmp(textbox->text, priv->pixbuf_text)))
2998
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
285 textbox_generate_pixmap(textbox);
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
286
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
287 if (priv->pixbuf) {
2998
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
288 if (skin_get_id() != priv->skin_id) {
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
289 priv->skin_id = skin_get_id();
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
290 textbox_generate_pixmap(textbox);
2998
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
291 }
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
292 obj = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, textbox->width, textbox->height);
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
293
2998
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
294 if (cfg.twoway_scroll) { // twoway scroll
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
295 cw = priv->pixbuf_width - priv->offset;
2998
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
296 if (cw > textbox->width)
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
297 cw = textbox->width;
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
298 gdk_pixbuf_copy_area(priv->pixbuf, priv->offset, 0, cw, textbox->height, obj, 0, 0);
2998
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
299 if (cw < textbox->width)
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
300 gdk_pixbuf_copy_area(priv->pixbuf, 0, 0, textbox->width - cw, textbox->height,
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
301 obj, textbox->width - cw, textbox->height);
2998
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
302 } else { // oneway scroll
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
303 int cw1, cw2;
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
304
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
305 if (priv->offset >= priv->pixbuf_width)
2998
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
306 priv->offset = 0;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
307
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
308 if (priv->pixbuf_width - priv->offset > textbox->width) { // case1
2998
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
309 cw1 = textbox->width;
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
310 gdk_pixbuf_copy_area(priv->pixbuf, priv->offset, 0, cw1, textbox->height,
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
311 obj, 0, 0);
2998
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
312 } else { // case 2
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
313 cw1 = priv->pixbuf_width - priv->offset;
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
314 gdk_pixbuf_copy_area(priv->pixbuf, priv->offset, 0, cw1, textbox->height, obj, 0, 0);
2998
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
315 cw2 = textbox->width - cw1;
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
316 gdk_pixbuf_copy_area(priv->pixbuf, 0, 0, cw2, textbox->height, obj, cw1, 0);
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
317 }
2998
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
318 }
3031
229db6d72934 don't keep img
Tomasz Mon <desowin@gmail.com>
parents: 3011
diff changeset
319
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
320 ui_skinned_widget_draw(widget, obj, textbox->width, textbox->height, priv->scaled);
3005
3db40ad79fd9 request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents: 2998
diff changeset
321
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
322 g_object_unref(obj);
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
323 }
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
324
2998
c200d6764e91 fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents: 2997
diff changeset
325 return FALSE;
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
326 }
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
327
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
328 static gboolean ui_skinned_textbox_button_press(GtkWidget *widget, GdkEventButton *event) {
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
329 g_return_val_if_fail (widget != NULL, FALSE);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
330 g_return_val_if_fail (UI_SKINNED_IS_TEXTBOX (widget), FALSE);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
331 g_return_val_if_fail (event != NULL, FALSE);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
332
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
333 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX (widget);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
334 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
335
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
336 if (event->type == GDK_BUTTON_PRESS) {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
337 textbox = UI_SKINNED_TEXTBOX(widget);
3358
7f6787eac9aa right click on textboxes without connected handler should bring up audacious menu
Tomasz Mon <desowin@gmail.com>
parents: 3293
diff changeset
338 if (event->button == 3 && !g_signal_has_handler_pending(widget, textbox_signals[RIGHT_CLICKED], 0, TRUE))
7f6787eac9aa right click on textboxes without connected handler should bring up audacious menu
Tomasz Mon <desowin@gmail.com>
parents: 3293
diff changeset
339 return FALSE;
7f6787eac9aa right click on textboxes without connected handler should bring up audacious menu
Tomasz Mon <desowin@gmail.com>
parents: 3293
diff changeset
340 else if (event->button == 1) {
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
341 if (priv->scroll_allowed) {
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
342 if ((priv->pixbuf_width > textbox->width) && priv->is_scrollable) {
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
343 priv->is_dragging = TRUE;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
344 priv->drag_off = priv->offset;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
345 priv->drag_x = event->x;
2942
1a59a0ced6a8 make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents: 2920
diff changeset
346 }
1a59a0ced6a8 make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents: 2920
diff changeset
347 } else
1a59a0ced6a8 make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents: 2920
diff changeset
348 g_signal_emit(widget, textbox_signals[CLICKED], 0);
1a59a0ced6a8 make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents: 2920
diff changeset
349
3957
fed07be6b708 every other menu shows on button press..
Tomasz Mon <desowin@gmail.com>
parents: 3956
diff changeset
350 } else if (event->button == 3) {
4135
07c1639b110b the less calls to gdk_window_get_pointer the better
Tomasz Mon <desowin@gmail.com>
parents: 4119
diff changeset
351 g_signal_emit(widget, textbox_signals[RIGHT_CLICKED], 0, event);
3032
6e98eedead3a little fix to ui_skinned_textbox_button_press()
Tomasz Mon <desowin@gmail.com>
parents: 3031
diff changeset
352 } else
6e98eedead3a little fix to ui_skinned_textbox_button_press()
Tomasz Mon <desowin@gmail.com>
parents: 3031
diff changeset
353 priv->is_dragging = FALSE;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
354 } else if (event->type == GDK_2BUTTON_PRESS) {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
355 if (event->button == 1) {
3230
cfb76302b468 fix unshading playlistwin when doubleclicking on textbox
Tomasz Mon <desowin@gmail.com>
parents: 3225
diff changeset
356 if (g_signal_has_handler_pending(widget, textbox_signals[DOUBLE_CLICKED], 0, TRUE))
cfb76302b468 fix unshading playlistwin when doubleclicking on textbox
Tomasz Mon <desowin@gmail.com>
parents: 3225
diff changeset
357 g_signal_emit(widget, textbox_signals[DOUBLE_CLICKED], 0);
cfb76302b468 fix unshading playlistwin when doubleclicking on textbox
Tomasz Mon <desowin@gmail.com>
parents: 3225
diff changeset
358 else
cfb76302b468 fix unshading playlistwin when doubleclicking on textbox
Tomasz Mon <desowin@gmail.com>
parents: 3225
diff changeset
359 return FALSE;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
360 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
361 }
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
362
2991
f7604f7d8e41 ui_skinned_textbox_button_release is no longer lost
Tomasz Mon <desowin@gmail.com>
parents: 2983
diff changeset
363 return TRUE;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
364 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
365
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
366 static gboolean ui_skinned_textbox_button_release(GtkWidget *widget, GdkEventButton *event) {
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
367 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(widget);
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
368
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
369 if (event->button == 1) {
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
370 priv->is_dragging = FALSE;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
371 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
372
2997
0adc8c00fc57 correct right-clicked signal
Tomasz Mon <desowin@gmail.com>
parents: 2996
diff changeset
373 return TRUE;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
374 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
375
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
376 static gboolean ui_skinned_textbox_motion_notify(GtkWidget *widget, GdkEventMotion *event) {
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
377 g_return_val_if_fail (widget != NULL, FALSE);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
378 g_return_val_if_fail (UI_SKINNED_IS_TEXTBOX (widget), FALSE);
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
379 g_return_val_if_fail (event != NULL, FALSE);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
380 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX(widget);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
381 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(widget);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
382
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
383 if (priv->is_dragging) {
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
384 if (priv->scroll_allowed &&
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
385 priv->pixbuf_width > textbox->width) {
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
386 priv->offset = priv->drag_off - (event->x - priv->drag_x);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
387
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
388 while (priv->offset < 0)
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
389 priv->offset = 0;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
390
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
391 while (priv->offset > (priv->pixbuf_width - textbox->width))
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
392 priv->offset = (priv->pixbuf_width - textbox->width);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
393
2965
f84d09bada0f correct _move_relative() and _resize_relative()
Tomasz Mon <desowin@gmail.com>
parents: 2962
diff changeset
394 gtk_widget_queue_draw(widget);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
395 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
396 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
397
2997
0adc8c00fc57 correct right-clicked signal
Tomasz Mon <desowin@gmail.com>
parents: 2996
diff changeset
398 return TRUE;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
399 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
400
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
401 static void ui_skinned_textbox_toggle_scaled(UiSkinnedTextbox *textbox) {
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
402 GtkWidget *widget = GTK_WIDGET (textbox);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
403 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
404
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
405 priv->scaled = !priv->scaled;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
406
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
407 gtk_widget_set_size_request(widget, textbox->width*(priv->scaled ? cfg.scale_factor : 1 ),
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
408 textbox->height*(priv->scaled ? cfg.scale_factor : 1 ));
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
409
2962
ba45ef731cf1 don't call ui_skinned_textbox_paint() directly, use gtk_widget_queue_draw() instead; fix ui_skinned_textbox_expose()
Tomasz Mon <desowin@gmail.com>
parents: 2961
diff changeset
410 gtk_widget_queue_draw(GTK_WIDGET(textbox));
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
411 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
412
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
413 static void ui_skinned_textbox_redraw(UiSkinnedTextbox *textbox) {
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
414 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
415
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
416 if (priv->move_x || priv->move_y)
3939
d46d60247826 we don't need to store GtkFixed pointer, do we?
Tomasz Mon <desowin@gmail.com>
parents: 3933
diff changeset
417 gtk_fixed_move(GTK_FIXED(gtk_widget_get_parent(GTK_WIDGET(textbox))), GTK_WIDGET(textbox),
d46d60247826 we don't need to store GtkFixed pointer, do we?
Tomasz Mon <desowin@gmail.com>
parents: 3933
diff changeset
418 textbox->x+priv->move_x, textbox->y+priv->move_y);
2965
f84d09bada0f correct _move_relative() and _resize_relative()
Tomasz Mon <desowin@gmail.com>
parents: 2962
diff changeset
419
2962
ba45ef731cf1 don't call ui_skinned_textbox_paint() directly, use gtk_widget_queue_draw() instead; fix ui_skinned_textbox_expose()
Tomasz Mon <desowin@gmail.com>
parents: 2961
diff changeset
420 gtk_widget_queue_draw(GTK_WIDGET(textbox));
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
421 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
422
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
423 static gboolean ui_skinned_textbox_should_scroll(UiSkinnedTextbox *textbox) {
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
424 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
425
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
426 if (!priv->scroll_allowed)
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
427 return FALSE;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
428
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
429 if (priv->font) {
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
430 gint width;
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
431 text_get_extents(priv->fontname, textbox->text, &width, NULL, NULL, NULL);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
432
2947
13591e28d89e cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2945
diff changeset
433 if (width <= textbox->width)
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
434 return FALSE;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
435 else
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
436 return TRUE;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
437 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
438
2947
13591e28d89e cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2945
diff changeset
439 if (g_utf8_strlen(textbox->text, -1) * bmp_active_skin->properties.textbox_bitmap_font_width > textbox->width)
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
440 return TRUE;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
441
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
442 return FALSE;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
443 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
444
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
445 void ui_skinned_textbox_set_xfont(GtkWidget *widget, gboolean use_xfont, const gchar * fontname) {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
446 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX (widget);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
447 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
448
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
449 gint ascent, descent;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
450
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
451 g_return_if_fail(textbox != NULL);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
452
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
453 if (priv->font) {
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
454 pango_font_description_free(priv->font);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
455 priv->font = NULL;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
456 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
457
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
458 textbox->y = priv->nominal_y;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
459 textbox->height = priv->nominal_height;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
460
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
461 /* Make sure the pixmap is regenerated */
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
462 if (priv->pixbuf_text) {
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
463 g_free(priv->pixbuf_text);
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
464 priv->pixbuf_text = NULL;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
465 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
466
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
467 if (!use_xfont || strlen(fontname) == 0)
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
468 return;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
469
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
470 priv->font = pango_font_description_from_string(fontname);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
471 priv->fontname = g_strdup(fontname);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
472
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
473 text_get_extents(fontname,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
474 "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz ",
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
475 NULL, NULL, &ascent, &descent);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
476 priv->font_ascent = ascent;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
477 priv->font_descent = descent;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
478
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
479
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
480 if (priv->font == NULL)
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
481 return;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
482
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
483 textbox->height = priv->font_ascent;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
484 if (textbox->height > priv->nominal_height)
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
485 textbox->y -= (textbox->height - priv->nominal_height) / 2;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
486 else
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
487 textbox->height = priv->nominal_height;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
488 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
489
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
490 void ui_skinned_textbox_set_text(GtkWidget *widget, const gchar *text) {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
491 g_return_if_fail(text != NULL);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
492 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX (widget);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
493 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
494
2957
c859aa1a1a4e don't update text if it haven't changed
Tomasz Mon <desowin@gmail.com>
parents: 2956
diff changeset
495 if (!strcmp(textbox->text, text))
c859aa1a1a4e don't update text if it haven't changed
Tomasz Mon <desowin@gmail.com>
parents: 2956
diff changeset
496 return;
2951
4586c0951eab Handle multibyte sequences properly when encountered.
William Pitcock <nenolod@atheme-project.org>
parents: 2949
diff changeset
497 if (textbox->text)
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
498 g_free(textbox->text);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
499
2952
cb15e12b6352 Preserve capitalization for xfont users.
William Pitcock <nenolod@atheme-project.org>
parents: 2951
diff changeset
500 textbox->text = str_to_utf8(text);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
501 priv->scroll_back = FALSE;
2981
3bd337a93c9d oops, those shouldn't be commented
Tomasz Mon <desowin@gmail.com>
parents: 2980
diff changeset
502 gtk_widget_queue_draw(GTK_WIDGET(textbox));
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
503 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
504
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
505 static void textbox_generate_xfont_pixmap(UiSkinnedTextbox *textbox, const gchar *pixmaptext) {
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
506 /* FIXME: should operate directly on priv->pixbuf, it shouldn't use pixmap */
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
507 gint length, i;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
508 GdkGC *gc, *maskgc;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
509 GdkColor *c, pattern;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
510 GdkBitmap *mask;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
511 PangoLayout *layout;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
512 gint width;
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
513 GdkPixmap *pixmap;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
514
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
515 g_return_if_fail(textbox != NULL);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
516 g_return_if_fail(pixmaptext != NULL);
4119
9d4b5cdae3ba oops, fix previous commit
Tomasz Mon <desowin@gmail.com>
parents: 4118
diff changeset
517 g_return_if_fail(textbox->height > 0);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
518
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
519 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
520
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
521 length = g_utf8_strlen(pixmaptext, -1);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
522
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
523 text_get_extents(priv->fontname, pixmaptext, &width, NULL, NULL, NULL);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
524
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
525 priv->pixbuf_width = MAX(width, textbox->width);
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
526 pixmap = gdk_pixmap_new(mainwin->window, priv->pixbuf_width,
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
527 textbox->height,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
528 gdk_rgb_get_visual()->depth);
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
529 gc = gdk_gc_new(pixmap);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
530 c = skin_get_color(bmp_active_skin, SKIN_TEXTBG);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
531 for (i = 0; i < textbox->height; i++) {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
532 gdk_gc_set_foreground(gc, &c[6 * i / textbox->height]);
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
533 gdk_draw_line(pixmap, gc, 0, i, priv->pixbuf_width, i);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
534 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
535
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
536 mask = gdk_pixmap_new(mainwin->window, priv->pixbuf_width, textbox->height, 1);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
537 maskgc = gdk_gc_new(mask);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
538 pattern.pixel = 0;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
539 gdk_gc_set_foreground(maskgc, &pattern);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
540
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
541 gdk_draw_rectangle(mask, maskgc, TRUE, 0, 0, priv->pixbuf_width, textbox->height);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
542 pattern.pixel = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
543 gdk_gc_set_foreground(maskgc, &pattern);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
544
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
545 gdk_gc_set_foreground(gc, skin_get_color(bmp_active_skin, SKIN_TEXTFG));
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
546
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
547 layout = gtk_widget_create_pango_layout(mainwin, pixmaptext);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
548 pango_layout_set_font_description(layout, priv->font);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
549
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
550 gdk_draw_layout(pixmap, gc, 0, (priv->font_descent / 2), layout);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
551 g_object_unref(layout);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
552
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
553 g_object_unref(maskgc);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
554
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
555 gdk_gc_set_clip_mask(gc, mask);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
556 c = skin_get_color(bmp_active_skin, SKIN_TEXTFG);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
557 for (i = 0; i < textbox->height; i++) {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
558 gdk_gc_set_foreground(gc, &c[6 * i / textbox->height]);
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
559 gdk_draw_line(pixmap, gc, 0, i, priv->pixbuf_width, i);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
560 }
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
561 priv->pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_colormap_get_system(), 0, 0, 0, 0, priv->pixbuf_width, textbox->height);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
562 g_object_unref(mask);
3005
3db40ad79fd9 request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents: 2998
diff changeset
563 g_object_unref(gc);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
564 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
565
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
566 static gboolean textbox_scroll(gpointer data) {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
567 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX(data);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
568 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
569
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
570 if (!priv->is_dragging) {
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
571 if (priv->scroll_dummy < TEXTBOX_SCROLL_WAIT)
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
572 priv->scroll_dummy++;
2948
830fdbec31be introduce scroll_dummy to stop scrolling when it reaches end
Tomasz Mon <desowin@gmail.com>
parents: 2947
diff changeset
573 else {
2968
83f03505f819 add support for one-way text scroll.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2967
diff changeset
574 if(cfg.twoway_scroll) {
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
575 if (priv->scroll_back)
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
576 priv->offset -= 1;
2968
83f03505f819 add support for one-way text scroll.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2967
diff changeset
577 else
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
578 priv->offset += 1;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
579
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
580 if (priv->offset >= (priv->pixbuf_width - textbox->width)) {
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
581 priv->scroll_back = TRUE;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
582 priv->scroll_dummy = 0;
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
583 priv->offset = priv->pixbuf_width - textbox->width;
2968
83f03505f819 add support for one-way text scroll.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2967
diff changeset
584 }
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
585 if (priv->offset <= 0) {
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
586 priv->scroll_back = FALSE;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
587 priv->scroll_dummy = 0;
3956
8be86c0b040e fix possible glitch which could be triggered by switching skin while textbox was scrolling
Tomasz Mon <desowin@gmail.com>
parents: 3939
diff changeset
588 priv->offset = 0;
2968
83f03505f819 add support for one-way text scroll.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2967
diff changeset
589 }
2948
830fdbec31be introduce scroll_dummy to stop scrolling when it reaches end
Tomasz Mon <desowin@gmail.com>
parents: 2947
diff changeset
590 }
2968
83f03505f819 add support for one-way text scroll.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2967
diff changeset
591 else { // oneway scroll
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
592 priv->scroll_back = FALSE;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
593 priv->offset += 1;
2948
830fdbec31be introduce scroll_dummy to stop scrolling when it reaches end
Tomasz Mon <desowin@gmail.com>
parents: 2947
diff changeset
594 }
2965
f84d09bada0f correct _move_relative() and _resize_relative()
Tomasz Mon <desowin@gmail.com>
parents: 2962
diff changeset
595 gtk_widget_queue_draw(GTK_WIDGET(textbox));
2942
1a59a0ced6a8 make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents: 2920
diff changeset
596 }
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
597 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
598 return TRUE;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
599 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
600
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
601 static void textbox_generate_pixmap(UiSkinnedTextbox *textbox) {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
602 gint length, i, x, y, wl;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
603 gchar *pixmaptext;
2953
80b6fc3f4d29 Fix invalid free.
William Pitcock <nenolod@atheme-project.org>
parents: 2952
diff changeset
604 gchar *tmp, *stxt;
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
605
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
606 g_return_if_fail(textbox != NULL);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
607 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
608
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
609 if (priv->pixbuf) {
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
610 g_object_unref(priv->pixbuf);
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
611 priv->pixbuf = NULL;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
612 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
613
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
614 /*
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
615 * Don't reset the offset if only text after the last '(' has
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
616 * changed. This is a hack to avoid visual noice on vbr files
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
617 * where we guess the length.
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
618 */
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
619 if (!(priv->pixbuf_text && strrchr(textbox->text, '(') &&
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
620 !strncmp(priv->pixbuf_text, textbox->text,
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
621 strrchr(textbox->text, '(') - textbox->text)))
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
622 priv->offset = 0;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
623
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
624 g_free(priv->pixbuf_text);
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
625 priv->pixbuf_text = g_strdup(textbox->text);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
626
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
627 /*
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
628 * wl is the number of (partial) letters visible. Only makes
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
629 * sense when using skinned font.
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
630 */
2947
13591e28d89e cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2945
diff changeset
631 wl = textbox->width / 5;
13591e28d89e cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2945
diff changeset
632 if (wl * 5 != textbox->width)
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
633 wl++;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
634
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
635 length = g_utf8_strlen(textbox->text, -1);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
636
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
637 priv->is_scrollable = FALSE;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
638
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
639 priv->is_scrollable = ui_skinned_textbox_should_scroll(textbox);
2916
3ef909ed3056 fix clearing textbox when short text is displayed
Tomasz Mon <desowin@gmail.com>
parents: 2913
diff changeset
640
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
641 if (priv->is_scrollable) {
2971
1db413cb4437 revise padding logic
Tomasz Mon <desowin@gmail.com>
parents: 2970
diff changeset
642 if(!cfg.twoway_scroll) {
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
643 pixmaptext = g_strdup_printf("%s *** ", priv->pixbuf_text);
2971
1db413cb4437 revise padding logic
Tomasz Mon <desowin@gmail.com>
parents: 2970
diff changeset
644 length += 5;
1db413cb4437 revise padding logic
Tomasz Mon <desowin@gmail.com>
parents: 2970
diff changeset
645 } else
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
646 pixmaptext = g_strdup(priv->pixbuf_text);
2971
1db413cb4437 revise padding logic
Tomasz Mon <desowin@gmail.com>
parents: 2970
diff changeset
647 } else
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
648 if (!priv->font && length <= wl) {
2916
3ef909ed3056 fix clearing textbox when short text is displayed
Tomasz Mon <desowin@gmail.com>
parents: 2913
diff changeset
649 gint pad = wl - length;
3ef909ed3056 fix clearing textbox when short text is displayed
Tomasz Mon <desowin@gmail.com>
parents: 2913
diff changeset
650 gchar *padchars = g_strnfill(pad, ' ');
3ef909ed3056 fix clearing textbox when short text is displayed
Tomasz Mon <desowin@gmail.com>
parents: 2913
diff changeset
651
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
652 pixmaptext = g_strconcat(priv->pixbuf_text, padchars, NULL);
2916
3ef909ed3056 fix clearing textbox when short text is displayed
Tomasz Mon <desowin@gmail.com>
parents: 2913
diff changeset
653 g_free(padchars);
3ef909ed3056 fix clearing textbox when short text is displayed
Tomasz Mon <desowin@gmail.com>
parents: 2913
diff changeset
654 length += pad;
2971
1db413cb4437 revise padding logic
Tomasz Mon <desowin@gmail.com>
parents: 2970
diff changeset
655 } else
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
656 pixmaptext = g_strdup(priv->pixbuf_text);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
657
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
658 if (priv->is_scrollable) {
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
659 if (priv->scroll_enabled && !priv->scroll_timeout) {
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
660 gint tag;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
661 tag = TEXTBOX_SCROLL_SMOOTH_TIMEOUT;
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
662 priv->scroll_timeout = g_timeout_add(tag, textbox_scroll, textbox);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
663 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
664 } else {
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
665 if (priv->scroll_timeout) {
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
666 g_source_remove(priv->scroll_timeout);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
667 priv->scroll_timeout = 0;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
668 }
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
669 priv->offset = 0;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
670 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
671
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
672 if (priv->font) {
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
673 textbox_generate_xfont_pixmap(textbox, pixmaptext);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
674 g_free(pixmaptext);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
675 return;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
676 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
677
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
678 priv->pixbuf_width = length * bmp_active_skin->properties.textbox_bitmap_font_width;
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
679 priv->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8,
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
680 priv->pixbuf_width, bmp_active_skin->properties.textbox_bitmap_font_height);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
681
2953
80b6fc3f4d29 Fix invalid free.
William Pitcock <nenolod@atheme-project.org>
parents: 2952
diff changeset
682 for (tmp = stxt = g_utf8_strup(pixmaptext, -1), i = 0;
2952
cb15e12b6352 Preserve capitalization for xfont users.
William Pitcock <nenolod@atheme-project.org>
parents: 2951
diff changeset
683 tmp != NULL && i < length; i++, tmp = g_utf8_next_char(tmp)) {
2951
4586c0951eab Handle multibyte sequences properly when encountered.
William Pitcock <nenolod@atheme-project.org>
parents: 2949
diff changeset
684 gchar c = *tmp;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
685 x = y = -1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
686 if (c >= 'A' && c <= 'Z') {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
687 x = bmp_active_skin->properties.textbox_bitmap_font_width * (c - 'A');
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
688 y = 0;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
689 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
690 else if (c >= '0' && c <= '9') {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
691 x = bmp_active_skin->properties.textbox_bitmap_font_width * (c - '0');
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
692 y = bmp_active_skin->properties.textbox_bitmap_font_height;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
693 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
694 else
3038
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
695 textbox_handle_special_char(tmp, &x, &y);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
696
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
697 skin_draw_pixbuf(GTK_WIDGET(textbox), bmp_active_skin,
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4135
diff changeset
698 priv->pixbuf, priv->skin_index,
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
699 x, y, i * bmp_active_skin->properties.textbox_bitmap_font_width, 0,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
700 bmp_active_skin->properties.textbox_bitmap_font_width,
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
701 bmp_active_skin->properties.textbox_bitmap_font_height);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
702 }
2953
80b6fc3f4d29 Fix invalid free.
William Pitcock <nenolod@atheme-project.org>
parents: 2952
diff changeset
703 g_free(stxt);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
704 g_free(pixmaptext);
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
705 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
706
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
707 void ui_skinned_textbox_set_scroll(GtkWidget *widget, gboolean scroll) {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
708 g_return_if_fail(widget != NULL);
2980
d58560be5a4c draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
709 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX(widget);
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
710 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
711
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
712 priv->scroll_enabled = scroll;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
713 if (priv->scroll_enabled && priv->is_scrollable && priv->scroll_allowed) {
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
714 gint tag;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
715 tag = TEXTBOX_SCROLL_SMOOTH_TIMEOUT;
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
716 if (priv->scroll_timeout) {
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
717 g_source_remove(priv->scroll_timeout);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
718 priv->scroll_timeout = 0;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
719 }
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
720 priv->scroll_timeout = g_timeout_add(tag, textbox_scroll, textbox);
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
721
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
722 } else {
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
723
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
724 if (priv->scroll_timeout) {
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
725 g_source_remove(priv->scroll_timeout);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
726 priv->scroll_timeout = 0;
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
727 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
728
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
729 priv->offset = 0;
2981
3bd337a93c9d oops, those shouldn't be commented
Tomasz Mon <desowin@gmail.com>
parents: 2980
diff changeset
730 gtk_widget_queue_draw(GTK_WIDGET(textbox));
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
731 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
732 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
733
3038
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
734 static void textbox_handle_special_char(gchar *c, gint * x, gint * y) {
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
735 gint tx, ty;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
736
3038
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
737 switch (*c) {
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
738 case '"':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
739 tx = 26;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
740 ty = 0;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
741 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
742 case '\r':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
743 tx = 10;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
744 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
745 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
746 case ':':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
747 case ';':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
748 tx = 12;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
749 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
750 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
751 case '(':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
752 tx = 13;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
753 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
754 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
755 case ')':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
756 tx = 14;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
757 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
758 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
759 case '-':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
760 tx = 15;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
761 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
762 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
763 case '`':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
764 case '\'':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
765 tx = 16;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
766 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
767 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
768 case '!':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
769 tx = 17;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
770 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
771 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
772 case '_':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
773 tx = 18;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
774 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
775 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
776 case '+':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
777 tx = 19;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
778 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
779 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
780 case '\\':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
781 tx = 20;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
782 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
783 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
784 case '/':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
785 tx = 21;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
786 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
787 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
788 case '[':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
789 tx = 22;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
790 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
791 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
792 case ']':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
793 tx = 23;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
794 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
795 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
796 case '^':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
797 tx = 24;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
798 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
799 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
800 case '&':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
801 tx = 25;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
802 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
803 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
804 case '%':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
805 tx = 26;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
806 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
807 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
808 case '.':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
809 case ',':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
810 tx = 27;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
811 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
812 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
813 case '=':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
814 tx = 28;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
815 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
816 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
817 case '$':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
818 tx = 29;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
819 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
820 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
821 case '#':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
822 tx = 30;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
823 ty = 1;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
824 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
825 case '?':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
826 tx = 3;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
827 ty = 2;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
828 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
829 case '*':
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
830 tx = 4;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
831 ty = 2;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
832 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
833 default:
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
834 tx = 29;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
835 ty = 0;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
836 break;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
837 }
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
838
3038
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
839 const gchar *change[] = {"Ą", "A", "Ę", "E", "Ć", "C", "Ł", "L", "Ó", "O", "Ś", "S", "Ż", "Z", "Ź", "Z",
3293
910c9296d6b3 when using bitmap font display as N
Tomasz Mon <desowin@gmail.com>
parents: 3251
diff changeset
840 "Ń", "N", "Ü", "U", NULL};
3038
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
841 int i;
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
842 for (i = 0; change[i]; i+=2) {
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
843 if (!strncmp(c, change[i], strlen(change[i]))) {
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
844 tx = (*change[i+1] - 'A');
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
845 break;
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
846 }
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
847 }
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
848
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
849 /* those are commonly included into skins */
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
850 if (!strncmp(c, "Å", strlen("Å"))) {
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
851 tx = 0;
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
852 ty = 2;
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
853 } else if (!strncmp(c, "Ö", strlen("Ö"))) {
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
854 tx = 1;
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
855 ty = 2;
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
856 } else if (!strncmp(c, "Ä", strlen("Ä"))) {
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
857 tx = 2;
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
858 ty = 2;
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
859 }
ff886a3a2098 little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents: 3032
diff changeset
860
2911
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
861 *x = tx * bmp_active_skin->properties.textbox_bitmap_font_width;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
862 *y = ty * bmp_active_skin->properties.textbox_bitmap_font_height;
cd21a4556dd2 include UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
863 }
2943
a8f2c99727eb replace Textbox in playlistwin with UiSkinnedTextbox, textbox.c no longer needed, temporary comment out g_usleep in textbox_scroll as it needs to be run as new thread
Tomasz Mon <desowin@gmail.com>
parents: 2942
diff changeset
864
a8f2c99727eb replace Textbox in playlistwin with UiSkinnedTextbox, textbox.c no longer needed, temporary comment out g_usleep in textbox_scroll as it needs to be run as new thread
Tomasz Mon <desowin@gmail.com>
parents: 2942
diff changeset
865 void ui_skinned_textbox_move_relative(GtkWidget *widget, gint x, gint y) {
2996
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
866 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(widget);
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
867 priv->move_x += x;
a2eb970ca669 bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents: 2991
diff changeset
868 priv->move_y += y;
2943
a8f2c99727eb replace Textbox in playlistwin with UiSkinnedTextbox, textbox.c no longer needed, temporary comment out g_usleep in textbox_scroll as it needs to be run as new thread
Tomasz Mon <desowin@gmail.com>
parents: 2942
diff changeset
869 }