Ejemplo n.º 1
0
static void
empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
{
	GtkWidget                  *arrow;
	GtkWidget                  *alignment;
	EmpathyPresenceChooserPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (chooser,
		EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooserPriv);

	chooser->priv = priv;
	gtk_button_set_relief (GTK_BUTTON (chooser), GTK_RELIEF_NONE);
	gtk_button_set_focus_on_click (GTK_BUTTON (chooser), FALSE);

	alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
	gtk_widget_show (alignment);
	gtk_container_add (GTK_CONTAINER (chooser), alignment);
	gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 1, 0);

	priv->hbox = gtk_hbox_new (FALSE, 1);
	gtk_widget_show (priv->hbox);
	gtk_container_add (GTK_CONTAINER (alignment), priv->hbox);

	priv->image = gtk_image_new ();
	gtk_widget_show (priv->image);
	gtk_box_pack_start (GTK_BOX (priv->hbox), priv->image, FALSE, TRUE, 0);

	priv->label = gtk_label_new (NULL);
	gtk_widget_show (priv->label);
	gtk_box_pack_start (GTK_BOX (priv->hbox), priv->label, TRUE, TRUE, 0);
	gtk_label_set_ellipsize (GTK_LABEL (priv->label), PANGO_ELLIPSIZE_END);
	gtk_misc_set_alignment (GTK_MISC (priv->label), 0, 0.5);
	gtk_misc_set_padding (GTK_MISC (priv->label), 4, 1);

	alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
	gtk_widget_show (alignment);
	gtk_box_pack_start (GTK_BOX (priv->hbox), alignment, FALSE, FALSE, 0);

	arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
	gtk_widget_show (arrow);
	gtk_container_add (GTK_CONTAINER (alignment), arrow);

	g_signal_connect (chooser, "toggled",
			  G_CALLBACK (presence_chooser_toggled_cb),
			  NULL);
	g_signal_connect (chooser, "button-press-event",
			  G_CALLBACK (presence_chooser_button_press_event_cb),
			  NULL);
	g_signal_connect (chooser, "scroll-event",
			  G_CALLBACK (presence_chooser_scroll_event_cb),
			  NULL);

	priv->idle = empathy_idle_dup_singleton ();
	presence_chooser_presence_changed_cb (chooser);
	g_signal_connect_swapped (priv->idle, "notify",
				  G_CALLBACK (presence_chooser_presence_changed_cb),
				  chooser);
}
Ejemplo n.º 2
0
static void
presence_chooser_set_state (McPresence   state,
			    const gchar *status)
{
	EmpathyIdle *idle;

	idle = empathy_idle_dup_singleton ();
	empathy_idle_set_presence (idle, state, status);
	g_object_unref (idle);
}
Ejemplo n.º 3
0
static void
account_manager_ready_cb (GObject *source_object,
    GAsyncResult *result,
    gpointer user_data)
{
  TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
  GError *error = NULL;
  EmpathyIdle *idle;
  EmpathyConnectivity *connectivity;
  gboolean autoconnect = TRUE;

  if (!tp_account_manager_prepare_finish (manager, result, &error))
    {
      DEBUG ("Failed to prepare account manager: %s", error->message);
      g_error_free (error);
      return;
    }

  /* Autoconnect */
  idle = empathy_idle_dup_singleton ();
  connectivity = empathy_connectivity_dup_singleton ();

  empathy_conf_get_bool (empathy_conf_get (),
      EMPATHY_PREFS_AUTOCONNECT, &autoconnect);
  if (autoconnect && !no_connect &&
      tp_connection_presence_type_cmp_availability
          (empathy_idle_get_state (idle), TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
            <= 0)
      /* if current state is Offline, then put it online */
      empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE);

  if (should_create_salut_account (manager)
      || !empathy_import_mc4_has_imported ())
    {
      EmpathyConnectionManagers *managers;
      managers = empathy_connection_managers_dup_singleton ();

      if (!check_connection_managers_ready (managers))
        {
          g_signal_connect (managers, "notify::ready",
            G_CALLBACK (connection_managers_ready_cb), NULL);
        }
    }
  else if (!start_hidden)
    {
      maybe_show_account_assistant ();
    }

  g_object_unref (idle);
  g_object_unref (connectivity);
}
Ejemplo n.º 4
0
static void
empathy_status_icon_init (EmpathyStatusIcon *icon)
{
	EmpathyStatusIconPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (icon,
		EMPATHY_TYPE_STATUS_ICON, EmpathyStatusIconPriv);

	icon->priv = priv;
	priv->icon = gtk_status_icon_new ();
	priv->account_manager = empathy_account_manager_dup_singleton ();
	priv->idle = empathy_idle_dup_singleton ();
	priv->event_manager = empathy_event_manager_dup_singleton ();

	g_signal_connect (priv->account_manager,
			  "account-connection-changed",
			  G_CALLBACK (status_icon_connection_changed_cb), icon);

	/* make icon listen and respond to MAIN_WINDOW_HIDDEN changes */
	empathy_conf_notify_add (empathy_conf_get (),
				 EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN,
				 status_icon_notify_visibility_cb,
				 icon);

#ifdef HAVE_LIBINDICATE
	empathy_conf_notify_add (empathy_conf_get (),
				 EMPATHY_PREFS_UI_USE_LIBINDICATE,
				 status_icon_notify_libindicate_cb,
				 icon);
#endif

	status_icon_create_menu (icon);
	status_icon_idle_notify_cb (icon);

	g_signal_connect_swapped (priv->idle, "notify",
				  G_CALLBACK (status_icon_idle_notify_cb),
				  icon);
	g_signal_connect (priv->event_manager, "event-added",
			  G_CALLBACK (status_icon_event_added_cb),
			  icon);
	g_signal_connect (priv->event_manager, "event-removed",
			  G_CALLBACK (status_icon_event_removed_cb),
			  icon);
	g_signal_connect (priv->event_manager, "event-updated",
			  G_CALLBACK (status_icon_event_updated_cb),
			  icon);
	g_signal_connect (priv->icon, "activate",
			  G_CALLBACK (status_icon_activate_cb),
			  icon);
	g_signal_connect (priv->icon, "popup-menu",
			  G_CALLBACK (status_icon_popup_menu_cb),
			  icon);
}
Ejemplo n.º 5
0
static void
main_window_contact_presence_changed_cb (EmpathyContactMonitor *monitor,
					 EmpathyContact *contact,
					 TpConnectionPresenceType current,
					 TpConnectionPresenceType previous,
					 EmpathyMainWindow *window)
{
  TpAccount *account;
  gboolean should_play = FALSE;
  EmpathyIdle *idle;

  account = empathy_contact_get_account (contact);
  idle = empathy_idle_dup_singleton ();

  should_play = !empathy_idle_account_is_just_connected (idle, account);

  if (!should_play)
    goto out;

  if (tp_connection_presence_type_cmp_availability (previous,
     TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
    {
      /* contact was online */
      if (tp_connection_presence_type_cmp_availability (current,
          TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0)
        /* someone is logging off */
        empathy_sound_play (GTK_WIDGET (window->window),
          EMPATHY_SOUND_CONTACT_DISCONNECTED);
    }
  else
    {
      /* contact was offline */
      if (tp_connection_presence_type_cmp_availability (current,
          TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
        /* someone is logging in */
        empathy_sound_play (GTK_WIDGET (window->window),
          EMPATHY_SOUND_CONTACT_CONNECTED);
    }

out:
  g_object_unref (idle);
}
Ejemplo n.º 6
0
int
main (int argc, char *argv[])
{
	guint32            startup_timestamp;
	EmpathyStatusIcon *icon;
	EmpathyDispatcher *dispatcher;
	EmpathyChatroomManager *chatroom_manager;
	EmpathyCallFactory *call_factory;
	GtkWidget         *window;
	MissionControl    *mc;
	EmpathyIdle       *idle;
	gboolean           autoconnect = TRUE;
	gboolean           no_connect = FALSE; 
	gboolean           hide_contact_list = FALSE;
	gboolean           accounts_dialog = FALSE;
	GError            *error = NULL;
	GOptionEntry       options[] = {
		{ "no-connect", 'n',
		  0, G_OPTION_ARG_NONE, &no_connect,
		  N_("Don't connect on startup"),
		  NULL },
		{ "hide-contact-list", 'h',
		  0, G_OPTION_ARG_NONE, &hide_contact_list,
		  N_("Don't show the contact list on startup"),
		  NULL },
		{ "accounts", 'a',
		  0, G_OPTION_ARG_NONE, &accounts_dialog,
		  N_("Show the accounts dialog"),
		  NULL },
		{ "version", 'v',
		  G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, show_version_cb, NULL, NULL },
		{ NULL }
	};

	/* Init */
	g_thread_init (NULL);
	empathy_init ();

	if (!gtk_init_with_args (&argc, &argv,
				 N_("- Empathy Instant Messenger"),
				 options, GETTEXT_PACKAGE, &error)) {
		g_warning ("Error in empathy init: %s", error->message);
		return EXIT_FAILURE;
	}

	empathy_gtk_init ();
	g_set_application_name (_(PACKAGE_NAME));

	gst_init (&argc, &argv);

	gtk_window_set_default_icon_name ("empathy");
	textdomain (GETTEXT_PACKAGE);

        /* Setting up the bacon connection */
	startup_timestamp = get_startup_timestamp ();
	connection = bacon_message_connection_new ("empathy");
	if (connection != NULL) {
		if (!bacon_message_connection_get_is_server (connection)) {
			gchar *message;

			if (accounts_dialog) {
				DEBUG ("Showing accounts dialog from existing Empathy instance");

				message = g_strdup ("accounts");

			} else {

				DEBUG ("Activating existing instance");

				message = g_strdup_printf ("%" G_GUINT32_FORMAT,
							   startup_timestamp);
			}

			bacon_message_connection_send (connection, message);

			/* We never popup a window, so tell startup-notification
			 * that we are done. */
			gdk_notify_startup_complete ();

			g_free (message);
			bacon_message_connection_free (connection);

			return EXIT_SUCCESS;
		}
	} else {
		g_warning ("Cannot create the 'empathy' bacon connection.");
	}

	/* Setting up MC */
	mc = empathy_mission_control_dup_singleton ();
	g_signal_connect (mc, "ServiceEnded",
			  G_CALLBACK (service_ended_cb),
			  NULL);
	g_signal_connect (mc, "Error",
			  G_CALLBACK (operation_error_cb),
			  NULL);

	if (accounts_dialog) {
		GtkWidget *dialog;

		dialog = empathy_accounts_dialog_show (NULL, NULL);
		g_signal_connect (dialog, "destroy",
				  G_CALLBACK (gtk_main_quit),
				  NULL);

		gtk_main ();
		return 0;
	}

	/* Setting up Idle */
	idle = empathy_idle_dup_singleton ();
	empathy_idle_set_auto_away (idle, TRUE);
	use_nm_notify_cb (empathy_conf_get (), EMPATHY_PREFS_USE_NM, idle);
	empathy_conf_notify_add (empathy_conf_get (), EMPATHY_PREFS_USE_NM,
				 use_nm_notify_cb, idle);

	/* Autoconnect */
	empathy_conf_get_bool (empathy_conf_get(),
			       EMPATHY_PREFS_AUTOCONNECT,
			       &autoconnect);
	if (autoconnect && ! no_connect &&
	    empathy_idle_get_state (idle) <= MC_PRESENCE_OFFLINE) {
		empathy_idle_set_state (idle, MC_PRESENCE_AVAILABLE);
	}
	
	create_salut_account ();

	/* Setting up UI */
	window = empathy_main_window_show ();
	icon = empathy_status_icon_new (GTK_WINDOW (window), hide_contact_list);

	if (connection) {
		/* We se the callback here because we need window */
		bacon_message_connection_set_callback (connection,
						       on_bacon_message_received,
						       window);
	}

	/* Handle channels */
	dispatcher = empathy_dispatcher_dup_singleton ();
	g_signal_connect (dispatcher, "dispatch", G_CALLBACK (dispatch_cb), NULL);

	chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL);
	empathy_chatroom_manager_observe (chatroom_manager, dispatcher);

	notify_init (_(PACKAGE_NAME));
	/* Create the call factory */
	call_factory = empathy_call_factory_initialise ();
	g_signal_connect (G_OBJECT (call_factory), "new-call-handler",
		G_CALLBACK (new_call_handler_cb), NULL);

	gtk_main ();

	empathy_idle_set_state (idle, MC_PRESENCE_OFFLINE);

	g_object_unref (mc);
	g_object_unref (idle);
	g_object_unref (icon);
	g_object_unref (dispatcher);
	g_object_unref (chatroom_manager);

	notify_uninit ();

	return EXIT_SUCCESS;
}
Ejemplo n.º 7
0
int
main (int argc, char *argv[])
{
#if HAVE_GEOCLUE
  EmpathyLocationManager *location_manager = NULL;
#endif
  EmpathyStatusIcon *icon;
  EmpathyDispatcher *dispatcher;
  TpAccountManager *account_manager;
  EmpathyLogManager *log_manager;
  EmpathyChatroomManager *chatroom_manager;
  EmpathyCallFactory *call_factory;
  EmpathyFTFactory  *ft_factory;
  GtkWidget *window;
  EmpathyIdle *idle;
  EmpathyConnectivity *connectivity;
  GError *error = NULL;
  TpDBusDaemon *dbus_daemon;
  UniqueApp *unique_app;
  gboolean chatroom_manager_ready;

  GOptionContext *optcontext;
  GOptionEntry options[] = {
      { "no-connect", 'n',
        0, G_OPTION_ARG_NONE, &no_connect,
        N_("Don't connect on startup"),
        NULL },
      { "start-hidden", 'h',
        0, G_OPTION_ARG_NONE, &start_hidden,
        N_("Don't display the contact list or any other dialogs on startup"),
        NULL },
      { "accounts", 'a',
        0, G_OPTION_ARG_NONE, &account_dialog_only,
        N_("Show the accounts dialog"),
        NULL },
      { "version", 'v',
        G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, show_version_cb,
        NULL, NULL },
      { NULL }
  };

  /* Init */
  g_thread_init (NULL);
  empathy_init ();

  optcontext = g_option_context_new (N_("- Empathy IM Client"));
  g_option_context_add_group (optcontext, gst_init_get_option_group ());
  g_option_context_add_group (optcontext, gtk_get_option_group (TRUE));
  g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE);

  if (!g_option_context_parse (optcontext, &argc, &argv, &error)) {
    g_print ("%s\nRun '%s --help' to see a full list of available command line options.\n",
        error->message, argv[0]);
    g_warning ("Error in empathy init: %s", error->message);
    return EXIT_FAILURE;
  }

  g_option_context_free (optcontext);

  empathy_gtk_init ();
  g_set_application_name (_(PACKAGE_NAME));
  g_setenv ("PULSE_PROP_media.role", "phone", TRUE);

#if HAVE_LIBCHAMPLAIN
  gtk_clutter_init (&argc, &argv);
#endif

  gtk_window_set_default_icon_name ("empathy");
  textdomain (GETTEXT_PACKAGE);

#ifdef ENABLE_DEBUG
  /* Set up debugger */
  g_log_set_default_handler (default_log_handler, NULL);
#endif

  unique_app = unique_app_new_with_commands ("org.gnome.Empathy",
      NULL, "accounts_dialog", COMMAND_ACCOUNTS_DIALOG, NULL);

  if (unique_app_is_running (unique_app))
    {
      unique_app_send_message (unique_app, account_dialog_only ?
          COMMAND_ACCOUNTS_DIALOG : UNIQUE_ACTIVATE, NULL);

      g_object_unref (unique_app);
      return EXIT_SUCCESS;
    }

  /* Take well-known name */
  dbus_daemon = tp_dbus_daemon_dup (&error);
  if (error == NULL)
    {
      if (!tp_dbus_daemon_request_name (dbus_daemon,
          "org.gnome.Empathy", TRUE, &error))
        {
          DEBUG ("Failed to request well-known name: %s",
                 error ? error->message : "no message");
          g_clear_error (&error);
        }
      g_object_unref (dbus_daemon);
    }
  else
    {
      DEBUG ("Failed to dup dbus daemon: %s",
             error ? error->message : "no message");
      g_clear_error (&error);
    }

  if (account_dialog_only)
    {
      account_manager = tp_account_manager_dup ();
      show_accounts_ui (NULL, TRUE);

      gtk_main ();

      g_object_unref (account_manager);
      return 0;
    }

  notify_init (_(PACKAGE_NAME));

  /* Setting up Idle */
  idle = empathy_idle_dup_singleton ();
  empathy_idle_set_auto_away (idle, TRUE);

  /* Setting up Connectivity */
  connectivity = empathy_connectivity_dup_singleton ();
  use_conn_notify_cb (empathy_conf_get (), EMPATHY_PREFS_USE_CONN,
      connectivity);
  empathy_conf_notify_add (empathy_conf_get (), EMPATHY_PREFS_USE_CONN,
      use_conn_notify_cb, connectivity);

  /* account management */
  account_manager = tp_account_manager_dup ();
  tp_account_manager_prepare_async (account_manager, NULL,
      account_manager_ready_cb, NULL);

  /* Handle channels */
  dispatcher = setup_dispatcher ();
  g_signal_connect (dispatcher, "dispatch", G_CALLBACK (dispatch_cb), NULL);

  migrate_config_to_xdg_dir ();

  /* Setting up UI */
  window = empathy_main_window_show ();
  icon = empathy_status_icon_new (GTK_WINDOW (window), start_hidden);

  g_signal_connect (unique_app, "message-received",
      G_CALLBACK (unique_app_message_cb), window);

  /* Logging */
  log_manager = empathy_log_manager_dup_singleton ();
  empathy_log_manager_observe (log_manager, dispatcher);

  chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL);
  empathy_chatroom_manager_observe (chatroom_manager, dispatcher);

  g_object_get (chatroom_manager, "ready", &chatroom_manager_ready, NULL);
  if (!chatroom_manager_ready)
    {
      g_signal_connect (G_OBJECT (chatroom_manager), "notify::ready",
          G_CALLBACK (chatroom_manager_ready_cb), account_manager);
    }
  else
    {
      chatroom_manager_ready_cb (chatroom_manager, NULL, account_manager);
    }

  /* Create the call factory */
  call_factory = empathy_call_factory_initialise ();
  g_signal_connect (G_OBJECT (call_factory), "new-call-handler",
      G_CALLBACK (new_call_handler_cb), NULL);
  /* Create the FT factory */
  ft_factory = empathy_ft_factory_dup_singleton ();
  g_signal_connect (ft_factory, "new-ft-handler",
      G_CALLBACK (new_ft_handler_cb), NULL);
  g_signal_connect (ft_factory, "new-incoming-transfer",
      G_CALLBACK (new_incoming_transfer_cb), NULL);

  /* Location mananger */
#if HAVE_GEOCLUE
  location_manager = empathy_location_manager_dup_singleton ();
#endif

  gtk_main ();

  empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE);

  g_object_unref (idle);
  g_object_unref (connectivity);
  g_object_unref (icon);
  g_object_unref (account_manager);
  g_object_unref (log_manager);
  g_object_unref (dispatcher);
  g_object_unref (chatroom_manager);
#if HAVE_GEOCLUE
  g_object_unref (location_manager);
#endif
  g_object_unref (ft_factory);
  g_object_unref (unique_app);

  notify_uninit ();

  return EXIT_SUCCESS;
}
static void
do_constructed (GObject *obj)
{
  EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
  TpAccount *account;
  const gchar *protocol, *cm_name;
  guint i = 0;
  struct {
    const gchar *cm_name;
    const gchar *protocol;
    const char *file;
    void (*func)(EmpathyAccountWidget *self, const gchar *filename);
  } widgets [] = {
    { "salut", "local-xmpp", "empathy-account-widget-local-xmpp.ui",
        account_widget_build_salut },
    WIDGET (gabble, jabber),
    WIDGET (butterfly, msn),
    WIDGET (haze, icq),
    WIDGET (haze, aim),
    WIDGET (haze, yahoo),
    WIDGET (haze, groupwise),
    WIDGET (idle, irc),
    WIDGET (sofiasip, sip),
  };

  cm_name = empathy_account_settings_get_cm (priv->settings);
  protocol = empathy_account_settings_get_protocol (priv->settings);

  for (i = 0 ; i < G_N_ELEMENTS (widgets); i++)
    {
      if (!tp_strdiff (widgets[i].cm_name, cm_name) &&
          !tp_strdiff (widgets[i].protocol, protocol))
        {
          gchar *filename;

          filename = empathy_file_lookup (widgets[i].file,
              "libempathy-gtk");
          widgets[i].func (self, filename);
          g_free (filename);

          break;
        }
    }

  if (i == G_N_ELEMENTS (widgets))
    {
      gchar *filename = empathy_file_lookup (
          "empathy-account-widget-generic.ui", "libempathy-gtk");
      account_widget_build_generic (self, filename);
      g_free (filename);
    }

  /* handle default focus */
  if (self->ui_details->default_focus != NULL)
    {
      GObject *default_focus_entry;

      default_focus_entry = gtk_builder_get_object
        (self->ui_details->gui, self->ui_details->default_focus);
      g_signal_connect (default_focus_entry, "realize",
          G_CALLBACK (gtk_widget_grab_focus),
          NULL);
    }

  /* handle forget button */
  if (self->ui_details->add_forget)
    {
      const gchar *password = NULL;

      priv->button_forget = GTK_WIDGET (gtk_builder_get_object
          (self->ui_details->gui, "button_forget"));
      priv->entry_password = GTK_WIDGET (gtk_builder_get_object
          (self->ui_details->gui, "entry_password"));

      password = empathy_account_settings_get_string (priv->settings,
          "password");
      gtk_widget_set_sensitive (priv->button_forget,
          !EMP_STR_EMPTY (password));

      g_signal_connect (priv->button_forget, "clicked",
          G_CALLBACK (account_widget_forget_clicked_cb),
          self);
      g_signal_connect (priv->entry_password, "changed",
          G_CALLBACK (account_widget_password_changed_cb),
          self);
    }

  /* handle apply and cancel button */
  if (!priv->simple)
    {
      GtkWidget *hbox = gtk_hbox_new (TRUE, 3);

      priv->cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);

      if (priv->creating_account)
        {
          TpConnectionPresenceType state;
          priv->idle = empathy_idle_dup_singleton ();

          empathy_signal_connect_weak (priv->idle, "notify::state",
              G_CALLBACK (idle_state_change_cb), obj);

          state = empathy_idle_get_state (priv->idle);

          if (state > TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
            {
              /* We are online, display a Login button */
              GtkWidget *image;

              priv->apply_button = gtk_button_new_with_mnemonic (_("L_og in"));
              image = gtk_image_new_from_stock (GTK_STOCK_CONNECT,
                  GTK_ICON_SIZE_BUTTON);
              gtk_button_set_image (GTK_BUTTON (priv->apply_button), image);
            }
          else
            {
              /* We are offline, display a Save button */
              priv->apply_button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
            }
        }
      else
        {
          /* We are editing an existing account, display an Apply button */
          priv->apply_button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
        }

      gtk_box_pack_end (GTK_BOX (hbox), priv->apply_button, TRUE,
          TRUE, 3);
      gtk_box_pack_end (GTK_BOX (hbox), priv->cancel_button, TRUE,
          TRUE, 3);

      gtk_box_pack_end (GTK_BOX (self->ui_details->widget), hbox, FALSE,
          FALSE, 3);

      g_signal_connect (priv->cancel_button, "clicked",
          G_CALLBACK (account_widget_cancel_clicked_cb),
          self);
      g_signal_connect (priv->apply_button, "clicked",
          G_CALLBACK (account_widget_apply_clicked_cb),
          self);
      gtk_widget_show_all (hbox);

      if (priv->creating_account)
        /* When creating an account, the user might have nothing to enter.
         * That means that no control interaction might occur,
         * so we update the control button sensitivity manually.
         */
        account_widget_handle_control_buttons_sensitivity (self);
      else
        account_widget_set_control_buttons_sensitivity (self, FALSE);
    }

  account = empathy_account_settings_get_account (priv->settings);

  if (account != NULL)
    {
      g_signal_connect (account, "notify::enabled",
          G_CALLBACK (empathy_account_widget_enabled_cb), self);
    }

  /* handle the "Enabled" checkbox. We only add it when modifying an account */
  if (!priv->creating_account && priv->table_common_settings != NULL)
    {
#ifdef HAVE_MOBLIN
      GtkWidget *w;
#endif
      guint nb_rows, nb_columns;
      gboolean is_enabled;

      is_enabled = tp_account_is_enabled (account);

#ifndef HAVE_MOBLIN
      priv->enabled_checkbox =
          gtk_check_button_new_with_label (_("Enabled"));

      gtk_toggle_button_set_active (
          GTK_TOGGLE_BUTTON (priv->enabled_checkbox), is_enabled);
#else
      /* Translators: this is used only when built on a moblin platform */
      w = gtk_label_new (_("Account:"));
      gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);

      priv->enabled_checkbox = nbtk_gtk_light_switch_new ();

      nbtk_gtk_light_switch_set_active (
          NBTK_GTK_LIGHT_SWITCH (priv->enabled_checkbox), is_enabled);

      gtk_widget_show (w);
#endif /* HAVE_MOBLIN */

      g_object_get (priv->table_common_settings, "n-rows", &nb_rows,
          "n-columns", &nb_columns, NULL);

      gtk_table_resize (GTK_TABLE (priv->table_common_settings), ++nb_rows,
          nb_columns);

#ifndef HAVE_MOBLIN
      gtk_table_attach (GTK_TABLE (priv->table_common_settings),
          priv->enabled_checkbox,
          0, nb_columns, nb_rows - 1, nb_rows,
          GTK_EXPAND | GTK_FILL, 0, 0, 0);
#else
      gtk_table_attach (GTK_TABLE (priv->table_common_settings),
          w,
          0, 1, nb_rows - 1, nb_rows,
          GTK_FILL, 0, 0, 0);
      gtk_table_attach (GTK_TABLE (priv->table_common_settings),
          priv->enabled_checkbox,
          1, nb_columns, nb_rows - 1, nb_rows,
          GTK_EXPAND | GTK_FILL, 0, 0, 0);
#endif /* HAVE_MOBLIN */

      gtk_widget_show (priv->enabled_checkbox);

#ifndef HAVE_MOBLIN
      g_signal_connect (G_OBJECT (priv->enabled_checkbox), "released",
          G_CALLBACK (account_widget_enabled_released_cb), self);
#else
      g_signal_connect (G_OBJECT (priv->enabled_checkbox), "switch-flipped",
          G_CALLBACK (account_widget_switch_flipped_cb), self);
#endif /* HAVE_MOBLIN */
    }

  /* hook up to widget destruction to unref ourselves */
  g_signal_connect (self->ui_details->widget, "destroy",
      G_CALLBACK (account_widget_destroy_cb), self);

  empathy_builder_unref_and_keep_widget (self->ui_details->gui,
      self->ui_details->widget);
  self->ui_details->gui = NULL;
}
Ejemplo n.º 9
0
static void
empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
{
	EmpathyPresenceChooserPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (chooser,
		EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooserPriv);
	GtkWidget *entry;
	GtkCellRenderer *renderer;

	chooser->priv = priv;

	presence_chooser_create_model (chooser);

	gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (chooser),
					     COL_STATUS_TEXT);
	gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (chooser),
					      combo_row_separator_func,
					      NULL, NULL);

	entry = gtk_bin_get_child (GTK_BIN (chooser));
	gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
					GTK_ENTRY_ICON_PRIMARY,
					FALSE);

	g_signal_connect_swapped (entry, "icon-release",
		G_CALLBACK (presence_chooser_entry_icon_release_cb),
		chooser);
	g_signal_connect_swapped (entry, "activate",
		G_CALLBACK (presence_chooser_entry_activate_cb),
		chooser);
	g_signal_connect_swapped (entry, "key-press-event",
		G_CALLBACK (presence_chooser_entry_key_press_event_cb),
		chooser);
	g_signal_connect_swapped (entry, "button-press-event",
		G_CALLBACK (presence_chooser_entry_button_press_event_cb),
		chooser);

	gtk_cell_layout_clear (GTK_CELL_LAYOUT (chooser));

	renderer = gtk_cell_renderer_pixbuf_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (chooser), renderer, FALSE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (chooser), renderer,
					"icon-name", COL_STATE_ICON_NAME,
					NULL);
	g_object_set (renderer, "stock-size", GTK_ICON_SIZE_MENU, NULL);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (chooser), renderer, TRUE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (chooser), renderer,
					"markup", COL_DISPLAY_MARKUP,
					NULL);

	g_signal_connect (chooser, "notify::popup-shown",
			G_CALLBACK (presence_chooser_popup_shown_cb), NULL);
	g_signal_connect (chooser, "changed",
			G_CALLBACK (presence_chooser_changed_cb), NULL);
	g_signal_connect_swapped (entry, "changed",
			G_CALLBACK (presence_chooser_entry_changed_cb),
			chooser);
	g_signal_connect_swapped (entry, "focus-out-event",
			G_CALLBACK (presence_chooser_entry_focus_out_cb),
			chooser);

	priv->idle = empathy_idle_dup_singleton ();
	presence_chooser_presence_changed_cb (chooser);
	g_signal_connect_swapped (priv->idle, "notify",
		G_CALLBACK (presence_chooser_presence_changed_cb),
		chooser);

	/* FIXME: this string sucks */
	gtk_widget_set_tooltip_text (GTK_WIDGET (chooser),
		_("Set your presence and current status"));
}
Ejemplo n.º 10
0
int
main (int argc,
    char *argv[])
{
  GOptionContext *optcontext;
  GOptionEntry options[] = {
      { NULL }
  };
#ifdef ENABLE_DEBUG
  TpDebugSender *debug_sender;
#endif
  GError *error = NULL;
  EmpathyChatManager *chat_mgr;
  EmpathyIdle *idle;
  gint retval;

  /* Init */
  g_thread_init (NULL);

  optcontext = g_option_context_new (N_("- Empathy Chat Client"));
  g_option_context_add_group (optcontext, gtk_get_option_group (TRUE));
  g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE);

  if (!g_option_context_parse (optcontext, &argc, &argv, &error))
    {
      g_print ("%s\nRun '%s --help' to see a full list of available command "
          "line options.\n",
          error->message, argv[0]);
      g_warning ("Error in empathy-av init: %s", error->message);
      return EXIT_FAILURE;
    }

  g_option_context_free (optcontext);

  empathy_gtk_init ();

  gtk_window_set_default_icon_name ("empathy");
  textdomain (GETTEXT_PACKAGE);

  app = gtk_application_new (EMPATHY_CHAT_DBUS_NAME, G_APPLICATION_IS_SERVICE);
  g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);

#ifdef ENABLE_DEBUG
  /* Set up debug sender */
  debug_sender = tp_debug_sender_dup ();
  g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN);
#endif

  /* Setting up Idle */
  idle = empathy_idle_dup_singleton ();

  chat_mgr = empathy_chat_manager_dup_singleton ();

  g_signal_connect (chat_mgr, "handled-chats-changed",
      G_CALLBACK (handled_chats_changed_cb), GUINT_TO_POINTER (1));

  if (g_getenv ("EMPATHY_PERSIST") != NULL)
    {
      DEBUG ("Disable timer");

      use_timer = FALSE;
    }

  /* the inactivity timeout can only be set while the application is held */
  g_application_hold (G_APPLICATION (app));
  g_application_set_inactivity_timeout (G_APPLICATION (app), TIMEOUT * 1000);
  g_application_release (G_APPLICATION (app));

  DEBUG ("Waiting for text channels to handle");

  retval = g_application_run (G_APPLICATION (app), argc, argv);

  g_object_unref (app);
  g_object_unref (idle);
  g_object_unref (chat_mgr);

#ifdef ENABLE_DEBUG
  g_object_unref (debug_sender);
#endif

  return retval;
}