Ejemplo n.º 1
0
void gui_sidebar_showhide(void)
{
	GtkAllocation allocation;
	if (!settings.docked) {
		gdk_window_raise(gtk_widget_get_window(GTK_WIDGET(widgets.dock_sb)));
		return;
	}

	if (settings.showshortcutbar) {
		xml_set_value("Xiphos", "misc", "show_sidebar", "0");
		settings.showshortcutbar = FALSE;
		gtk_widget_hide(widgets.shortcutbar);
		sync_windows();
		gtk_widget_get_allocation(GTK_WIDGET(widgets.vpaned),
					  &allocation);
		settings.biblepane_width = allocation.width;

	} else {
		xml_set_value("Xiphos", "misc", "show_sidebar", "1");
		settings.showshortcutbar = TRUE;
		gtk_paned_set_position(GTK_PANED(widgets.epaned),
				       settings.sidebar_width);
		gtk_widget_show(widgets.shortcutbar);
		sync_windows();
		gtk_widget_get_allocation(GTK_WIDGET(widgets.vpaned),
					  &allocation);
		settings.biblepane_width = allocation.width;
	}
}
Ejemplo n.º 2
0
static gboolean tree_key_press_cb(GtkWidget *widget,
				  GdkEventKey *event, gpointer user_data)
{
	GtkTreeSelection *selection;
	GtkTreeModel *model;
	GtkTreeIter selected;
	gchar *key = NULL;

	selection = gtk_tree_view_get_selection((GtkTreeView *)
						sidebar.results_list);
	model =
	    gtk_tree_view_get_model(GTK_TREE_VIEW(sidebar.results_list));

	if (!gtk_tree_selection_get_selected(selection, NULL, &selected))
		return FALSE;

	gtk_tree_model_get(GTK_TREE_MODEL(model), &selected, 0, &key, -1);
	if (!key)
		return FALSE;

	if (event) {

		switch (event->keyval) {
		case 0xff0d: /* "65293" */
		case 0xff8d: /* "65421" */
		{
			gchar *url =
			    g_strdup_printf("sword://%s/%s",
					    settings.sb_search_mod,
					    key);
			main_url_handler(url, TRUE);
			g_free(url);
		} break;

		case 0x20: /* "32" */
			gui_open_passage_in_new_tab(key);
			sync_windows();
			break;

		case 0xffe1: /* shift keys */
		case 0xffe2:
			XI_warning(("shift key pressed"));
			shift_key_pressed = TRUE;
			sync_windows();
			break;

		default:
			break;
		}
	}
	g_free(key);

	sync_windows();

	gtk_widget_grab_focus(sidebar.results_list);
	return FALSE;
}
Ejemplo n.º 3
0
/******************************************************************************
 * Name
 *  gui_close_passage_tab
 *
 * Synopsis
 *   #include "tabbed_browser.h"
 *
 *   void gui_close_passage_tab(gint pagenum)
 *
 * Description
 *   closes the given passage tab or the current one if pagenum = -1
 *
 * Return value
 *   void
 */
void gui_close_passage_tab(gint pagenum)
{
	if (stop_refresh)
		return;

	if (-1 == pagenum)
		pagenum =
		    gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets.notebook_main));
	if (1 ==
	    gtk_notebook_get_n_pages(GTK_NOTEBOOK(widgets.notebook_main)))
		return;
	PASSAGE_TAB_INFO *pt =
	    (PASSAGE_TAB_INFO *)g_list_nth_data(passage_list,
						(guint)pagenum);
	if (pt->showparallel || (2 <=
				 gtk_notebook_get_n_pages(GTK_NOTEBOOK(widgets.notebook_main)))) {
		// (surely this is always true!?)

		if (pagenum > 0) {
			gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets.notebook_main), 0);
			cur_passage_tab = (PASSAGE_TAB_INFO *)
			    g_list_nth_data(passage_list, (guint)0);
		}
	}

	stop_refresh = TRUE;
	sync_windows();
	stop_refresh = FALSE;

	passage_list = g_list_remove(passage_list, pt);
	if (pt->text_mod)
		g_free(pt->text_mod);
	if (pt->commentary_mod)
		g_free(pt->commentary_mod);
	if (pt->dictlex_mod)
		g_free(pt->dictlex_mod);
	if (pt->book_mod)
		g_free(pt->book_mod);
	if (pt->text_commentary_key)
		g_free(pt->text_commentary_key);
	if (pt->dictlex_key)
		g_free(pt->dictlex_key);
	if (pt->book_offset)
		g_free(pt->book_offset);
	if (pt->showparallel) {
		gtk_widget_hide(pt->paratab);
		gui_destroy_parallel_tab();
		settings.showparatab = FALSE;
		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widgets.parallel_tab_item),
					       settings.showparatab);
	}
	g_free(pt);
	//cur_passage_tab = NULL;
	removed_page = pagenum;
	gtk_notebook_remove_page(GTK_NOTEBOOK(widgets.notebook_main),
				 pagenum);
}
Ejemplo n.º 4
0
static void on_search_button_clicked(GtkButton *button,
				     gpointer user_data)
{
	if (search_active) {
		terminate_search = TRUE;
#ifdef HAVE_GTK_310
		gtk_button_set_image((GtkButton *)remember_search,
				     gtk_image_new_from_icon_name("edit-find-symbolic", GTK_ICON_SIZE_BUTTON));
#else
		gtk_button_set_label((GtkButton *)remember_search,
				     "gtk-find");
		gtk_button_set_use_stock((GtkButton *)remember_search,
					 TRUE);

#endif
		sync_windows();
	} else {
#ifdef HAVE_GTK_310
		gtk_button_set_image((GtkButton *)remember_search,
				     gtk_image_new_from_icon_name("process-stop-symbolic",
								  GTK_ICON_SIZE_BUTTON));
#else
		gtk_button_set_label((GtkButton *)remember_search,
				     "gtk-stop");
		gtk_button_set_use_stock((GtkButton *)remember_search,
					 TRUE);
#endif

		// do the search
		main_do_sidebar_search(user_data);

#ifdef HAVE_GTK_310
		gtk_button_set_image((GtkButton *)remember_search,
				     gtk_image_new_from_icon_name("edit-find-symbolic", GTK_ICON_SIZE_BUTTON));
#else
		gtk_button_set_label((GtkButton *)remember_search,
				     "gtk-find");
		gtk_button_set_use_stock((GtkButton *)remember_search,
					 TRUE);
#endif
	}
}
Ejemplo n.º 5
0
/******************************************************************************
 * Name
 *  redisplay_to_realign
 *
 * Synopsis
 *   void redisplay_to_realign()
 *
 * Description
 *    when en/disabling panes, we must redisplay in order that text
 *    (especially current verse) not suddenly find itself out of view.
 *
 * Return value
 *   void
 */
void redisplay_to_realign()
{
	static int realign_busy = FALSE;
	int save_comm_show = settings.comm_showing;

	if (realign_busy || change_tabs_no_redisplay)
		return;
	realign_busy = TRUE;

	/* first realize the pane size updates. */
	sync_windows();

	/* then just redisplay everything as-is. */
	gchar *url = g_strdup_printf("sword://%s/%s",
				     settings.MainWindowModule,
				     settings.currentverse);
	main_url_handler(url, TRUE);
	g_free(url);
	if (settings.DictWindowModule && *settings.DictWindowModule /* not empty */
	    && settings.dictkey) {
		url = g_strdup_printf("sword://%s/%s",
				      settings.DictWindowModule,
				      settings.dictkey);
		main_url_handler(url, TRUE);
		g_free(url);
	}
	if (settings.book_mod && *settings.book_mod /* not empty */
	    && settings.book_key) {
		url = g_strdup_printf("sword://%s/%s",
				      settings.book_mod,
				      settings.book_key);
		main_url_handler(url, TRUE);
		g_free(url);
	}

	settings.comm_showing = save_comm_show;
	gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets.notebook_comm_book),
				      (settings.comm_showing ? 0 : 1));

	realign_busy = FALSE;
}
Ejemplo n.º 6
0
/******************************************************************************
 * Name
 *  gui_recompute_shows
 *
 * Synopsis
 *   #include "tabbed_browser.h"
 *
 *   void gui_recompute_shows(void)
 *
 * Description
 *   a new set of text/preview/comm/dict showings has been selected.
 *   re-align the displayed world with that.
 *
 * Return value
 *   void
 */
void gui_recompute_shows(gboolean flush)
{
	if (stop_refresh)
		return;
	stop_refresh = TRUE;

	if (flush)
		main_flush_widgets_content();

	if (cur_passage_tab)
		gui_reassign_strdup(&settings.currentverse,
				    cur_passage_tab->text_commentary_key);

	gui_show_hide_preview(settings.showpreview);
	gui_show_hide_texts(settings.showtexts);
	gui_show_hide_dicts(settings.showdicts);
	gui_show_hide_comms(settings.showcomms);
	gui_set_bible_comm_layout();

	sync_windows();

	stop_refresh = FALSE;
}
Ejemplo n.º 7
0
static gint ask_about_saving(EDITOR *e)
{
	gint test;
	GS_DIALOG *info;
	gchar *buf = NULL;
	gchar *buf1 = NULL;
	gchar *buf2 = NULL;
	gchar *buf3 = NULL;
	gint retval = FALSE;

	switch (e->type) {
	case BOOK_EDITOR:
	case NOTE_EDITOR:
		info = gui_new_dialog();
		info->stock_icon = GTK_STOCK_DIALOG_WARNING;

		buf = g_strdup_printf("%s: %s", e->module, e->key);
		buf1 = _("Save the changes to document");
		buf2 = _("before closing?");
		buf3 =
		    g_strdup_printf("<span weight=\"bold\" size=\"larger\">%s %s %s</span>",
				    buf1, buf, buf2);
		info->label_top = buf3;
		info->label2 = _("If you don't save, changes will be permanently lost.");
		info->save = TRUE;
		info->cancel = TRUE;
		info->no_save = TRUE;

		test = gui_alert_dialog(info);
		retval = test;

		if (test == GS_YES) {
			if (e->type == NOTE_EDITOR) {
				/* save notes and prayer lists */
				_save_note(e);

			} else {
				/* save notes and prayer lists */
				_save_book(e);
			}
		}
		g_free(info);
		g_free(buf);
		g_free(buf3);
		break;

	case STUDYPAD_EDITOR:
		info = gui_new_dialog();
		info->stock_icon =
#ifdef HAVE_GTK_310
		    "dialog-warning";
#else
		    GTK_STOCK_DIALOG_WARNING;
#endif
		if (settings.studypadfilename)
			buf = settings.studypadfilename;
		else
			buf = N_("File");
		buf1 = _("Save the changes to document");
		buf2 = _("before closing?");
		buf3 =
		    g_strdup_printf("<span weight=\"bold\" size=\"larger\">%s %s %s</span>",
				    buf1, buf, buf2);
		info->label_top = buf3;
		info->label2 = _("If you don't save, changes will be permanently lost.");
		info->save = TRUE;
		info->cancel = TRUE;
		info->no_save = TRUE;

		test = gui_alert_dialog(info);
		retval = test;
		if (test == GS_YES) {
			if (e->filename)
				gtkhtml_editor_save(GTKHTML_EDITOR(e->window),
						    e->filename, TRUE,
						    NULL);
			/*else
			   open_or_save_as_dialog(e,
			   OP_SAVE_THROUGH_PERSIST_FILE); */
		}
		g_free(info);
		g_free(buf3);
		break;
	}
	sync_windows();
	return retval;
}
Ejemplo n.º 8
0
Archivo: xiphos.c Proyecto: acli/xiphos
void frontend_display(const char *tabs)
{
	GdkScreen *screen = gdk_screen_get_default();
	gint screen_width = gdk_screen_get_width(screen);
	gint screen_height = gdk_screen_get_height(screen);

	XI_print(("%s\n", "Displaying Xiphos"));
	gui_show_main_window();

	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widgets.viewtexts_item),
				       settings.showtexts);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widgets.viewcomms_item),
				       settings.showcomms);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widgets.viewdicts_item),
				       settings.showdicts);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widgets.viewpreview_item),
				       settings.showpreview);
	gui_show_hide_preview(settings.showpreview);
	gui_show_hide_texts(settings.showtexts);
	gui_show_hide_dicts(settings.showdicts);
	gui_show_hide_comms(settings.showcomms);

	/*
	 * a little paranoia:
	 * clamp geometry values to a reasonable bound.
	 * sometimes xiphos gets insane reconfig events as it dies,
	 * especially if it's due to just shutting linux down.
	 */
	if (settings.app_x < 0)
		settings.app_x = 0;
	if (settings.app_x > (screen_width - 100))
		settings.app_x = screen_width - 100;
	if (settings.app_y < 0)
		settings.app_y = 0;
	if (settings.app_y > (screen_height - 100))
		settings.app_y = screen_height - 100;
	if (settings.maximized)
		gtk_window_maximize(GTK_WINDOW(widgets.app));

	gtk_window_move(GTK_WINDOW(widgets.app), settings.app_x,
			settings.app_y);

	/* gecko  needs the widgets to be visible before writing */
	sync_windows();

	// setup passage notebook
	//      if (settings.browsing) {
	gui_notebook_main_setup(settings.browsing, tabs);
	/*	} else {
		url = g_strdup_printf("sword://%s/%s",settings.DictWindowModule,
						      settings.dictkey);
		main_url_handler(url);
		g_free(url);

		gtk_widget_realize(widgets.html_book);
		url = g_strdup_printf("sword://%s/%d",settings.book_mod,
						      settings.book_offset);
		main_url_handler(url);
		g_free(url);

		settings.addhistoryitem = FALSE;
		url = g_strdup_printf("sword://%s/%s",settings.MainWindowModule,
						      settings.currentverse);
		main_url_handler(url);
		g_free(url);
	} */
	/* must be set after tab stuff is done */

	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widgets.parallel_tab_item),
				       settings.showparatab);
	g_signal_connect(G_OBJECT(widgets.parallel_tab_item),
			 "toggled",
			 G_CALLBACK(gui_parallel_tab_activate), NULL);
	gui_show_previewer_in_sidebar(settings.show_previewer_in_sidebar);

	/* open saved windows as needed */
	if (settings.display_parallel)
		on_undockInt_activate(NULL);
	if (settings.display_modmgr)
		gui_open_mod_mgr();
	if (settings.display_advsearch)
		main_open_search_dialog();
	if (settings.display_prefs)
		gui_setup_preferences_dialog();

	if (settings.showdevotional)
		main_display_devotional();
	else
		main_init_previewer();
	gtk_widget_grab_focus(sidebar.module_list);

	XI_print(("%s\n\n", "done"));
}