static void
update_active_tab (GeditCollaborationWindowHelper *helper)
{
	GeditTab *tab;
	GeditCollaborationUserStore *user_store = NULL;

	tab = gedit_window_get_active_tab (helper->priv->window);

	if (tab)
	{
		GeditCollaborationSubscription *subscription;

		subscription = gedit_collaboration_manager_tab_get_subscription (helper->priv->manager,
		                                                                 tab);

		if (subscription != NULL)
		{
			user_store = gedit_collaboration_subscription_get_user_store (subscription);
		}
	}

	if (user_store)
	{
		gtk_tree_view_set_model (GTK_TREE_VIEW (helper->priv->tree_view_user_view),
		                         GTK_TREE_MODEL (user_store));

		gtk_widget_show (helper->priv->scrolled_window_user_view);
	}
	else
	{
		gtk_widget_hide (helper->priv->scrolled_window_user_view);
	}
}
Beispiel #2
0
static void
update_ui (GeditSpellPlugin *plugin)
{
	GeditSpellPluginPrivate *priv;
	GeditView *view;
	GAction *check_spell_action;
	GAction *config_spell_action;
	GAction *auto_spell_action;

	gedit_debug (DEBUG_PLUGINS);

	priv = plugin->priv;

	view = gedit_window_get_active_view (priv->window);

	check_spell_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window),
	                                                 "check-spell");
	g_simple_action_set_enabled (G_SIMPLE_ACTION (check_spell_action),
	                             (view != NULL) &&
	                             gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));

	config_spell_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window),
	                                                  "config-spell");
	g_simple_action_set_enabled (G_SIMPLE_ACTION (config_spell_action),
	                             (view != NULL) &&
	                             gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));

	auto_spell_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window),
	                                                "auto-spell");
	g_simple_action_set_enabled (G_SIMPLE_ACTION (auto_spell_action),
	                             (view != NULL) &&
	                             gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));

	if (view != NULL)
	{
		GeditDocument *doc;
		GeditTab *tab;
		GeditTabState state;
		gboolean autospell;

		doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
		tab = gedit_window_get_active_tab (priv->window);
		state = gedit_tab_get_state (tab);
		autospell = (doc != NULL &&
		             gedit_automatic_spell_checker_get_from_document (doc) != NULL);

		/* If the document is loading we can't get the metadata so we
		   endup with an useless speller */
		if (state == GEDIT_TAB_STATE_NORMAL)
		{
			g_action_change_state (auto_spell_action, g_variant_new_boolean (autospell));
		}

		g_simple_action_set_enabled (G_SIMPLE_ACTION (check_spell_action),
		                             gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (doc)) > 0);
	}
}
static void
on_clear_collaboration_colors_activate (GtkAction                      *action,
                                        GeditCollaborationWindowHelper *helper)
{
	GeditTab *tab;

	tab = gedit_window_get_active_tab (helper->priv->window);

	gedit_collaboration_manager_clear_colors (helper->priv->manager,
	                                          tab);
}
static void
refresh_notebook (GeditDocumentsPanel *panel,
		  GeditNotebook       *notebook,
		  GtkTreeIter         *parent)
{
	GList *tabs;
	GList *l;
	GtkTreeStore *tree_store;
	GeditTab *active_tab;

	gedit_debug (DEBUG_PANEL);

	tree_store = GTK_TREE_STORE (panel->priv->model);

	active_tab = gedit_window_get_active_tab (panel->priv->window);

	tabs = gtk_container_get_children (GTK_CONTAINER (notebook));

	for (l = tabs; l != NULL; l = g_list_next (l))
	{
		GdkPixbuf *pixbuf;
		gchar *name;
		GtkTreeIter iter;

		name = tab_get_name (GEDIT_TAB (l->data));
		pixbuf = _gedit_tab_get_icon (GEDIT_TAB (l->data));

		/* Add a new row to the model */
		gtk_tree_store_append (tree_store, &iter, parent);
		gtk_tree_store_set (tree_store,
				    &iter,
				    PIXBUF_COLUMN, pixbuf,
				    NAME_COLUMN, name,
				    NOTEBOOK_COLUMN, notebook,
				    TAB_COLUMN, l->data,
				    -1);

		g_free (name);
		if (pixbuf != NULL)
		{
			g_object_unref (pixbuf);
		}

		if (l->data == active_tab)
		{
			select_iter (panel, &iter);
		}
	}

	g_list_free (tabs);
}
void
_gedit_cmd_documents_move_to_new_window (GtkAction   *action,
					 GeditWindow *window)
{
	GeditTab *tab;

	gedit_debug (DEBUG_COMMANDS);

	tab = gedit_window_get_active_tab (window);

	if (tab == NULL)
		return;

	_gedit_window_move_tab_to_new_window (window, tab);
}
void
_gedit_cmd_documents_move_to_new_window (GSimpleAction *action,
                                         GVariant      *parameter,
                                         gpointer       user_data)
{
	GeditWindow *window = GEDIT_WINDOW (user_data);
	GeditTab *tab;

	gedit_debug (DEBUG_COMMANDS);

	tab = gedit_window_get_active_tab (window);

	if (tab == NULL)
		return;

	_gedit_window_move_tab_to_new_window (window, tab);
}
Beispiel #7
0
static void
update_ui_real (GeditWindow *window,
		WindowData *data)
{
	GeditDocument *doc;
	GeditView *view;
	gboolean autospell;
	GtkAction *action;

	gedit_debug (DEBUG_PLUGINS);

	doc = gedit_window_get_active_document (window);
	view = gedit_window_get_active_view (window);

	autospell = (doc != NULL &&
	             gedit_automatic_spell_checker_get_from_document (doc) != NULL);

	if (doc != NULL)
	{
		GeditTab *tab;
		GeditTabState state;

		tab = gedit_window_get_active_tab (window);
		state = gedit_tab_get_state (tab);

		/* If the document is loading we can't get the metadata so we
		   endup with an useless speller */
		if (state == GEDIT_TAB_STATE_NORMAL)
		{
			action = gtk_action_group_get_action (data->action_group,
							      "AutoSpell");
	
			g_signal_handlers_block_by_func (action, auto_spell_cb,
							 window);
			set_auto_spell (window, doc, autospell);
			gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
						      autospell);
			g_signal_handlers_unblock_by_func (action, auto_spell_cb,
							   window);
		}
	}

	gtk_action_group_set_sensitive (data->action_group,
					(view != NULL) &&
					gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));
}
void
gedit_collaboration_window_helper_update_state (GeditWindowActivatable *activatable)
{
	GeditTab *tab;
	gboolean sensitive;
	GtkAction *action;
	GeditCollaborationWindowHelper *helper;

	helper = GEDIT_COLLABORATION_WINDOW_HELPER (activatable);

	tab = gedit_window_get_active_tab (helper->priv->window);

	sensitive = tab != NULL &&
	            gedit_collaboration_manager_tab_get_subscription (helper->priv->manager,
	                                                              tab) != NULL;

	action = gtk_action_group_get_action (helper->priv->action_group,
	                                      "CollaborationClearColorsAction");

	gtk_action_set_sensitive (action, sensitive);
}