mirror of
git://projects.qi-hardware.com/fped.git
synced 2025-04-21 12:27:27 +03:00
support switching variables between assignment and key (WIP)
This is a little awkward: to change a variable used as key to an assignment, one first had to change the name such that it doesn't clash, hit Enter, and then edit the variable again to change its type. Variable type changes should pick up the edit in progress and allow a type change to also imply acceptance of the variable.
This commit is contained in:
58
gui_status.c
58
gui_status.c
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* gui_status.c - GUI, status area
|
||||
*
|
||||
* Written 2009-2011 by Werner Almesberger
|
||||
* Copyright 2009-2011 by Werner Almesberger
|
||||
* Written 2009-2012 by Werner Almesberger
|
||||
* Copyright 2009-2012 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "gui_util.h"
|
||||
#include "gui_style.h"
|
||||
#include "gui_canvas.h"
|
||||
#include "gui_frame.h"
|
||||
#include "gui.h"
|
||||
#include "gui_status.h"
|
||||
|
||||
@@ -186,6 +187,59 @@ static void entry_color(GtkWidget *widget, const char *color)
|
||||
}
|
||||
|
||||
|
||||
/* ----- variable type display and change ---------------------------------- */
|
||||
|
||||
|
||||
static struct var *curr_var;
|
||||
static GtkWidget *var_type;
|
||||
|
||||
|
||||
static void show_var_type(void)
|
||||
{
|
||||
gtk_label_set_text(GTK_LABEL(var_type),
|
||||
curr_var->key ? "key" : "assign");
|
||||
}
|
||||
|
||||
|
||||
static gboolean var_type_button_press_event(GtkWidget *widget,
|
||||
GdkEventButton *event, gpointer data)
|
||||
{
|
||||
switch (event->button) {
|
||||
case 1:
|
||||
if (curr_var->key &&
|
||||
find_var_in_frame(curr_var->frame, curr_var->name,
|
||||
curr_var))
|
||||
return TRUE;
|
||||
curr_var->key = !curr_var->key;
|
||||
show_var_type();
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* We can't just redraw() here, because changing the variable type may
|
||||
* also affect lots of other things. So we change the world and hope
|
||||
* we end up selecting the same variable afterwards.
|
||||
*/
|
||||
change_world();
|
||||
reselect_var(curr_var);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void edit_var_type(struct var *var)
|
||||
{
|
||||
vacate_widget(status_box_x);
|
||||
curr_var = var;
|
||||
var_type = label_in_box_new(NULL, "Variable type. Click to cycle.");
|
||||
gtk_container_add(GTK_CONTAINER(status_box_x), box_of_label(var_type));
|
||||
label_in_box_bg(var_type, COLOR_SELECTOR);
|
||||
g_signal_connect(G_OBJECT(box_of_label(var_type)),
|
||||
"button_press_event", G_CALLBACK(var_type_button_press_event),
|
||||
NULL);
|
||||
show_var_type();
|
||||
gtk_widget_show_all(status_box_x);
|
||||
}
|
||||
|
||||
|
||||
/* ----- pad type display and change --------------------------------------- */
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user