summaryrefslogtreecommitdiff
path: root/demos/scrapbook/scrapbook.h
blob: 802e73698ae0b2b3ddd70ad2f0e54c3b2e85269f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
 * GData Client
 * Copyright (C) Joe Cortes 2010 <escozzia@gmail.com>
 *
 * GData Client is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * GData Client is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with GData Client.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gdata/gdata.h>
#include <glib.h>
#include <glib-object.h>
#define DEVELOPER_KEY "AI39si5MkSF-0bzTmP5WETk1D-Z7inHaQJzX13PeG_5Uzeu8mz3vo40cFoqnxjejB-UqzYFrqzOSlsqJvHuPNEGqdycqnPo30A"
#define CLIENT_ID "ytapi-GNOME-libgdata-444fubtt-0"
#define THUMBNAIL_WIDTH 180
#define MAX_RESULTS 	10

/* how this works is that there's a struct for every window opened
 * they contain that individual window's data
 * and every one of them (except for scrap data, which is for the main window)
 * has a pointer to the one for the main window called main_data */

enum {
	COL_PIXBUF,
	COL_TITLE,
	COL_VIDEO,
	N_COLS
};

enum {
	P_COL_PIXBUF,
	P_COL_TITLE,
	P_COL_USER,
	P_COL_PIC,
	P_N_COLS
};


enum {
	ORIG_COL_PIXBUF,
	ORIG_COL_TITLE,
	ORIG_COL_ENTRY,
	ORIG_N_COLS
};

typedef struct _ScrapYTSearch ScrapYTSearch;
typedef struct _ScrapPSearch  ScrapPSearch;
typedef struct _ScrapPUpload  ScrapPUpload;
typedef struct _ScrapPicSearch ScrapPicSearch;

typedef struct _ScrapData {
	GtkWidget		*window;
	gint			currentCol;
	gint			currentRow[5];
	GtkWidget		*box1;
	GtkWidget *grid;
	GtkWidget		*scrollWindow;
	ScrapYTSearch	*yt_search;
	ScrapPSearch	*p_search;
	ScrapPicSearch *pic_search;
	ScrapPUpload	*p_upload;
	gint			max_rows;
	gchar			*username;
	gchar			*password;
	GtkListStore	*lStore;

	GDataYouTubeService *youtube_service;
	GDataPicasaWebService *picasaweb_service;
} ScrapData;
struct _ScrapPUpload {
	ScrapData			*main_data;
	GDataPicasaWebFile	*file;
	GtkWidget			*dialog;
	GtkWidget			*name;
	GtkWidget			*description;
};

struct _ScrapPicSearch { /* for finding pictures */
	const gchar *title;
	gchar					*uri;
	const gchar *user;
	GdkPixbuf				*thumbnail;
	ScrapData				*main_data;
	ScrapPSearch			*search_data;
	GDataQuery				*query;
	GDataPicasaWebFile		*file;
	GtkListStore			*lStore;
	GtkWidget				*tView;
};

struct _ScrapYTSearch { /* youtube search data */
	GtkWidget 			*txt_entry;
	const gchar *txt;
	GtkWidget			*window;
	GDataQuery		 	*query;
	gchar				*title;
	gchar				*uri;
	GdkPixbuf			*thumbnail;
	GtkWidget 			*box1;
	ScrapData			*main_data; /* <- points to a structure containing main vars */
	GtkListStore		*lStore;
	GtkWidget			*tView;
};

struct _ScrapPSearch { /* for finding albums */
	GtkWidget				*window;
	GDataQuery				*query;
	gchar					*title;
	gchar					*uri;
	GdkPixbuf				*thumbnail;
	GtkWidget				*box1;
	ScrapData				*main_data;
	GtkWidget				*user_entry;
	const gchar *user;
	ScrapPicSearch			*pic;
};

typedef struct _ScrapProps {
	GtkWidget	*window;
	GtkWidget	*box1;
	GtkWidget	*username_entry, *password_entry;
	ScrapData	*main_data;
} ScrapProps;


static void
open_in_web_browser (GtkWidget *widget, gchar *uri);

static void
picture_selected (GtkTreeView *tree, GtkTreePath *path, GtkTreeViewColumn *column, ScrapPicSearch *self);

static void
video_selected (GtkTreeView *tree, GtkTreePath *path, GtkTreeViewColumn *column, ScrapYTSearch *self);

static void
p_display_tree (ScrapPicSearch *self);

static void
yt_display_tree (ScrapYTSearch *self);

GDataMediaThumbnail *
choose_best_thumbnail (GList *thumbnails, gint ideal_size);

static void
find_pictures  (GDataEntry *entry, guint entry_key, guint entry_count, ScrapPicSearch *self);

static void
p_query_element (GDataEntry *entry, guint entry_key, guint entry_count, ScrapPSearch *self);

static void
p_text_callback (GtkWidget *widget, ScrapPSearch *self);

static void
yt_query_element (GDataEntry *entry, guint entry_key, guint entry_count, ScrapYTSearch *self);

static void
yt_text_callback (GtkWidget *widget, ScrapYTSearch *self);

static void
start_new_picasa_search (GtkWidget *widget, ScrapData *first);

static void
start_new_youtube_search (GtkWidget *widget, ScrapData *first);

static void
properties_set (GtkWidget *widget, ScrapProps *self);

static void
properties_show (GtkWidget *widget, ScrapData *first);

static void
upload (GtkWidget *widget, ScrapData *first);