const gchar *status);
static void presence_chooser_custom_activate_cb (GtkWidget *item,
gpointer user_data);
-static void presence_chooser_dialog_show (void);
+static void presence_chooser_dialog_show (GtkWindow *parent);
G_DEFINE_TYPE (EmpathyPresenceChooser, empathy_presence_chooser, GTK_TYPE_COMBO_BOX_ENTRY);
ENTRY_TYPE_BUILTIN,
ENTRY_TYPE_SAVED,
ENTRY_TYPE_CUSTOM,
+ ENTRY_TYPE_SEPARATOR,
+ ENTRY_TYPE_EDIT_CUSTOM,
};
static GtkTreeModel *
}
}
+
+ /* add a separator */
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ COL_TYPE, ENTRY_TYPE_SEPARATOR,
+ -1);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ COL_STATE_ICON_NAME, GTK_STOCK_EDIT,
+ COL_STATUS_TEXT, "",
+ COL_DISPLAY_MARKUP, "Edit Custom Messages...",
+ COL_TYPE, ENTRY_TYPE_EDIT_CUSTOM,
+ -1);
return GTK_TREE_MODEL (store);
}
GTK_STOCK_OK);
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY,
- "Set status");
+ _("Set status"));
gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
GTK_ENTRY_ICON_PRIMARY,
FALSE);
-1);
GtkWidget *entry = gtk_bin_get_child (GTK_BIN (self));
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY,
- icon_name);
- if (type == ENTRY_TYPE_CUSTOM)
+ if (type == ENTRY_TYPE_EDIT_CUSTOM)
{
+ /* recover the status that was unset because COL_STATUS_TEXT
+ * is "". Unfortunately if you try and set COL_STATUS_TEXT to
+ * NULL, it generates a g_critical. I wonder if there is a
+ * better way around this. */
+ const char *status = empathy_idle_get_status (priv->idle);
+ priv->block_set_editing++;
+ gtk_entry_set_text (GTK_ENTRY (entry), status);
+ priv->block_set_editing--;
+
+ /* attempt to get the toplevel for this widget */
+ GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ if (!GTK_WIDGET_TOPLEVEL (window) || !GTK_IS_WINDOW (window))
+ {
+ window = NULL;
+ }
+
+ presence_chooser_dialog_show (GTK_WINDOW (window));
+ }
+ else if (type == ENTRY_TYPE_CUSTOM)
+ {
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ icon_name);
+
/* grab the focus */
gtk_widget_grab_focus (entry);
+
set_status_editing (EMPATHY_PRESENCE_CHOOSER (self), TRUE);
}
else
g_free (icon_name);
}
+static gboolean
+combo_row_separator_func (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ int type;
+ gtk_tree_model_get (model, iter,
+ COL_TYPE, &type,
+ -1);
+
+ return (type == ENTRY_TYPE_SEPARATOR);
+}
+
static void
empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
{
GtkTreeModel *model = create_model ();
gtk_combo_box_set_model (GTK_COMBO_BOX (chooser), GTK_TREE_MODEL (model));
- gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (chooser), COL_STATUS_TEXT);
+ 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);
GtkWidget *entry = gtk_bin_get_child (GTK_BIN (chooser));
gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
g_signal_connect_swapped (priv->idle, "notify",
G_CALLBACK (presence_chooser_presence_changed_cb),
chooser);
+
+ g_object_set (chooser,
+ // FIXME: this string sucks
+ "tooltip-text", _("Set your presence and current status"),
+ NULL);
}
static void
presence_chooser_custom_activate_cb (GtkWidget *item,
gpointer user_data)
{
- presence_chooser_dialog_show ();
+ presence_chooser_dialog_show (NULL);
}
static McPresence
}
static void
-presence_chooser_dialog_show (void)
+presence_chooser_dialog_show (GtkWindow *parent)
{
GladeXML *glade;
gchar *filename;
gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (message_dialog->comboboxentry_message), 0);
- /* FIXME: Set transian for a window ? */
+ if (parent)
+ {
+ gtk_window_set_transient_for (
+ GTK_WINDOW (message_dialog->dialog),
+ parent);
+ }
gtk_widget_show_all (message_dialog->dialog);
}