2 "$Id: spells.c 9201 2008-06-01 17:32:45Z anmaster $";
35 #include <glade/glade.h>
58 "spell_attuned",
"spell_repelled",
"spell_denied",
"spell_normal"
76 static int style_has_init=0;
80 tmp_style = gtk_rc_get_style_by_paths(gtk_settings_get_default(), NULL,
86 LOG(
LOG_INFO,
"spells.c::spell_get_styles",
"Unable to find style for %s",
105 GtkTreeSelection *selection,
108 gboolean path_currently_selected,
125 PangoFontDescription *
font=NULL;
141 gtk_widget_modify_fg(
spell_label[i],GTK_STATE_NORMAL,
147 gtk_widget_modify_fg(
spell_label[i],GTK_STATE_NORMAL, NULL);
158 if (spell->
sp) snprintf(buf,
sizeof(buf),
"%d Mana ", spell->
sp);
159 if (spell->
grace) snprintf(buf + strlen(buf),
sizeof(buf)-strlen(buf),
"%d Grace", spell->
grace);
167 foreground = &row_style->text[GTK_STATE_NORMAL];
168 background = &row_style->base[GTK_STATE_NORMAL];
169 font = row_style->font_desc;
205 GtkCellRenderer *renderer;
206 GtkTreeViewColumn *column;
209 xml_tree = glade_get_widget_tree(GTK_WIDGET(
spell_window));
211 spell_invoke = glade_xml_get_widget(xml_tree,
"spell_invoke");
212 spell_cast = glade_xml_get_widget(xml_tree,
"spell_cast");
213 spell_options = glade_xml_get_widget(xml_tree,
"spell_options");
214 spell_treeview = glade_xml_get_widget(xml_tree,
"spell_treeview");
218 g_signal_connect ((gpointer)
spell_cast,
"clicked",
223 widget = glade_xml_get_widget(xml_tree,
"spell_close");
224 g_signal_connect ((gpointer) widget,
"clicked",
241 PANGO_TYPE_FONT_DESCRIPTION
244 gtk_tree_view_set_model(GTK_TREE_VIEW(spell_treeview), GTK_TREE_MODEL(
spell_store));
245 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(spell_treeview),
TRUE);
252 renderer = gtk_cell_renderer_text_new ();
253 column = gtk_tree_view_column_new_with_attributes (
"Spell", renderer,
256 gtk_tree_view_append_column (GTK_TREE_VIEW (spell_treeview), column);
257 gtk_tree_view_column_set_sort_column_id(column,
LIST_NAME);
258 gtk_tree_view_column_add_attribute(column, renderer,
"background-gdk",
LIST_BACKGROUND);
259 gtk_tree_view_column_add_attribute(column, renderer,
"foreground-gdk",
LIST_FOREGROUND);
260 gtk_tree_view_column_add_attribute(column, renderer,
"font-desc",
LIST_FONT);
262 renderer = gtk_cell_renderer_text_new ();
263 column = gtk_tree_view_column_new_with_attributes (
"Level", renderer,
266 gtk_tree_view_append_column (GTK_TREE_VIEW (spell_treeview), column);
267 gtk_tree_view_column_set_sort_column_id(column,
LIST_LEVEL);
268 gtk_tree_view_column_add_attribute(column, renderer,
"background-gdk",
LIST_BACKGROUND);
269 gtk_tree_view_column_add_attribute(column, renderer,
"foreground-gdk",
LIST_FOREGROUND);
270 gtk_tree_view_column_add_attribute(column, renderer,
"font-desc",
LIST_FONT);
272 renderer = gtk_cell_renderer_text_new ();
273 column = gtk_tree_view_column_new_with_attributes (
"SP/Mana Cost", renderer,
276 gtk_tree_view_append_column (GTK_TREE_VIEW (spell_treeview), column);
281 gtk_tree_view_column_set_sort_column_id(column,
LIST_MAX_SP);
282 gtk_tree_view_column_add_attribute(column, renderer,
"background-gdk",
LIST_BACKGROUND);
283 gtk_tree_view_column_add_attribute(column, renderer,
"foreground-gdk",
LIST_FOREGROUND);
284 gtk_tree_view_column_add_attribute(column, renderer,
"font-desc",
LIST_FONT);
286 renderer = gtk_cell_renderer_text_new ();
287 column = gtk_tree_view_column_new_with_attributes (
"Damage", renderer,
290 gtk_tree_view_append_column (GTK_TREE_VIEW (spell_treeview), column);
291 gtk_tree_view_column_set_sort_column_id(column,
LIST_DAMAGE);
292 gtk_tree_view_column_add_attribute(column, renderer,
"background-gdk",
LIST_BACKGROUND);
293 gtk_tree_view_column_add_attribute(column, renderer,
"foreground-gdk",
LIST_FOREGROUND);
294 gtk_tree_view_column_add_attribute(column, renderer,
"font-desc",
LIST_FONT);
296 column = gtk_tree_view_column_new_with_attributes (
"Skill", renderer,
299 gtk_tree_view_append_column (GTK_TREE_VIEW (spell_treeview), column);
300 gtk_tree_view_column_set_sort_column_id(column,
LIST_SKILL);
301 gtk_tree_view_column_add_attribute(column, renderer,
"background-gdk",
LIST_BACKGROUND);
302 gtk_tree_view_column_add_attribute(column, renderer,
"foreground-gdk",
LIST_FOREGROUND);
303 gtk_tree_view_column_add_attribute(column, renderer,
"font-desc",
LIST_FONT);
305 renderer = gtk_cell_renderer_text_new ();
306 column = gtk_tree_view_column_new_with_attributes (
"Description", renderer,
309 gtk_tree_view_append_column (GTK_TREE_VIEW (spell_treeview), column);
310 gtk_tree_view_column_add_attribute(column, renderer,
"background-gdk",
LIST_BACKGROUND);
311 gtk_tree_view_column_add_attribute(column, renderer,
"foreground-gdk",
LIST_FOREGROUND);
312 gtk_tree_view_column_add_attribute(column, renderer,
"font-desc",
LIST_FONT);
314 spell_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(spell_treeview));
320 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(
spell_store),
326 glade_xml_get_widget(xml_tree,
"spell_label_attuned");
328 glade_xml_get_widget(xml_tree,
"spell_label_repelled");
330 glade_xml_get_widget(xml_tree,
"spell_label_denied");
332 glade_xml_get_widget(xml_tree,
"spell_label_normal");
340 glade_xml_get_widget(xml_tree,
"spell_eventbox_attuned");
342 glade_xml_get_widget(xml_tree,
"spell_eventbox_repelled");
344 glade_xml_get_widget(xml_tree,
"spell_eventbox_denied");
346 glade_xml_get_widget(xml_tree,
"spell_eventbox_normal");
369 GtkTreeViewColumn *column,
376 const char *options = NULL;
378 model = gtk_tree_view_get_model(treeview);
379 if (gtk_tree_model_get_iter(model, &iter, path)) {
380 gtk_tree_model_get(model, &iter,
LIST_TAG, &tag, -1);
383 LOG(
LOG_ERROR,
"spells.c:on_spell_cast_clicked",
"Unable to get spell tag\n");
386 snprintf(command,
MAX_BUF-1,
"cast %d %s", tag, options);
400 const char *options = NULL;
408 if (gtk_tree_selection_get_selected (
spell_selection, &model, &iter)) {
409 gtk_tree_model_get(model, &iter,
LIST_TAG, &tag, -1);
412 LOG(
LOG_ERROR,
"spells.c:on_spell_cast_clicked",
"Unable to get spell tag\n");
415 snprintf(command,
MAX_BUF-1,
"cast %d %s", tag, options);
430 const char *options = NULL;
438 if (gtk_tree_selection_get_selected (
spell_selection, &model, &iter)) {
439 gtk_tree_model_get(model, &iter,
LIST_TAG, &tag, -1);
442 LOG(
LOG_ERROR,
"spells.c:on_spell_invoke_clicked",
"Unable to get spell tag\n");
445 snprintf(command,
MAX_BUF-1,
"invoke %d %s", tag, options);
void on_spells_activate(GtkMenuItem *menuitem, gpointer user_data)
static GtkWidget * spell_label[Style_Last]
static XFontStruct * font
const char *const rcsid_gtk2_spells_c
static const char * Style_Names[Style_Last]
static GtkWidget * spell_eventbox[Style_Last]
void on_spell_cast_clicked(GtkButton *button, gpointer user_data)
static unsigned long background
void on_spell_treeview_row_activated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
static GtkWidget * spell_cast
void LOG(LogLevel level, const char *origin, const char *format,...)
static GtkTreeSelection * spell_selection
void on_spell_close_clicked(GtkButton *button, gpointer user_data)
int send_command(const char *command, int repeat, int must_send)
void spell_get_styles(void)
static unsigned long foreground
void on_spell_invoke_clicked(GtkButton *button, gpointer user_data)
static GtkWidget * spell_window
struct Spell_struct * next
static GtkWidget * spell_treeview
void update_spell_information(void)
static gboolean spell_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer userdata)
static GtkListStore * spell_store
static GtkStyle * spell_styles[Style_Last]
static GtkWidget * spell_invoke
static GtkWidget * spell_options