Commit 43282365304e601fc3cc80d4035ee7aa716b0da7
1 parent
9767f7f9
Exists in
master
and in
1 other branch
Implementing accelerator change.
Showing
1 changed file
with
40 additions
and
16 deletions
Show diff stats
src/dialogs/settings/accelerator.c
| ... | ... | @@ -102,7 +102,6 @@ |
| 102 | 102 | { |
| 103 | 103 | // Create Accelerator list |
| 104 | 104 | GtkCellRenderer * text_renderer = gtk_cell_renderer_text_new(); |
| 105 | - | |
| 106 | 105 | GtkCellRenderer * accel_renderer[] = { gtk_cell_renderer_accel_new(), gtk_cell_renderer_accel_new() }; |
| 107 | 106 | |
| 108 | 107 | g_object_set( |
| ... | ... | @@ -117,8 +116,8 @@ |
| 117 | 116 | "editable", TRUE, |
| 118 | 117 | NULL); |
| 119 | 118 | |
| 120 | - g_signal_connect (G_OBJECT (accel_renderer[0]), "accel_edited", G_CALLBACK (accel_edited), widget); | |
| 121 | - g_signal_connect (G_OBJECT (accel_renderer[1]), "accel_edited", G_CALLBACK (alternative_edited), widget); | |
| 119 | + g_signal_connect (G_OBJECT(accel_renderer[0]), "accel_edited", G_CALLBACK (accel_edited), widget); | |
| 120 | + g_signal_connect (G_OBJECT(accel_renderer[1]), "accel_edited", G_CALLBACK (alternative_edited), widget); | |
| 122 | 121 | |
| 123 | 122 | 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)); |
| 124 | 123 | |
| ... | ... | @@ -205,7 +204,7 @@ static gboolean check_accel(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter |
| 205 | 204 | size_t ix; |
| 206 | 205 | GValue value; |
| 207 | 206 | |
| 208 | - debug("%s",__FUNCTION__); | |
| 207 | +// debug("%s",__FUNCTION__); | |
| 209 | 208 | |
| 210 | 209 | for(ix = 0; ix < 2; ix++) |
| 211 | 210 | { |
| ... | ... | @@ -224,7 +223,7 @@ static gboolean check_accel(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter |
| 224 | 223 | |
| 225 | 224 | if(key == info->accel_key && mask == info->mask) { |
| 226 | 225 | |
| 227 | - debug("************ Index %d cmp=%d",(unsigned int) ix, gtk_tree_path_compare(path, info->path)); | |
| 226 | + debug("Index %d cmp=%d",(unsigned int) ix, gtk_tree_path_compare(path, info->path)); | |
| 228 | 227 | GtkWidget * dialog; |
| 229 | 228 | |
| 230 | 229 | if(gtk_tree_path_compare(path, info->path)) |
| ... | ... | @@ -261,7 +260,7 @@ static gboolean check_accel(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter |
| 261 | 260 | dialog = gtk_message_dialog_new_with_markup( |
| 262 | 261 | GTK_WINDOW(gtk_widget_get_toplevel(info->widget)), |
| 263 | 262 | GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, |
| 264 | - GTK_MESSAGE_QUESTION, | |
| 263 | + GTK_MESSAGE_INFO, | |
| 265 | 264 | GTK_BUTTONS_CANCEL, |
| 266 | 265 | _( "The selected accelerator is in use by the same action" ) |
| 267 | 266 | ); |
| ... | ... | @@ -275,6 +274,13 @@ static gboolean check_accel(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter |
| 275 | 274 | if(info->response == GTK_RESPONSE_YES) |
| 276 | 275 | { |
| 277 | 276 | debug("%s: Removing accelerator from the other action",__FUNCTION__); |
| 277 | + gtk_list_store_set( | |
| 278 | + GTK_LIST_STORE(model), | |
| 279 | + iter, | |
| 280 | + columns[(ix * 2)], 0, | |
| 281 | + columns[(ix * 2)+1], 0, | |
| 282 | + -1 | |
| 283 | + ); | |
| 278 | 284 | |
| 279 | 285 | } |
| 280 | 286 | |
| ... | ... | @@ -322,26 +328,44 @@ static void change_accel(V3270AcceleratorSettings *widget, gchar *path, guint ac |
| 322 | 328 | |
| 323 | 329 | gtk_tree_model_foreach(GTK_TREE_MODEL(widget->store), (GtkTreeModelForeachFunc) check_accel, &info); |
| 324 | 330 | |
| 325 | - gtk_tree_path_free(info.path); | |
| 326 | - | |
| 327 | - if(info.response == GTK_RESPONSE_YES) | |
| 331 | + if(info.response == GTK_RESPONSE_YES && gtk_tree_model_get_iter(GTK_TREE_MODEL(widget->store),&iter,info.path)) | |
| 328 | 332 | { |
| 329 | - debug("%s: Aplicar alteração",__FUNCTION__); | |
| 333 | + debug("%s: Setting the new accelerator to %u/%d",__FUNCTION__,accel_key,mask); | |
| 334 | + | |
| 335 | + gtk_list_store_set( | |
| 336 | + widget->store, | |
| 337 | + &iter, | |
| 338 | + id_key, accel_key, | |
| 339 | + id_mask, mask, | |
| 340 | + -1 | |
| 341 | + ); | |
| 330 | 342 | |
| 331 | 343 | } |
| 332 | 344 | |
| 345 | + gtk_tree_path_free(info.path); | |
| 346 | + | |
| 333 | 347 | } |
| 334 | 348 | |
| 335 | -static void accel_edited(GtkCellRendererAccel *renderer, gchar *path, guint accel_key, GdkModifierType mask, guint hardware_keycode, V3270AcceleratorSettings *widget) | |
| 349 | +static void accel_edited(GtkCellRendererAccel G_GNUC_UNUSED(*accel), gchar *path, guint accel_key, GdkModifierType mask, guint G_GNUC_UNUSED(hardware_keycode), V3270AcceleratorSettings *widget) | |
| 336 | 350 | { |
| 337 | - debug("%s(%s)",__FUNCTION__,path); | |
| 338 | - change_accel(widget, path, accel_key, mask, MAIN_MASK, MAIN_VALUE); | |
| 351 | +#ifdef DEBUG | |
| 352 | + { | |
| 353 | + g_autofree gchar * keyname = gtk_accelerator_name(accel_key,mask); | |
| 354 | + debug("%s(%s) = %u/%d (%s)",__FUNCTION__,path,accel_key,mask,keyname); | |
| 355 | + } | |
| 356 | +#endif // DEBUG | |
| 357 | + change_accel(widget, path, accel_key, mask, MAIN_VALUE, MAIN_MASK); | |
| 339 | 358 | } |
| 340 | 359 | |
| 341 | -static void alternative_edited(GtkCellRendererAccel *renderer, gchar *path, guint accel_key, GdkModifierType mask, guint hardware_keycode, V3270AcceleratorSettings *widget) | |
| 360 | +static void alternative_edited(GtkCellRendererAccel G_GNUC_UNUSED(*accel), gchar *path, guint accel_key, GdkModifierType mask, guint G_GNUC_UNUSED(hardware_keycode), V3270AcceleratorSettings *widget) | |
| 342 | 361 | { |
| 343 | - debug("%s(%s)",__FUNCTION__,path); | |
| 344 | - change_accel(widget, path, accel_key, mask, ALTERNATIVE_MASK, ALTERNATIVE_VALUE); | |
| 362 | +#ifdef DEBUG | |
| 363 | + { | |
| 364 | + g_autofree gchar * keyname = gtk_accelerator_name(accel_key,mask); | |
| 365 | + debug("%s(%s) = %u/%d (%s)",__FUNCTION__,path,accel_key,mask,keyname); | |
| 366 | + } | |
| 367 | +#endif // DEBUG | |
| 368 | + change_accel(widget, path, accel_key, mask, ALTERNATIVE_VALUE, ALTERNATIVE_MASK); | |
| 345 | 369 | } |
| 346 | 370 | |
| 347 | 371 | void load(GtkWidget *widget, GtkWidget *terminal) | ... | ... |