~ubuntu-branches/ubuntu/vivid/xiphos/vivid-proposed

« back to all changes in this revision

Viewing changes to src/gnome2/dictlex.c

  • Committer: Package Import Robot
  • Author(s): Dimitri John Ledkov
  • Date: 2014-07-12 17:08:46 UTC
  • mfrom: (17.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140712170846-1lcybpijz5fn72fg
Tags: 3.2.2+dfsg1-1
* New upstream release.
* Bump standards version.
* Switch uscan to sf.net redirector.
* Unpack waf in get-orig-source target.
* Bump to debhelper 9.
* Add uuid-dev build-dep.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Xiphos Bible Study Tool
3
3
 * _dictlex.c - gui for commentary modules
4
4
 *
5
 
 * Copyright (C) 2000-2011 Xiphos Developer Team
 
5
 * Copyright (C) 2000-2014 Xiphos Developer Team
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or modify
8
8
 * it under the terms of the GNU General Public License as published by
24
24
#endif
25
25
 
26
26
#include <gtk/gtk.h>
27
 
#ifdef GTKHTML
28
 
#include <gtkhtml/gtkhtml.h>
29
 
#include "gui/html.h"
30
 
#endif
31
27
 
32
 
#include "../xiphos_html/xiphos_html.h"
 
28
#include "xiphos_html/xiphos_html.h"
33
29
 
34
30
#include "gui/dictlex.h"
35
31
#include "gui/bookmark_dialog.h"
43
39
#include "gui/find_dialog.h"
44
40
#include "gui/font_dialog.h"
45
41
#include "gui/widgets.h"
 
42
#include "gui/utilities.h"
46
43
 
47
44
#include "main/sword.h"
48
45
#include "main/settings.h"
209
206
}
210
207
 
211
208
 
212
 
/******************************************************************************
213
 
 * Name
214
 
 *  html_button_pressed
215
 
 *
216
 
 * Synopsis
217
 
 *   #include "gui/dictlex.h"
218
 
 *
219
 
 *   gint html_button_pressed(GtkWidget * html, GdkEventButton * event,
220
 
 *                                      GSHTMLEditorControlData * d)
221
 
 *
222
 
 * Description
223
 
 *    mouse button pressed in dictionary / lexicon
224
 
 *
225
 
 * Return value
226
 
 *   gint
227
 
 */
228
 
 
229
 
#ifndef USE_XIPHOS_HTML
230
 
static gint html_button_pressed(GtkWidget * html,
231
 
                                GdkEventButton * event, gpointer data)
232
 
{
233
 
        settings.whichwindow = DICTIONARY_WINDOW;
234
 
 
235
 
        //gui_change_window_title(settings.DictWindowModule);
236
 
 
237
 
        switch (event->button) {
238
 
        case 1:
239
 
 
240
 
                break;
241
 
        case 2:
242
 
                /*
243
 
                 * pass this for pasting
244
 
                 */
245
 
                break;
246
 
        case 3:
247
 
                //gui_create_pm_dictionary();
248
 
                gui_menu_popup (NULL, settings.DictWindowModule, NULL);
249
 
                break;
250
 
                /*gtk_signal_emit_stop_by_name(G_OBJECT(html),
251
 
                   "button_press_event"); */
252
 
                break;
253
 
        default:
254
 
                break;
255
 
        }
256
 
 
257
 
        return FALSE;
258
 
}
259
 
 
260
 
 
261
 
 
262
 
/******************************************************************************
263
 
 * Name
264
 
 *  html_button_released
265
 
 *
266
 
 * Synopsis
267
 
 *   #include "gui/dictlex.h"
268
 
 *
269
 
 *   gint html_button_released(GtkWidget * html, GdkEventButton * event,
270
 
 *                                      GSHTMLEditorControlData * d)
271
 
 *
272
 
 * Description
273
 
 *    mouse button released in dictionary / lexicon
274
 
 *
275
 
 * Return value
276
 
 *   gint
277
 
 */
278
 
 
279
 
extern gboolean in_url;
280
 
 
281
 
static gint html_button_released(GtkWidget * html,
282
 
                                GdkEventButton * event, gpointer data)
283
 
{
284
 
#ifdef GTKHTML
285
 
        gchar *key;
286
 
        const gchar *url;
287
 
#endif
288
 
 
289
 
        settings.whichwindow = DICTIONARY_WINDOW;
290
 
 
291
 
        //gui_change_window_title(settings.DictWindowModule);
292
 
 
293
 
#ifdef GTKHTML
294
 
        switch (event->button) {
295
 
        case 1:
296
 
                if (in_url)
297
 
                        break;
298
 
                key = gui_button_press_lookup(widgets.html_dict);
299
 
                if (key) {
300
 
                        if (g_strstr_len(key,strlen(key),"*")) {
301
 
                                key = g_strdelimit(key, "*", ' ');
302
 
                                key = g_strstrip(key);
303
 
                                url = g_strdup_printf(
304
 
                                        "passagestudy.jsp?action=showModInfo&value=1&module=%s",
305
 
                                        key);
306
 
                                main_url_handler(url,TRUE);
307
 
                                g_free((gchar*)url);
308
 
                                g_free(key);
309
 
                                break;
310
 
                        }
311
 
                }
312
 
                break;
313
 
        }
314
 
#endif /* GTKHTML */
315
 
        return FALSE;
316
 
}
317
 
 
318
 
#endif /* !USE_XIPHOS_HTML */
319
 
 
320
 
/******************************************************************************
321
 
 * Name
322
 
 *  list_button_released
323
 
 *
324
 
 * Synopsis
325
 
 *   #include "gui/dictlex.h"
326
 
 *
327
 
 *   gint list_button_released(GtkWidget * html, GdkEventButton * event,
328
 
 *                                      GSHTMLEditorControlData * d)
329
 
 *
330
 
 * Description
331
 
 *    mouse button released in key list
332
 
 *
333
 
 * Return value
334
 
 *   gint
335
 
 */
336
 
#if 0
337
 
static gint list_button_released(GtkWidget * treeview,
338
 
                         GdkEventButton * event, gpointer data)
339
 
{
340
 
        GtkTreeSelection *selection;
341
 
        GtkTreeIter selected;
342
 
        gchar *buf = NULL;
343
 
        GtkTreeModel *model;
344
 
 
345
 
        selection =
346
 
            gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
347
 
 
348
 
        if (!gtk_tree_selection_get_selected
349
 
            (selection, &model, &selected))
350
 
                return 0;
351
 
 
352
 
        switch (event->button) {
353
 
        case 1:
354
 
                gtk_tree_model_get(model, &selected, 0, &buf, -1);
355
 
                if (buf) {
356
 
                        gtk_entry_set_text(GTK_ENTRY
357
 
                                           (widgets.entry_dict), buf);
358
 
                        g_free(buf);
359
 
                }
360
 
                break;
361
 
        case 2:
362
 
        case 3:
363
 
        default:
364
 
                break;
365
 
        }
366
 
 
367
 
        return FALSE;
368
 
}
369
 
 
370
 
 
371
 
 
372
 
static void add_columns(GtkTreeView * treeview)
373
 
{
374
 
        GtkCellRenderer *renderer;
375
 
        GtkTreeViewColumn *column;
376
 
//      GtkTreeModel *model = gtk_tree_view_get_model(treeview);
377
 
 
378
 
        /* column for fixed toggles */
379
 
        renderer = gtk_cell_renderer_text_new();
380
 
 
381
 
        column = gtk_tree_view_column_new_with_attributes("Keys",
382
 
                                                          renderer,
383
 
                                                          "text", 0,
384
 
                                                          NULL);
385
 
        gtk_tree_view_column_set_sort_column_id(column, 0);
386
 
 
387
 
        gtk_tree_view_append_column(treeview, column);
388
 
        /* get cell (row) height */
389
 
        gtk_cell_renderer_get_size(renderer,
390
 
                                   GTK_WIDGET(treeview),
391
 
                                   NULL,
392
 
                                   NULL,
393
 
                                   NULL, NULL, &settings.cell_height);
394
 
}
395
 
#endif /* 0 */
396
 
 
397
 
 
398
209
void dict_key_entry_changed(GtkEntry * entry, gpointer data)
399
210
{
400
211
        gchar *buf = NULL;
533
344
        }
534
345
        return FALSE;
535
346
}
536
 
#ifdef USE_XIPHOS_HTML
 
347
 
537
348
static void
538
349
_popupmenu_requested_cb (XiphosHtml *html,
539
350
                             gchar *uri,
542
353
        gui_menu_popup (html, settings.DictWindowModule, NULL);
543
354
        //gui_create_pm_dictionary();
544
355
}
545
 
#endif
546
356
 
547
357
GtkWidget *gui_create_dictionary_pane(void)
548
358
{
556
366
        GtkWidget *dict_drop_down;
557
367
        GtkWidget *scrolledwindow;
558
368
 
559
 
        box_dict = gtk_vbox_new(FALSE, 0);
 
369
        UI_VBOX(box_dict, FALSE, 0);
560
370
        gtk_widget_show(box_dict);
561
371
 
562
372
        gtk_container_set_border_width (GTK_CONTAINER (box_dict), 1);
563
373
 
564
 
        hbox2 = gtk_hbox_new(FALSE, 0);
 
374
        UI_HBOX(hbox2, FALSE, 0);
565
375
        gtk_widget_show(hbox2);
566
376
        gtk_box_pack_start(GTK_BOX(box_dict), hbox2, FALSE, FALSE, 0);
567
377
 
583
393
        gtk_box_pack_start(GTK_BOX(hbox2), button10, FALSE, FALSE, 0);
584
394
        gtk_button_set_relief(GTK_BUTTON(button10), GTK_RELIEF_NONE);
585
395
 
586
 
        image1 = gtk_image_new_from_stock(GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON);
 
396
        image1 = 
 
397
#ifdef HAVE_GTK_310
 
398
            gtk_image_new_from_icon_name ("go-up",
 
399
                                    GTK_ICON_SIZE_BUTTON);
 
400
#else                        
 
401
                
 
402
            gtk_image_new_from_stock(GTK_STOCK_GO_UP,
 
403
                                     GTK_ICON_SIZE_BUTTON);
 
404
#endif   
587
405
        gtk_widget_show(image1);
588
406
        gtk_container_add(GTK_CONTAINER(button10), image1);
589
407
 
592
410
        gtk_box_pack_start(GTK_BOX(hbox2), button11, FALSE, FALSE, 0);
593
411
        gtk_button_set_relief(GTK_BUTTON(button11), GTK_RELIEF_NONE);
594
412
 
595
 
        image2 = gtk_image_new_from_stock(GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON);
 
413
        image2 = 
 
414
#ifdef HAVE_GTK_310
 
415
            gtk_image_new_from_icon_name ("go-down",
 
416
                                    GTK_ICON_SIZE_BUTTON);
 
417
#else                        
 
418
                
 
419
            gtk_image_new_from_stock(GTK_STOCK_GO_DOWN,
 
420
                                     GTK_ICON_SIZE_BUTTON);
 
421
#endif          
596
422
        gtk_widget_show(image2);
597
423
        gtk_container_add(GTK_CONTAINER(button11), image2);
598
424
 
602
428
        
603
429
        gtk_scrolled_window_set_shadow_type((GtkScrolledWindow *)scrolledwindow,
604
430
                                             settings.shadow_type);
605
 
#ifdef USE_XIPHOS_HTML
 
431
 
606
432
        widgets.html_dict = GTK_WIDGET(XIPHOS_HTML_NEW(NULL, FALSE, DICTIONARY_TYPE));
607
433
        gtk_widget_show(widgets.html_dict);
608
434
        gtk_container_add(GTK_CONTAINER(scrolledwindow),
611
437
                      "popupmenu_requested",
612
438
                      G_CALLBACK (_popupmenu_requested_cb),
613
439
                      NULL);
614
 
#else
615
 
 
616
 
        widgets.html_dict = gtk_html_new();
617
 
        gtk_widget_show(widgets.html_dict);
618
 
        gtk_container_add(GTK_CONTAINER(scrolledwindow),
619
 
                          widgets.html_dict);
620
 
 
621
 
        g_signal_connect(G_OBJECT(widgets.html_dict),
622
 
                         "button_press_event",
623
 
                         G_CALLBACK(html_button_pressed), NULL);
624
 
        g_signal_connect(G_OBJECT(widgets.html_dict),
625
 
                         "button_release_event",
626
 
                         G_CALLBACK(html_button_released), NULL);
627
 
        g_signal_connect(G_OBJECT(widgets.html_dict),
628
 
                         "url_requested",
629
 
                         G_CALLBACK(url_requested), NULL);
630
 
        g_signal_connect(G_OBJECT(widgets.html_dict), "on_url",
631
 
                         G_CALLBACK(gui_url),
632
 
                         GINT_TO_POINTER(DICTIONARY_TYPE));
633
 
        g_signal_connect(G_OBJECT(widgets.html_dict), "link_clicked",
634
 
                         G_CALLBACK(gui_link_clicked), NULL);
635
 
#endif
636
440
 
637
441
        g_signal_connect (dict_drop_down,
638
442
                          "button_press_event",