194
gView->errormessage ("stat error: %d:%s", errno, strerror (errno));
190
gView->errormessage ("stat error: %d:%s", errno, strerror (errno));
198
194
if (S_ISDIR (buf->st_mode))
200
mReady = walk_dir_path_index (NULL, path);
196
mReady = walk_dir_path_index (NULL, path);
204
mFile = ApvlvFile::newfile (path);
200
mFile = ApvlvFile::newfile (path);
206
if (mFile != NULL && (mIndex = mFile->new_index ()) != NULL)
208
for (ApvlvFileIndexIter itr = mIndex->children.begin ();
209
itr != mIndex->children.end (); ++itr)
211
bool ready = walk_file_index (NULL, itr);
202
if (mFile != NULL && (mIndex = mFile->new_index ()) != NULL)
204
for (ApvlvFileIndexIter itr = mIndex->children.begin ();
205
itr != mIndex->children.end (); ++itr)
207
bool ready = walk_file_index (NULL, itr);
229
(gboolean (*)(gpointer)) apvlv_dir_first_select_cb,
225
(gboolean (*)(gpointer)) apvlv_dir_first_select_cb,
358
354
gtk_tree_model_get (GTK_TREE_MODEL (mStore), &mCurrentIter, 0, &node, -1);
359
355
if (node == NULL)
364
360
const char *name = NULL;
366
362
if (!node->dest (&name, &pn))
371
367
ApvlvCore *ndoc = NULL;
372
368
if (name != NULL)
374
if (gParams->valueb ("content"))
376
ndoc = new ApvlvDir (mWidth, mHeight);
377
if (!ndoc->loadfile (name))
370
if (gParams->valueb ("content"))
372
ndoc = new ApvlvDir (mWidth, mHeight);
373
if (!ndoc->loadfile (name))
387
new ApvlvDoc (mWidth, mHeight, gParams->values ("zoom"),
388
gParams->valueb ("cache"));
389
if (!ndoc->loadfile (name))
383
new ApvlvDoc (mWidth, mHeight, gParams->values ("zoom"),
384
gParams->valueb ("cache"));
385
if (!ndoc->loadfile (name))
399
new ApvlvDoc (mWidth, mHeight, gParams->values ("zoom"),
400
gParams->valueb ("cache"));
401
if (!ndoc->loadfile (filename ()))
395
new ApvlvDoc (mWidth, mHeight, gParams->values ("zoom"),
396
gParams->valueb ("cache"));
397
if (!ndoc->loadfile (filename ()))
409
((ApvlvDoc *) ndoc)->showpage (pn);
405
((ApvlvDoc *) ndoc)->showpage (pn);
413
409
if (ndoc == NULL)
418
414
gView->regloaded (ndoc);
537
533
for (gboolean ret = TRUE; times > 0 && ret; times--)
540
gtk_tree_model_iter_children (GTK_TREE_MODEL (mStore), &itr,
536
gtk_tree_model_iter_children (GTK_TREE_MODEL (mStore), &itr,
548
544
GtkTreePath *path =
549
545
gtk_tree_model_get_path (GTK_TREE_MODEL (mStore), &mCurrentIter);
552
gtk_tree_view_expand_to_path (GTK_TREE_VIEW (mDirView), path);
553
gtk_tree_selection_select_iter (mSelection, &mCurrentIter);
554
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (mDirView), path, NULL,
556
gtk_tree_path_free (path);
548
gtk_tree_view_expand_to_path (GTK_TREE_VIEW (mDirView), path);
549
gtk_tree_selection_select_iter (mSelection, &mCurrentIter);
550
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (mDirView), path, NULL,
552
gtk_tree_path_free (path);
559
555
mStatus->show ();
569
565
if (*str == '\0' && mSearchStr == "")
575
571
if (*str != '\0')
581
577
ApvlvDirNode *info = NULL;
582
578
gtk_tree_model_get (GTK_TREE_MODEL (mStore), &mCurrentIter, 0, &info, -1);
583
579
if (info == NULL || mDirNodes == NULL)
585
gView->errormessage ("can't find word: '%s'", mSearchStr.c_str ());
581
gView->errormessage ("can't find word: '%s'", mSearchStr.c_str ());
590
586
for (list = mDirNodes; list; list = g_list_next (list))
592
if (info == list->data)
588
if (info == list->data)
598
594
if (list == NULL)
600
gView->errormessage ("can't find word: '%s'", mSearchStr.c_str ());
596
gView->errormessage ("can't find word: '%s'", mSearchStr.c_str ());
608
list = g_list_previous (list);
612
list = g_list_next (list);
604
list = g_list_previous (list);
608
list = g_list_next (list);
616
612
bool wrap = gParams->valueb ("wrapscan");
618
614
for (GList * origin = list; list != NULL;)
620
info = (ApvlvDirNode *) list->data;
621
if (strstr (info->phrase (), mSearchStr.c_str ()) != NULL)
628
list = g_list_previous (list);
632
list = g_list_next (list);
641
if (list == NULL && wrap)
645
list = g_list_last (mDirNodes);
616
info = (ApvlvDirNode *) list->data;
617
if (strstr (info->phrase (), mSearchStr.c_str ()) != NULL)
624
list = g_list_previous (list);
628
list = g_list_next (list);
637
if (list == NULL && wrap)
641
list = g_list_last (mDirNodes);
654
650
if (list == NULL)
656
gView->errormessage ("can't find word: '%s'", mSearchStr.c_str ());
652
gView->errormessage ("can't find word: '%s'", mSearchStr.c_str ());
660
656
mCurrentIter = *info->iter ();
691
687
mDirNodes = g_list_append (mDirNodes, node);
693
689
GdkPixbuf *pix = gdk_pixbuf_new_from_file_at_size (iconreg.c_str (), 40,
697
gtk_tree_store_set (mStore, nitr, 0, node, 1, pix, 2,
698
iter->title.c_str (), -1);
699
g_object_unref (pix);
693
gtk_tree_store_set (mStore, nitr, 0, node, 1, pix, 2,
694
iter->title.c_str (), -1);
695
g_object_unref (pix);
703
gtk_tree_store_set (mStore, nitr, 0, node, 2,
704
iter->title.c_str (), -1);
699
gtk_tree_store_set (mStore, nitr, 0, node, 2,
700
iter->title.c_str (), -1);
707
703
for (ApvlvFileIndexIter itr = iter->children.begin ();
708
itr != iter->children.end (); ++itr)
704
itr != iter->children.end (); ++itr)
710
bool chas = walk_file_index (has ? nitr : titr, itr);
706
bool chas = walk_file_index (has ? nitr : titr, itr);
721
ApvlvDir::apvlv_dir_on_changed (GtkTreeSelection * selection,
717
ApvlvDir::apvlv_dir_on_changed (GtkTreeSelection * selection,
724
720
GtkTreeModel *model;
725
721
gtk_tree_selection_get_selected (selection, &model, &dir->mCurrentIter);
767
763
if (mDoc->filename ())
769
char temp[AD_STATUS_SIZE][256];
771
bn = g_path_get_basename (mDoc->filename ());
772
g_snprintf (temp[0], sizeof temp[0], "%s", bn);
773
g_snprintf (temp[1], sizeof temp[1], "apvlv");
774
g_snprintf (temp[2], sizeof temp[2], "%d%%",
775
(int) (mDoc->zoomvalue () * 100));
776
g_snprintf (temp[3], sizeof temp[3], "%d%%",
777
(int) (mDoc->scrollrate () * 100));
778
for (unsigned int i = 0; i < AD_STATUS_SIZE; ++i)
780
gtk_label_set_text (GTK_LABEL (mStlab[i]), temp[i]);
765
char temp[AD_STATUS_SIZE][256];
767
bn = g_path_get_basename (mDoc->filename ());
768
g_snprintf (temp[0], sizeof temp[0], "%s", bn);
769
g_snprintf (temp[1], sizeof temp[1], "apvlv");
770
g_snprintf (temp[2], sizeof temp[2], "%d%%",
771
(int) (mDoc->zoomvalue () * 100));
772
g_snprintf (temp[3], sizeof temp[3], "%d%%",
773
(int) (mDoc->scrollrate () * 100));
774
for (unsigned int i = 0; i < AD_STATUS_SIZE; ++i)
776
gtk_label_set_text (GTK_LABEL (mStlab[i]), temp[i]);
799
795
GDir *dir = g_dir_open (path, 0, NULL);
803
while ((name = g_dir_read_name (dir)) != NULL)
805
if (strcmp (name, ".") == 0)
807
debug ("avoid hidden file: %s", name);
799
while ((name = g_dir_read_name (dir)) != NULL)
801
if (strcmp (name, ".") == 0)
803
debug ("avoid hidden file: %s", name);
811
gchar *realname = g_strjoin (PATH_SEP_S, path, name, NULL);
807
gchar *realname = g_strjoin (PATH_SEP_S, path, name, NULL);
812
808
// debug ("add a item: %s[%s]", name, realname);
814
ApvlvDirNode *node = NULL;
817
g_locale_from_utf8 (realname, -1, NULL, NULL, NULL);
818
if (wrealname == NULL)
824
int ret = stat (wrealname, buf);
833
if (S_ISDIR (buf->st_mode))
836
gtk_tree_store_append (mStore, mitr, itr);
837
node = new ApvlvDirNode (mitr, true, realname, name);
840
gdk_pixbuf_new_from_file_at_size (icondir.c_str (), 40, 20,
844
gtk_tree_store_set (mStore, mitr, 0, node, 1, pix, 2,
846
g_object_unref (pix);
850
gtk_tree_store_set (mStore, mitr, 0, node, 2, name, -1);
853
if (!walk_dir_path_index (mitr, realname))
855
gtk_tree_store_remove (mStore, mitr);
862
mDirNodes = g_list_append (mDirNodes, node);
866
else if (g_ascii_strncasecmp (name + strlen (name) - 4, ".pdf", 4)
868
|| g_ascii_strncasecmp (name + strlen (name) - 5,
870
|| g_ascii_strncasecmp (name + strlen (name) - 4, ".djv",
874
gtk_tree_store_append (mStore, mitr, itr);
875
node = new ApvlvDirNode (mitr, false, realname, name);
876
mDirNodes = g_list_append (mDirNodes, node);
879
gdk_pixbuf_new_from_file_at_size (iconpdf.c_str (), 40, 20,
883
gtk_tree_store_set (mStore, mitr, 0, node, 1, pix, 2,
885
g_object_unref (pix);
889
gtk_tree_store_set (mStore, mitr, 0, node, 2, name, -1);
810
ApvlvDirNode *node = NULL;
813
g_locale_from_utf8 (realname, -1, NULL, NULL, NULL);
814
if (wrealname == NULL)
820
int ret = stat (wrealname, buf);
829
if (S_ISDIR (buf->st_mode))
832
gtk_tree_store_append (mStore, mitr, itr);
833
node = new ApvlvDirNode (mitr, true, realname, name);
836
gdk_pixbuf_new_from_file_at_size (icondir.c_str (), 40, 20,
840
gtk_tree_store_set (mStore, mitr, 0, node, 1, pix, 2,
842
g_object_unref (pix);
846
gtk_tree_store_set (mStore, mitr, 0, node, 2, name, -1);
849
if (!walk_dir_path_index (mitr, realname))
851
gtk_tree_store_remove (mStore, mitr);
858
mDirNodes = g_list_append (mDirNodes, node);
862
else if (g_ascii_strncasecmp (name + strlen (name) - 4, ".pdf", 4)
865
|| g_ascii_strncasecmp (name + strlen (name) - 5,
867
|| g_ascii_strncasecmp (name + strlen (name) - 4, ".djv",
871
|| g_ascii_strncasecmp (name + strlen (name) - 4,
877
gtk_tree_store_append (mStore, mitr, itr);
878
node = new ApvlvDirNode (mitr, false, realname, name);
879
mDirNodes = g_list_append (mDirNodes, node);
882
gdk_pixbuf_new_from_file_at_size (iconpdf.c_str (), 40, 20,
886
gtk_tree_store_set (mStore, mitr, 0, node, 1, pix, 2,
888
g_object_unref (pix);
892
gtk_tree_store_set (mStore, mitr, 0, node, 2, name, -1);
898
901
g_dir_close (dir);