~cahr-gr/gloobus-preview/monitors

« back to all changes in this revision

Viewing changes to src/gloobus-preview-interface-list.cpp

  • Committer: Jordi Puigdellívol
  • Date: 2010-05-26 14:35:12 UTC
  • mfrom: (213.1.33 gloobus-preview)
  • Revision ID: jordi@badchoice-20100526143512-bhndzc2y7o8un30v
Merged, now its really good

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "gloobus-preview-interface-list.h"
2
2
 
3
 
// ================m_scwin========= DESTRUCTOR =================================== //
 
3
#define ILIST_WIDTH 500
 
4
#define ILIST_HEIGHT 500
 
5
#define ILIST_PADDING 10
 
6
 
4
7
iList::iList()
5
 
        :m_pixbuf(0)
6
 
        ,m_reflection(0)
 
8
        :pix_icon(0)
 
9
        ,pix_reflection(0)
7
10
        ,n_items(0)
8
11
        ,m_store(0)
9
12
        ,m_scwin(0)
18
21
iList::~iList()
19
22
{
20
23
        g_debug("Destroying iList");
21
 
        if(m_pixbuf)
22
 
                g_object_unref( m_pixbuf );
23
 
        if(m_reflection)
24
 
                g_object_unref( m_reflection );
 
24
        if(pix_icon)
 
25
                g_object_unref( pix_icon );
 
26
        if(pix_reflection)
 
27
                g_object_unref( pix_reflection );
25
28
        if(m_store)
26
29
                g_object_unref( m_store );
27
30
}
36
39
        else
37
40
                delete self_ptr;
38
41
 
39
 
        if(m_scwin)
40
 
                gtk_widget_destroy(m_scwin);
41
 
        g_debug("ended");
 
42
        //if(m_scwin)
 
43
        //      gtk_widget_destroy(m_scwin);
42
44
}
43
45
// ========================= CONSTRUCTOR ================================= //
44
46
bool iList::load()
45
47
{
46
48
        g_debug("Loading iList");
47
49
        GdkPixbuf* temp = get_pixbuf();
48
 
        m_pixbuf         = scale_pixbuf(temp ,ICON_SIZE,ICON_SIZE);
49
 
        m_reflection = pixbuf_reflection(m_pixbuf);             //Creates the reflection Pixbuf
 
50
        pix_icon         = ui->pixbuf_scale(temp ,ICON_SIZE,ICON_SIZE);
 
51
        pix_reflection = ui->pixbuf_reflect(pix_icon);
50
52
        g_object_unref(temp);
51
53
 
52
54
        m_scwin = gtk_scrolled_window_new(NULL,NULL);
54
56
                GTK_POLICY_AUTOMATIC ,GTK_POLICY_AUTOMATIC );
55
57
        gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_scwin),
56
58
                GTK_SHADOW_NONE);
57
 
        gtk_widget_set_size_request( m_scwin , 500 - 2 * SHADOW_WIDTH - 18, 280);
 
59
        //gtk_widget_set_size_request( m_scwin , 480 , 285);
58
60
        //FIXME: shouldn't use 500. Should get window width.
59
61
 
60
62
        //n_items = get_n_items();
90
92
// =========================== GET SIZE (W)================================= //
91
93
int  iList::get_width()
92
94
{
93
 
        return 500;
 
95
        return ILIST_WIDTH;
94
96
};
95
97
 
96
98
// =========================== GET SIZE (H)================================= //
97
99
int  iList::get_height()
98
100
{
99
 
        return 500;
100
 
};
101
 
 
102
 
// =========================== DRAW ICON ================================= //
103
 
void iList::draw_icon(GtkContainer * container)
104
 
{
105
 
        GtkWidget *image                                = gtk_image_new_from_pixbuf (m_pixbuf);
106
 
        GtkWidget *image_container              = gtk_fixed_new ();
107
 
        GtkWidget *reflection                   = gtk_image_new_from_pixbuf (m_reflection);
108
 
        GtkWidget *reflection_container = gtk_fixed_new ();
109
 
 
110
 
        int x = SHADOW_WIDTH;                                                   //Default values are at top left
111
 
        int y = HEADER_HEIGHT + SHADOW_WIDTH;                   //and 20 from top (For the header)
112
 
 
113
 
        if(gdk_pixbuf_get_width(m_pixbuf) < 300)                //Minum width
114
 
        {
115
 
                x = 150-gdk_pixbuf_get_width(m_pixbuf)/2;
116
 
        }
117
 
        if(gdk_pixbuf_get_height(m_pixbuf) < 300)               //Minium height
118
 
        {
119
 
                y = 150-gdk_pixbuf_get_height(m_pixbuf)/2;
120
 
        }
121
 
 
122
 
 
123
 
        gtk_fixed_put           (GTK_FIXED(image_container),image,50+SHADOW_WIDTH, 26 + SHADOW_WIDTH + HEADER_HEIGHT);
124
 
        gtk_fixed_put           (GTK_FIXED(reflection_container),reflection,50+SHADOW_WIDTH, 26 + SHADOW_WIDTH + HEADER_HEIGHT + gdk_pixbuf_get_height(m_pixbuf));
125
 
        gtk_container_add       (GTK_CONTAINER(container),image_container);
126
 
        gtk_container_add       (GTK_CONTAINER(container),reflection_container);
127
 
        gtk_widget_show         (image_container);
128
 
        gtk_widget_show         (image);
129
 
        gtk_widget_show         (reflection_container);
130
 
        gtk_widget_show         (reflection);
131
 
}
132
 
 
133
 
// =========================== DRAW LIST ================================= //
134
 
void iList::draw_list(GtkContainer * container)
135
 
{
136
 
        gtk_fixed_put(GTK_FIXED(container), m_scwin, 24 + SHADOW_WIDTH,
137
 
                240 + SHADOW_WIDTH + HEADER_HEIGHT);
138
 
        gtk_widget_show_all ( m_scwin );
139
 
};
140
 
 
141
 
// ========================= DRAW IMAGE INFO ===================== //
142
 
void iList::draw_file_info(GtkContainer * container)
143
 
{
144
 
        draw_properties ( container, get_file_info_string(), 285 + SHADOW_WIDTH,80 + SHADOW_WIDTH);
145
 
}
146
 
 
147
 
// ========================= DRAW ===================== //
148
 
// Virtual function that draws what plugin wants
 
101
        return ILIST_HEIGHT;
 
102
};
 
103
 
149
104
void iList::draw( GtkContainer * container )
150
105
{
151
 
        draw_icon               ( GTK_CONTAINER(container ));
152
 
        draw_list               ( GTK_CONTAINER(container ));
153
 
        draw_file_info  ( GTK_CONTAINER(container ));
 
106
        gtk_alignment_set(GTK_ALIGNMENT(container), 0.5,0.5,0,0);
 
107
        GtkWidget *align = gtk_alignment_new(0.5,0.5,1,1);
 
108
        gtk_widget_set_size_request(align, ILIST_WIDTH, ILIST_HEIGHT);
 
109
        gtk_alignment_set_padding(GTK_ALIGNMENT(align),
 
110
                ILIST_PADDING, ILIST_PADDING, ILIST_PADDING, ILIST_PADDING);
 
111
        
 
112
        icon            = gtk_image_new_from_pixbuf (pix_icon);
 
113
        reflection      = gtk_image_new_from_pixbuf (pix_reflection);
 
114
        GtkWidget *mpad = gtk_alignment_new(0.5,0.5,1,1);
 
115
        gtk_widget_set_size_request(mpad, 25, 20);
 
116
 
 
117
        string info = get_file_info_string();
 
118
        GtkWidget *info_label = ui->get_theme()->get_label(info.c_str());
 
119
        gtk_misc_set_alignment(GTK_MISC(info_label), 0.5 , 0.5 );
 
120
 
 
121
        GtkWidget *vbox = gtk_vbox_new(false, 0);
 
122
        GtkWidget *hbox = gtk_hbox_new(false, 10);
 
123
        GtkWidget *mbox = gtk_vbox_new(false, 0);
 
124
 
 
125
        gtk_box_pack_start(GTK_BOX(mbox), icon, false, false, 0);
 
126
        gtk_box_pack_start(GTK_BOX(mbox), reflection, false, false, 0);
 
127
 
 
128
        gtk_box_pack_start(GTK_BOX(hbox), mpad, false, false, 0);
 
129
        gtk_box_pack_start(GTK_BOX(hbox), mbox, false, false, 0);
 
130
        gtk_box_pack_start(GTK_BOX(hbox), info_label, true, true, 0);
 
131
 
 
132
        gtk_box_pack_start(GTK_BOX(vbox), hbox, false, false, 0);
 
133
        gtk_box_pack_start(GTK_BOX(vbox), m_scwin, true, true, 0);
 
134
 
 
135
        gtk_container_add(GTK_CONTAINER(align), vbox);
 
136
        gtk_container_add(container, align);
 
137
        
 
138
        //gtk_fixed_put( GTK_FIXED(container), icon, 50, 10);
 
139
        //gtk_fixed_put( GTK_FIXED(container), reflection, 50, 10 + ICON_SIZE);
 
140
        //gtk_fixed_put( GTK_FIXED(container), m_scwin , 10 , 205 );
 
141
        //gtk_widget_show_all( m_scwin );
 
142
        //draw_properties ( container, get_file_info_string(), 250 , 60 );
 
143
        gtk_widget_show_all( GTK_WIDGET(container) );
154
144
}
155
145
 
156
 
// ====================== FULLSCREEN ================= //
157
 
bool iList::can_fullscreen  ( void ){ return false;}                                            //Returns true if the plugin can do fullscreen
158
146
void iList::draw_fullscreen ( GtkContainer * container )
159
 
{
 
147
{/*
 
148
        int x = ( ui->get_screen_width()-get_width() ) / 2;
 
149
        int y = ( ui->get_screen_height()-get_height() ) / 2;
 
150
        gtk_fixed_move( GTK_FIXED(container), icon, x+50, y+10);
 
151
        gtk_fixed_move( GTK_FIXED(container), reflection, x+50, y+10 + ICON_SIZE);
 
152
        gtk_fixed_move( GTK_FIXED(container), m_scwin , x+10 , y+205 );
 
153
        gtk_fixed_move( GTK_FIXED(container), m_info , x+250 , y+60 );*/
160
154
}
 
155
 
161
156
void iList::draw_unfullscreen ( GtkContainer * container )
162
 
{
163
 
}
164
 
 
165
 
// ============================ DRAW FLOATING CONTROLS ================================ //
166
 
void iList::draw_toolbar        ( GtkWidget * container )
167
 
{
168
 
    g_debug("iList toolbar buttons");
169
 
        draw_default_toolbar(container);
170
 
}
171
 
 
 
157
{/*
 
158
        gtk_fixed_move( GTK_FIXED(container), icon, 50, 10);
 
159
        gtk_fixed_move( GTK_FIXED(container), reflection, 50, 10 + ICON_SIZE);
 
160
        gtk_fixed_move( GTK_FIXED(container), m_scwin , 10 , 205 );
 
161
        gtk_fixed_move( GTK_FIXED(container), m_info , 250 , 60 );*/
 
162
}
172
163
 
173
164
gboolean iList::file_loader(gpointer ptr) {
174
165
        g_debug("File loader started");
180
171
        GtkTreeIter iter;
181
172
 
182
173
        while(list->has_items()) {
183
 
                g_debug("Adding %d", list->n_items);
 
174
                //g_debug("Adding %d", list->n_items);
184
175
                int i = list->n_items;
185
176
                gtk_list_store_append(list->m_store, &iter);
186
177
                for ( int j = 0 ; j < list->get_n_columns() ; j++) {
205
196
                        list->m_error = g_error_new(g_quark_from_string ("iList"), 901,
206
197
                        _("Error listing files"));
207
198
                }
208
 
                Gloobus::instance()->end_file_and_error();
 
199
                Gloobus::instance()->show_error();
209
200
        }
210
201
        return false;
211
202
}