]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-sidebar-attachments.c
[dualscreen] fix crash on ctrl+w and fix control window closing
[evince.git] / shell / ev-sidebar-attachments.c
index d89617b1d6471ffc126b558e83376abeab009727..5b717896ac1a913732a58c6dcaaa8d3040ca4e81 100644 (file)
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -67,7 +67,7 @@ struct _EvSidebarAttachmentsPrivate {
        GHashTable     *icon_cache;
 };
 
-static void ev_sidebar_attachments_page_iface_init (EvSidebarPageIface *iface);
+static void ev_sidebar_attachments_page_iface_init (EvSidebarPageInterface *iface);
 
 G_DEFINE_TYPE_EXTENDED (EvSidebarAttachments,
                         ev_sidebar_attachments,
@@ -273,7 +273,7 @@ ev_sidebar_attachments_button_press (EvSidebarAttachments *ev_attachbar,
                                     GdkEventButton       *event,
                                     GtkWidget            *icon_view)
 {
-       if (!GTK_WIDGET_HAS_FOCUS (icon_view)) {
+       if (!gtk_widget_has_focus (icon_view)) {
                gtk_widget_grab_focus (icon_view);
        }
        
@@ -410,7 +410,7 @@ ev_sidebar_attachments_drag_data_get (GtkWidget        *widget,
                GtkTreePath  *path;
                GtkTreeIter   iter;
                GFile        *file;
-               gchar        *filename;
+               gchar        *template;
                GError       *error = NULL;
                
                path = (GtkTreePath *) l->data;
@@ -421,13 +421,12 @@ ev_sidebar_attachments_drag_data_get (GtkWidget        *widget,
                                    COLUMN_ATTACHMENT, &attachment,
                                    -1);
 
-               filename = g_build_filename (ev_tmp_dir (),
-                                            ev_attachment_get_name (attachment),
-                                            NULL);
-               file = g_file_new_for_path (filename);
-               g_free (filename);
+                /* FIXMEchpe: convert to filename encoding first! */
+                template = g_strdup_printf ("%s.XXXXXX", ev_attachment_get_name (attachment));
+                file = ev_mkstemp_file (template, &error);
+                g_free (template);
                
-               if (ev_attachment_save (attachment, file, &error)) {
+               if (file != NULL && ev_attachment_save (attachment, file, &error)) {
                        gchar *uri;
 
                        uri = g_file_get_uri (file);
@@ -473,7 +472,7 @@ ev_sidebar_attachments_get_property (GObject    *object,
 }
 
 static void
-ev_sidebar_attachments_destroy (GtkObject *object)
+ev_sidebar_attachments_dispose (GObject *object)
 {
        EvSidebarAttachments *ev_attachbar = EV_SIDEBAR_ATTACHMENTS (object);
 
@@ -495,22 +494,20 @@ ev_sidebar_attachments_destroy (GtkObject *object)
                ev_attachbar->priv->icon_cache = NULL;
        }
 
-       (* GTK_OBJECT_CLASS (ev_sidebar_attachments_parent_class)->destroy) (object);
+       G_OBJECT_CLASS (ev_sidebar_attachments_parent_class)->dispose (object);
 }
 
 static void
 ev_sidebar_attachments_class_init (EvSidebarAttachmentsClass *ev_attachbar_class)
 {
        GObjectClass   *g_object_class;
-       GtkObjectClass *gtk_object_class;
        GtkWidgetClass *gtk_widget_class;
 
        g_object_class = G_OBJECT_CLASS (ev_attachbar_class);
-       gtk_object_class = GTK_OBJECT_CLASS (ev_attachbar_class);
        gtk_widget_class = GTK_WIDGET_CLASS (ev_attachbar_class);
 
        g_object_class->get_property = ev_sidebar_attachments_get_property;
-       gtk_object_class->destroy = ev_sidebar_attachments_destroy;
+       g_object_class->dispose = ev_sidebar_attachments_dispose;
        gtk_widget_class->popup_menu = ev_sidebar_attachments_popup_menu;
        gtk_widget_class->screen_changed = ev_sidebar_attachments_screen_changed;
 
@@ -535,12 +532,6 @@ ev_sidebar_attachments_class_init (EvSidebarAttachmentsClass *ev_attachbar_class
 static void
 ev_sidebar_attachments_init (EvSidebarAttachments *ev_attachbar)
 {
-#if !GTK_CHECK_VERSION (2, 15, 0)
-        const GtkTargetEntry drag_targets[] = {
-                { "text/uri-list", 0, 0 }
-        };
-#endif
-
        GtkWidget *swindow;
        
        ev_attachbar->priv = EV_SIDEBAR_ATTACHMENTS_GET_PRIVATE (ev_attachbar);
@@ -590,21 +581,12 @@ ev_sidebar_attachments_init (EvSidebarAttachments *ev_attachbar)
                                                                g_object_unref);
 
        /* Drag and Drop */
-#if GTK_CHECK_VERSION (2, 15, 0)
        gtk_icon_view_enable_model_drag_source (
                GTK_ICON_VIEW (ev_attachbar->priv->icon_view),
                GDK_BUTTON1_MASK,
                NULL, 0,
                GDK_ACTION_COPY);
         gtk_drag_source_add_uri_targets (ev_attachbar->priv->icon_view);
-#else
-       gtk_icon_view_enable_model_drag_source (
-               GTK_ICON_VIEW (ev_attachbar->priv->icon_view),
-               GDK_BUTTON1_MASK,
-               drag_targets,
-               G_N_ELEMENTS (drag_targets),
-               GDK_ACTION_COPY);
-#endif
 
        g_signal_connect (ev_attachbar->priv->icon_view,
                          "drag-data-get",
@@ -714,7 +696,7 @@ ev_sidebar_attachments_get_label (EvSidebarPage *sidebar_page)
 }
 
 static void
-ev_sidebar_attachments_page_iface_init (EvSidebarPageIface *iface)
+ev_sidebar_attachments_page_iface_init (EvSidebarPageInterface *iface)
 {
        iface->support_document = ev_sidebar_attachments_support_document;
        iface->set_model = ev_sidebar_attachments_set_model;