~ubuntu-branches/ubuntu/oneiric/libgdata/oneiric-backports

« back to all changes in this revision

Viewing changes to demos/scrapbook/scrapbook.h

  • Committer: Package Import Robot
  • Author(s): Evan Broder
  • Date: 2011-11-15 21:59:48 UTC
  • mfrom: (4.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20111115215948-e17s889ocgu5fv4f
Tags: 0.10.1-1~oneiric1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
2
/*
 
3
 * GData Client
 
4
 * Copyright (C) Joe Cortes 2010 <escozzia@gmail.com>
 
5
 *
 
6
 * GData Client is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Lesser General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2.1 of the License, or (at your option) any later version.
 
10
 *
 
11
 * GData Client 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 GNU
 
14
 * Lesser General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public
 
17
 * License along with GData Client.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include <stdio.h>
 
21
#include <stdlib.h>
 
22
#include <gtk/gtk.h>
 
23
#include <gdata/gdata.h>
 
24
#include <glib.h>
 
25
#include <glib-object.h>
 
26
#define DEVELOPER_KEY "AI39si5MkSF-0bzTmP5WETk1D-Z7inHaQJzX13PeG_5Uzeu8mz3vo40cFoqnxjejB-UqzYFrqzOSlsqJvHuPNEGqdycqnPo30A"
 
27
#define CLIENT_ID "ytapi-GNOME-libgdata-444fubtt-0"
 
28
#define THUMBNAIL_WIDTH 180
 
29
#define MAX_RESULTS     10
 
30
 
 
31
/* how this works is that there's a struct for every window opened
 
32
 * they contain that individual window's data
 
33
 * and every one of them (except for scrap data, which is for the main window)
 
34
 * has a pointer to the one for the main window called main_data */
 
35
 
 
36
enum {
 
37
        COL_PIXBUF,
 
38
        COL_TITLE,
 
39
        COL_VIDEO,
 
40
        N_COLS
 
41
};
 
42
 
 
43
enum {
 
44
        P_COL_PIXBUF,
 
45
        P_COL_TITLE,
 
46
        P_COL_USER,
 
47
        P_COL_PIC,
 
48
        P_N_COLS
 
49
};
 
50
 
 
51
 
 
52
enum {
 
53
        ORIG_COL_PIXBUF,
 
54
        ORIG_COL_TITLE,
 
55
        ORIG_COL_ENTRY,
 
56
        ORIG_N_COLS
 
57
};
 
58
 
 
59
typedef struct _ScrapYTSearch ScrapYTSearch;
 
60
typedef struct _ScrapPSearch  ScrapPSearch;
 
61
typedef struct _ScrapPUpload  ScrapPUpload;
 
62
typedef struct _ScrapPicSearch ScrapPicSearch;
 
63
 
 
64
typedef struct _ScrapData {
 
65
        GtkWidget               *window;
 
66
        gint                    currentCol;
 
67
        gint                    currentRow[5];
 
68
        GtkWidget               *box1;
 
69
        GtkWidget               *table;
 
70
        GtkWidget               *scrollWindow;
 
71
        ScrapYTSearch   *yt_search;
 
72
        ScrapPSearch    *p_search;
 
73
        ScrapPicSearch *pic_search;
 
74
        ScrapPUpload    *p_upload;
 
75
        gint                    max_rows;
 
76
        gchar                   *username;
 
77
        gchar                   *password;
 
78
        GtkListStore    *lStore;
 
79
 
 
80
        GDataYouTubeService *youtube_service;
 
81
        GDataPicasaWebService *picasaweb_service;
 
82
} ScrapData;
 
83
struct _ScrapPUpload {
 
84
        ScrapData                       *main_data;
 
85
        GDataPicasaWebFile      *file;
 
86
        GtkWidget                       *dialog;
 
87
        GtkWidget                       *name;
 
88
        GtkWidget                       *description;
 
89
};
 
90
 
 
91
struct _ScrapPicSearch { /* for finding pictures */
 
92
        const gchar *title;
 
93
        gchar                                   *uri;
 
94
        const gchar *user;
 
95
        GdkPixbuf                               *thumbnail;
 
96
        ScrapData                               *main_data;
 
97
        ScrapPSearch                    *search_data;
 
98
        GDataQuery                              *query;
 
99
        GDataPicasaWebFile              *file;
 
100
        GtkListStore                    *lStore;
 
101
        GtkWidget                               *tView;
 
102
};
 
103
 
 
104
struct _ScrapYTSearch { /* youtube search data */
 
105
        GtkWidget                       *txt_entry;
 
106
        const gchar *txt;
 
107
        GtkWidget                       *window;
 
108
        GDataQuery                      *query;
 
109
        gchar                           *title;
 
110
        gchar                           *uri;
 
111
        GdkPixbuf                       *thumbnail;
 
112
        GtkWidget                       *box1;
 
113
        ScrapData                       *main_data; /* <- points to a structure containing main vars */
 
114
        GtkListStore            *lStore;
 
115
        GtkWidget                       *tView;
 
116
};
 
117
 
 
118
struct _ScrapPSearch { /* for finding albums */
 
119
        GtkWidget                               *window;
 
120
        GDataQuery                              *query;
 
121
        gchar                                   *title;
 
122
        gchar                                   *uri;
 
123
        GdkPixbuf                               *thumbnail;
 
124
        GtkWidget                               *box1;
 
125
        ScrapData                               *main_data;
 
126
        GtkWidget                               *user_entry;
 
127
        const gchar *user;
 
128
        ScrapPicSearch                  *pic;
 
129
};
 
130
 
 
131
typedef struct _ScrapProps {
 
132
        GtkWidget       *window;
 
133
        GtkWidget       *box1;
 
134
        GtkWidget       *username_entry, *password_entry;
 
135
        ScrapData       *main_data;
 
136
} ScrapProps;
 
137
 
 
138
 
 
139
static void
 
140
open_in_web_browser (GtkWidget *widget, gchar *uri);
 
141
 
 
142
static void
 
143
picture_selected (GtkTreeView *tree, GtkTreePath *path, GtkTreeViewColumn *column, ScrapPicSearch *self);
 
144
 
 
145
static void
 
146
video_selected (GtkTreeView *tree, GtkTreePath *path, GtkTreeViewColumn *column, ScrapYTSearch *self);
 
147
 
 
148
static void
 
149
p_display_tree (ScrapPicSearch *self);
 
150
 
 
151
static void
 
152
yt_display_tree (ScrapYTSearch *self);
 
153
 
 
154
GDataMediaThumbnail *
 
155
choose_best_thumbnail (GList *thumbnails, gint ideal_size);
 
156
 
 
157
static void
 
158
find_pictures  (GDataEntry *entry, guint entry_key, guint entry_count, ScrapPicSearch *self);
 
159
 
 
160
static void
 
161
p_query_element (GDataEntry *entry, guint entry_key, guint entry_count, ScrapPSearch *self);
 
162
 
 
163
static void
 
164
p_text_callback (GtkWidget *widget, ScrapPSearch *self);
 
165
 
 
166
static void
 
167
yt_query_element (GDataEntry *entry, guint entry_key, guint entry_count, ScrapYTSearch *self);
 
168
 
 
169
static void
 
170
yt_text_callback (GtkWidget *widget, ScrapYTSearch *self);
 
171
 
 
172
static void
 
173
start_new_picasa_search (GtkWidget *widget, ScrapData *first);
 
174
 
 
175
static void
 
176
start_new_youtube_search (GtkWidget *widget, ScrapData *first);
 
177
 
 
178
static void
 
179
properties_set (GtkWidget *widget, ScrapProps *self);
 
180
 
 
181
static void
 
182
properties_show (GtkWidget *widget, ScrapData *first);
 
183
 
 
184
static void
 
185
upload (GtkWidget *widget, ScrapData *first);
 
186
 
 
187
 
 
188