Commit c7967136bb9b0bfb09f8ad068f8b7b0c21359f9a
1 parent
3d042e76
Exists in
master
and in
1 other branch
Implementing accelerator customization.
Showing
1 changed file
with
62 additions
and
4 deletions
Show diff stats
src/dialogs/settings/accelerator.c
| ... | ... | @@ -36,6 +36,8 @@ |
| 36 | 36 | #include <v3270/dialogs.h> |
| 37 | 37 | #include <v3270/settings.h> |
| 38 | 38 | #include <lib3270/log.h> |
| 39 | + #include <v3270/actions.h> | |
| 40 | + #include <terminal.h> | |
| 39 | 41 | |
| 40 | 42 | /*--[ Widget Definition ]----------------------------------------------------------------------------*/ |
| 41 | 43 | |
| ... | ... | @@ -50,6 +52,8 @@ |
| 50 | 52 | { |
| 51 | 53 | V3270Settings parent; |
| 52 | 54 | |
| 55 | + GtkListStore * store; | |
| 56 | + | |
| 53 | 57 | } V3270AcceleratorSettings; |
| 54 | 58 | |
| 55 | 59 | typedef struct _V3270AcceleratorSettingsClass |
| ... | ... | @@ -92,10 +96,14 @@ |
| 92 | 96 | GtkCellRenderer * text_renderer = gtk_cell_renderer_text_new(); |
| 93 | 97 | |
| 94 | 98 | GtkCellRenderer * accel_renderer = gtk_cell_renderer_accel_new(); |
| 95 | - g_object_set(accel_renderer, "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_GTK,"editable", TRUE, NULL); | |
| 99 | + g_object_set( | |
| 100 | + accel_renderer, | |
| 101 | + "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_OTHER, | |
| 102 | + "editable", TRUE, | |
| 103 | + NULL); | |
| 96 | 104 | |
| 97 | - GtkTreeModel * model = (GtkTreeModel *) gtk_tree_store_new(COLUMNS, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_INT, G_TYPE_UINT, G_TYPE_INT, G_TYPE_UINT); | |
| 98 | - GtkWidget * view = gtk_tree_view_new_with_model(model); | |
| 105 | + widget->store = GTK_LIST_STORE(gtk_list_store_new(COLUMNS, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_INT, G_TYPE_UINT, G_TYPE_INT, G_TYPE_UINT)); | |
| 106 | + GtkWidget * view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(widget->store)); | |
| 99 | 107 | |
| 100 | 108 | gtk_widget_set_tooltip_markup(view,_("Keyboard accelerators")); |
| 101 | 109 | |
| ... | ... | @@ -153,12 +161,62 @@ LIB3270_EXPORT GtkWidget * v3270_accelerator_settings_new() |
| 153 | 161 | return GTK_WIDGET(settings); |
| 154 | 162 | } |
| 155 | 163 | |
| 164 | + | |
| 156 | 165 | void load(GtkWidget *widget, GtkWidget *terminal) |
| 157 | 166 | { |
| 167 | + struct KeyMap | |
| 168 | + { | |
| 169 | + guint key; | |
| 170 | + GdkModifierType mods; | |
| 171 | + }; | |
| 172 | + | |
| 173 | + debug("%s::%s","V3270AcceleratorSettings",__FUNCTION__); | |
| 174 | + | |
| 175 | + GtkListStore * store = GTK_V3270_ACCELERATOR_SETTINGS(widget)->store; | |
| 176 | + GSList * accelerator = GTK_V3270(terminal)->accelerators; | |
| 177 | + | |
| 178 | + while(accelerator) | |
| 179 | + { | |
| 180 | + struct KeyMap keymaps[2]; | |
| 181 | + size_t ix = 0; | |
| 182 | + V3270Accelerator * current = (V3270Accelerator *) accelerator->data; | |
| 183 | + | |
| 184 | + memset(keymaps,0,sizeof(keymaps)); | |
| 185 | + | |
| 186 | + while(accelerator && (((V3270Accelerator *) accelerator->data)->activate == current->activate) && (((V3270Accelerator *) accelerator->data)->arg == current->arg)) | |
| 187 | + { | |
| 188 | + V3270Accelerator *accel = (V3270Accelerator *) accelerator->data; | |
| 189 | + | |
| 190 | + if(ix < G_N_ELEMENTS(keymaps)) | |
| 191 | + { | |
| 192 | + keymaps[ix].key = accel->key; | |
| 193 | + keymaps[ix].mods = accel->mods; | |
| 194 | + ix++; | |
| 195 | + } | |
| 196 | + | |
| 197 | + accelerator = g_slist_next(accelerator); | |
| 198 | + } | |
| 199 | + | |
| 200 | + // Add entry | |
| 201 | + GtkTreeIter iter; | |
| 202 | + gtk_list_store_append(store, &iter); | |
| 203 | + gtk_list_store_set( | |
| 204 | + store, | |
| 205 | + &iter, | |
| 206 | + ACTION, current, | |
| 207 | + DESCRIPTION, v3270_accelerator_get_description(current), | |
| 208 | + MAIN_MASK, keymaps[0].mods, | |
| 209 | + MAIN_VALUE, keymaps[0].key, | |
| 210 | + ALTERNATIVE_MASK, keymaps[1].mods, | |
| 211 | + ALTERNATIVE_VALUE, keymaps[1].key, | |
| 212 | + -1 | |
| 213 | + ); | |
| 214 | + | |
| 215 | + } | |
| 158 | 216 | |
| 159 | 217 | } |
| 160 | 218 | |
| 161 | 219 | void apply(GtkWidget *widget, GtkWidget *terminal) |
| 162 | 220 | { |
| 163 | - | |
| 221 | + debug("%s::%s","V3270AcceleratorSettings",__FUNCTION__); | |
| 164 | 222 | } | ... | ... |