コード例 #1
0
static void
on_browser_status_changed (InfcBrowser                    *browser,
                           GParamSpec                     *spec,
                           GeditCollaborationWindowHelper *helper)
{
	update_sensitivity (helper);

	if (infc_browser_get_status (browser) == INFC_BROWSER_CONNECTED)
	{
		request_chat (browser, helper);
	}
	else if (infc_browser_get_status (browser) == INFC_BROWSER_DISCONNECTED)
	{
		remove_chat (browser, helper);
	}
}
コード例 #2
0
static void
inf_test_chat_notify_status_cb(GObject* object,
                               GParamSpec* pspec,
                               gpointer user_data)
{
  InfTestChat* test;
  InfcBrowserStatus status;
  InfcNodeRequest* request;

  test = (InfTestChat*)user_data;
  status = infc_browser_get_status(test->browser);

  if(status == INFC_BROWSER_CONNECTED)
  {
    printf("Connection established, subscribing to chat...\n");

    /* Subscribe to chat */
    request = infc_browser_subscribe_chat(test->browser);

    g_signal_connect_after(
      G_OBJECT(request),
      "failed",
      G_CALLBACK(inf_chat_test_subscribe_failed_cb),
      test
    );

    g_signal_connect_after(
      G_OBJECT(request),
      "finished",
      G_CALLBACK(inf_chat_test_subscribe_finished_cb),
      test
    );
  }

  if(status == INFC_BROWSER_DISCONNECTED)
  {
    printf("Connection closed\n");
    if(inf_standalone_io_loop_running(test->io))
      inf_standalone_io_loop_quit(test->io);
  }
}
コード例 #3
0
static void
update_sensitivity (GeditCollaborationWindowHelper *helper)
{
	gboolean has_selection;
	GtkTreeIter selected;
	GtkTreeIter sorted;
	InfcBrowser *browser = NULL;
	InfDiscovery *discovery = NULL;
	GtkTreeModel *model;
	GtkAction *action;
	GtkTreePath *path;
	gboolean toplevel = FALSE;

	model = GTK_TREE_MODEL (helper->priv->browser_store);

	has_selection =
		inf_gtk_browser_view_get_selected (INF_GTK_BROWSER_VIEW (helper->priv->browser_view),
		                                   &sorted);

	if (has_selection)
	{
		gtk_tree_model_sort_convert_iter_to_child_iter (
			GTK_TREE_MODEL_SORT (
				inf_gtk_browser_view_get_model (
					INF_GTK_BROWSER_VIEW (helper->priv->browser_view)
				)
			),
			&selected,
			&sorted
		);
	}

	if (has_selection)
	{
		/* Check if the iter is a top-level (aka. browser node) */
		gtk_tree_model_get (model,
		                    &selected,
		                    INF_GTK_BROWSER_MODEL_COL_BROWSER,
		                    &browser,
		                    INF_GTK_BROWSER_MODEL_COL_DISCOVERY,
		                    &discovery,
		                    -1);

		path = gtk_tree_model_get_path (model, &selected);
		toplevel = gtk_tree_path_get_depth (path) == 1;
		gtk_tree_path_free (path);
	}

	gtk_action_group_set_sensitive (get_action_group (helper, "action_group_connected"),
	                                browser != NULL &&
	                                infc_browser_get_status (browser) == INFC_BROWSER_CONNECTED);

	action = get_action (helper, "SessionDisconnect");
	gtk_action_set_sensitive (action,
	                          toplevel &&
	                          browser != NULL &&
	                          infc_browser_get_status (browser) != INFC_BROWSER_DISCONNECTED);

	/* Handle other actions manually */
	action = get_action (helper, "ItemDelete");
	gtk_action_set_sensitive (action,
	                          has_selection &&
	                          (!toplevel || (
	                          discovery == NULL &&
	                          (browser == NULL ||
	                           infc_browser_get_status (browser) != INFC_BROWSER_CONNECTED))));


	action = get_action (helper, "BookmarkEdit");
	gtk_action_set_sensitive (action,
	                          has_selection &&
	                          discovery == NULL &&
	                          toplevel);

	if (browser)
	{
		g_object_unref (browser);
	}

	if (discovery)
	{
		g_object_unref (discovery);
	}
}
コード例 #4
0
void
on_action_item_delete (GtkAction                      *action,
                       GeditCollaborationWindowHelper *helper)
{
	GtkTreeIter iter;
	GtkTreeIter selected;
	InfcBrowser *browser;
	InfcBrowserIter *browser_iter;
	InfcBrowserIter parent;

	if (!inf_gtk_browser_view_get_selected (INF_GTK_BROWSER_VIEW (helper->priv->browser_view),
	                                        &selected))
	{
		return;
	}

	gtk_tree_model_sort_convert_iter_to_child_iter (
		GTK_TREE_MODEL_SORT (
			gtk_tree_view_get_model (
				GTK_TREE_VIEW (helper->priv->browser_view)
			)
		),
		&iter,
		&selected
	);

	gtk_tree_model_get (GTK_TREE_MODEL (helper->priv->browser_store),
	                    &iter,
	                    INF_GTK_BROWSER_MODEL_COL_BROWSER,
	                    &browser,
	                    INF_GTK_BROWSER_MODEL_COL_NODE,
	                    &browser_iter,
	                    -1);

	parent = *browser_iter;

	if (!infc_browser_iter_get_parent (browser, &parent))
	{
		/* Toplevel bookmark */
		InfXmlConnection *connection = infc_browser_get_connection (browser);
		GeditCollaborationBookmarks *bookmarks;
		GeditCollaborationBookmark *bookmark =
			g_object_get_data (G_OBJECT (connection),
			                   BOOKMARK_DATA_KEY);

		/* Close connection first */
		if (infc_browser_get_status (browser) != INFC_BROWSER_DISCONNECTED)
		{
			inf_xml_connection_close (connection);
		}

		inf_gtk_browser_store_remove_connection (helper->priv->browser_store,
		                                         connection);

		bookmarks = gedit_collaboration_bookmarks_get_default ();
		gedit_collaboration_bookmarks_remove (bookmarks, bookmark);
	}
	else
	{
		/* Remove the iter itself */
		infc_browser_remove_node (browser, browser_iter);
	}

	g_object_unref (browser);

	if (browser_iter)
	{
		infc_browser_iter_free (browser_iter);
	}
}