void keyboard_option_add_new(GtkTreeIter *parent,
const gchar *oname,
GType otype,
- gpointer oval);
+ gpointer oval,
+ GtkTreeIter *newret);
void keyboard_key_store_add_default_options(GtkTreeIter *it);
void keyboard_fill_key_store(GtkTreeIter *parent, xmlNode *a_node);
void keyboard_write_bindings();
key_name = gdk_keyval_name(gdk_keymap_lookup_key(NULL, &key));
c[1] = '-';
- c[2] = (gchar) NULL;
+ c[2] = '\0';
txt = g_string_new(gtk_entry_get_text(GTK_ENTRY(w)));
/* if the last char in the entry is not a '-', then the user has started
* entering the new keybinding, so clear the entry first... */
if (txt->str[txt->len - 1] != (gchar) '-')
- {
gtk_entry_set_text(GTK_ENTRY(w), "");
- }
if (!strncmp(key_name, SHIFT, strlen(SHIFT)))
- {
c[0] = 'S';
- }
else if (!strncmp(key_name, CONTROL, strlen(CONTROL)))
- {
c[0] = 'C';
- }
else if (!strncmp(key_name, ALT, strlen(ALT)))
- {
c[0] = 'A';
- }
else if (!strncmp(key_name, SUPER, strlen(SUPER)))
- {
c[0] = 'W';
- }
else if (!strncmp(key_name, META, strlen(SUPER)))
- {
c[0] = 'C';
- }
else if (!strncmp(key_name, HYPER, strlen(HYPER)))
- {
c[0] = 'H';
- }
- else
- {
- c[0] = (gchar) NULL;
+ else {
+ c[0] = '\0';
gtk_entry_append_text(GTK_ENTRY(w), key_name);
}
gtk_entry_append_text(GTK_ENTRY(w), c);
key_name = gdk_keyval_name(gdk_keymap_lookup_key(NULL, &key));
c[1] = '-';
- c[2] = (gchar) NULL;
+ c[2] = '\0';
gtk_tree_model_get(GTK_TREE_MODEL(key_store), it, KEY_COL, &txt, -1);
len = strlen(txt);
if (txt[len - 1] != (gchar) '-')
{
g_free(txt);
- gtk_tree_store_set(GTK_TREE_MODEL(key_store), (GtkTreeIter *) it,
+ gtk_tree_store_set(key_store, (GtkTreeIter *) it,
KEY_COL, "", -1);
}
}
else
{
- c[0] = (gchar) NULL;
+ c[0] = '\0';
gtk_tree_model_get(GTK_TREE_MODEL(key_store), it, KEY_COL, &txt, -1);
new_text = g_strconcat(txt, key_name, NULL);
g_free(txt);
- gtk_tree_store_set(GTK_TREE_MODEL(key_store), (GtkTreeIter *) it,
+ gtk_tree_store_set(key_store, (GtkTreeIter *) it,
KEY_COL, new_text, -1);
}
gtk_tree_model_get(GTK_TREE_MODEL(key_store), it, KEY_COL, &txt, -1);
new_text = g_strconcat(txt, c, NULL);
g_free(txt);
- gtk_tree_store_set(GTK_TREE_MODEL(key_store), (GtkTreeIter *) it,
+ gtk_tree_store_set(key_store, (GtkTreeIter *) it,
KEY_COL, new_text, -1);
old_text[len + 1] = '\0';
new_text = g_strconcat(old_text, key_name, NULL);
- gtk_tree_store_set(GTK_TREE_MODEL(key_store), (GtkTreeIter *) it,
+ gtk_tree_store_set(key_store, (GtkTreeIter *) it,
KEY_COL, new_text, -1);
g_free(txt);
}
}
gtk_tree_view_scroll_to_cell
- (tv, gtk_tree_model_get_path(GTK_TREE_MODEL(key_store), it),
+ (GTK_TREE_VIEW(tv),
+ gtk_tree_model_get_path(GTK_TREE_MODEL(key_store), it),
NULL, TRUE, .5, 0);
gtk_widget_grab_focus(tv);
gtk_tree_model_get(GTK_TREE_MODEL(key_store), it, KEY_COL, &text, -1);
g_free(text);
- gtk_tree_store_set(GTK_TREE_MODEL(key_store), (GtkTreeIter *) it,
+ gtk_tree_store_set(key_store, (GtkTreeIter *) it,
KEY_COL, "Enter Keybinding", -1);
gdk_keyboard_grab
gtk_tree_store_append(key_store, &new, &parent);
gtk_tree_view_expand_to_path
- (tv, gtk_tree_model_get_path(GTK_TREE_MODEL(key_store), &new));
+ (GTK_TREE_VIEW(tv),
+ gtk_tree_model_get_path(GTK_TREE_MODEL(key_store), &new));
gtk_tree_view_scroll_to_cell
- (tv, gtk_tree_model_get_path(GTK_TREE_MODEL(key_store), &new),
+ (GTK_TREE_VIEW(tv),
+ gtk_tree_model_get_path(GTK_TREE_MODEL(key_store), &new),
NULL, FALSE, 0, 0);
gtk_tree_selection_select_iter
- (gtk_tree_view_get_selection(tv), &new);
+ (gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)), &new);
on_tool_edit_clicked(NULL, NULL);
}
gtk_tree_store_insert_after(key_store, &new, NULL, &it);
gtk_tree_view_expand_to_path
- (tv, gtk_tree_model_get_path(GTK_TREE_MODEL(key_store), &new));
+ (GTK_TREE_VIEW(tv),
+ gtk_tree_model_get_path(GTK_TREE_MODEL(key_store), &new));
gtk_tree_view_scroll_to_cell
- (tv, gtk_tree_model_get_path(GTK_TREE_MODEL(key_store), &new),
+ (GTK_TREE_VIEW(tv),
+ gtk_tree_model_get_path(GTK_TREE_MODEL(key_store), &new),
NULL, FALSE, 0, 0);
gtk_tree_selection_select_iter
- (gtk_tree_view_get_selection(tv), &new);
+ (gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)), &new);
on_tool_edit_clicked(NULL, NULL);
}
}
gtk_tree_view_expand_to_path
- (tv, gtk_tree_model_get_path(GTK_TREE_MODEL(key_store), &new));
+ (GTK_TREE_VIEW(tv),
+ gtk_tree_model_get_path(GTK_TREE_MODEL(key_store), &new));
gtk_tree_view_scroll_to_cell
- (tv, gtk_tree_model_get_path(GTK_TREE_MODEL(key_store), &new),
+ (GTK_TREE_VIEW(tv),
+ gtk_tree_model_get_path(GTK_TREE_MODEL(key_store), &new),
NULL, FALSE, 0, 0);
gtk_tree_selection_select_iter
- (gtk_tree_view_get_selection(tv), &new);
+ (gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)), &new);
keyboard_write_bindings();
}
ACTION_COL, &old_text, -1);
if (!strcmp(new_text, old_text))
- {
return;
- }
g_free(old_text);
void keyboard_option_add_new(GtkTreeIter *parent,
const gchar *oname,
GType otype,
- gpointer oval)
+ gpointer oval,
+ GtkTreeIter *newret)
{
GtkTreeIter new;
GtkAdjustment *adj;
switch (otype)
{
- case G_TYPE_STRING:
- gtk_tree_store_set(key_store, &new,
- OPTION_COL, oname,
- OVAL_STR_COL, (gchar *) oval,
- OVAL_TYPE_STR_COL, TRUE,
- EDITABLE_COL, FALSE,
- -1);
- break;
- case G_TYPE_BOOLEAN:
- gtk_tree_store_set(key_store, &new,
- OPTION_COL, oname,
- OVAL_BOOL_COL, (gboolean) oval,
- OVAL_TYPE_BOOL_COL, TRUE,
- EDITABLE_COL, FALSE,
- -1);
- break;
- case G_TYPE_INT:
- adj = GTK_ADJUSTMENT(gtk_adjustment_new
- ((gint) oval,
- -5000, 5000, 1, 1, 0));
- g_ascii_dtostr(buf, 16, (gdouble)((gint) oval));
- gtk_tree_store_set(key_store, &new,
- OPTION_COL, oname,
- OVAL_INT_COL, G_OBJECT(adj),
- OVAL_STR_COL, buf,
- OVAL_TYPE_INT_COL, TRUE,
- EDITABLE_COL, FALSE,
- -1);
- break;
+ case G_TYPE_NONE:
+ gtk_tree_store_set(key_store, &new,
+ OPTION_COL, oname,
+ -1);
+ break;
+ case G_TYPE_STRING:
+ gtk_tree_store_set(key_store, &new,
+ OPTION_COL, oname,
+ OVAL_STR_COL, (gchar *) oval,
+ OVAL_TYPE_STR_COL, TRUE,
+ EDITABLE_COL, FALSE,
+ -1);
+ break;
+ case G_TYPE_BOOLEAN:
+ gtk_tree_store_set(key_store, &new,
+ OPTION_COL, oname,
+ OVAL_BOOL_COL, *((gboolean*)oval),
+ OVAL_TYPE_BOOL_COL, TRUE,
+ EDITABLE_COL, FALSE,
+ -1);
+ break;
+ case G_TYPE_INT:
+ adj = GTK_ADJUSTMENT(gtk_adjustment_new
+ (*((gint*)oval),
+ -5000, 5000, 1, 1, 0));
+ g_ascii_dtostr(buf, 16, (gdouble)*((gint*)oval));
+ gtk_tree_store_set(key_store, &new,
+ OPTION_COL, oname,
+ OVAL_INT_COL, G_OBJECT(adj),
+ OVAL_STR_COL, buf,
+ OVAL_TYPE_INT_COL, TRUE,
+ EDITABLE_COL, FALSE,
+ -1);
+ break;
}
-
+ if (newret) *newret = new;
}
void keyboard_key_store_add_default_options(GtkTreeIter *it)
{
gchar *atext;
Action action;
+ GtkTreeIter chld;
+ gboolean b;
+ gint i;
gtk_tree_model_get(GTK_TREE_MODEL(key_store), it, ACTION_COL, &atext, -1);
action = action_get_name_from_text(atext);
- switch (action)
- {
- case A_EXECUTE:
- keyboard_option_add_new(it, "execute", G_TYPE_STRING, "");
- break;
- case A_SHOW_MENU:
- keyboard_option_add_new(it, "menu", G_TYPE_STRING, "");
- break;
- case A_NEXT_WINDOW:
- case A_PREVIOUS_WINDOW:
- keyboard_option_add_new(it, "dialog", G_TYPE_BOOLEAN,
- (gpointer) TRUE);
- keyboard_option_add_new(it, "allDesktops", G_TYPE_BOOLEAN, FALSE);
- keyboard_option_add_new(it, "panels", G_TYPE_BOOLEAN, FALSE);
- keyboard_option_add_new(it, "desktop", G_TYPE_BOOLEAN, FALSE);
- keyboard_option_add_new(it, "linear", G_TYPE_BOOLEAN, FALSE);
- break;
- case A_DIRECTIONAL_FOCUS_NORTH:
- case A_DIRECTIONAL_FOCUS_SOUTH:
- case A_DIRECTIONAL_FOCUS_EAST:
- case A_DIRECTIONAL_FOCUS_WEST:
- case A_DIRECTIONAL_FOCUS_NORTH_WEST:
- case A_DIRECTIONAL_FOCUS_NORTH_EAST:
- case A_DIRECTIONAL_FOCUS_SOUTH_WEST:
- case A_DIRECTIONAL_FOCUS_SOUTH_EAST:
- keyboard_option_add_new(it, "dialog", G_TYPE_BOOLEAN,
- (gpointer) TRUE);
- break;
- case A_DESKTOP:
- keyboard_option_add_new(it, "desktop", G_TYPE_INT, 1);
- break;
- case A_DESKTOP_NEXT:
- case A_DESKTOP_PREVIOUS:
- case A_DESKTOP_LEFT:
- case A_DESKTOP_RIGHT:
- case A_DESKTOP_UP:
- case A_DESKTOP_DOWN:
- keyboard_option_add_new(it, "dialog", G_TYPE_BOOLEAN, TRUE);
- keyboard_option_add_new(it, "wrap", G_TYPE_BOOLEAN, TRUE);
- break;
- case A_DESKTOP_LAST:
- case A_ADD_DESKTOP_LAST:
- case A_REMOVE_DESKTOP_LAST:
- case A_ADD_DESKTOP_CURRENT:
- case A_REMOVE_DESKTOP_CURRENT:
- case A_TOGGLE_SHOW_DESKTOP:
- case A_SHOW_DESKTOP:
- case A_UNSHOW_DESKTOP:
- case A_TOGGLE_DOCK_AUTOHIDE:
- case A_RECONFIGURE:
- case A_RESTART:
- case A_EXIT:
- break;
- case A_DEBUG:
- keyboard_option_add_new(it, "string", G_TYPE_STRING, "");
- break;
-
- case A_ACTIVATE:
- case A_FOCUS:
- case A_RAISE:
- case A_LOWER:
- case A_RAISE_LOWER:
- case A_UNFOCUS:
- case A_FOCUS_TO_BOTTOM:
- case A_ICONIFY:
- case A_CLOSE:
- case A_TOGGLE_SHADE:
- case A_SHADE:
- case A_UNSHADE:
- case A_TOGGLE_OMNIPRESENT:
- case A_TOGGLE_MAXIMIZE_FULL:
- case A_MAXIMIZE_FULL:
- case A_UNMAXIMIZE_FULL:
- case A_TOGGLE_MAXIMIZE_VERT:
- case A_MAXIMIZE_VERT:
- case A_UNMAXIMIZE_VERT:
- case A_TOGGLE_MAXIMIZE_HORZ:
- case A_MAXIMIZE_HORZ:
- case A_UNMAXIMIZE_HORZ:
- case A_TOGGLE_FULLSCREEN:
- case A_TOGGLE_DECORATIONS:
- break;
- case A_SEND_TO_DESKTOP:
- keyboard_option_add_new(it, "desktop", G_TYPE_INT, 1);
- keyboard_option_add_new(it, "follow", G_TYPE_BOOLEAN, TRUE);
- break;
- case A_SEND_TO_DESKTOP_NEXT:
- case A_SEND_TO_DESKTOP_PREVIOUS:
- case A_SEND_TO_DESKTOP_LEFT:
- case A_SEND_TO_DESKTOP_RIGHT:
- case A_SEND_TO_DESKTOP_UP:
- case A_SEND_TO_DESKTOP_DOWN:
- keyboard_option_add_new(it, "follow", G_TYPE_BOOLEAN, TRUE);
- keyboard_option_add_new(it, "wrap", G_TYPE_BOOLEAN, TRUE);
- break;
- case A_MOVE:
- break;
- case A_RESIZE:
- keyboard_option_add_new(it, "edge", G_TYPE_STRING, "");
- break;
- case A_MOVE_TO_CENTER:
- break;
- case A_MOVE_RELATIVE:
- keyboard_option_add_new(it, "x", G_TYPE_INT, 0);
- keyboard_option_add_new(it, "y", G_TYPE_INT, 0);
- break;
- case A_RESIZE_RELATIVE:
- keyboard_option_add_new(it, "left", G_TYPE_INT, 0);
- keyboard_option_add_new(it, "right", G_TYPE_INT, 0);
- keyboard_option_add_new(it, "up", G_TYPE_INT, 0);
- keyboard_option_add_new(it, "down", G_TYPE_INT, 0);
- break;
- case A_MOVE_TO_EDGE_NORTH:
- case A_MOVE_TO_EDGE_SOUTH:
- case A_MOVE_TO_EDGE_WEST:
- case A_MOVE_TO_EDGE_EAST:
- case A_MOVE_FROM_EDGE_NORTH:
- case A_MOVE_FROM_EDGE_SOUTH:
- case A_MOVE_FROM_EDGE_WEST:
- case A_MOVE_FROM_EDGE_EAST:
- case A_GROW_TO_EDGE_NORTH:
- case A_GROW_TO_EDGE_SOUTH:
- case A_GROW_TO_EDGE_WEST:
- case A_GROW_TO_EDGE_EAST:
- case A_SHADE_LOWER:
- case A_UNSHADE_RAISE:
- case A_TOGGLE_ALWAYS_ON_TOP:
- case A_TOGGLE_ALWAYS_ON_BOTTOM:
- case A_SEND_TO_TOP_LAYER:
- case A_SEND_TO_BOTTOM_LAYER:
- case A_SEND_TO_NORMAL_LAYER:
- break;
-
- case NUM_ACTIONS:
- default:
- break;
+ switch (action) {
+ case A_EXECUTE:
+ keyboard_option_add_new(it, "execute", G_TYPE_STRING, "", NULL);
+ keyboard_option_add_new(it, "startupnotify", G_TYPE_NONE, NULL, &chld);
+ b = FALSE;
+ keyboard_option_add_new(&chld, "enabled", G_TYPE_BOOLEAN, &b, NULL);
+ keyboard_option_add_new(&chld, "wmclass", G_TYPE_STRING, "", NULL);
+ keyboard_option_add_new(&chld, "name", G_TYPE_STRING, "", NULL);
+ keyboard_option_add_new(&chld, "icon", G_TYPE_STRING, "", NULL);
+ break;
+ case A_SHOW_MENU:
+ keyboard_option_add_new(it, "menu", G_TYPE_STRING, "", NULL);
+ break;
+ case A_NEXT_WINDOW:
+ case A_PREVIOUS_WINDOW:
+ b = TRUE;
+ keyboard_option_add_new(it, "dialog", G_TYPE_BOOLEAN, &b, NULL);
+ b = FALSE;
+ keyboard_option_add_new(it, "allDesktops", G_TYPE_BOOLEAN, &b, NULL);
+ keyboard_option_add_new(it, "panels", G_TYPE_BOOLEAN, &b, NULL);
+ keyboard_option_add_new(it, "desktop", G_TYPE_BOOLEAN, &b, NULL);
+ keyboard_option_add_new(it, "linear", G_TYPE_BOOLEAN, &b, NULL);
+ break;
+ case A_DIRECTIONAL_FOCUS_NORTH:
+ case A_DIRECTIONAL_FOCUS_SOUTH:
+ case A_DIRECTIONAL_FOCUS_EAST:
+ case A_DIRECTIONAL_FOCUS_WEST:
+ case A_DIRECTIONAL_FOCUS_NORTH_WEST:
+ case A_DIRECTIONAL_FOCUS_NORTH_EAST:
+ case A_DIRECTIONAL_FOCUS_SOUTH_WEST:
+ case A_DIRECTIONAL_FOCUS_SOUTH_EAST:
+ b = TRUE;
+ keyboard_option_add_new(it, "dialog", G_TYPE_BOOLEAN, &b, NULL);
+ break;
+ case A_DESKTOP:
+ i = 1;
+ keyboard_option_add_new(it, "desktop", G_TYPE_INT, &i, NULL);
+ break;
+ case A_DESKTOP_NEXT:
+ case A_DESKTOP_PREVIOUS:
+ case A_DESKTOP_LEFT:
+ case A_DESKTOP_RIGHT:
+ case A_DESKTOP_UP:
+ case A_DESKTOP_DOWN:
+ b = TRUE;
+ keyboard_option_add_new(it, "dialog", G_TYPE_BOOLEAN, &b, NULL);
+ keyboard_option_add_new(it, "wrap", G_TYPE_BOOLEAN, &b, NULL);
+ break;
+ case A_DESKTOP_LAST:
+ case A_ADD_DESKTOP_LAST:
+ case A_REMOVE_DESKTOP_LAST:
+ case A_ADD_DESKTOP_CURRENT:
+ case A_REMOVE_DESKTOP_CURRENT:
+ case A_TOGGLE_SHOW_DESKTOP:
+ case A_SHOW_DESKTOP:
+ case A_UNSHOW_DESKTOP:
+ case A_TOGGLE_DOCK_AUTOHIDE:
+ case A_RECONFIGURE:
+ case A_RESTART:
+ case A_EXIT:
+ break;
+ case A_DEBUG:
+ keyboard_option_add_new(it, "string", G_TYPE_STRING, "", NULL);
+ break;
+
+ case A_ACTIVATE:
+ case A_FOCUS:
+ case A_RAISE:
+ case A_LOWER:
+ case A_RAISE_LOWER:
+ case A_UNFOCUS:
+ case A_FOCUS_TO_BOTTOM:
+ case A_ICONIFY:
+ case A_CLOSE:
+ case A_TOGGLE_SHADE:
+ case A_SHADE:
+ case A_UNSHADE:
+ case A_TOGGLE_OMNIPRESENT:
+ case A_TOGGLE_MAXIMIZE_FULL:
+ case A_MAXIMIZE_FULL:
+ case A_UNMAXIMIZE_FULL:
+ case A_TOGGLE_MAXIMIZE_VERT:
+ case A_MAXIMIZE_VERT:
+ case A_UNMAXIMIZE_VERT:
+ case A_TOGGLE_MAXIMIZE_HORZ:
+ case A_MAXIMIZE_HORZ:
+ case A_UNMAXIMIZE_HORZ:
+ case A_TOGGLE_FULLSCREEN:
+ case A_TOGGLE_DECORATIONS:
+ break;
+ case A_SEND_TO_DESKTOP:
+ i = 1;
+ keyboard_option_add_new(it, "desktop", G_TYPE_INT, &i, NULL);
+ b = TRUE;
+ keyboard_option_add_new(it, "follow", G_TYPE_BOOLEAN, &b, NULL);
+ break;
+ case A_SEND_TO_DESKTOP_NEXT:
+ case A_SEND_TO_DESKTOP_PREVIOUS:
+ case A_SEND_TO_DESKTOP_LEFT:
+ case A_SEND_TO_DESKTOP_RIGHT:
+ case A_SEND_TO_DESKTOP_UP:
+ case A_SEND_TO_DESKTOP_DOWN:
+ b = TRUE;
+ keyboard_option_add_new(it, "follow", G_TYPE_BOOLEAN, &b, NULL);
+ keyboard_option_add_new(it, "wrap", G_TYPE_BOOLEAN, &b, NULL);
+ break;
+ case A_MOVE:
+ break;
+ case A_RESIZE:
+ keyboard_option_add_new(it, "edge", G_TYPE_STRING, "", NULL);
+ break;
+ case A_MOVE_TO_CENTER:
+ break;
+ case A_MOVE_RELATIVE:
+ i = 0;
+ keyboard_option_add_new(it, "x", G_TYPE_INT, &i, NULL);
+ keyboard_option_add_new(it, "y", G_TYPE_INT, &i, NULL);
+ break;
+ case A_RESIZE_RELATIVE:
+ i = 0;
+ keyboard_option_add_new(it, "left", G_TYPE_INT, &i, NULL);
+ keyboard_option_add_new(it, "right", G_TYPE_INT, &i, NULL);
+ keyboard_option_add_new(it, "up", G_TYPE_INT, &i, NULL);
+ keyboard_option_add_new(it, "down", G_TYPE_INT, &i, NULL);
+ break;
+ case A_MOVE_TO_EDGE_NORTH:
+ case A_MOVE_TO_EDGE_SOUTH:
+ case A_MOVE_TO_EDGE_WEST:
+ case A_MOVE_TO_EDGE_EAST:
+ case A_MOVE_FROM_EDGE_NORTH:
+ case A_MOVE_FROM_EDGE_SOUTH:
+ case A_MOVE_FROM_EDGE_WEST:
+ case A_MOVE_FROM_EDGE_EAST:
+ case A_GROW_TO_EDGE_NORTH:
+ case A_GROW_TO_EDGE_SOUTH:
+ case A_GROW_TO_EDGE_WEST:
+ case A_GROW_TO_EDGE_EAST:
+ case A_SHADE_LOWER:
+ case A_UNSHADE_RAISE:
+ case A_TOGGLE_ALWAYS_ON_TOP:
+ case A_TOGGLE_ALWAYS_ON_BOTTOM:
+ case A_SEND_TO_TOP_LAYER:
+ case A_SEND_TO_BOTTOM_LAYER:
+ case A_SEND_TO_NORMAL_LAYER:
+ break;
+
+ case NUM_ACTIONS:
+ default:
+ break;
}
return;
gchar *attr;
gchar *option;
GType otype;
- gboolean tmpbool;
GtkAdjustment *adj;
for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
if (!strcmp("keybind", cur_node->name)) {
+ /* a keybind */
gtk_tree_store_append(key_store, &iter, parent);
parse_attr_string("key", cur_node, &attr);
gtk_tree_store_set(key_store, &iter, KEY_COL, attr, -1);
} else if (!strcmp("action", cur_node->name)) {
+ /* an action */
gtk_tree_store_append(key_store, &iter, parent);
parse_attr_string("name", cur_node, &attr);
gtk_tree_store_set(key_store, &iter,
- ACTION_COL, attr,
- EDITABLE_COL, TRUE,
- -1);
+ ACTION_COL, attr,
+ EDITABLE_COL, TRUE,
+ -1);
keyboard_key_store_add_default_options(&iter);
- } else if (!strcmp("action", cur_node->parent->name)) {
- gtk_tree_model_iter_children(GTK_TREE_MODEL(key_store),
- &iter,
- parent);
+ } else if (!strcmp("action", cur_node->parent->name) ||
+ !strcmp("startupnotify", cur_node->parent->name)) {
+ /* an option for an action */
+ gboolean next_child;
+
+ next_child =
+ gtk_tree_model_iter_children(GTK_TREE_MODEL(key_store),
+ &iter,
+ parent);
parse_attr_string("name", cur_node->parent, &attr);
- do
- {
+ while (next_child) {
gtk_tree_model_get(GTK_TREE_MODEL(key_store), &iter,
OPTION_COL, &option, -1);
- if (!strcmp(option, cur_node->name))
- {
+ if (option && !strcmp(option, cur_node->name)) {
otype = action_option_get_type_from_text
- (attr, cur_node->name);
- switch (otype)
- {
- case G_TYPE_STRING:
- gtk_tree_store_set(key_store, &iter,
- OVAL_STR_COL, parse_string(doc, cur_node),
- -1);
- break;
- case G_TYPE_BOOLEAN:
- tmpbool = !strcmp
- (parse_string(doc, cur_node), "yes")
- ?TRUE:FALSE;
- gtk_tree_store_set(key_store, &iter,
- OVAL_BOOL_COL, tmpbool,
- -1);
- break;
- case G_TYPE_INT:
- adj = GTK_ADJUSTMENT(gtk_adjustment_new
- (parse_int(doc, cur_node),
- -5000, 5000, 1, 1, 0));
- gtk_tree_store_set(key_store, &iter,
- OVAL_INT_COL, G_OBJECT(adj),
- OVAL_STR_COL, parse_string(doc, cur_node),
- -1);
- break;
+ (attr, cur_node->name);
+ switch (otype) {
+ case G_TYPE_STRING:
+ gtk_tree_store_set(key_store, &iter,
+ OVAL_STR_COL,
+ parse_string(doc, cur_node),
+ -1);
+ break;
+ case G_TYPE_BOOLEAN:
+ gtk_tree_store_set(key_store, &iter,
+ OVAL_BOOL_COL,
+ parse_bool(doc, cur_node),
+ -1);
+ break;
+ case G_TYPE_INT:
+ adj = GTK_ADJUSTMENT(gtk_adjustment_new
+ (parse_int(doc, cur_node),
+ -5000, 5000, 1, 1, 0));
+ gtk_tree_store_set(key_store, &iter,
+ OVAL_INT_COL, G_OBJECT(adj),
+ OVAL_STR_COL,
+ parse_string(doc, cur_node),
+ -1);
+ break;
}
break;
}
- } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(key_store), &iter));
+ next_child =
+ gtk_tree_model_iter_next(GTK_TREE_MODEL(key_store), &iter);
+ }
}
keyboard_fill_key_store(&iter, cur_node->children);
gboolean ovalbool;
if (!gtk_tree_model_iter_children
- (GTK_TREE_MODEL(key_store), &iter, it_parent))
+ (GTK_TREE_MODEL(key_store), &iter, it_parent))
{
- return;
+ return;
}
do
{
- gtk_tree_model_get(GTK_TREE_MODEL(key_store), &iter,
- KEY_COL, &key,
- ACTION_COL, &action,
- OPTION_COL, &option, -1);
- if (key != NULL)
- {
- new_node = xmlNewChild(xml_parent, NULL, "keybind", NULL);
- xmlSetProp(new_node, "key", key);
- }
- else if (action != NULL)
- {
- new_node = xmlNewChild(xml_parent, NULL, "action", NULL);
- xmlSetProp(new_node, "name", action);
- }
- else if (option != NULL)
- {
- g_free(action);
- gtk_tree_model_get(GTK_TREE_MODEL(key_store), it_parent,
- ACTION_COL, &action, -1);
- optype = action_option_get_type_from_text(action, option);
-
- switch (optype)
- {
- case G_TYPE_STRING:
- case G_TYPE_INT:
- gtk_tree_model_get(GTK_TREE_MODEL(key_store), &iter,
- OVAL_STR_COL, &ovalstr, -1);
- new_node =
- xmlNewTextChild(xml_parent, NULL, option, ovalstr);
- g_free(ovalstr);
- break;
- case G_TYPE_BOOLEAN:
- gtk_tree_model_get(GTK_TREE_MODEL(key_store), &iter,
- OVAL_BOOL_COL, &ovalbool, -1);
- new_node =
- xmlNewTextChild
- (xml_parent, NULL, option, ovalbool?"yes":"no");
- break;
- default:
- break;
- }
- }
-
- g_free(key);
- g_free(action);
- g_free(option);
-
- keyboard_write_bindings_tree(&iter, new_node);
+ gtk_tree_model_get(GTK_TREE_MODEL(key_store), &iter,
+ KEY_COL, &key,
+ ACTION_COL, &action,
+ OPTION_COL, &option, -1);
+ if (key != NULL)
+ {
+ new_node = xmlNewChild(xml_parent, NULL, "keybind", NULL);
+ xmlSetProp(new_node, "key", key);
+ }
+ else if (action != NULL)
+ {
+ new_node = xmlNewChild(xml_parent, NULL, "action", NULL);
+ xmlSetProp(new_node, "name", action);
+ }
+ else if (option != NULL)
+ {
+ g_free(action);
+ gtk_tree_model_get(GTK_TREE_MODEL(key_store), it_parent,
+ ACTION_COL, &action, -1);
+ optype = action_option_get_type_from_text(action, option);
+
+ switch (optype)
+ {
+ case G_TYPE_NONE:
+ new_node =
+ xmlNewTextChild(xml_parent, NULL, option, "");
+ break;
+ case G_TYPE_STRING:
+ case G_TYPE_INT:
+ gtk_tree_model_get(GTK_TREE_MODEL(key_store), &iter,
+ OVAL_STR_COL, &ovalstr, -1);
+ new_node =
+ xmlNewTextChild(xml_parent, NULL, option, ovalstr);
+ g_free(ovalstr);
+ break;
+ case G_TYPE_BOOLEAN:
+ gtk_tree_model_get(GTK_TREE_MODEL(key_store), &iter,
+ OVAL_BOOL_COL, &ovalbool, -1);
+ new_node =
+ xmlNewTextChild
+ (xml_parent, NULL, option, ovalbool?"yes":"no");
+ break;
+ default:
+ break;
+ }
+ }
+
+ g_free(key);
+ g_free(action);
+ g_free(option);
+
+ keyboard_write_bindings_tree(&iter, new_node);
} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(key_store), &iter));
}
kb = tree_get_node("keyboard", NULL);
while (c = kb->children)
{
- xmlUnlinkNode(c);
- xmlFreeNode(c);
+ xmlUnlinkNode(c);
+ xmlFreeNode(c);
}
on_chain_quit_key_changed(GTK_ENTRY(get_widget("chain_quit_key")), NULL);
gtk_entry_set_text(GTK_ENTRY(w), chainquitkey);
g_free(chainquitkey);
chain_release_id = g_signal_connect
- (w, "key-release-event",
- G_CALLBACK(on_chain_quit_key_key_release_event),
- NULL);
+ (w, "key-release-event",
+ G_CALLBACK(on_chain_quit_key_key_release_event),
+ NULL);
/* treeview setup */
w = get_widget("key_bindings");
g_signal_connect(render, "edited",
G_CALLBACK(on_action_edited), NULL);
g_object_set(render, "has-entry", FALSE,
- "model", action_store,
- "text-column", 0,
- NULL);
+ "model", action_store,
+ "text-column", 0,
+ NULL);
column = gtk_tree_view_column_new_with_attributes
- ("Action", render, "text", ACTION_COL,
- "editable", EDITABLE_COL,
- NULL);
+ ("Action", render, "text", ACTION_COL,
+ "editable", EDITABLE_COL,
+ NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(w), column);
/* option column */
gtk_tree_view_column_pack_start(column, render, TRUE);
gtk_tree_view_column_set_attributes
(column, render, "text", OVAL_STR_COL,
- "editable", OVAL_TYPE_STR_COL,
- "visible", OVAL_TYPE_STR_COL, NULL);
+ "editable", OVAL_TYPE_STR_COL,
+ "visible", OVAL_TYPE_STR_COL, NULL);
render = gtk_cell_renderer_toggle_new();
g_signal_connect(render, "toggled",
gtk_tree_view_column_pack_start(column, render, TRUE);
gtk_tree_view_column_set_attributes
(column, render, "active", OVAL_BOOL_COL,
- "visible", OVAL_TYPE_BOOL_COL, NULL);
+ "visible", OVAL_TYPE_BOOL_COL, NULL);
render = gtk_cell_renderer_spin_new();
g_signal_connect(render, "edited",
gtk_tree_view_column_pack_start(column, render, TRUE);
gtk_tree_view_column_set_attributes
(column, render, "adjustment", OVAL_INT_COL,
- "text", OVAL_STR_COL,
- "editable", OVAL_TYPE_INT_COL,
- "visible", OVAL_TYPE_INT_COL, NULL);
+ "text", OVAL_STR_COL,
+ "editable", OVAL_TYPE_INT_COL,
+ "visible", OVAL_TYPE_INT_COL, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(w), column);
}