Commit 83078a43d2f103c2894fdca4da6275e5c68a611f
1 parent
60154693
Exists in
master
and in
1 other branch
Improving visual on the accelerator settings dialog.
Showing
6 changed files
with
80 additions
and
31 deletions
Show diff stats
src/dialogs/settings/accelerator.c
| ... | ... | @@ -104,10 +104,27 @@ |
| 104 | 104 | COLUMNS ///< @brief Number of view columns. |
| 105 | 105 | }; |
| 106 | 106 | |
| 107 | + static void realize(GtkWidget G_GNUC_UNUSED(*widget), GtkTreeView *view) | |
| 108 | + { | |
| 109 | + gtk_tree_view_columns_autosize(view); | |
| 110 | + } | |
| 111 | + | |
| 107 | 112 | static void V3270AcceleratorSettings_init(V3270AcceleratorSettings *widget) |
| 108 | 113 | { |
| 109 | - // Create Accelerator list | |
| 114 | + // Create description list | |
| 110 | 115 | GtkCellRenderer * text_renderer = gtk_cell_renderer_text_new(); |
| 116 | + | |
| 117 | + /* | |
| 118 | + g_object_set( | |
| 119 | + text_renderer, | |
| 120 | + "alignment", PANGO_ALIGN_LEFT, | |
| 121 | + "wrap-width", 100, | |
| 122 | + "wrap-mode", PANGO_WRAP_WORD_CHAR, | |
| 123 | + NULL | |
| 124 | + ); | |
| 125 | + */ | |
| 126 | + | |
| 127 | + // Create accelerator render | |
| 111 | 128 | GtkCellRenderer * accel_renderer[] = { gtk_cell_renderer_accel_new(), gtk_cell_renderer_accel_new() }; |
| 112 | 129 | |
| 113 | 130 | g_object_set( |
| ... | ... | @@ -130,19 +147,40 @@ |
| 130 | 147 | gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(widget->store),1,GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID); |
| 131 | 148 | |
| 132 | 149 | GtkWidget * view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(widget->store)); |
| 150 | + g_signal_connect(G_OBJECT(widget),"realize",G_CALLBACK(realize),view); | |
| 151 | + | |
| 152 | + /* | |
| 153 | + g_object_set( | |
| 154 | + view, | |
| 155 | + "horizontal-separator", 50, | |
| 156 | + "vertical-separator", 50, | |
| 157 | + NULL | |
| 158 | + ); | |
| 159 | + */ | |
| 133 | 160 | |
| 134 | 161 | gtk_widget_set_tooltip_markup(view,_("Keyboard accelerators")); |
| 162 | + gtk_tree_view_set_fixed_height_mode(GTK_TREE_VIEW(view),FALSE); | |
| 163 | + | |
| 164 | + // Description column | |
| 165 | + GtkTreeViewColumn * column = | |
| 166 | + gtk_tree_view_column_new_with_attributes( | |
| 167 | + _("Action"), | |
| 168 | + text_renderer, | |
| 169 | + "text", | |
| 170 | + DESCRIPTION, | |
| 171 | + NULL | |
| 172 | + ); | |
| 135 | 173 | |
| 136 | - gtk_tree_view_insert_column_with_attributes( | |
| 174 | + gtk_tree_view_column_set_resizable(column, TRUE); | |
| 175 | + gtk_tree_view_column_set_min_width(column, 500); | |
| 176 | + | |
| 177 | + gtk_tree_view_insert_column( | |
| 137 | 178 | GTK_TREE_VIEW(view), |
| 138 | - -1, | |
| 139 | - _("Action"), | |
| 140 | - text_renderer, | |
| 141 | - "text", | |
| 142 | - DESCRIPTION, | |
| 143 | - NULL | |
| 179 | + column, | |
| 180 | + -1 | |
| 144 | 181 | ); |
| 145 | 182 | |
| 183 | + // Accelerator columns | |
| 146 | 184 | gtk_tree_view_insert_column_with_attributes( |
| 147 | 185 | GTK_TREE_VIEW(view), |
| 148 | 186 | -1, |
| ... | ... | @@ -169,13 +207,15 @@ |
| 169 | 207 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(box),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); |
| 170 | 208 | gtk_container_add(GTK_CONTAINER(box),view); |
| 171 | 209 | |
| 210 | + /* | |
| 172 | 211 | gtk_widget_set_vexpand(view,TRUE); |
| 173 | 212 | gtk_widget_set_hexpand(view,TRUE); |
| 213 | + */ | |
| 174 | 214 | |
| 175 | 215 | gtk_widget_set_vexpand(box,TRUE); |
| 176 | 216 | gtk_widget_set_hexpand(box,TRUE); |
| 177 | 217 | |
| 178 | - gtk_grid_attach(GTK_GRID(widget),box,0,0,4,4); | |
| 218 | + gtk_grid_attach(GTK_GRID(widget),box,0,0,10,10); | |
| 179 | 219 | } |
| 180 | 220 | |
| 181 | 221 | } |
| ... | ... | @@ -435,7 +475,7 @@ void load(GtkWidget *widget, GtkWidget *terminal) |
| 435 | 475 | |
| 436 | 476 | } |
| 437 | 477 | |
| 438 | -static gboolean add_accel(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GSList **accelerators) | |
| 478 | +static gboolean add_accel(GtkTreeModel *model, GtkTreePath G_GNUC_UNUSED(*path), GtkTreeIter *iter, GSList **accelerators) | |
| 439 | 479 | { |
| 440 | 480 | static const gint columns[] = { MAIN_MASK, MAIN_VALUE, ALTERNATIVE_MASK, ALTERNATIVE_VALUE }; |
| 441 | 481 | size_t ix; |
| ... | ... | @@ -451,9 +491,6 @@ static gboolean add_accel(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *i |
| 451 | 491 | |
| 452 | 492 | for(ix = 0; ix < 2; ix++) |
| 453 | 493 | { |
| 454 | - guint key; | |
| 455 | - GdkModifierType mask; | |
| 456 | - | |
| 457 | 494 | memset(&value,0,sizeof(value)); |
| 458 | 495 | gtk_tree_model_get_value(model, iter, columns[(ix * 2)], &value); |
| 459 | 496 | keymap[ix].mods = (GdkModifierType) g_value_get_int(&value); | ... | ... |
src/include/internals.h
| ... | ... | @@ -379,7 +379,8 @@ G_GNUC_INTERNAL void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned |
| 379 | 379 | G_GNUC_INTERNAL void v3270_update_toggle(GtkWidget *widget, LIB3270_TOGGLE_ID id, unsigned char value, const char *name); |
| 380 | 380 | |
| 381 | 381 | // Accelerators |
| 382 | - G_GNUC_INTERNAL void v3270_init_accelerators(v3270 *widget); | |
| 382 | + G_GNUC_INTERNAL void v3270_accelerator_map_sort(v3270 *widget); | |
| 383 | + G_GNUC_INTERNAL void v3270_init_accelerators(v3270 *widget); | |
| 383 | 384 | |
| 384 | 385 | G_END_DECLS |
| 385 | 386 | ... | ... |
src/include/v3270/actions.h
| ... | ... | @@ -79,7 +79,7 @@ |
| 79 | 79 | // |
| 80 | 80 | // Keyboard accelerators |
| 81 | 81 | // |
| 82 | - LIB3270_EXPORT void v3270_backtab(GtkWidget *widget); | |
| 82 | + LIB3270_EXPORT void v3270_backtab(GtkWidget *widget); | |
| 83 | 83 | |
| 84 | 84 | /// @brief Reset accelerator map to defaults. |
| 85 | 85 | LIB3270_EXPORT void v3270_accelerator_map_reset(GtkWidget *widget); |
| ... | ... | @@ -98,6 +98,8 @@ |
| 98 | 98 | /// @return A newly-allocated string representing the accelerator. |
| 99 | 99 | LIB3270_EXPORT gchar * v3270_accelerator_get_label(const V3270Accelerator * accel); |
| 100 | 100 | |
| 101 | + LIB3270_EXPORT V3270Accelerator * v3270_accelerator_copy(const V3270Accelerator *accel); | |
| 102 | + | |
| 101 | 103 | G_END_DECLS |
| 102 | 104 | |
| 103 | 105 | #endif // V3270_ACTIONS_H_INCLUDED | ... | ... |
src/terminal/keyboard/accelerator.c
| ... | ... | @@ -158,6 +158,7 @@ |
| 158 | 158 | break; |
| 159 | 159 | |
| 160 | 160 | case V3270_ACCELERATOR_TYPE_INTERNAL: |
| 161 | + | |
| 161 | 162 | if( ((V3270_ACTION *) accel->arg)->summary ) |
| 162 | 163 | return gettext(((V3270_ACTION *) accel->arg)->summary); |
| 163 | 164 | |
| ... | ... | @@ -177,8 +178,10 @@ |
| 177 | 178 | break; |
| 178 | 179 | |
| 179 | 180 | case V3270_ACCELERATOR_TYPE_PFKEY: |
| 181 | + | |
| 180 | 182 | if( ((V3270PFKeyAccelerator *)accel)->name ) |
| 181 | 183 | return ((V3270PFKeyAccelerator *)accel)->name; |
| 184 | + | |
| 182 | 185 | break; |
| 183 | 186 | |
| 184 | 187 | } | ... | ... |
src/terminal/keyboard/init.c
| ... | ... | @@ -99,7 +99,7 @@ |
| 99 | 99 | |
| 100 | 100 | for(ix = 0; actions[ix].name; ix++) |
| 101 | 101 | { |
| 102 | - if(actions[ix].keys) | |
| 102 | + if(actions[ix].keys && *actions[ix].keys) | |
| 103 | 103 | { |
| 104 | 104 | size_t key; |
| 105 | 105 | |
| ... | ... | @@ -125,6 +125,16 @@ |
| 125 | 125 | g_strfreev(keys); |
| 126 | 126 | |
| 127 | 127 | } |
| 128 | + else | |
| 129 | + { | |
| 130 | + V3270Accelerator * accelerator = g_new0(V3270Accelerator,1); | |
| 131 | + | |
| 132 | + accelerator->type = V3270_ACCELERATOR_TYPE_LIB3270_ACTION; | |
| 133 | + accelerator->arg = (gconstpointer) &actions[ix]; | |
| 134 | + accelerator->activate = G_CALLBACK(fire_lib3270_action); | |
| 135 | + widget->accelerators = g_slist_prepend(widget->accelerators,accelerator); | |
| 136 | + | |
| 137 | + } | |
| 128 | 138 | |
| 129 | 139 | } |
| 130 | 140 | |
| ... | ... | @@ -137,19 +147,17 @@ |
| 137 | 147 | |
| 138 | 148 | for(ix = 0; toggles[ix].name; ix++) |
| 139 | 149 | { |
| 140 | - if(toggles[ix].key) | |
| 141 | - { | |
| 142 | - V3270Accelerator * accelerator = g_new0(V3270Accelerator,1); | |
| 150 | + V3270Accelerator * accelerator = g_new0(V3270Accelerator,1); | |
| 143 | 151 | |
| 144 | - accelerator->type = V3270_ACCELERATOR_TYPE_LIB3270_TOGGLE; | |
| 145 | - accelerator->arg = (gconstpointer) &toggles[ix]; | |
| 146 | - accelerator->activate = G_CALLBACK(fire_lib3270_toggle); | |
| 152 | + accelerator->type = V3270_ACCELERATOR_TYPE_LIB3270_TOGGLE; | |
| 153 | + accelerator->arg = (gconstpointer) &toggles[ix]; | |
| 154 | + accelerator->activate = G_CALLBACK(fire_lib3270_toggle); | |
| 147 | 155 | |
| 156 | + if(toggles[ix].key) | |
| 148 | 157 | gtk_accelerator_parse(toggles[ix].key,&accelerator->key,&accelerator->mods); |
| 149 | 158 | |
| 150 | - widget->accelerators = g_slist_prepend(widget->accelerators,accelerator); | |
| 159 | + widget->accelerators = g_slist_prepend(widget->accelerators,accelerator); | |
| 151 | 160 | |
| 152 | - } | |
| 153 | 161 | } |
| 154 | 162 | |
| 155 | 163 | } |
| ... | ... | @@ -164,11 +172,11 @@ |
| 164 | 172 | { |
| 165 | 173 | V3270Accelerator * accelerator = g_new0(V3270Accelerator,1); |
| 166 | 174 | |
| 167 | - accelerator->type = V3270_ACCELERATOR_TYPE_INTERNAL; | |
| 168 | - accelerator->arg = (gconstpointer) &actions[ix]; | |
| 169 | - accelerator->activate = G_CALLBACK(actions[ix].activate); | |
| 170 | - accelerator->key = actions[ix].key; | |
| 171 | - accelerator->mods = actions[ix].mods; | |
| 175 | + accelerator->type = V3270_ACCELERATOR_TYPE_INTERNAL; | |
| 176 | + accelerator->arg = (gconstpointer) &actions[ix]; | |
| 177 | + accelerator->activate = G_CALLBACK(actions[ix].activate); | |
| 178 | + accelerator->key = actions[ix].key; | |
| 179 | + accelerator->mods = actions[ix].mods; | |
| 172 | 180 | |
| 173 | 181 | widget->accelerators = g_slist_prepend(widget->accelerators,accelerator); |
| 174 | 182 | ... | ... |
src/terminal/keyboard/private.h