示例#1
0
G_MODULE_EXPORT void on_verse_per_line_activate(GtkCheckMenuItem *
						    menuitem,
						gpointer user_data)
{
	gchar *file = g_strdup_printf("%s/modops.conf",
				      settings.gSwordDir);

	gchar *url = g_strdup_printf("sword://%s/%s",
				     (is_dialog ? dialog->mod_name : settings.MainWindowModule),
				     (is_dialog ? dialog->key : settings.currentverse));

	save_conf_file_item(file, (is_dialog
				       ? dialog->mod_name
				       : settings.MainWindowModule),
			    "style",
			    (gtk_check_menu_item_get_active(menuitem)
				 ? "verse"
				 : "paragraph"));
	if (settings.havebible) {
		if (is_dialog) {
			/* show the change */
			main_dialogs_url_handler(dialog, url, TRUE);
		} else {
			settings.versestyle =
			    gtk_check_menu_item_get_active(menuitem);
			main_url_handler(url, TRUE);
		}
	}
	g_free(url);
	g_free(file);
}
示例#2
0
G_MODULE_EXPORT void on_popup_font_activate(GtkMenuItem *menuitem,
					    gpointer user_data)
{
	if (is_dialog) {
		gchar *url = g_strdup_printf("sword://%s/%s",
					     dialog->mod_name,
					     dialog->key);
		gui_set_module_font(dialog->mod_name);
		/* show the change */
		main_dialogs_url_handler(dialog, url, TRUE);
		g_free(url);
	} else {
		gchar *key = _get_key(menu_mod_name);
		if (key) {
			gchar *url = g_strdup_printf("sword://%s/%s",
						     menu_mod_name,
						     key);
			gui_set_module_font(menu_mod_name);
			/* show the change */
			main_url_handler(url, TRUE);
			g_free(url);
			g_free(key);
		}
	}
}
示例#3
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;
}
示例#4
0
文件: main_menu.c 项目: acli/xiphos
/******************************************************************************
 * 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;
}
示例#5
0
文件: ipc.c 项目: elijahdorman/Xiphos
/**
 * ipc_object_set_current_reference:
 * @obj: an #IpcObject
 * @reference: the reference to set
 * @error: GError
 *
 * to be called from dbus; sets the current reference in Xiphos;
 * calls main_url_handler to handle the navigation
 *
 * Since: 3.2
 */
gboolean ipc_object_set_current_reference(IpcObject *obj,
					  gchar *reference,
					  GError **error)
{
	//easy route
	main_url_handler((const gchar *)reference, TRUE);
	//it should be done like this, probably
	/* g_signal_emit(obj,
	   "navigate-requested",
	   reference); */

	return TRUE;
}
示例#6
0
static void sync_with_main(void)
{
	gchar *buf = NULL;

	buf = (gchar *)main_url_encode(settings.currentverse);

	if (buf && (strlen(buf) > 3)) {
		gchar *url =
		    g_strdup_printf("passagestudy.jsp?action=showParallel&"
				    "type=verse&value=%s",
				    buf);
		main_url_handler(url, TRUE);
		g_free(url);
	}
}
示例#7
0
static void on_view_mod_activate(GtkMenuItem *menuitem,
				 gpointer user_data)
{
	if (is_dialog)
		return;

	gchar *module_name = main_module_name_from_description((gchar *)user_data);
	gchar *key;

	if (module_name && (key = _get_key(menu_mod_name))) {
		gchar *url = g_strdup_printf("sword://%s/%s", module_name, key);
		main_url_handler(url, TRUE);
		g_free(url);
	}
	g_free(module_name);
	g_free(key);
}
static void on_notebook_comm_book_switch_page(GtkNotebook *notebook,
					      GtkNotebookPage *page,
					      gint page_num, GList **tl)
#endif
{
	gchar *url = NULL;

	if (page_num == 0) {
#if 0
		gtk_drag_dest_unset(GTK_WIDGET(widgets.html_book));
		gui_set_drop_target(widgets.html_comm);
#endif /* 0 */
		settings.comm_showing = TRUE;
		gtk_widget_show(nav_toolbar);
	} else {
#if 0
		gtk_drag_dest_unset(GTK_WIDGET(widgets.html_comm));
		gui_set_drop_target(widgets.html_book);
#endif /* 0 */
		settings.comm_showing = FALSE;
		if (!settings.showtexts)
			gtk_widget_hide(nav_toolbar);
	}

	gui_update_tab_struct(NULL,
			      settings.CommWindowModule,
			      NULL,
			      NULL,
			      NULL,
			      NULL,
			      settings.comm_showing,
			      settings.showtexts,
			      settings.showpreview,
			      settings.showcomms, settings.showdicts);
	if (settings.comm_showing)
		main_display_commentary(settings.CommWindowModule,
					settings.currentverse);
	else if (settings.book_mod && *settings.book_mod) {
		url = g_strdup_printf("sword://%s/%ld", settings.book_mod,
				      settings.book_offset);
		main_url_handler(url, TRUE);
		g_free(url);
	}
	gui_set_tab_label(settings.currentverse, TRUE);
}
示例#9
0
static void sync_with_main(const gchar *key)
{
	gchar *buf = NULL;

	if (key)
		buf = (gchar *)main_url_encode(key);
	else
		buf = (gchar *)
		    main_url_encode(xml_get_value("keys", "verse"));
	XI_message(("%s", buf));
	if (buf && (strlen(buf) > 3)) {
		gchar *url =
		    g_strdup_printf("passagestudy.jsp?action=showParallel&"
				    "type=verse&value=%s", buf);

		main_url_handler(url, TRUE);
		g_free(url);
	}
}
示例#10
0
文件: wk-html.c 项目: acli/xiphos
static gboolean button_press_handler(GtkWidget *widget, GdkEventButton *event)
{
	WkHtmlPriv *priv;
	priv = WK_HTML_GET_PRIVATE(WK_HTML(widget));

	if (event->type == GDK_2BUTTON_PRESS && !x_uri) {
		db_click = TRUE;
		return FALSE;
	}

	db_click = FALSE;

	/* this is a left click */
	if (event->button == 1) {
		/* go to the correct url otherwise webkit will do its own thing */
		if (x_uri) {
			if (priv->is_dialog) {
				main_dialogs_url_handler(priv->dialog, x_uri, TRUE);
			} else {
				main_url_handler(x_uri, TRUE);
			}

			return TRUE;
		}

		return FALSE;
	}

	/* this is a right click */
	if (event->button == 3) {
		/* display our own popup menu instead of webkit's one */
		g_signal_emit(widget, signals[POPUPMENU_REQUESTED], 0, priv->dialog, FALSE);
		return TRUE;
	}

	if (event->button == 2) {
		/* ignore middle button */
		return TRUE;
	}

	return FALSE;
}
示例#11
0
static void kbd_toggle_option(gboolean cond, gchar *option)
{
	gchar *msg;

	if (cond) {
		int opt = !main_get_one_option(sM, option); // negate.
		main_save_module_options(sM, option, opt);
		gchar *url = g_strdup_printf("sword://%s/%s", sM, sV);
		main_url_handler(url, TRUE);
		g_free(url);
		msg =
		    g_strdup_printf("%s %s", option, (opt ? "on" : "off"));
		gui_set_statusbar(msg);
		g_free(msg);
	} else {
		msg = g_strdup_printf(_("Module has no support for %s."),
				      option);
		gui_generic_warning(msg);
		g_free(msg);
	}
}
示例#12
0
文件: wk-html.c 项目: acli/xiphos
/* this is the link handler for when a link is clicked */
static void link_handler(GtkWidget *widget,
#ifdef USE_WEBKIT2
			 WebKitHitTestResult *hit_test_result,
			 guint modifiers,
#else
			 gchar *title,
			 gchar *uri,
#endif
			 gpointer user_data)
{
#ifdef USE_WEBKIT2
	const char *uri;
	uri = webkit_hit_test_result_get_link_uri(hit_test_result);
#endif

	WkHtmlPriv *priv;
	priv = WK_HTML_GET_PRIVATE(WK_HTML(widget));
	XI_message(("html_link_message: uri = %s", (uri ? uri : "-none-")));

	if (x_uri) {
		g_free(x_uri);
		x_uri = NULL;
	}

	if (uri) {
		x_uri = g_strdup(uri);
		in_url = 1;
	} else
		in_url = 0;

	g_signal_emit(widget, signals[URI_SELECTED], 0, uri, FALSE);

	if (uri) {
		if (priv->is_dialog)
			main_dialogs_url_handler(priv->dialog, uri, FALSE);
		else
			main_url_handler(uri, FALSE);
	}
}
示例#13
0
static gboolean on_treeview_button_press_event(GtkWidget *widget,
					       GdkEventButton *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->type == GDK_2BUTTON_PRESS) {
		if (verse_selected)
			g_free(verse_selected);
		verse_selected = g_strdup_printf("sword:///%s", key);
		main_url_handler(verse_selected, TRUE);
	}
	switch (event->button) {
	case 3:
		gtk_menu_popup((GtkMenu *)sidebar.menu_item_save_search,
			       NULL, NULL, NULL, NULL, 2,
			       gtk_get_current_event_time());
		return TRUE;

	default:
		break;
	}
	return FALSE;
}
示例#14
0
static void _global_option_main_pane(GtkMenuItem *menuitem, const gchar *option)
{
	gchar *key = _get_key(menu_mod_name);
	gchar *mod =
	    (gchar *)(is_dialog ? dialog->mod_name : menu_mod_name);
	XI_message(("module option = %s", option));
	if (key) {
		gchar *url = g_strdup_printf("sword://%s/%s",
					     mod,
					     key);
		main_save_module_options(mod, (gchar *)option,
					 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)));
		if (is_dialog) {
			/* show the change */
			main_dialogs_url_handler(dialog, url, TRUE);
		} else {
			/* show the change */
			main_url_handler(url, TRUE);
		}

		g_free(url);
		g_free(key);
	}
}