~ubuntu-branches/ubuntu/quantal/gupnp-tools/quantal

« back to all changes in this revision

Viewing changes to src/av-cp/gui.c

  • Committer: Bazaar Package Importer
  • Author(s): Ross Burton
  • Date: 2008-05-09 10:40:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080509104041-d5yleszdmuwsdzzr
Tags: 0.3-1
* New upstream release.
* Add debian/watch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2007 Zeeshan Ali <zeenix@gstreamer.net>
 
3
 *
 
4
 * Authors: Zeeshan Ali <zeenix@gstreamer.net>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
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.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License along
 
17
 * with this program; if not, write to the Free Software Foundation,
 
18
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
19
 */
 
20
 
 
21
#include <string.h>
 
22
#include <stdlib.h>
 
23
#include <config.h>
 
24
 
 
25
#include "gui.h"
 
26
#include "playlist-treeview.h"
 
27
#include "renderer-combo.h"
 
28
#include "renderer-controls.h"
 
29
#include "main.h"
 
30
#include "icons.h"
 
31
 
 
32
#define GLADE_FILE DATA_DIR "/gupnp-av-cp.glade"
 
33
#define ICON_FILE  "pixmaps/av-cp.png"
 
34
 
 
35
static GladeXML  *glade_xml;
 
36
static GtkWidget *main_window;
 
37
static GtkWidget *about_dialog;
 
38
 
 
39
gboolean
 
40
on_delete_event (GtkWidget *widget,
 
41
                 GdkEvent  *event,
 
42
                 gpointer   user_data)
 
43
{
 
44
        application_exit ();
 
45
 
 
46
        return TRUE;
 
47
}
 
48
 
 
49
static void
 
50
setup_icons (GladeXML *glade_xml)
 
51
{
 
52
        GdkPixbuf *icon_pixbuf;
 
53
        GtkWidget *volume_min;
 
54
        GtkWidget *volume_max;
 
55
 
 
56
        init_icons ();
 
57
 
 
58
        icon_pixbuf = load_pixbuf_file (ICON_FILE);
 
59
        g_assert (icon_pixbuf != NULL);
 
60
 
 
61
        gtk_window_set_icon (GTK_WINDOW (main_window), icon_pixbuf);
 
62
        gtk_window_set_icon (GTK_WINDOW (about_dialog), icon_pixbuf);
 
63
        gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG (about_dialog),
 
64
                                   icon_pixbuf);
 
65
        g_object_unref (icon_pixbuf);
 
66
 
 
67
        volume_min = glade_xml_get_widget (glade_xml, "volume-min-image");
 
68
        g_assert (volume_min != NULL);
 
69
        volume_max = glade_xml_get_widget (glade_xml, "volume-max-image");
 
70
        g_assert (volume_max != NULL);
 
71
 
 
72
        gtk_image_set_from_pixbuf (GTK_IMAGE (volume_min),
 
73
                                   get_icon_by_id (ICON_MIN_VOLUME));
 
74
        gtk_image_set_from_pixbuf (GTK_IMAGE (volume_max),
 
75
                                   get_icon_by_id (ICON_MAX_VOLUME));
 
76
}
 
77
 
 
78
gboolean
 
79
init_ui (gint   *argc,
 
80
         gchar **argv[])
 
81
{
 
82
        gint window_width, window_height;
 
83
 
 
84
        gtk_init (argc, argv);
 
85
        glade_init ();
 
86
        g_thread_init (NULL);
 
87
 
 
88
        glade_xml = glade_xml_new (GLADE_FILE, NULL, NULL);
 
89
        if (glade_xml == NULL) {
 
90
                g_critical ("Unable to load the GUI file %s", GLADE_FILE);
 
91
                return FALSE;
 
92
        }
 
93
 
 
94
        main_window = glade_xml_get_widget (glade_xml, "main-window");
 
95
        g_assert (main_window != NULL);
 
96
        about_dialog = glade_xml_get_widget (glade_xml, "about-dialog");
 
97
        g_assert (about_dialog != NULL);
 
98
 
 
99
        /* 40% of the screen but don't get bigger than 1000x800 */
 
100
        window_width = CLAMP ((gdk_screen_width () * 40 / 100), 10, 1000);
 
101
        window_height = CLAMP ((gdk_screen_height () * 40 / 100), 10, 800);
 
102
        gtk_window_set_default_size (GTK_WINDOW (main_window),
 
103
                                     window_width,
 
104
                                     window_height);
 
105
 
 
106
        gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (about_dialog),
 
107
                                      VERSION);
 
108
 
 
109
        glade_xml_signal_autoconnect (glade_xml);
 
110
 
 
111
        setup_icons (glade_xml);
 
112
        setup_playlist_treeview (glade_xml);
 
113
        setup_renderer_controls (glade_xml);
 
114
        setup_renderer_combo (glade_xml);
 
115
 
 
116
        gtk_widget_show_all (main_window);
 
117
 
 
118
        return TRUE;
 
119
}
 
120
 
 
121
void
 
122
deinit_ui (void)
 
123
{
 
124
        g_object_unref (glade_xml);
 
125
        gtk_widget_destroy (main_window);
 
126
        gtk_widget_destroy (about_dialog);
 
127
        deinit_icons ();
 
128
}
 
129