Commit 2cfebbcb3afcd5d524d749d78418580493a06658
1 parent
402173bc
Exists in
master
and in
5 other branches
Iniciando inclusão de suporte para "move" actions
Showing
4 changed files
with
30 additions
and
1 deletions
Show diff stats
src/gtk/uiparser/action.c
@@ -97,6 +97,12 @@ | @@ -97,6 +97,12 @@ | ||
97 | { | 97 | { |
98 | g_object_set_data_full(G_OBJECT(action),"accel_attr",g_strdup(value[f]),g_free); | 98 | g_object_set_data_full(G_OBJECT(action),"accel_attr",g_strdup(value[f]),g_free); |
99 | } | 99 | } |
100 | + else if(!g_strcasecmp(name[f],"target")) | ||
101 | + { | ||
102 | + } | ||
103 | + else if(!g_strcasecmp(name[f],"direction")) | ||
104 | + { | ||
105 | + } | ||
100 | else if(!g_strcasecmp(name[f],"id")) | 106 | else if(!g_strcasecmp(name[f],"id")) |
101 | { | 107 | { |
102 | g_object_set_data(G_OBJECT(action),"action_id",(gpointer) atoi(value[f])); | 108 | g_object_set_data(G_OBJECT(action),"action_id",(gpointer) atoi(value[f])); |
src/gtk/uiparser/parsefile.c
@@ -139,7 +139,9 @@ | @@ -139,7 +139,9 @@ | ||
139 | 139 | ||
140 | static GtkAction * get_action(const gchar *name, struct parser *info, const gchar **names, const gchar **values, GError **error) | 140 | static GtkAction * get_action(const gchar *name, struct parser *info, const gchar **names, const gchar **values, GError **error) |
141 | { | 141 | { |
142 | - const gchar * id = ui_get_attribute("id",names,values); | 142 | + const gchar * target = NULL; |
143 | + const gchar * direction = NULL; | ||
144 | + const gchar * id = ui_get_attribute("id",names,values); | ||
143 | GtkAction * action; | 145 | GtkAction * action; |
144 | gchar * nm; | 146 | gchar * nm; |
145 | void (*connect)(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id) = ui_connect_action; | 147 | void (*connect)(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id) = ui_connect_action; |
@@ -151,6 +153,19 @@ | @@ -151,6 +153,19 @@ | ||
151 | create = (GtkAction * (*)(const gchar *,const gchar *,const gchar *,const gchar *)) gtk_toggle_action_new; | 153 | create = (GtkAction * (*)(const gchar *,const gchar *,const gchar *,const gchar *)) gtk_toggle_action_new; |
152 | connect = ui_connect_toggle; | 154 | connect = ui_connect_toggle; |
153 | } | 155 | } |
156 | + else if(!g_strcasecmp(name,"move")) | ||
157 | + { | ||
158 | + const gchar *target = ui_get_attribute("target",names,values); | ||
159 | + const gchar *direction = ui_get_attribute("direction",names,values); | ||
160 | + | ||
161 | + if(!(target && direction)) | ||
162 | + { | ||
163 | + *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_("Move action needs target & direction attributes" )); | ||
164 | + return NULL; | ||
165 | + } | ||
166 | + | ||
167 | + nm = g_strconcat("move",target,direction,NULL); | ||
168 | + } | ||
154 | else if(!g_strcasecmp(name,"toggleset")) | 169 | else if(!g_strcasecmp(name,"toggleset")) |
155 | { | 170 | { |
156 | nm = g_strconcat("set",id,NULL); | 171 | nm = g_strconcat("set",id,NULL); |
@@ -201,6 +216,8 @@ | @@ -201,6 +216,8 @@ | ||
201 | ui_connect_index_action(info->action[ix] = action,info->center_widget,ix,info->action); | 216 | ui_connect_index_action(info->action[ix] = action,info->center_widget,ix,info->action); |
202 | else if(g_strcasecmp(name,"quit")) | 217 | else if(g_strcasecmp(name,"quit")) |
203 | connect(action,info->center_widget,name,id); | 218 | connect(action,info->center_widget,name,id); |
219 | + else if(target) | ||
220 | + ui_connect_target_action(action,info->center_widget,target,direction,error); | ||
204 | else | 221 | else |
205 | g_signal_connect(action,"activate",G_CALLBACK(gtk_main_quit), NULL); | 222 | g_signal_connect(action,"activate",G_CALLBACK(gtk_main_quit), NULL); |
206 | 223 |
src/gtk/uiparser/parser.h
@@ -53,6 +53,7 @@ | @@ -53,6 +53,7 @@ | ||
53 | 53 | ||
54 | GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, const gchar **actionname, GtkWidget *widget, const UI_WIDGET_SETUP *itn); | 54 | GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, const gchar **actionname, GtkWidget *widget, const UI_WIDGET_SETUP *itn); |
55 | void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | 55 | void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); |
56 | + void ui_connect_target_action(GtkAction *action, GtkWidget *widget, const gchar *target, const gchar *direction, GError **error); | ||
56 | void ui_connect_index_action(GtkAction *action, GtkWidget *widget, int ix, GtkAction **lst); | 57 | void ui_connect_index_action(GtkAction *action, GtkWidget *widget, int ix, GtkAction **lst); |
57 | void ui_connect_toggle(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | 58 | void ui_connect_toggle(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); |
58 | void ui_connect_pfkey(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | 59 | void ui_connect_pfkey(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); |
src/gtk/uiparser/testprogram.c
@@ -30,6 +30,11 @@ void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name, | @@ -30,6 +30,11 @@ void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name, | ||
30 | g_signal_connect(action,"activate",G_CALLBACK(activated),widget); | 30 | g_signal_connect(action,"activate",G_CALLBACK(activated),widget); |
31 | } | 31 | } |
32 | 32 | ||
33 | +void ui_connect_target_action(GtkAction *action, GtkWidget *widget, const gchar *target, const gchar *direction, GError **error) | ||
34 | +{ | ||
35 | + g_signal_connect(action,"activate",G_CALLBACK(activated),widget); | ||
36 | +} | ||
37 | + | ||
33 | void ui_connect_toggle(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id) | 38 | void ui_connect_toggle(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id) |
34 | { | 39 | { |
35 | trace("Connecting action %s with toggle %s and widget %p",gtk_action_get_name(action),id,widget); | 40 | trace("Connecting action %s with toggle %s and widget %p",gtk_action_get_name(action),id,widget); |