1 /* HexChat
2  * Copyright (C) 1998-2010 Peter Zelezny.
3  * Copyright (C) 2009-2013 Berke Viktor.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19 
20 #ifndef HEXCHAT_FE_GTK_H
21 #define HEXCHAT_FE_GTK_H
22 
23 #include "config.h"
24 
25 #define DISPLAY_NAME "HexChat"
26 
27 #ifndef WIN32
28 #include <sys/types.h>
29 #endif
30 
31 #include <glib/gi18n.h>
32 #include <gtk/gtk.h>
33 
34 #ifdef HAVE_GTK_MAC
35 #include <gtkosxapplication.h>
36 #endif
37 
38 #include "banlist.h"
39 
40 #define flag_c flag_wid[0]
41 #define flag_n flag_wid[1]
42 #define flag_t flag_wid[2]
43 #define flag_i flag_wid[3]
44 #define flag_m flag_wid[4]
45 #define flag_l flag_wid[5]
46 #define flag_k flag_wid[6]
47 #define flag_b flag_wid[7]
48 #define NUM_FLAG_WIDS 8
49 
50 #ifdef HAVE_GTK_MAC
51 extern GtkosxApplication *osx_app;
52 #endif
53 
54 struct server_gui
55 {
56 	GtkWidget *rawlog_window;
57 	GtkWidget *rawlog_textlist;
58 
59 	/* join dialog */
60 	GtkWidget *joind_win;
61 	GtkWidget *joind_entry;
62 	GtkWidget *joind_radio1;
63 	GtkWidget *joind_radio2;
64 	GtkWidget *joind_check;
65 
66 	/* chanlist variables */
67 	GtkWidget *chanlist_wild;		/* GtkEntry */
68 	GtkWidget *chanlist_window;
69 	GtkWidget *chanlist_list;
70 	GtkWidget *chanlist_label;
71 	GtkWidget *chanlist_min_spin;	/* minusers GtkSpinButton */
72 	GtkWidget *chanlist_refresh;	/* buttons */
73 	GtkWidget *chanlist_join;
74 	GtkWidget *chanlist_savelist;
75 	GtkWidget *chanlist_search;
76 
77 	GSList *chanlist_data_stored_rows;	/* stored list so it can be resorted  */
78 	GSList *chanlist_pending_rows;
79 	gint chanlist_tag;
80 	gint chanlist_flash_tag;
81 
82 	gboolean chanlist_match_wants_channel;	/* match in channel name */
83 	gboolean chanlist_match_wants_topic;	/* match in topic */
84 
85 	GRegex *chanlist_match_regex;	/* compiled regular expression here */
86 	unsigned int have_regex;
87 
88 	guint chanlist_users_found_count;	/* users total for all channels */
89 	guint chanlist_users_shown_count;	/* users total for displayed channels */
90 	guint chanlist_channels_found_count;	/* channel total for /LIST operation */
91 	guint chanlist_channels_shown_count;	/* total number of displayed
92 														   channels */
93 
94 	guint32 chanlist_maxusers;
95 	guint32 chanlist_minusers;
96 	guint32 chanlist_minusers_downloaded;	/* used by LIST IRC command */
97 	int chanlist_search_type;		/* 0=simple 1=pattern/wildcard 2=regexp */
98 	gboolean chanlist_caption_is_stale;
99 };
100 
101 /* this struct is persistant even when delinking/relinking */
102 
103 typedef struct restore_gui
104 {
105 	banlist_info *banlist;
106 
107 	void *tab;			/* (chan *) */
108 
109 	/* information stored when this tab isn't front-most */
110 	GtkListStore *user_model;	/* for filling the GtkTreeView */
111 	void *buffer;		/* xtext_Buffer */
112 	char *input_text;	/* input text buffer (while not-front tab) */
113 	char *topic_text;	/* topic GtkEntry buffer */
114 	char *key_text;
115 	char *limit_text;
116 	gfloat old_ul_value;	/* old userlist value (for adj) */
117 	gfloat lag_value;	/* lag-o-meter */
118 	char *lag_text;	/* lag-o-meter text */
119 	char *lag_tip;		/* lag-o-meter tooltip */
120 	gfloat queue_value; /* outbound queue meter */
121 	char *queue_text;		/* outbound queue text */
122 	char *queue_tip;		/* outbound queue tooltip */
123 	short flag_wid_state[NUM_FLAG_WIDS];
124 	unsigned int c_graph:1;	/* connecting graph, is there one? */
125 } restore_gui;
126 
127 typedef struct session_gui
128 {
129 	GtkWidget
130 		*xtext,
131 		*vscrollbar,
132 		*window,	/* toplevel */
133 		*topic_entry,
134 		*note_book,
135 		*main_table,
136 		*user_tree,	/* GtkTreeView */
137 		*user_box,	/* userlist box */
138 		*button_box_parent,
139 		*button_box,	/* userlist buttons' box */
140 		*dialogbutton_box,
141 		*topicbutton_box,
142 		*meter_box,	/* all the meters inside this */
143 		*lagometer,
144 		*laginfo,
145 		*throttlemeter,
146 		*throttleinfo,
147 		*topic_bar,
148 		*hpane_left,
149 		*hpane_right,
150 		*vpane_left,
151 		*vpane_right,
152 		*menu,
153 		*bar,				/* connecting progress bar */
154 		*nick_box,		/* contains label to the left of input_box */
155 		*nick_label,
156 		*op_xpm,			/* icon to the left of nickname */
157 		*namelistinfo,	/* label above userlist */
158 		*input_box,
159 		*flag_wid[NUM_FLAG_WIDS],		/* channelmode buttons */
160 		*limit_entry,		  /* +l */
161 		*key_entry;		  /* +k */
162 
163 		GtkWidget *shbox, *shentry;	/* search bar hbox */
164 		gulong search_changed_signal; /* hook for search change event so blanking the box doesn't suck */
165 
166 #define MENU_ID_NUM 14
167 	GtkWidget *menu_item[MENU_ID_NUM+1]; /* some items we may change state of */
168 
169 	void *chanview;	/* chanview.h */
170 
171 	int bartag;		/*connecting progressbar timeout */
172 
173 	int pane_left_size;	/*last position of the pane*/
174 	int pane_right_size;
175 
176 	guint16 is_tab;	/* is tab or toplevel? */
177 	guint16 ul_hidden;	/* userlist hidden? */
178 
179 } session_gui;
180 
181 extern GdkPixmap *channelwin_pix;
182 extern GdkPixmap *dialogwin_pix;
183 
184 #define SPELL_ENTRY_GET_TEXT(e) ((char *)(gtk_entry_get_text (GTK_ENTRY(e))))
185 #define SPELL_ENTRY_SET_TEXT(e,txt) gtk_entry_set_text(GTK_ENTRY(e),txt)
186 #define SPELL_ENTRY_SET_EDITABLE(e,v) gtk_editable_set_editable(GTK_EDITABLE(e),v)
187 #define SPELL_ENTRY_GET_POS(e) gtk_editable_get_position(GTK_EDITABLE(e))
188 #define SPELL_ENTRY_SET_POS(e,p) gtk_editable_set_position(GTK_EDITABLE(e),p);
189 #define SPELL_ENTRY_INSERT(e,t,l,p) gtk_editable_insert_text(GTK_EDITABLE(e),t,l,p)
190 
191 #endif
192