Modified xmlrpc to send irreco version in correct format.
[irreco.git] / irreco / src / core / irreco_style_browser_dlg.c
blobfdc650f90a7f717731f2d7318bd150a9ea3e36a8
1 /*
2 * irreco - Ir Remote Control
3 * Copyright (C) 2007 Arto Karppinen (arto.karppinen@iki.fi),
4 * Harri Vattulainen (t5vaha01@students.oamk.fi)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "irreco_style_browser_dlg.h"
22 #include "irreco_scrolled_window.h"
23 #include <hildon/hildon-banner.h>
25 /**
26 * @typedef IrrecoStyleBrowser
28 * Dialog which displays a list of button styles to the user, so the user
29 * can select one.
32 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
33 /* Prototypes */
34 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
35 void irreco_style_browser_dlg_set_button_widget(IrrecoStyleBrowserDlg *self);
36 void irreco_style_browser_dlg_theme_image_selection_changed(
37 GtkTreeSelection * selection,
38 IrrecoStyleBrowserDlg * self);
40 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
41 /* Construction & Destruction */
42 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
43 G_DEFINE_TYPE(IrrecoStyleBrowserDlg, irreco_style_browser_dlg, IRRECO_TYPE_DLG)
45 static void irreco_style_browser_dlg_finalize(GObject *object)
47 IRRECO_ENTER
48 G_OBJECT_CLASS(irreco_style_browser_dlg_parent_class)->finalize(object);
49 IRRECO_RETURN
52 static void irreco_style_browser_dlg_class_init(IrrecoStyleBrowserDlgClass *klass)
54 GObjectClass *object_class = G_OBJECT_CLASS(klass);
55 object_class->finalize = irreco_style_browser_dlg_finalize;
58 static void irreco_style_browser_dlg_init(IrrecoStyleBrowserDlg *self)
60 IRRECO_ENTER
62 self->style = NULL;
64 /* Construct dialog. */
65 gtk_window_set_title(GTK_WINDOW(self), _("Style Browser"));
66 gtk_window_set_modal(GTK_WINDOW(self), TRUE);
67 gtk_window_set_destroy_with_parent(GTK_WINDOW(self), TRUE);
68 gtk_dialog_set_has_separator(GTK_DIALOG(self), FALSE);
69 gtk_dialog_add_buttons(GTK_DIALOG(self),
70 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
71 NULL);
73 /* Show dialog, hopefully on the left-top corner of the screen. */
74 gtk_widget_show_all(GTK_WIDGET(self));
75 gtk_window_move(GTK_WINDOW(self), 80, 60);
76 IRRECO_RETURN
79 GtkWidget* irreco_style_browser_dlg_new(IrrecoData *irreco_data,
80 GtkWindow *parent)
82 IrrecoStyleBrowserDlg *self;
83 IRRECO_ENTER
84 self = g_object_new(IRRECO_TYPE_STYLE_BROWSER_DLG, NULL);
85 irreco_dlg_set_parent(IRRECO_DLG(self), parent);
86 irreco_style_browser_dlg_set_irreco_data(self, irreco_data);
87 irreco_style_browser_dlg_set_button_widget(self);
88 IRRECO_RETURN_PTR(self);
91 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
92 /* Private Functions */
93 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
94 static void irreco_style_browser_dlg_loading_cancel(IrrecoStyleBrowserDlg *self)
96 IRRECO_ENTER
97 if (self->loading != NULL) self->loading->self = NULL;
98 IRRECO_RETURN
101 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
102 /* Functions */
103 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
104 void irreco_style_browser_dlg_set_irreco_data(IrrecoStyleBrowserDlg *self,
105 IrrecoData *irreco_data)
107 IRRECO_ENTER
108 self->irreco_data = irreco_data;
109 IRRECO_RETURN
112 void irreco_style_browser_dlg_set_button_widget(IrrecoStyleBrowserDlg *self)
114 IRRECO_ENTER
116 self->button_widget = irreco_button_browser_widget_new(self->irreco_data);
117 gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(self)->vbox),
118 GTK_WIDGET(self->button_widget));
120 /* Signal handler */
121 g_signal_connect(G_OBJECT(IRRECO_LISTBOX(
122 self->button_widget->images)->tree_selection),
123 "changed",
124 G_CALLBACK(irreco_style_browser_dlg_theme_image_selection_changed),
125 self);
127 gtk_widget_show_all(GTK_WIDGET(self));
129 IRRECO_RETURN
132 gboolean irreco_show_style_browser_dlg(IrrecoData *irreco_data,
133 GtkWindow *parent,
134 IrrecoThemeButton **style)
136 gint response;
137 IrrecoStyleBrowserDlg *self;
138 IRRECO_ENTER
140 self = IRRECO_STYLE_BROWSER_DLG(irreco_style_browser_dlg_new(
141 irreco_data, parent));
142 response = gtk_dialog_run(GTK_DIALOG(self));
143 irreco_style_browser_dlg_loading_cancel(self);
145 if (response == 1) *style = self->style;
146 gtk_widget_destroy(GTK_WIDGET(self));
148 if (response == 1) IRRECO_RETURN_BOOL(TRUE);
149 IRRECO_RETURN_BOOL(FALSE);
152 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
153 /* Events and Callbacks */
154 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
155 void irreco_style_browser_dlg_theme_image_selection_changed(
156 GtkTreeSelection * selection,
157 IrrecoStyleBrowserDlg * self)
159 IrrecoThemeButton *button = self->button_widget->current_image;
160 IRRECO_ENTER
162 if (button != NULL) {
163 self->style = button;
164 gtk_dialog_response(GTK_DIALOG(self), 1);
166 IRRECO_RETURN