2 * irreco - Ir Remote Control
3 * Copyright (C) 2007 Arto Karppinen (arto.karppinen@iki.fi)
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "irreco_window_user.h"
21 #include "irreco_button.h"
22 #include "irreco_window_edit.h"
23 #include "irreco_input_dlg.h"
24 #include "irreco_config.h"
25 #include "irreco_webdb_upload_dlg.h"
26 #include </usr/include/hildon-1/hildon/hildon-button.h>
27 #include "irreco_select_remote_dlg.h"
30 * @addtogroup IrrecoWindowUser
33 * User interface for using button layouts.
40 * Source file of @ref IrrecoWindowUser.
44 void irreco_window_user_draw_background(IrrecoWindowUser
* user_window
);
45 void irreco_window_user_main_menu_create(IrrecoWindowUser
* user_window
);
46 void irreco_window_user_main_menu_download(GtkMenuItem
* menuitem
,
47 IrrecoWindowUser
* user_window
);
48 void irreco_window_user_new_remote(GtkMenuItem
* menuitem
, IrrecoWindowUser
* user_window
);
49 void irreco_window_user_edit_remote(GtkMenuItem
* menuitem
, IrrecoWindowUser
* user_window
);
50 void irreco_window_user_main_menu_rename(GtkMenuItem
* menuitem
,
51 IrrecoWindowUser
* user_window
);
52 void irreco_window_user_main_menu_upload(GtkMenuItem
* menuitem
,
53 IrrecoWindowUser
* user_window
);
54 void irreco_window_user_delete_remote(GtkMenuItem
* menuitem
,
55 IrrecoWindowUser
* user_window
);
56 void irreco_window_user_show_remote(GtkButton
*button
, IrrecoWindowUser
* user_window
);
57 void irreco_window_user_menu_about(GtkMenuItem
* menuitem
, IrrecoWindowUser
* user_window
);
58 void irreco_window_user_button_release(IrrecoButton
* irreco_button
,
59 IrrecoWindowUser
* user_window
);
60 void irreco_window_user_execute_start(IrrecoWindowUser
* user_window
,
61 IrrecoCmdChain
* cmd_chain
,
62 IrrecoButton
* irreco_button
);
63 void irreco_window_user_execute_finish(IrrecoCmdChain
* cmd_chain
,
64 IrrecoWindowUser
* user_window
);
65 gboolean
irreco_window_user_key_press(GtkWidget
* widget
, GdkEventKey
* event
,
66 IrrecoWindowUser
* user_window
);
67 gboolean
irreco_window_user_window_state_event(GtkWidget
*widget
,
68 GdkEventWindowState
*event
,
69 IrrecoWindowUser
*user_window
);
72 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
74 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
82 * Crate and display IrrecoWindowUser.
84 * @param irreco_layout IrrecoButtonLayout to display. If NULL, attempts to
85 * display first layout from
86 * irreco_data->irreco_layout_array.
88 IrrecoWindowUser
*irreco_window_user_create(IrrecoWindowManager
* manager
)
90 IrrecoData
*irreco_data
= manager
->irreco_data
;
91 IrrecoWindowUser
*user_window
;
94 user_window
= g_slice_new0(IrrecoWindowUser
);
95 user_window
->manager
= manager
;
96 user_window
->irreco_data
= irreco_data
;
97 user_window
->window
= irreco_window_create();
99 irreco_window_user_main_menu_create(user_window
);
100 /* irreco_window_user_create_show_remote_menu(user_window);*/
102 g_signal_connect(G_OBJECT(user_window
->window
),
104 G_CALLBACK(irreco_window_user_key_press
),
106 g_signal_connect(G_OBJECT(user_window
->window
),
107 "window-state-event",
108 G_CALLBACK(irreco_window_user_window_state_event
),
110 IRRECO_RETURN_PTR(user_window
);
113 void irreco_window_user_destroy(IrrecoWindowUser
* user_window
)
116 if (user_window
->irreco_layout
!= NULL
) {
117 irreco_button_layout_reset(user_window
->irreco_layout
);
120 irreco_window_destroy(user_window
->window
);
121 g_slice_free(IrrecoWindowUser
, user_window
);
126 * Set and display layout, or, if NULL is given, unset layout.
128 void irreco_window_user_set_layout(IrrecoWindowUser
* user_window
,
129 IrrecoButtonLayout
* layout
)
133 if (user_window
->irreco_layout
!= NULL
) {
135 irreco_button_layout_reset(user_window
->irreco_layout
);
140 if (irreco_string_table_is_empty(
141 user_window
->irreco_data
->irreco_layout_array
)) {
142 gtk_widget_set_sensitive(
143 GTK_WIDGET(user_window
->menu_show_remote
), FALSE
);
145 gtk_widget_set_sensitive(
146 GTK_WIDGET(user_window
->menu_show_remote
), TRUE
);
149 if (layout
== NULL
) {
150 IRRECO_PRINTF("Layout unset.\n");
151 user_window
->irreco_layout
= NULL
;
153 /* Disable menu entries. */
154 gtk_widget_set_sensitive(
155 GTK_WIDGET(user_window
->menu_edit_remote
), FALSE
);
156 gtk_widget_set_sensitive(
157 GTK_WIDGET(user_window
->menu_rename_remote
), FALSE
);
158 gtk_widget_set_sensitive(
159 GTK_WIDGET(user_window
->menu_upload_remote
), FALSE
);
160 gtk_widget_set_sensitive(
161 GTK_WIDGET(user_window
->menu_delete_remote
), FALSE
);
165 /* Enable menu entries. */
166 gtk_widget_set_sensitive(
167 GTK_WIDGET(user_window
->menu_edit_remote
), TRUE
);
168 gtk_widget_set_sensitive(
169 GTK_WIDGET(user_window
->menu_rename_remote
), TRUE
);
170 gtk_widget_set_sensitive(
171 GTK_WIDGET(user_window
->menu_upload_remote
), TRUE
);
172 gtk_widget_set_sensitive(
173 GTK_WIDGET(user_window
->menu_delete_remote
), TRUE
);
177 IRRECO_PRINTF("Displaying layout \"%s\".\n",
178 irreco_button_layout_get_name(layout
));
179 irreco_button_layout_reset(layout
);
181 user_window
->irreco_layout
= layout
;
183 irreco_button_layout_set_container(layout
, user_window
->window
->layout
);
185 irreco_button_layout_create_widgets(layout
);
186 irreco_button_layout_set_press_callback(layout
, irreco_button_down
);
187 irreco_button_layout_set_release_callback(
188 layout
, irreco_window_user_button_release
);
189 irreco_button_layout_set_callback_data(layout
, user_window
);
190 irreco_window_user_draw_background(user_window
);
194 void irreco_window_user_draw_background(IrrecoWindowUser
* user_window
)
197 const GdkColor
*color
;
199 irreco_button_layout_get_bg(user_window
->irreco_layout
, &image
, &color
);
200 irreco_window_set_background_image(user_window
->window
, color
,
210 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
212 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
220 * Button release callback handler.
222 void irreco_window_user_button_release(IrrecoButton
* irreco_button
,
223 IrrecoWindowUser
* user_window
)
226 irreco_window_user_execute_start(
228 irreco_button_get_cmd_chain(irreco_button
),
234 void irreco_window_user_execute_start(IrrecoWindowUser
* user_window
,
235 IrrecoCmdChain
* cmd_chain
,
236 IrrecoButton
* irreco_button
)
239 if (irreco_cmd_chain_execute(cmd_chain
, user_window
->irreco_data
,
240 G_FUNC(irreco_window_user_execute_finish
),
242 user_window
->execution_button
= irreco_button
;
243 user_window
->executing_cmd_chain
= TRUE
;
244 gtk_widget_set_sensitive(user_window
->menu
, FALSE
);
245 gtk_widget_set_sensitive(user_window
->window
->scrolled_window
,
248 } else if (irreco_button
!= NULL
) {
249 irreco_button_up(irreco_button
);
254 void irreco_window_user_execute_finish(IrrecoCmdChain
* cmd_chain
,
255 IrrecoWindowUser
* user_window
)
259 gtk_widget_set_sensitive(user_window
->menu
, TRUE
);
260 gtk_widget_set_sensitive(user_window
->window
->scrolled_window
, TRUE
);
261 if (user_window
->execution_button
!= NULL
) {
262 irreco_button_up(user_window
->execution_button
);
265 user_window
->executing_cmd_chain
= FALSE
;
266 user_window
->execution_button
= NULL
;
275 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
277 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
284 void irreco_window_user_main_menu_create(IrrecoWindowUser
* user_window
)
289 user_window
->menu
= GTK_WIDGET( hildon_app_menu_new() );
290 user_window
->menu_new_remote
= hildon_button_new_with_text(2 | 4, 0, NULL
, "New remote");
291 user_window
->menu_download_remote
= hildon_button_new_with_text(2 | 4, 0, NULL
, "Download remote");
292 user_window
->menu_edit_remote
= hildon_button_new_with_text(2 | 4, 0, NULL
, "Edit remote");
293 user_window
->menu_rename_remote
= hildon_button_new_with_text(2 | 4, 0, NULL
, "Rename remote");
294 user_window
->menu_upload_remote
= hildon_button_new_with_text(2 | 4, 0, NULL
, "Upload remote");
295 user_window
->menu_delete_remote
= hildon_button_new_with_text(2 | 4, 0, NULL
, "Delete remote");
296 user_window
->menu_show_remote
= hildon_button_new_with_text(2 | 4, 0, NULL
, "Select remote");
297 user_window
->menu_about
= hildon_button_new_with_text(2 | 4, 0, NULL
, "About Irreco");
299 hildon_app_menu_append(HILDON_APP_MENU(user_window
->menu
),
300 GTK_BUTTON(user_window
->menu_new_remote
));
301 hildon_app_menu_append(HILDON_APP_MENU(user_window
->menu
),
302 GTK_BUTTON(user_window
->menu_download_remote
));
303 hildon_app_menu_append(HILDON_APP_MENU(user_window
->menu
),
304 GTK_BUTTON(user_window
->menu_edit_remote
));
305 hildon_app_menu_append(HILDON_APP_MENU(user_window
->menu
),
306 GTK_BUTTON(user_window
->menu_upload_remote
));
307 hildon_app_menu_append(HILDON_APP_MENU(user_window
->menu
),
308 GTK_BUTTON(user_window
->menu_rename_remote
));
309 hildon_app_menu_append(HILDON_APP_MENU(user_window
->menu
),
310 GTK_BUTTON(user_window
->menu_show_remote
));
311 hildon_app_menu_append(HILDON_APP_MENU(user_window
->menu
),
312 GTK_BUTTON(user_window
->menu_delete_remote
));
313 hildon_app_menu_append(HILDON_APP_MENU(user_window
->menu
),
314 GTK_BUTTON(user_window
->menu_about
));
317 hildon_window_set_app_menu(HILDON_WINDOW(user_window
->window
),
318 HILDON_APP_MENU(user_window
->menu
));
319 gtk_widget_show_all(user_window
->menu
);
321 /* Connect signals. */
322 g_signal_connect(G_OBJECT(user_window
->menu_new_remote
),
324 G_CALLBACK(irreco_window_user_new_remote
),
326 g_signal_connect(G_OBJECT(user_window
->menu_download_remote
),
328 G_CALLBACK(irreco_window_user_main_menu_download
),
330 g_signal_connect(G_OBJECT(user_window
->menu_edit_remote
),
332 G_CALLBACK(irreco_window_user_edit_remote
),
334 g_signal_connect(G_OBJECT(user_window
->menu_rename_remote
),
336 G_CALLBACK(irreco_window_user_main_menu_rename
),
338 g_signal_connect(G_OBJECT(user_window
->menu_upload_remote
),
340 G_CALLBACK(irreco_window_user_main_menu_upload
),
342 g_signal_connect(G_OBJECT(user_window
->menu_delete_remote
),
344 G_CALLBACK(irreco_window_user_delete_remote
),
346 g_signal_connect(G_OBJECT(user_window
->menu_show_remote
),
348 G_CALLBACK(irreco_window_user_show_remote
),
350 g_signal_connect(G_OBJECT(user_window
->menu_about
),
352 G_CALLBACK(irreco_window_user_menu_about
),
359 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
360 /* Main menu callback functions. */
361 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
364 * @name Main menu callback functions
369 * Create dialog window and ask the user for remote name. If user gives the
370 * remote name and clicks create, a new IrrecoButtonLayout and edit user interface
373 void irreco_window_user_new_remote(GtkMenuItem
* menuitem
, IrrecoWindowUser
* user_window
)
375 IrrecoData
*irreco_data
= user_window
->irreco_data
;
376 GtkWindow
*parent
= irreco_window_get_gtk_window(user_window
->window
);
378 if (irreco_window_user_create_new_remote(irreco_data
, parent
)) {
379 irreco_window_manager_show(irreco_data
->window_manager
,
386 void irreco_window_user_main_menu_download(GtkMenuItem
* menuitem
,
387 IrrecoWindowUser
* user_window
)
391 irreco_show_remote_download_dlg(user_window
->irreco_data
,
392 irreco_window_get_gtk_window(
393 user_window
->window
));
398 void irreco_window_user_edit_remote(GtkMenuItem
* menuitem
, IrrecoWindowUser
* user_window
)
400 IrrecoData
*irreco_data
= user_window
->irreco_data
;
403 if (irreco_string_table_is_empty(irreco_data
->irreco_layout_array
)) {
404 irreco_info_dlg(irreco_window_get_gtk_window(user_window
->window
),
405 _(IRRECO_NO_REMOTE_HELP
));
407 irreco_window_manager_set_layout(user_window
->manager
,
408 user_window
->irreco_layout
);
409 irreco_window_manager_show(user_window
->manager
,
416 void irreco_window_user_main_menu_rename(GtkMenuItem
* menuitem
,
417 IrrecoWindowUser
* user_window
)
419 IrrecoInputDlg
*input
;
422 IRRECO_PRINTF("%p\n", (void *) user_window
);
424 /* Create input dialog. */
425 input
= IRRECO_INPUT_DLG(irreco_input_dlg_new(
426 irreco_window_get_gtk_window(
427 user_window
->window
), _("Rename remote")));
428 irreco_input_dlg_set_label(input
, _("Name"));
429 irreco_input_dlg_set_entry(input
, irreco_button_layout_get_name(
430 user_window
->irreco_layout
));
432 /* Loop until cancel or successfull rename. */
434 if (irreco_show_input_dlg(input
) == FALSE
) break;
435 if (irreco_string_table_change_key(
436 user_window
->irreco_data
->irreco_layout_array
,
437 irreco_button_layout_get_name(
438 user_window
->irreco_layout
),
439 irreco_input_dlg_get_entry(input
)) == TRUE
) break;
440 irreco_error_dlg(GTK_WINDOW(input
),
441 _(IRRECO_LAYOUT_NAME_COLLISION
));
444 irreco_config_save_layouts(user_window
->irreco_data
);
445 /* irreco_window_user_create_show_remote_menu(user_window);*/
446 gtk_widget_destroy(GTK_WIDGET(input
));
450 void irreco_window_user_main_menu_upload(GtkMenuItem
* menuitem
,
451 IrrecoWindowUser
* user_window
)
455 irreco_show_remote_upload_dlg(user_window
->irreco_data
,
456 irreco_window_get_gtk_window(
457 user_window
->window
));
462 void irreco_window_user_delete_remote(GtkMenuItem
* menuitem
,
463 IrrecoWindowUser
* user_window
)
466 IrrecoButtonLayout
*irreco_layout
= NULL
;
467 IrrecoData
* irreco_data
= user_window
->irreco_data
;
470 /* Do we have anything to destroy? */
471 if (user_window
->irreco_layout
== NULL
) {
472 irreco_info_dlg(irreco_window_get_gtk_window(
473 user_window
->window
),
474 _(IRRECO_NO_REMOTE_HELP
));
476 /* If we can get the index of the current layout, and user agrees,
477 then destroy the layout. */
479 irreco_string_table_get_index(irreco_data
->irreco_layout_array
,
480 user_window
->irreco_layout
, &index
) &&
481 irreco_yes_no_dlg(irreco_window_get_gtk_window(user_window
->window
),
482 _("Delete remote?"))) {
484 IrrecoButtonLayout
* layout
= user_window
->irreco_layout
;
485 IRRECO_PRINTF("Destroying layout: \"%s\" from index %u\n",
486 irreco_button_layout_get_name(layout
), index
);
488 irreco_window_manager_set_layout(user_window
->manager
, NULL
);
489 irreco_string_table_remove_by_data(
490 irreco_data
->irreco_layout_array
, layout
);
491 irreco_config_save_layouts(irreco_data
);
493 if (index
> 0) index
--;
494 IRRECO_PRINTF("Displaying layout from index %u\n", index
);
495 irreco_string_table_index(irreco_data
->irreco_layout_array
,
497 (gpointer
*) &irreco_layout
);
498 irreco_window_manager_set_layout(user_window
->manager
,
506 * Pop up a info message if the user has not created any remotes.
509 void irreco_window_user_show_remote(GtkButton
*button
,
510 IrrecoWindowUser
*user_window
)
514 if (irreco_string_table_is_empty(
515 user_window
->irreco_data
->irreco_layout_array
)) {
516 irreco_info_dlg(irreco_window_get_gtk_window(
517 user_window
->window
),
518 _(IRRECO_NO_REMOTE_HELP
));
520 irreco_show_select_remote_dlg(user_window
);
526 void irreco_window_user_menu_about(GtkMenuItem
* menuitem
,
527 IrrecoWindowUser
* user_window
)
529 GError
*error
= NULL
;
530 GdkPixbuf
*icon
= NULL
;
531 GString
*license
= NULL
;
532 const gchar
*authors
[] = { "Arto Karppinen <arto.karppinen@iki.fi>\n"
533 "Joni Kokko <t5kojo01@students.oamk.fi>\n"
534 "Harri Vattulainen <t5vaha01@students.oamk.fi>\n"
535 "Sami Mäki <kasmra@xob.kapsi.fi>\n"
536 "Sampo Savola <samposav@paju.oulu.fi>\n"
537 "Sami Parttimaa <t5pasa02@students.oamk.fi>\n"
538 "Pekka Gehör <pegu6@msn.com>\n",
542 license
= g_string_new(NULL
);
543 g_string_append(license
,
544 "This program is free software; you can redistribute it and/or "
545 "modify it under the terms of the GNU General Public License "
546 "as published by the Free Software Foundation; either version 2 "
547 "of the License, or (at your option) any later version. "
549 g_string_append(license
,
550 "This program is distributed in the hope that it will be useful, "
551 "but WITHOUT ANY WARRANTY; without even the implied warranty of "
552 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
553 "GNU General Public License for more details. "
555 g_string_append(license
,
556 "You should have received a copy of the GNU General Public "
557 "License along with this program; if not, write to the Free "
558 "Software Foundation, Inc., 51 Franklin Street, Fifth Floor, "
559 "Boston, MA 02110-1301, USA.");
561 IRRECO_PRINTF("Loading icon: \"%s\".\n", IRRECO_ICON
);
562 icon
= gdk_pixbuf_new_from_file(IRRECO_ICON
, &error
);
563 if (error
!= NULL
) g_error_free(error
);
565 gtk_show_about_dialog(
566 irreco_window_manager_get_gtk_window(user_window
->manager
),
568 "license", license
->str
,
571 "website", "http://irreco.garage.maemo.org",
572 "wrap-license", TRUE
,
574 g_string_free(license
, TRUE
);
578 gboolean
irreco_window_user_key_press(GtkWidget
* widget
, GdkEventKey
* event
,
579 IrrecoWindowUser
* user_window
)
581 IrrecoCmdChain
*chain
;
584 if (user_window
->irreco_layout
!= NULL
) {
585 if (event
->keyval
== IRRECO_HARDKEY_MENU
||
586 event
->keyval
== IRRECO_HARDKEY_HOME
) {
587 gchar
*hardkey
= irreco_hardkey_to_str(event
->keyval
);
588 IRRECO_PRINTF("Ignoring keyval \"%s\"\n", hardkey
);
591 chain
= irreco_hardkey_map_get_cmd_chain(
592 user_window
->irreco_layout
->hardkey_map
,
595 irreco_window_user_execute_start(
596 user_window
, chain
, NULL
);
600 IRRECO_RETURN_BOOL(FALSE
);
603 gboolean
irreco_window_user_window_state_event(GtkWidget
*widget
,
604 GdkEventWindowState
*event
,
605 IrrecoWindowUser
*user_window
)
609 /* Syncronize menu option state with window fullscreen state. */
610 if (event
->changed_mask
& GDK_WINDOW_STATE_FULLSCREEN
) {
611 g_signal_handler_block(user_window
->menu_fullscreen
,
612 user_window
->menu_fullscreen_handler
);
614 if (event
->new_window_state
& GDK_WINDOW_STATE_FULLSCREEN
) {
615 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
616 user_window
->menu_fullscreen
), TRUE
);
618 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
619 user_window
->menu_fullscreen
), FALSE
);
622 g_signal_handler_unblock(user_window
->menu_fullscreen
,
623 user_window
->menu_fullscreen_handler
);
626 IRRECO_RETURN_BOOL(FALSE
);
633 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
635 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
638 * @name Public Functions
643 * Create dialog window and ask the user for remote name. If user gives the
644 * remote name and clicks create, a new IrrecoButtonLayout and edit user interface
647 gboolean
irreco_window_user_create_new_remote(IrrecoData
*irreco_data
,
650 gboolean loop
= TRUE
;
651 IrrecoInputDlg
*input_dlg
;
652 gboolean remote_created
= FALSE
;
655 /* Create input dialog. */
656 input_dlg
= IRRECO_INPUT_DLG(irreco_input_dlg_new(parent
,
658 irreco_input_dlg_set_label(input_dlg
, _("Name"));
660 /* Loop until we get a name, or user cancels. */
661 while (loop
== TRUE
&& irreco_show_input_dlg(input_dlg
)) {
662 const gchar
*name
= irreco_input_dlg_get_entry(input_dlg
);
664 /* Does it exist already? */
665 if (irreco_string_table_exists(irreco_data
->irreco_layout_array
,
667 irreco_error_dlg(GTK_WINDOW(input_dlg
),
668 _(IRRECO_LAYOUT_NAME_COLLISION
));
670 /* Create new layout. */
672 IrrecoButtonLayout
*layout
;
673 IrrecoCmdChain
*chain
;
676 /* Create button layout. */
677 layout
= irreco_button_layout_create(
678 NULL
, irreco_data
->cmd_chain_manager
);
679 irreco_button_layout_set_name(layout
, name
);
680 irreco_string_table_add(
681 irreco_data
->irreco_layout_array
,
682 irreco_button_layout_get_name(layout
),
684 irreco_string_table_sort_abc(
685 irreco_data
->irreco_layout_array
);
687 /* Attach fullscreen command to fullscreen button. */
688 irreco_hardkey_map_assosiate_chain(
689 layout
->hardkey_map
, IRRECO_HARDKEY_FULLSCREEN
);
690 chain
= irreco_hardkey_map_get_cmd_chain(
691 layout
->hardkey_map
, IRRECO_HARDKEY_FULLSCREEN
);
692 command
= irreco_cmd_create();
693 irreco_cmd_set_builtin(
694 command
, IRRECO_COMMAND_FULLSCREEN_TOGGLE
);
695 irreco_cmd_chain_append(chain
, command
);
697 /* Attach next remote command to plus button. */
698 irreco_hardkey_map_assosiate_chain(
699 layout
->hardkey_map
, IRRECO_HARDKEY_PLUS
);
700 chain
= irreco_hardkey_map_get_cmd_chain(
701 layout
->hardkey_map
, IRRECO_HARDKEY_PLUS
);
702 command
= irreco_cmd_create();
703 irreco_cmd_set_builtin(
704 command
, IRRECO_COMMAND_NEXT_REMOTE
);
705 irreco_cmd_chain_append(chain
, command
);
707 /* Attach previous remote command to minus button. */
708 irreco_hardkey_map_assosiate_chain(
709 layout
->hardkey_map
, IRRECO_HARDKEY_MINUS
);
710 chain
= irreco_hardkey_map_get_cmd_chain(
711 layout
->hardkey_map
, IRRECO_HARDKEY_MINUS
);
712 command
= irreco_cmd_create();
713 irreco_cmd_set_builtin(
714 command
, IRRECO_COMMAND_PREVIOUS_REMOTE
);
715 irreco_cmd_chain_append(chain
, command
);
718 irreco_window_manager_set_layout(
719 irreco_data
->window_manager
, layout
);
721 remote_created
= TRUE
;
725 gtk_widget_destroy(GTK_WIDGET(input_dlg
));
726 IRRECO_RETURN_BOOL(remote_created
);