| | 23 | |
|---|
| | 24 | |
|---|
| | 25 | |
|---|
| | 26 | /** |
|---|
| | 27 | * tny_mime_part_view_set_save_strategy: |
|---|
| | 28 | * @self: A #TnyMimePartView instance |
|---|
| | 29 | * @strategy: A TnySaveStrategy instace |
|---|
| | 30 | * |
|---|
| | 31 | * Set the strategy used for saving mime-parts |
|---|
| | 32 | * |
|---|
| | 33 | * Implementors: This method should set the strategy for saving a mime-part. |
|---|
| | 34 | * The user interface of the view can for example have a popup menu in its |
|---|
| | 35 | * attachment viewer that will have to use this strategy for saving the |
|---|
| | 36 | * mime-part. |
|---|
| | 37 | * |
|---|
| | 38 | * Example: |
|---|
| | 39 | * <informalexample><programlisting> |
|---|
| | 40 | * static void |
|---|
| | 41 | * tny_my_mime_part_view_set_save_strategy (TnyMimePartView *self_i, TnySaveStrategy *strat) |
|---|
| | 42 | * { |
|---|
| | 43 | * TnyMyMimePartView *self = TNY_MY_MIME_PART_VIEW (self_i); |
|---|
| | 44 | * if (self->save_strategy) |
|---|
| | 45 | * g_object_unref (G_OBJECT (self->save_strategy)); |
|---|
| | 46 | * self->save_strategy = g_object_ref (G_OBJECT (strat)); |
|---|
| | 47 | * } |
|---|
| | 48 | * static void |
|---|
| | 49 | * tny_my_mime_part_view_finalize (TnyMyMimePartView *self) |
|---|
| | 50 | * { |
|---|
| | 51 | * if (self->save_strategy)) |
|---|
| | 52 | * g_object_unref (G_OBJECT (self->save_strategy)); |
|---|
| | 53 | * } |
|---|
| | 54 | * </programlisting></informalexample> |
|---|
| | 55 | * |
|---|
| | 56 | * <informalexample><programlisting> |
|---|
| | 57 | * static void |
|---|
| | 58 | * tny_my_mime_part_view_on_save_clicked (TnyMimePartView *self, TnyMimePart *attachment) |
|---|
| | 59 | * { |
|---|
| | 60 | * TnyMyMimePartView *self = TNY_MY_MIME_PART_VIEW (self_i); |
|---|
| | 61 | * tny_save_strategy_save (self->save_strategy, attachment); |
|---|
| | 62 | * } |
|---|
| | 63 | * </programlisting></informalexample> |
|---|
| | 64 | * |
|---|
| | 65 | * The idea is that devices can have a specific such strategy. For example a |
|---|
| | 66 | * strategy that sends it to another computer or a strategy that saves it to |
|---|
| | 67 | * a flash disk. However. In the mime part view component, you don't care about |
|---|
| | 68 | * that. You only care about the API of the save-strategy interface. |
|---|
| | 69 | * |
|---|
| | 70 | **/ |
|---|
| | 71 | void |
|---|
| | 72 | tny_mime_part_view_set_save_strategy (TnyMimePartView *self, TnySaveStrategy *strategy) |
|---|
| | 73 | { |
|---|
| | 74 | #ifdef DEBUG |
|---|
| | 75 | if (!TNY_MIME_PART_VIEW_GET_IFACE (self)->set_save_strategy_func) |
|---|
| | 76 | g_critical ("You must implement tny_mime_part_view_set_save_strategy\n"); |
|---|
| | 77 | #endif |
|---|
| | 78 | |
|---|
| | 79 | TNY_MIME_PART_VIEW_GET_IFACE (self)->set_save_strategy_func (self, strategy); |
|---|
| | 80 | return; |
|---|
| | 81 | } |
|---|
| | 82 | |
|---|
| | 83 | /** |
|---|
| | 84 | * tny_mime_part_view_is_supported: |
|---|
| | 85 | * @self: A #TnyMimePartView instance |
|---|
| | 86 | * @part: a #TnyMimePart instance |
|---|
| | 87 | * |
|---|
| | 88 | * Figures out whether or not the view supports viewing a mime part |
|---|
| | 89 | * |
|---|
| | 90 | * Return value: Whether or not the view supports viewing this mime-part |
|---|
| | 91 | **/ |
|---|
| | 92 | gboolean |
|---|
| | 93 | tny_mime_part_view_is_supported (TnyMimePartView *self, TnyMimePart *part) |
|---|
| | 94 | { |
|---|
| | 95 | #ifdef DEBUG |
|---|
| | 96 | if (!TNY_MIME_PART_VIEW_GET_IFACE (self)->can_view_func) |
|---|
| | 97 | g_critical ("You must implement tny_mime_part_view_is_supported\n"); |
|---|
| | 98 | #endif |
|---|
| | 99 | |
|---|
| | 100 | TNY_MIME_PART_VIEW_GET_IFACE (self)->can_view_func (self, part); |
|---|
| | 101 | return; |
|---|
| | 102 | } |
|---|