예제 #1
0
static void
presence_chooser_toggled_cb (GtkWidget *chooser,
			     gpointer   user_data)
{
	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chooser))) {
		presence_chooser_menu_popup (EMPATHY_PRESENCE_CHOOSER (chooser));
	} else {
		presence_chooser_menu_popdown (EMPATHY_PRESENCE_CHOOSER (chooser));
	}
}
예제 #2
0
static gboolean
presence_chooser_entry_focus_out_idle_cb (gpointer user_data)
{
	EmpathyPresenceChooser *chooser;
	GtkWidget *entry;

	DEBUG ("Autocommiting status message\n");

	chooser = EMPATHY_PRESENCE_CHOOSER (user_data);
	entry = gtk_bin_get_child (GTK_BIN (chooser));

	presence_chooser_entry_activate_cb (chooser, GTK_ENTRY (entry));

	return FALSE;
}
예제 #3
0
static void
presence_chooser_popup_shown_cb (GObject *self,
                                 GParamSpec *pspec,
				 gpointer user_data)
{
	EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
	gboolean shown;

	g_object_get (self, "popup-shown", &shown, NULL);
	if (!shown) {
		return;
	}

	/* see presence_chooser_entry_focus_out_cb () for what this does */
	if (priv->focus_out_idle_source != 0) {
		g_source_remove (priv->focus_out_idle_source);
		priv->focus_out_idle_source = 0;
	}

	presence_chooser_create_model (EMPATHY_PRESENCE_CHOOSER (self));
}
예제 #4
0
static void
presence_chooser_changed_cb (GtkComboBox *self, gpointer user_data)
{
	EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
	GtkTreeIter iter;
	char *icon_name;
	TpConnectionPresenceType new_state;
	gboolean customisable = TRUE;
	PresenceChooserEntryType type = -1;
	GtkWidget *entry;
	GtkTreeModel *model;

	if (priv->block_changed ||
	    !gtk_combo_box_get_active_iter (self, &iter)) {
		return;
	}

	model = gtk_combo_box_get_model (self);
	gtk_tree_model_get (model, &iter,
			    COL_STATE_ICON_NAME, &icon_name,
			    COL_STATE, &new_state,
			    COL_STATUS_CUSTOMISABLE, &customisable,
			    COL_TYPE, &type,
			    -1);

	entry = gtk_bin_get_child (GTK_BIN (self));

	/* some types of status aren't editable, set the editability of the
	 * entry appropriately. Unless we're just about to reset it anyway,
	 * in which case, don't fiddle with it */
	if (type != ENTRY_TYPE_EDIT_CUSTOM) {
		gtk_editable_set_editable (GTK_EDITABLE (entry), customisable);
		priv->state = new_state;
	}

	if (type == ENTRY_TYPE_EDIT_CUSTOM) {
		GtkWidget *window, *dialog;

		presence_chooser_reset_status (EMPATHY_PRESENCE_CHOOSER (self));

		/* attempt to get the toplevel for this widget */
		window = gtk_widget_get_toplevel (GTK_WIDGET (self));
		if (!GTK_WIDGET_TOPLEVEL (window) || !GTK_IS_WINDOW (window)) {
			window = NULL;
		}

		dialog = empathy_status_preset_dialog_new (GTK_WINDOW (window));
		gtk_dialog_run (GTK_DIALOG (dialog));
		gtk_widget_destroy (dialog);
	}
	else if (type == ENTRY_TYPE_CUSTOM) {
		gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
						   GTK_ENTRY_ICON_PRIMARY,
						   icon_name);

		/* preseed the status */
		if (priv->previous_type == ENTRY_TYPE_BUILTIN) {
			/* if their previous entry was a builtin, don't
			 * preseed */
			gtk_entry_set_text (GTK_ENTRY (entry), "");
		} else {
			/* else preseed the text of their currently entered
			 * status message */
			const char *status;

			status = empathy_idle_get_status (priv->idle);
			gtk_entry_set_text (GTK_ENTRY (entry), status);
		}

		/* grab the focus */
		gtk_widget_grab_focus (entry);
	} else {
		char *status;

		/* just in case we were setting a new status when
		 * things were changed */
		presence_chooser_set_status_editing (
			EMPATHY_PRESENCE_CHOOSER (self),
			FALSE);
		gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
					   GTK_ENTRY_ICON_PRIMARY,
					   icon_name);

		gtk_tree_model_get (model, &iter,
				    COL_STATUS_TEXT, &status,
				    -1);

		empathy_idle_set_presence (priv->idle, priv->state, status);

		g_free (status);
	}

	if (type != ENTRY_TYPE_EDIT_CUSTOM) {
		priv->previous_type = type;
	}
	g_free (icon_name);
}