typedef struct _ModestComboBoxPrivate ModestComboBoxPrivate;
struct _ModestComboBoxPrivate {
- /* my private members go here, eg. */
- /* gboolean frobnicate_mode; */
+ GEqualFunc id_equal_func;
+
};
#define MODEST_COMBO_BOX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_COMBO_BOX, \
}
static GtkTreeModel*
-get_model (const GSList *pairs)
+get_model (const ModestPairList *pairs)
{
GtkTreeIter iter;
GtkListStore *store;
GtkWidget*
-modest_combo_box_new (const GSList *pairs)
+modest_combo_box_new (const ModestPairList *pairs, GEqualFunc id_equal_func)
{
GtkTreeModel *model;
GtkCellRenderer *renderer;
GObject *obj;
+ ModestComboBoxPrivate *priv;
+ g_return_val_if_fail (pairs, NULL);
+
obj = G_OBJECT(g_object_new(MODEST_TYPE_COMBO_BOX, NULL));
-
+ priv = MODEST_COMBO_BOX_GET_PRIVATE(obj);
+
model = get_model (pairs);
-
if (model) {
gtk_combo_box_set_model (GTK_COMBO_BOX(obj), model);
g_object_unref (model);
}
gtk_combo_box_set_active (GTK_COMBO_BOX(obj), 0);
+
+ if (id_equal_func)
+ priv->id_equal_func = id_equal_func;
+ else
+ priv->id_equal_func = g_direct_equal; /* compare the ptr values */
+
return GTK_WIDGET(obj);
}
get_active (ModestComboBox *self, GValue *val, gint column)
{
GtkTreeIter iter;
-
g_return_if_fail (self);
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX(self), &iter)) {
gpointer
modest_combo_box_get_active_id (ModestComboBox *self)
{
- g_return_val_if_fail (self, NULL);
GValue val = {0,};
gpointer retval;
+ g_return_val_if_fail (self, NULL);
+
/* Do not unset the GValue */
get_active (self, &val, COLUMN_ID);
retval = g_value_peek_pointer (&val);
return retval;
}
-gpointer
+
+void
+modest_combo_box_set_active_id (ModestComboBox *self, gpointer id)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ ModestComboBoxPrivate *priv;
+ gboolean found;
+
+ g_return_if_fail (self);
+
+ priv = MODEST_COMBO_BOX_GET_PRIVATE(self);
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX(self));
+ if (!gtk_tree_model_get_iter_first (model, &iter))
+ return; /* empty list */
+
+ do {
+ gpointer row_id;
+ gtk_tree_model_get (model, &iter, COLUMN_ID, &row_id, -1);
+ if ((priv->id_equal_func)(id, row_id) == 0) {
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX(self), &iter);
+ found = TRUE;
+ }
+ } while (!found && gtk_tree_model_iter_next (model, &iter));
+
+ if (!found)
+ g_printerr ("modest: could not set the active id\n");
+}
+
+
+
+const gchar*
modest_combo_box_get_active_display_name (ModestComboBox *self)
{
- g_return_val_if_fail (self, NULL);
GValue val = {0,};
gpointer retval;
+ g_return_val_if_fail (self, NULL);
+
/* Do not unset the GValue */
get_active (self, &val, COLUMN_DISPLAY_NAME);
retval = g_value_peek_pointer (&val);
- return retval;
+ return (gchar*) retval;
}
/**
* modest_combo_box_new
- * @hash: a ptr to a GSList; each element should be a ptr to
- * a ModestPair
+ * @pairs: a #ModestPairList; each element should be a ptr to a #ModestPair
+ * @cmp_id_func: a GEqualFunc to compare the ids (= the first elements of the pairs)
+ * For example, if the ids are strings, you can use g_str_equal.
*
+ * (If you provide NULL for this parameter, the id ptr address will be compared)
+ *
* create a new modest combo box
*
* Returns: a new GtkComboBox instance, or NULL in case of failure
*/
-GtkWidget* modest_combo_box_new (const GSList *hash);
+GtkWidget* modest_combo_box_new (const ModestPairList* pairs,
+ GEqualFunc id_equal_func);
/**
* modest_combo_box_get_active_id
* @self: a valid ModestComboBox instance
*
- * get the id for the currently active lemma, or NULL if there's nothing chosen
+ * get the id for the currently active item, or NULL if there's nothing chosen
+ * (ie., the id is the first element of the pair)
*
* Returns: the id or NULL if there's nothing chosen.
*/
gpointer modest_combo_box_get_active_id (ModestComboBox *self);
/**
+ * modest_combo_box_set_active_id
+ * @self: a valid ModestComboBox instance
+ * @id: the id to make active
+ *
+ * set the active item
+ *
+ */
+void modest_combo_box_set_active_id (ModestComboBox *self, gpointer id);
+
+/**
* modest_combo_box_get_active_display_name
* @self: a valid ModestComboBox instance
*
*
* Returns: the display name or NULL if there's nothing chosen.
*/
-gpointer modest_combo_box_get_active_display_name (ModestComboBox *self);
+const gchar* modest_combo_box_get_active_display_name (ModestComboBox *self);
G_END_DECLS
MODEST_EDIT_TYPE_NEW,
MODEST_EDIT_TYPE_REPLY,
MODEST_EDIT_TYPE_FORWARD,
- MODEST_EDIT_TYPE_VIEW,
MODEST_EDIT_TYPE_NUM
} ModestEditType;
-typedef struct _MsgData {
+typedef struct {
gchar *from, *to, *cc, *bcc, *subject, *body;
} MsgData;
/**
* modest_msg_edit_window_new:
+ * #msg: a #TnyMsg instance
+ * #account_name: the account this message applies to
*
* instantiates a new #ModestMsgEditWindow widget
*
* Returns: a new #ModestMsgEditWindow, or NULL in case of error
*/
-ModestWindow* modest_msg_edit_window_new (ModestEditType type);
-
-
-/**
- * modest_msg_edit_window_set_msg:
- * @self: a #ModestMsgEditWindow
- * @msg: a #TnyMsg
- *
- * shows the message @msg in a #ModestMsgEditWindow
- **/
-void modest_msg_edit_window_set_msg (ModestMsgEditWindow *self,
- TnyMsg *msg);
+ModestWindow* modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name);
/**
/**
* modest_msg_view_window_new:
+ * @msg: an #TnyMsg instance
+ * @account: the account name
*
- * instantiates a new #ModestMsgViewWindow widget
+ * instantiates a new #ModestMsgViewWindow widget. The account name is used to
+ * set the proper account when choosing reply/forward from the msg view window
*
* Returns: a new #ModestMsgViewWindow, or NULL in case of error
*/
-ModestWindow* modest_msg_view_window_new (TnyMsg *msg);
+ModestWindow* modest_msg_view_window_new (TnyMsg *msg, const gchar *account);
G_END_DECLS
}
-
static gchar*
get_header_info (TnyMsg *msg, gboolean outgoing)
{
GtkUIManager *ui_manager;
GtkWidget *toolbar;
GtkWidget *menubar;
+
+ gchar *active_account;
};
#define MODEST_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
priv = MODEST_WINDOW_GET_PRIVATE(obj);
- priv->ui_manager = NULL;
- priv->toolbar = NULL;
- priv->menubar = NULL;
+ priv->ui_manager = NULL;
+ priv->toolbar = NULL;
+ priv->menubar = NULL;
+
+ priv->active_account = NULL;
}
static void
priv->ui_manager = NULL;
}
+ g_free (priv->active_account);
+
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
+
+
+
+const gchar*
+modest_window_get_active_account (ModestWindow *self)
+{
+ g_return_val_if_fail (self, NULL);
+
+ return MODEST_WINDOW_GET_PRIVATE(self)->active_account;
+}
+
+void
+modest_window_set_active_account (ModestWindow *self, const gchar *active_account)
+{
+ ModestWindowPrivate *priv;
+
+ priv = MODEST_WINDOW_GET_PRIVATE(self);
+
+ if (active_account == priv->active_account)
+ return;
+ else {
+ g_free (priv->active_account);
+ priv->active_account = g_strdup (active_account);
+ }
+}
ModestWindowParentClass parent_class;
};
-/* member functions */
+/**
+ * modest_window_get_type:
+ *
+ * get the #GType for #ModestWindow
+ *
+ * Returns: the type
+ */
GType modest_window_get_type (void) G_GNUC_CONST;
+
+/**
+ * modest_window_get_active_account:
+ * @self: a modest window instance
+ *
+ * get the name of the active account
+ *
+ * Returns: the active account name as a constant string
+ */
+const gchar* modest_window_get_active_account (ModestWindow *self);
+
+
+
+/**
+ * modest_window_set_active_account:
+ * @self: a modest window instance
+ * @active_account: a new active account name for this window
+ *
+ * set the active account for this window
+ *
+ */
+void modest_window_set_active_account (ModestWindow *self, const gchar *active_account);
+
+
G_END_DECLS
#endif /* __MODEST_WINDOW_H__ */