~ubuntu-branches/debian/sid/tickr/sid

« back to all changes in this revision

Viewing changes to src/tickr/tickr_feedpicker.c

  • Committer: Package Import Robot
  • Author(s): Emmanuel Thomas-Maurin
  • Date: 2012-06-04 14:23:24 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120604142324-j6ycu0cw6vvoahhy
Tags: 0.6.1-1
* Add: 'quick setup' thing (in tickr_quicksetup.c) which is launched
  at program startup if config file doesn't exist.

* Little improvements in layout of 'feed picker win' and 'preferences
  win'.

* Fix a segfault that happens when trying to export params and no
  config file exists yet.

* Make several windows that should not be resized by user, unresizable.

* Fix Launchpad bug #1007346: When 'window always-on-top' is disabled,
  'visible on all user desktops' stops working.

* If mouse wheel scrolling applies to speed (or feed), then Ctrl +
  mouse wheel scrolling applies to feed (or speed.)

* No real code changes in libetm, only in comments, so no need for a
  new version number.

* Update tickr_helptext.c and tickr.1 (man page.)

* Add new cli option 'no-ui' (similar to 'instance-id') used by new
  IF_UI_ALLOWED macro and remove all #if USE_GUI occurences.

* In tickr_list.c, free listfname before using it. Fixed by swapping 2
  lines:
    warning(FALSE, 4, "Can't save URL list ", listfname, ...);
    l_str_free(listfname);

* Use/add #define
    FONT_MAXLEN         68
    ARBITRARY_TASKBAR_HEIGHT    25
  to replace a few 'magic' numeric values.

* Rename: rss_title/description(_delimiter) ->
    item_title/description(_delimiter)
  then add new param: feed_title(_delimiter). Now we have:
  feed title / item title / item description.

* Use table in resource properties window.

* Fix a bug in f_list_load_from_file() in tickr_list.c which
  uncorrectly retrieves any feed title string containing TITLE_TAG_CHAR
  when TITLE_TAG_CHAR has not been removed from string first, for
  instance: 'NYT > World' -> ' World'.

* New param: disable left-click.

* Add 'check for updates' feature.

* Launch 'import OPML file' if feed list doesn't exist.

* Remove code changing get_params()->disable_popups value in
    START/END_PAUSE_TICKER_WHILE_OPENING
  macros which prevents this setting to be saved and add
    START/END_PAUSE_TICKER_ENABLE_POPUPS_WHILE_OPENING
  new macros. Which ones to use depends on context.

* Move:
    #ifdef G_OS_WIN32
    extern FILE *stdout_fp, *stderr_fp;
    #endif
  from *.c into tickr.h.

* Default always-on-top setting changed to 'n' (so that tickr is not
  intrusive by default.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
#include "tickr.h"
20
20
 
21
 
#if USE_GUI
22
21
#define URL_ENTRY_LENGTH        100
23
 
#define SC_WIN_HEIGHT           350
24
22
 
25
 
/* predefined GTK_RESPONSE_ are < 0, those ones are app level defined and >= 0 */
 
23
/* Predefined GTK_RESPONSE_ are < 0, those ones are app level defined and >= 0. */
26
24
enum {
27
25
        GTK_RESPONSE_SELECT_ALL, GTK_RESPONSE_UNSELECT_ALL, GTK_RESPONSE_TOP, GTK_RESPONSE_HOME,
28
26
        GTK_RESPONSE_REMOVE, GTK_RESPONSE_ADD, GTK_RESPONSE_SINGLE, GTK_RESPONSE_SELECTION
32
30
 
33
31
static GtkWidget        *dialog, *entry_url;
34
32
static FList            *flist;
35
 
static int              f_index;        /* starting at 0 (row starts at 1) */
 
33
static int              f_index;        /* Starting at 0 (row starts at 1) */
36
34
static gchar            home_feed[FILE_NAME_MAXLEN + 1];
37
35
 
38
 
static gint esc_key_pressed(GtkWidget *dialog2, GdkEventKey *event)
39
 
{
40
 
        if (event->keyval == GDK_Escape) {
41
 
                gtk_dialog_response(GTK_DIALOG(dialog2), GTK_RESPONSE_CLOSE);
42
 
                return TRUE;
43
 
        } else
44
 
                return FALSE;
45
 
}
46
 
 
47
 
static void force_quit_dialog(GtkWidget *dialog2)
48
 
{
49
 
        gtk_dialog_response(GTK_DIALOG(dialog2), GTK_RESPONSE_CLOSE);
50
 
}
51
 
 
52
 
/* tree selection callback - update f_index and copy selected url to entry_url (override) */
 
36
/* Tree selection callback - update f_index and copy selected url to entry_url (override) */
53
37
static gint tree_selection_changed(GtkTreeSelection *selection)
54
38
{
55
39
        GtkTreeModel    *tree_model = NULL;
70
54
        return TRUE;
71
55
}
72
56
 
73
 
/* catch double-click on tree view */
 
57
/* Catch double-click on tree view */
74
58
static gint double_click_on_tree_view(GtkTreeView *tree_view, GtkTreePath *tree_path)
75
59
{
76
60
        GtkTreeModel    *tree_model = NULL;
173
157
        }
174
158
}
175
159
 
176
 
/* select and scroll to row */
 
160
/* Select and scroll to row */
177
161
void highlight_and_go_to_row(GtkTreeView *tree_view, GtkTreeSelection *selection, int row)
178
162
{
179
163
        GtkTreeModel    *tree_model;
194
178
        }
195
179
}
196
180
 
197
 
/* clear the list before filling it */
 
181
/* Clear the list before filling it */
198
182
static void fill_list_store_from_flnode(GtkListStore *list_store)
199
183
{
200
184
        FList           *flist2;
227
211
                if (IS_FLIST(flist))
228
212
                        flist = f_list_last(flist);
229
213
                if (get_feed_info(resrc->id, rss_feed_title, rss_feed_link, rss_feed_ttl) == OK)
230
 
                        /* added url is set unselected */
 
214
                        /* Added url is set unselected */
231
215
                        flist = f_list_add_at_end(flist, resrc->id, rss_feed_title, FALSE);
232
216
                else
233
217
                        flist = f_list_add_at_end(flist, resrc->id, "", FALSE);
238
222
}
239
223
 
240
224
/*
241
 
 * open a dialog with a list of urls to choose from and an url entry
 
225
 * Open a dialog with a list of urls to choose from and an url entry.
242
226
 *
243
 
 * entry format in url list file:
 
227
 * Entry format in url list file:
244
228
 *      ["*" (selected) or "-" (unselected) + url [+ ">" + title] + '\n']
245
229
 *
246
 
 * entry max length = FILE_NAME_MAXLEN
247
 
 * see also: (UN)SELECTED_URL_CHAR in tickr.h
 
230
 * Entry max length = FILE_NAME_MAXLEN.
 
231
 * See also: (UN)SELECTED_URL_CHAR in tickr.h.
248
232
 */
249
233
void get_new_url(Resource *resrc)
250
234
{
251
235
        TickerEnv               *env;
252
 
        GtkWidget               *vbox, *sc_win, *hbox, *label[3];
 
236
        GtkWidget               *sc_win, *hbox;
253
237
        GtkWidget               *cancel_but, *selectall_but, *unselectall_but;
254
238
        GtkWidget               *top_but, *home_but, *remove_but, *add_but;
255
239
        GtkWidget               *single_but, *selection_but, *clear_but;
285
269
        selection_but = gtk_dialog_add_button(GTK_DIALOG(dialog), "OK (Selec)", GTK_RESPONSE_SELECTION);
286
270
        clear_but = gtk_button_new_with_label("Clear");
287
271
 
288
 
        cancel_but = cancel_but;        /* to get rid of one compiler warning */
 
272
        cancel_but = cancel_but;        /* To get rid of some annoying compiler warnings */
289
273
        selectall_but = selectall_but;
290
274
        unselectall_but = unselectall_but;
291
275
        top_but = top_but;
294
278
        add_but = add_but;
295
279
        single_but = single_but;
296
280
        selection_but = selection_but;
297
 
        clear_but = clear_but;          /* until here */
 
281
        clear_but = clear_but;          /* Until here */
298
282
 
299
283
        set_tickr_icon_to_dialog(GTK_WINDOW(dialog));
300
284
        gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ALWAYS);
301
285
 
302
 
        vbox = gtk_vbox_new(FALSE, 0);
303
 
        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbox, FALSE, TRUE, 0);
304
 
        gtk_container_set_border_width(GTK_CONTAINER(GTK_BOX(vbox)), 15);
 
286
        sc_win = gtk_scrolled_window_new(NULL, NULL);
 
287
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sc_win),
 
288
                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 
289
        gtk_container_set_border_width(GTK_CONTAINER(sc_win), 5);
 
290
        /* Whole window must be visible on netbooks as well */
 
291
        gtk_widget_set_size_request(sc_win, 1000, 450);
 
292
        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), sc_win, TRUE, FALSE, 0);
305
293
 
306
294
        str_n_cpy(home_feed, get_params()->homefeed, FILE_NAME_MAXLEN);
307
295
        list_store = gtk_list_store_new(N_COLUMNS, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING);
333
321
                "text", COLUMN_STRING_URL, NULL);
334
322
        gtk_tree_view_append_column(tree_view, column3);
335
323
 
336
 
        sc_win = gtk_scrolled_window_new(NULL, NULL);
337
 
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sc_win),
338
 
                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
339
 
        gtk_widget_set_size_request(sc_win, -1, SC_WIN_HEIGHT);
340
 
 
341
 
        gtk_container_add(GTK_CONTAINER(vbox), sc_win);
342
324
        gtk_container_add(GTK_CONTAINER(sc_win), GTK_WIDGET(tree_view));
343
325
 
344
 
        label[0] = gtk_label_new("");
345
 
        gtk_container_add(GTK_CONTAINER(vbox), label[0]);
346
 
 
347
326
        selection = gtk_tree_view_get_selection(tree_view);
348
327
        gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
349
328
 
352
331
        g_signal_connect(G_OBJECT(renderer1), "toggled", G_CALLBACK(checkbox_toggled), tree_view);
353
332
 
354
333
        hbox = gtk_hbox_new(FALSE, 0);
355
 
        label[1] = gtk_label_new("Enter new URL:");
356
 
        gtk_box_pack_start(GTK_BOX(hbox), label[1], FALSE, FALSE, 0);
357
 
        label[2] = gtk_label_new("  ");
358
 
        gtk_box_pack_start(GTK_BOX(hbox), label[2], TRUE, FALSE, 0);
 
334
        gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new("Enter new URL:"), FALSE, FALSE, 0);
 
335
        gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new("  "), TRUE, FALSE, 0);
359
336
        entry_url = gtk_entry_new();
360
337
        gtk_entry_set_max_length(GTK_ENTRY(entry_url), FILE_NAME_MAXLEN);
361
338
        gtk_entry_set_width_chars(GTK_ENTRY(entry_url), URL_ENTRY_LENGTH);
362
339
        gtk_box_pack_start(GTK_BOX(hbox), entry_url, FALSE, FALSE, 0);
363
340
        gtk_box_pack_start(GTK_BOX(hbox), clear_but, FALSE, FALSE, 0);
364
 
        gtk_container_add(GTK_CONTAINER(vbox), hbox);
 
341
        gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
 
342
        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0);
365
343
 
366
344
        g_signal_connect(G_OBJECT(entry_url), "activate", G_CALLBACK(enter_key_pressed_in_entry), NULL);
367
345
        g_signal_connect(G_OBJECT(clear_but), "clicked", G_CALLBACK(clear_entry), NULL);
369
347
        g_signal_connect(G_OBJECT(dialog), "delete_event", G_CALLBACK(force_quit_dialog), NULL);
370
348
 
371
349
        gtk_widget_show_all(dialog);
372
 
        gtk_widget_set_size_request(sc_win, -1, SC_WIN_HEIGHT);
373
350
 
374
 
        /* backup last valid opened resource (if any) */
 
351
        /* Backup last valid opened resource (if any) */
375
352
        str_n_cpy(resrc_bak.id, resrc->id, FILE_NAME_MAXLEN);
376
 
        /* is it better like that ? */
 
353
        /* Is it better like that ? */
377
354
        if (IS_FLIST(flist) && resrc->id[0] != '\0')
378
355
                if ((f_index = f_list_search(flist, resrc->id)) > -1)
379
356
                        highlight_and_go_to_row(tree_view, selection, f_index + 1);
418
395
                                        if ((f_index = f_list_search(flist,
419
396
                                                        gtk_entry_get_text(GTK_ENTRY(entry_url)))) > -1)
420
397
                                                highlight_and_go_to_row(tree_view, selection, f_index + 1);
421
 
                                        /* backup last valid opened resource (if any) */
 
398
                                        /* Backup last valid opened resource (if any) */
422
399
                                        str_n_cpy(resrc_bak.id, resrc->id, FILE_NAME_MAXLEN);
423
400
                                } else {
424
 
                                        /* restore last valid opened resource (if any) */
 
401
                                        /* Restore last valid opened resource (if any) */
425
402
                                        str_n_cpy(resrc->id, resrc_bak.id, FILE_NAME_MAXLEN);
426
403
                                        gtk_widget_grab_focus(GTK_WIDGET(entry_url));
427
404
                                        gtk_editable_set_position(GTK_EDITABLE(entry_url), cursor_position);
441
418
                                        env->reload_rq = TRUE;
442
419
                                        break;
443
420
                                } else
444
 
                                        /* restore last valid opened resource (if any) */
 
421
                                        /* Restore last valid opened resource (if any) */
445
422
                                        str_n_cpy(resrc->id, resrc_bak.id, FILE_NAME_MAXLEN);
446
423
                        } else
447
424
                                warning(FALSE, 1, "You must enter or select an URL first");
477
454
        check_main_win_always_on_top();
478
455
        env->suspend_rq = FALSE;
479
456
}
480
 
#endif