static void
status_icon_create_menu (EmpathyStatusIcon *icon)
{
    EmpathyStatusIconPriv *priv = GET_PRIV (icon);
    GladeXML              *glade;
    gchar                 *filename;

    filename = empathy_file_lookup ("empathy-status-icon.glade", "src");
    glade = empathy_glade_get_file (filename,
                                    "tray_menu",
                                    NULL,
                                    "tray_menu", &priv->popup_menu,
                                    "tray_show_list", &priv->show_window_item,
                                    "tray_new_message", &priv->message_item,
                                    "tray_status", &priv->status_item,
                                    NULL);
    g_free (filename);

    empathy_glade_connect (glade,
                           icon,
                           "tray_show_list", "toggled", status_icon_show_hide_window_cb,
                           "tray_new_message", "activate", status_icon_new_message_cb,
                           "tray_quit", "activate", status_icon_quit_cb,
                           NULL);

    g_object_unref (glade);
}
GtkWidget *
empathy_account_widget_salut_new (McAccount *account)
{
	GladeXML  *glade;
	GtkWidget *widget;
	gchar     *filename;

	filename = empathy_file_lookup ("empathy-account-widget-salut.glade",
					"libempathy-gtk");
	glade = empathy_glade_get_file (filename,
					"vbox_salut_settings",
					NULL,
					"vbox_salut_settings", &widget,
					NULL);
	g_free (filename);

	empathy_account_widget_handle_params (account, glade,
			"entry_published", "published-name",
			"entry_nickname", "nickname",
			"entry_first_name", "first-name",
			"entry_last_name", "last-name",
			"entry_email", "email",
			"entry_jid", "jid",
			NULL);

	g_object_unref (glade);

	gtk_widget_show (widget);

	return widget;
}
GtkWidget *
empathy_account_widget_groupwise_new (McAccount *account)
{
	GladeXML  *glade;
	GtkWidget *widget;
	gchar     *filename;

	filename = empathy_file_lookup ("empathy-account-widget-groupwise.glade",
					"libempathy-gtk");
	glade = empathy_glade_get_file (filename,
					"vbox_groupwise_settings",
					NULL,
					"vbox_groupwise_settings", &widget,
					NULL);
	g_free (filename);

	empathy_account_widget_handle_params (account, glade,
			"entry_id", "account",
			"entry_password", "password",
			"entry_server", "server",
			"spinbutton_port", "port",
			NULL);

	empathy_account_widget_add_forget_button (account, glade,
						  "button_forget",
						  "entry_password");

	g_object_unref (glade);

	gtk_widget_show (widget);

	return widget;
}
GtkWidget *
empathy_account_widget_generic_new (McAccount *account)
{
	GladeXML  *glade;
	GtkWidget *widget;
	GtkWidget *table_common_settings;
	GtkWidget *table_advanced_settings;
	gchar     *filename;

	g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);

	filename = empathy_file_lookup ("empathy-account-widget-generic.glade",
					"libempathy-gtk");
	glade = empathy_glade_get_file (filename,
					"vbox_generic_settings",
					NULL,
					"vbox_generic_settings", &widget,
					"table_common_settings", &table_common_settings,
					"table_advanced_settings", &table_advanced_settings,
					NULL);
	g_free (filename);

	accounts_widget_generic_setup (account, table_common_settings, table_advanced_settings);

	g_object_unref (glade);

	gtk_widget_show_all (widget);

	return widget;
}
Exemplo n.º 5
0
static void
presence_chooser_dialog_show (void)
{
	GladeXML *glade;
	gchar    *filename;

	if (message_dialog) {
		gtk_window_present (GTK_WINDOW (message_dialog->dialog));
		return;
	}

	message_dialog = g_new0 (CustomMessageDialog, 1);

	filename = empathy_file_lookup ("empathy-presence-chooser.glade",
					"libempathy-gtk");
	glade = empathy_glade_get_file (filename,
				       "custom_message_dialog",
				       NULL,
				       "custom_message_dialog", &message_dialog->dialog,
				       "checkbutton_save", &message_dialog->checkbutton_save,
				       "comboboxentry_message", &message_dialog->comboboxentry_message,
				       "combobox_status", &message_dialog->combobox_status,
				       NULL);
	g_free (filename);

	empathy_glade_connect (glade,
			       message_dialog,
			       "custom_message_dialog", "destroy", presence_chooser_dialog_destroy_cb,
			       "custom_message_dialog", "response", presence_chooser_dialog_response_cb,
			       "combobox_status", "changed", presence_chooser_dialog_status_changed_cb,
			       "checkbutton_save", "toggled", presence_chooser_dialog_save_toggled_cb,
			       NULL);

	g_object_unref (glade);

	/* Setup the message combobox */
	message_dialog->entry_message = GTK_BIN (message_dialog->comboboxentry_message)->child;
	gtk_entry_set_activates_default (GTK_ENTRY (message_dialog->entry_message), TRUE);
	gtk_entry_set_width_chars (GTK_ENTRY (message_dialog->entry_message), 25);
	g_signal_connect (message_dialog->entry_message, "changed",
			  G_CALLBACK (presence_chooser_dialog_message_changed_cb),
			  message_dialog);

	presence_chooser_dialog_setup (message_dialog);

	gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (message_dialog->comboboxentry_message), 0);

	/* FIXME: Set transian for a window ? */

	gtk_widget_show_all (message_dialog->dialog);
}
GtkWidget *
empathy_account_widget_jabber_new (McAccount *account)
{
	GladeXML  *glade;
	GtkWidget *widget;
	GtkWidget *spinbutton_port;
	GtkWidget *checkbutton_ssl;
	gchar     *filename;

	filename = empathy_file_lookup ("empathy-account-widget-jabber.glade",
					"libempathy-gtk");
	glade = empathy_glade_get_file (filename,
				        "vbox_jabber_settings",
				        NULL,
				        "vbox_jabber_settings", &widget,
				        "spinbutton_port", &spinbutton_port,
				        "checkbutton_ssl", &checkbutton_ssl,
				        NULL);
	g_free (filename);

	empathy_account_widget_handle_params (account, glade,
			"entry_id", "account",
			"entry_password", "password",
			"entry_resource", "resource",
			"entry_server", "server",
			"spinbutton_port", "port",
			"spinbutton_priority", "priority",
			"checkbutton_ssl", "old-ssl",
			"checkbutton_ignore_ssl_errors", "ignore-ssl-errors",
			"checkbutton_encryption", "require-encryption",
			NULL);

	empathy_account_widget_add_forget_button (account, glade,
						  "button_forget",
						  "entry_password");

	g_signal_connect (checkbutton_ssl, "toggled",
			  G_CALLBACK (account_widget_jabber_ssl_toggled_cb),
			  spinbutton_port);

	g_object_unref (glade);

	gtk_widget_show (widget);

	return widget;
}
/**
 * empathy_account_widget_sip_new:
 * @account: the #McAccount to configure
 *
 * Creates a new SIP account widget to configure a given #McAccount
 *
 * Returns: The toplevel container of the configuration widget
 */
GtkWidget *
empathy_account_widget_sip_new (McAccount *account)
{
  EmpathyAccountWidgetSip *settings;
  GladeXML *glade;
  gchar *filename;

  settings = g_slice_new0 (EmpathyAccountWidgetSip);
  settings->account = g_object_ref (account);

  filename = empathy_file_lookup ("empathy-account-widget-sip.glade",
      "libempathy-gtk");
  glade = empathy_glade_get_file (filename,
      "vbox_sip_settings",
      NULL,
      "vbox_sip_settings", &settings->vbox_settings,
      "entry_stun-server", &settings->entry_stun_server,
      "spinbutton_stun-port", &settings->spinbutton_stun_part,
      "checkbutton_discover-stun", &settings->checkbutton_discover_stun,
      NULL);
  g_free (filename);

  empathy_account_widget_handle_params (account, glade,
      "entry_userid", "account",
      "entry_password", "password",
      "checkbutton_discover-stun", "discover-stun",
      "entry_stun-server", "stun-server",
      "spinbutton_stun-port", "stun-port",
      NULL);

  empathy_account_widget_add_forget_button (account, glade,
                                            "button_forget",
                                            "entry_password");

  account_widget_sip_discover_stun_toggled_cb (settings->checkbutton_discover_stun,
                                               settings);

  empathy_glade_connect (glade, settings,
      "vbox_sip_settings", "destroy", account_widget_sip_destroy_cb,
      "checkbutton_discover-stun", "toggled", account_widget_sip_discover_stun_toggled_cb,
      NULL);

  g_object_unref (glade);

  return settings->vbox_settings;
}
GtkWidget *
empathy_account_widget_yahoo_new (McAccount *account)
{
	GladeXML  *glade;
	GtkWidget *widget;
	gchar     *filename;

	filename = empathy_file_lookup ("empathy-account-widget-yahoo.glade",
					"libempathy-gtk");
	glade = empathy_glade_get_file (filename,
					"vbox_yahoo_settings",
					NULL,
					"vbox_yahoo_settings", &widget,
					NULL);
	g_free (filename);

	empathy_account_widget_handle_params (account, glade,
			"entry_id", "account",
			"entry_password", "password",
			"entry_server", "server",
			"entry_locale", "room-list-locale",
			"entry_charset", "charset",
			"spinbutton_port", "port",
			"checkbutton_yahoojp", "yahoojp",
			"checkbutton_ignore_invites", "ignore-invites",
			NULL);

	empathy_account_widget_add_forget_button (account, glade,
						  "button_forget",
						  "entry_password");

	g_object_unref (glade);

	gtk_widget_show (widget);

	return widget;
}
Exemplo n.º 9
0
static void
empathy_chat_window_init (EmpathyChatWindow *window)
{
	GladeXML              *glade;
	GtkAccelGroup         *accel_group;
	GClosure              *closure;
	GtkWidget             *menu_conv;
	GtkWidget             *menu;
	gint                   i;
	GtkWidget             *chat_vbox;
	gchar                 *filename;
	EmpathyChatWindowPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (window,
		EMPATHY_TYPE_CHAT_WINDOW, EmpathyChatWindowPriv);

	window->priv = priv;
	filename = empathy_file_lookup ("empathy-chat-window.glade", "src");
	glade = empathy_glade_get_file (filename,
				       "chat_window",
				       NULL,
				       "chat_window", &priv->dialog,
				       "chat_vbox", &chat_vbox,
				       "menu_conv", &menu_conv,
				       "menu_conv_clear", &priv->menu_conv_clear,
				       "menu_conv_insert_smiley", &priv->menu_conv_insert_smiley,
				       "menu_conv_contact", &priv->menu_conv_contact,
				       "menu_conv_close", &priv->menu_conv_close,
				       "menu_edit_cut", &priv->menu_edit_cut,
				       "menu_edit_copy", &priv->menu_edit_copy,
				       "menu_edit_paste", &priv->menu_edit_paste,
				       "menu_tabs_next", &priv->menu_tabs_next,
				       "menu_tabs_prev", &priv->menu_tabs_prev,
				       "menu_tabs_left", &priv->menu_tabs_left,
				       "menu_tabs_right", &priv->menu_tabs_right,
				       "menu_tabs_detach", &priv->menu_tabs_detach,
				       "menu_help_contents", &priv->menu_help_contents,
				       "menu_help_about", &priv->menu_help_about,
				       NULL);
	g_free (filename);

	empathy_glade_connect (glade,
			      window,
			      "chat_window", "configure-event", chat_window_configure_event_cb,
			      "menu_conv", "activate", chat_window_conv_activate_cb,
			      "menu_conv_clear", "activate", chat_window_clear_activate_cb,
			      "menu_conv_close", "activate", chat_window_close_activate_cb,
			      "menu_edit", "activate", chat_window_edit_activate_cb,
			      "menu_edit_cut", "activate", chat_window_cut_activate_cb,
			      "menu_edit_copy", "activate", chat_window_copy_activate_cb,
			      "menu_edit_paste", "activate", chat_window_paste_activate_cb,
			      "menu_tabs_left", "activate", chat_window_tabs_left_activate_cb,
			      "menu_tabs_right", "activate", chat_window_tabs_right_activate_cb,
			      "menu_tabs_detach", "activate", chat_window_detach_activate_cb,
			      "menu_help_contents", "activate", chat_window_help_contents_cb,
			      "menu_help_about", "activate", chat_window_help_about_cb,
			      NULL);

	g_object_unref (glade);

	priv->notebook = gtk_notebook_new ();
 	gtk_notebook_set_group (GTK_NOTEBOOK (priv->notebook), "EmpathyChatWindow"); 
	gtk_box_pack_start (GTK_BOX (chat_vbox), priv->notebook, TRUE, TRUE, 0);
	gtk_widget_show (priv->notebook);

	/* Set up accels */
	accel_group = gtk_accel_group_new ();
	gtk_window_add_accel_group (GTK_WINDOW (priv->dialog), accel_group);

	for (i = 0; i < G_N_ELEMENTS (tab_accel_keys); i++) {
		closure =  g_cclosure_new (G_CALLBACK (chat_window_accel_cb),
					   window,
					   NULL);
		gtk_accel_group_connect (accel_group,
					 tab_accel_keys[i],
					 GDK_MOD1_MASK,
					 0,
					 closure);
	}

	g_object_unref (accel_group);

	/* Set up smiley menu */
	menu = empathy_chat_view_get_smiley_menu (
		G_CALLBACK (chat_window_insert_smiley_activate_cb),
		window);
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (priv->menu_conv_insert_smiley), menu);

	/* Set up signals we can't do with glade since we may need to
	 * block/unblock them at some later stage.
	 */

	g_signal_connect (priv->dialog,
			  "delete_event",
			  G_CALLBACK (chat_window_delete_event_cb),
			  window);

	g_signal_connect_swapped (priv->menu_tabs_prev,
				  "activate",
				  G_CALLBACK (gtk_notebook_prev_page),
				  priv->notebook);
	g_signal_connect_swapped (priv->menu_tabs_next,
				  "activate",
				  G_CALLBACK (gtk_notebook_next_page),
				  priv->notebook);

	g_signal_connect (priv->dialog,
			  "focus_in_event",
			  G_CALLBACK (chat_window_focus_in_event_cb),
			  window);
	g_signal_connect_after (priv->notebook,
				"switch_page",
				G_CALLBACK (chat_window_page_switched_cb),
				window);
	g_signal_connect (priv->notebook,
			  "page_added",
			  G_CALLBACK (chat_window_page_added_cb),
			  window);
	g_signal_connect (priv->notebook,
			  "page_removed",
			  G_CALLBACK (chat_window_page_removed_cb),
			  window);

	/* Set up drag and drop */
	gtk_drag_dest_set (GTK_WIDGET (priv->notebook),
			   GTK_DEST_DEFAULT_ALL,
			   drag_types_dest,
			   G_N_ELEMENTS (drag_types_dest),
			   GDK_ACTION_MOVE);

	g_signal_connect (priv->notebook,
			  "drag-data-received",
			  G_CALLBACK (chat_window_drag_data_received),
			  window);

	chat_windows = g_list_prepend (chat_windows, window);

	/* Set up private details */
	priv->chats = NULL;
	priv->chats_new_msg = NULL;
	priv->chats_composing = NULL;
	priv->current_chat = NULL;
}
Exemplo n.º 10
0
void
empathy_new_chatroom_dialog_show (GtkWindow *parent)
{
	EmpathyNewChatroomDialog *dialog;
	GladeXML                 *glade;
	GtkSizeGroup             *size_group;
	gchar                    *filename;

	if (dialog_p) {
		gtk_window_present (GTK_WINDOW (dialog_p->window));
		return;
	}

	dialog_p = dialog = g_new0 (EmpathyNewChatroomDialog, 1);

	filename = empathy_file_lookup ("empathy-new-chatroom-dialog.glade", "src");
	glade = empathy_glade_get_file (filename,
				       "new_chatroom_dialog",
				       NULL,
				       "new_chatroom_dialog", &dialog->window,
				       "table_info", &dialog->table_info,
				       "label_account", &dialog->label_account,
				       "label_server", &dialog->label_server,
				       "label_room", &dialog->label_room,
				       "entry_server", &dialog->entry_server,
				       "entry_room", &dialog->entry_room,
				       "togglebutton_refresh", &dialog->togglebutton_refresh,
				       "vbox_browse", &dialog->vbox_browse,
				       "image_status", &dialog->image_status,
				       "label_status", &dialog->label_status,
				       "hbox_status", &dialog->hbox_status,
				       "treeview", &dialog->treeview,
				       "button_join", &dialog->button_join,
				       NULL);
	g_free (filename);

	empathy_glade_connect (glade,
			      dialog,
			      "new_chatroom_dialog", "response", new_chatroom_dialog_response_cb,
			      "new_chatroom_dialog", "destroy", new_chatroom_dialog_destroy_cb,
			      "entry_server", "changed", new_chatroom_dialog_entry_changed_cb,
			      "entry_server", "activate", new_chatroom_dialog_entry_server_activate_cb,
			      "entry_room", "changed", new_chatroom_dialog_entry_changed_cb,
			      "togglebutton_refresh", "toggled", new_chatroom_dialog_togglebutton_refresh_toggled_cb,
			      NULL);

	g_object_unref (glade);

	g_object_add_weak_pointer (G_OBJECT (dialog->window), (gpointer) &dialog_p);

	/* Label alignment */
	size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

	gtk_size_group_add_widget (size_group, dialog->label_account);
	gtk_size_group_add_widget (size_group, dialog->label_server);
	gtk_size_group_add_widget (size_group, dialog->label_room);

	g_object_unref (size_group);

	/* Set up chatrooms treeview */
	new_chatroom_dialog_model_setup (dialog);

	/* Add throbber */
	dialog->throbber = ephy_spinner_new ();
	ephy_spinner_set_size (EPHY_SPINNER (dialog->throbber), GTK_ICON_SIZE_LARGE_TOOLBAR);
	gtk_widget_show (dialog->throbber);

	gtk_box_pack_start (GTK_BOX (dialog->hbox_status), dialog->throbber, 
			    FALSE, FALSE, 0);

	/* Account chooser for custom */
	dialog->account_chooser = empathy_account_chooser_new ();
	empathy_account_chooser_set_filter (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser),
					    empathy_account_chooser_filter_is_connected,
					    NULL);
	gtk_table_attach_defaults (GTK_TABLE (dialog->table_info),
				   dialog->account_chooser,
				   1, 3, 0, 1);
	gtk_widget_show (dialog->account_chooser);

	g_signal_connect (GTK_COMBO_BOX (dialog->account_chooser), "changed",
			  G_CALLBACK (new_chatroom_dialog_account_changed_cb),
			  dialog);
	new_chatroom_dialog_account_changed_cb (GTK_COMBO_BOX (dialog->account_chooser),
						dialog);

	if (parent) {
		gtk_window_set_transient_for (GTK_WINDOW (dialog->window),
					      GTK_WINDOW (parent));
	}

	gtk_widget_show (dialog->window);
}
void
empathy_import_dialog_show (GtkWindow *parent,
                            gboolean warning)
{
  static EmpathyImportDialog *dialog = NULL;
  GladeXML *glade;
  gchar *filename;
  GList *accounts = NULL;

  /* This window is a singleton. If it already exist, present it */
  if (dialog)
    {
      gtk_window_present (GTK_WINDOW (dialog->window));
      return;
    }

  /* Load all accounts from all supported applications */
  accounts = g_list_concat (accounts, empathy_import_pidgin_load ());
  accounts = g_list_concat (accounts, empathy_import_gajim_load ());

  /* Check if we have accounts to import before creating the window */
  if (!accounts)
    {
      GtkWidget *message;

      if (warning)
        {
          message = gtk_message_dialog_new (parent,
              GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE,
              _("There are no accounts to import."));

          gtk_dialog_run (GTK_DIALOG (message));
          gtk_widget_destroy (message);
        }
      else
        DEBUG ("No accounts to import; closing dialog silently.");
      return;
    }
  
  /* We have accounts, let's display the window with them */
  dialog = g_slice_new0 (EmpathyImportDialog);
  dialog->accounts = accounts;  

  filename = empathy_file_lookup ("empathy-import-dialog.glade", "src");
  glade = empathy_glade_get_file (filename,
      "import_dialog",
      NULL,
      "import_dialog", &dialog->window,
      "treeview", &dialog->treeview,
      NULL);

  empathy_glade_connect (glade,
      dialog,
      "import_dialog", "destroy", import_dialog_destroy_cb,
      "import_dialog", "response", import_dialog_response_cb,
      NULL);

  g_object_add_weak_pointer (G_OBJECT (dialog->window), (gpointer) &dialog);

  g_free (filename);
  g_object_unref (glade);

  if (parent)
    gtk_window_set_transient_for (GTK_WINDOW (dialog->window), parent);

  import_dialog_set_up_account_list (dialog);

  gtk_widget_show (dialog->window);
}
Exemplo n.º 12
0
GtkWidget *
empathy_preferences_show (GtkWindow *parent)
{
	static EmpathyPreferences *preferences;
	GladeXML                 *glade;
	gchar                    *filename;

	if (preferences) {
		gtk_window_present (GTK_WINDOW (preferences->dialog));
		return preferences->dialog;
	}

	preferences = g_new0 (EmpathyPreferences, 1);

	filename = empathy_file_lookup ("empathy-preferences.glade", "src");
	glade = empathy_glade_get_file (filename,
		"preferences_dialog",
		NULL,
		"preferences_dialog", &preferences->dialog,
		"notebook", &preferences->notebook,
		"checkbutton_show_avatars", &preferences->checkbutton_show_avatars,
		"checkbutton_compact_contact_list", &preferences->checkbutton_compact_contact_list,
		"checkbutton_show_smileys", &preferences->checkbutton_show_smileys,
		"combobox_chat_theme", &preferences->combobox_chat_theme,
		"checkbutton_separate_chat_windows", &preferences->checkbutton_separate_chat_windows,
		"checkbutton_autoconnect", &preferences->checkbutton_autoconnect,
		"radiobutton_contact_list_sort_by_name", &preferences->radiobutton_contact_list_sort_by_name,
		"radiobutton_contact_list_sort_by_state", &preferences->radiobutton_contact_list_sort_by_state,
		"checkbutton_sounds_for_messages", &preferences->checkbutton_sounds_for_messages,
		"checkbutton_sounds_when_busy", &preferences->checkbutton_sounds_when_busy,
		"checkbutton_sounds_when_away", &preferences->checkbutton_sounds_when_away,
		"checkbutton_popups_when_available", &preferences->checkbutton_popups_when_available,
		"treeview_spell_checker", &preferences->treeview_spell_checker,
		NULL);
	g_free (filename);

	empathy_glade_connect (glade,
			      preferences,
			      "preferences_dialog", "destroy", preferences_destroy_cb,
			      "preferences_dialog", "response", preferences_response_cb,
			      NULL);

	g_object_unref (glade);

	g_object_add_weak_pointer (G_OBJECT (preferences->dialog), (gpointer) &preferences);

	preferences_themes_setup (preferences);

	preferences_setup_widgets (preferences);

	preferences_languages_setup (preferences);
	preferences_languages_add (preferences);
	preferences_languages_load (preferences);

	if (empathy_spell_supported ()) {
		GtkWidget *page;

		page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (preferences->notebook), 2);
		gtk_widget_show (page);
	}

	if (parent) {
		gtk_window_set_transient_for (GTK_WINDOW (preferences->dialog),
					      GTK_WINDOW (parent));
	}

	gtk_widget_show (preferences->dialog);

	return preferences->dialog;
}
Exemplo n.º 13
0
/**
 * empathy_irc_network_dialog_show:
 * @network: the #EmpathyIrcNetwork to configure
 * @parent: the parent of this dialog
 *
 * Display a dialog to configure a given #EmpathyIrcNetwork.
 * This function is a singleton so if a configuration dialog already
 * exists we use this one to edit the network.
 *
 * Returns: The displayed #GtkDialog
 */
GtkWidget *
empathy_irc_network_dialog_show (EmpathyIrcNetwork *network,
                                 GtkWidget *parent)
{
  static EmpathyIrcNetworkDialog *dialog = NULL;
  GladeXML *glade;
  GtkListStore *store;
  GtkCellRenderer *renderer;
  GtkAdjustment *adjustment;
  GtkTreeSelection *selection;
  GtkTreeViewColumn *column;
  gchar *filename;

  g_return_val_if_fail (network != NULL, NULL);

  if (dialog != NULL)
    {
      change_network (dialog, network);
      gtk_window_present (GTK_WINDOW (dialog->dialog));

      return dialog->dialog;
    }

  dialog = g_slice_new0 (EmpathyIrcNetworkDialog);

  dialog->network = network;
  g_object_ref (dialog->network);

  filename = empathy_file_lookup ("empathy-account-widget-irc.glade",
      "libempathy-gtk");
  glade = empathy_glade_get_file (filename,
      "irc_network_dialog",
      NULL,
      "irc_network_dialog", &dialog->dialog,
      "button_close", &dialog->button_close,
      "entry_network", &dialog->entry_network,
      "combobox_charset", &dialog->combobox_charset,
      "treeview_servers", &dialog->treeview_servers,
      "button_add", &dialog->button_add,
      "button_remove", &dialog->button_remove,
      "button_up", &dialog->button_up,
      "button_down", &dialog->button_down,
      NULL);
  g_free (filename);

  store = gtk_list_store_new (4, G_TYPE_OBJECT, G_TYPE_STRING,
      G_TYPE_UINT, G_TYPE_BOOLEAN);
  gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->treeview_servers),
      GTK_TREE_MODEL (store));
  g_object_unref (store);

  /* address */
  renderer = gtk_cell_renderer_text_new ();
  g_object_set (renderer, "editable", TRUE, NULL);
  g_signal_connect (renderer, "edited",
      G_CALLBACK (irc_network_dialog_address_edited_cb), dialog);
  gtk_tree_view_insert_column_with_attributes (
      GTK_TREE_VIEW (dialog->treeview_servers),
      -1, _("Server"), renderer, "text", COL_ADR,
      NULL);

  /* port */
  adjustment = (GtkAdjustment *) gtk_adjustment_new (6667, 1, G_MAXUINT16,
      1, 10, 0);
  renderer = gtk_cell_renderer_spin_new ();
  g_object_set (renderer,
      "editable", TRUE, 
      "adjustment", adjustment,
      NULL);
  g_signal_connect (renderer, "edited",
      G_CALLBACK (irc_network_dialog_port_edited_cb), dialog);
  gtk_tree_view_insert_column_with_attributes (
      GTK_TREE_VIEW (dialog->treeview_servers),
      -1, _("Port"), renderer, "text", COL_PORT,
      NULL);
  column = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->treeview_servers),
      1);
  gtk_tree_view_column_set_expand (column, TRUE);

  /* SSL */
  renderer = gtk_cell_renderer_toggle_new ();
  g_object_set (renderer, "activatable", TRUE, NULL);
  g_signal_connect (renderer, "toggled",
      G_CALLBACK (irc_network_dialog_ssl_toggled_cb), dialog);
  gtk_tree_view_insert_column_with_attributes (
      GTK_TREE_VIEW (dialog->treeview_servers),
      -1, _("SSL"), renderer, "active", COL_SSL,
      NULL);

  selection = gtk_tree_view_get_selection (
      GTK_TREE_VIEW (dialog->treeview_servers));
  gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);

  /* charset */
  totem_subtitle_encoding_init (GTK_COMBO_BOX (dialog->combobox_charset));

  irc_network_dialog_setup (dialog);

  empathy_glade_connect (glade, dialog,
      "irc_network_dialog", "destroy", irc_network_dialog_destroy_cb,
      "button_close", "clicked", irc_network_dialog_close_clicked_cb,
      "entry_network", "focus-out-event", irc_network_dialog_network_focus_cb,
      "button_add", "clicked", irc_network_dialog_button_add_clicked_cb,
      "button_remove", "clicked", irc_network_dialog_button_remove_clicked_cb,
      "button_up", "clicked", irc_network_dialog_button_up_clicked_cb,
      "button_down", "clicked", irc_network_dialog_button_down_clicked_cb,
      "combobox_charset", "changed", irc_network_dialog_combobox_charset_changed_cb,
      NULL);

  g_object_unref (glade);

  g_object_add_weak_pointer (G_OBJECT (dialog->dialog),
      (gpointer) &dialog);

  g_signal_connect (selection, "changed",
      G_CALLBACK (irc_network_dialog_selection_changed_cb),
      dialog);

  gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog),
      GTK_WINDOW (parent));
  gtk_window_set_modal (GTK_WINDOW (dialog->dialog), TRUE);

  irc_network_dialog_network_update_buttons (dialog);

  return dialog->dialog;
}
Exemplo n.º 14
0
/**
 * empathy_account_widget_irc_new:
 * @account: the #McAccount to configure
 *
 * Creates a new IRC account widget to configure a given #McAccount
 *
 * Returns: The toplevel container of the configuration widget
 */
GtkWidget *
empathy_account_widget_irc_new (McAccount *account)
{
  EmpathyAccountWidgetIrc *settings;
  gchar *dir, *user_file_with_path, *global_file_with_path;
  GladeXML *glade;
  GtkListStore *store;
  GtkCellRenderer *renderer;
  gchar *filename;

  settings = g_slice_new0 (EmpathyAccountWidgetIrc);
  settings->account = g_object_ref (account);

  dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
  g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
  user_file_with_path = g_build_filename (dir, IRC_NETWORKS_FILENAME, NULL);
  g_free (dir);

  global_file_with_path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"),
      "libempathy-gtk", IRC_NETWORKS_FILENAME, NULL);
  if (!g_file_test (global_file_with_path, G_FILE_TEST_EXISTS))
    {
      g_free (global_file_with_path);
      global_file_with_path = g_build_filename (DATADIR, "empathy",
          IRC_NETWORKS_FILENAME, NULL);
    }

  settings->network_manager = empathy_irc_network_manager_new (
      global_file_with_path,
      user_file_with_path);

  g_free (global_file_with_path);
  g_free (user_file_with_path);

  filename = empathy_file_lookup ("empathy-account-widget-irc.glade",
      "libempathy-gtk");
  glade = empathy_glade_get_file (filename,
      "vbox_irc_settings",
      NULL,
      "vbox_irc_settings", &settings->vbox_settings,
      "combobox_network", &settings->combobox_network,
      "button_network", &settings->button_network,
      "button_add_network", &settings->button_add_network,
      "button_remove", &settings->button_remove,
      NULL);
  g_free (filename);

  /* Fill the networks combobox */
  store = gtk_list_store_new (2, G_TYPE_OBJECT, G_TYPE_STRING);

  gtk_cell_layout_clear (GTK_CELL_LAYOUT (settings->combobox_network)); 
  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (settings->combobox_network),
      renderer, TRUE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (settings->combobox_network),
      renderer,
      "text", COL_NETWORK_NAME,
      NULL);

  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
      COL_NETWORK_NAME,
      GTK_SORT_ASCENDING);

  gtk_combo_box_set_model (GTK_COMBO_BOX (settings->combobox_network),
      GTK_TREE_MODEL (store));
  g_object_unref (store);

  account_widget_irc_setup (settings);

  empathy_account_widget_handle_params (account, glade,
      "entry_nick", "account",
      "entry_fullname", "fullname",
      "entry_password", "password",
      "entry_quit_message", "quit-message",
      NULL);

  empathy_glade_connect (glade, settings,
      "vbox_irc_settings", "destroy", account_widget_irc_destroy_cb,
      "button_network", "clicked", account_widget_irc_button_edit_network_clicked_cb,
      "button_add_network", "clicked", account_widget_irc_button_add_network_clicked_cb,
      "button_remove", "clicked", account_widget_irc_button_remove_clicked_cb,
      "combobox_network", "changed", account_widget_irc_combobox_network_changed_cb,
      NULL);

  g_object_unref (glade);

  return settings->vbox_settings;
}