~ubuntu-branches/ubuntu/trusty/unity-place-files/trusty

« back to all changes in this revision

Viewing changes to src/daemon.vala

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-08-26 18:52:52 UTC
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20100826185252-rtxst6inf3chd7po
Tags: upstream-0.5.18
ImportĀ upstreamĀ versionĀ 0.5.18

Show diffs side-by-side

added added

removed removed

Lines of Context:
273
273
          sections.clear ();
274
274
        }
275
275
 
276
 
      sections.append (SectionsColumn.DISPLAY_NAME, "All Files",
277
 
                       SectionsColumn.ICON_HINT, "", -1);
278
 
      sections.append (SectionsColumn.DISPLAY_NAME, "Documents",
279
 
                       SectionsColumn.ICON_HINT, "", -1);
280
 
      sections.append (SectionsColumn.DISPLAY_NAME, "Folders",
281
 
                       SectionsColumn.ICON_HINT, "", -1);
282
 
      sections.append (SectionsColumn.DISPLAY_NAME, "Images",
283
 
                       SectionsColumn.ICON_HINT, "", -1);
284
 
      sections.append (SectionsColumn.DISPLAY_NAME, "Audio",
285
 
                       SectionsColumn.ICON_HINT, "", -1);
286
 
      sections.append (SectionsColumn.DISPLAY_NAME, "Videos",
287
 
                       SectionsColumn.ICON_HINT, "", -1);
288
 
      sections.append (SectionsColumn.DISPLAY_NAME, "Presentations",
289
 
                       SectionsColumn.ICON_HINT, "", -1);
290
 
      sections.append (SectionsColumn.DISPLAY_NAME, "Other",
 
276
      sections.append (SectionsColumn.DISPLAY_NAME, _("All Files"),
 
277
                       SectionsColumn.ICON_HINT, "", -1);
 
278
      sections.append (SectionsColumn.DISPLAY_NAME, _("Documents"),
 
279
                       SectionsColumn.ICON_HINT, "", -1);
 
280
      sections.append (SectionsColumn.DISPLAY_NAME, _("Folders"),
 
281
                       SectionsColumn.ICON_HINT, "", -1);
 
282
      sections.append (SectionsColumn.DISPLAY_NAME, _("Images"),
 
283
                       SectionsColumn.ICON_HINT, "", -1);
 
284
      sections.append (SectionsColumn.DISPLAY_NAME, _("Audio"),
 
285
                       SectionsColumn.ICON_HINT, "", -1);
 
286
      sections.append (SectionsColumn.DISPLAY_NAME, _("Videos"),
 
287
                       SectionsColumn.ICON_HINT, "", -1);
 
288
      sections.append (SectionsColumn.DISPLAY_NAME, _("Presentations"),
 
289
                       SectionsColumn.ICON_HINT, "", -1);
 
290
      sections.append (SectionsColumn.DISPLAY_NAME, _("Other"),
291
291
                       SectionsColumn.ICON_HINT, "", -1);
292
292
    }
293
293
 
301
301
          groups.clear ();
302
302
        }
303
303
 
304
 
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
305
 
                     GroupsColumn.DISPLAY_NAME, "Top Results",
306
 
                     GroupsColumn.ICON_HINT, "", -1);
307
 
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
308
 
                     GroupsColumn.DISPLAY_NAME, "Recent",
309
 
                     GroupsColumn.ICON_HINT, "", -1);
310
 
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
311
 
                     GroupsColumn.DISPLAY_NAME, "Downloads",
312
 
                     GroupsColumn.ICON_HINT, "", -1);
313
 
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
314
 
                     GroupsColumn.DISPLAY_NAME, "Favorite Folders",
315
 
                     GroupsColumn.ICON_HINT, "", -1);
316
 
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
317
 
                     GroupsColumn.DISPLAY_NAME, "Files",
 
304
      /* Always expand the Favorite Folders group */
 
305
      files.entry_renderer_info.set_hint ("ExpandedGroups",
 
306
                                          @"$((uint)Group.FAVORITE_FOLDERS)");
 
307
 
 
308
      groups.append (GroupsColumn.RENDERER, "UnityFileInfoRenderer",
 
309
                     GroupsColumn.DISPLAY_NAME, _("Top Results"),
 
310
                     GroupsColumn.ICON_HINT, "", -1);
 
311
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
 
312
                     GroupsColumn.DISPLAY_NAME, _("Recent"),
 
313
                     GroupsColumn.ICON_HINT, "", -1);
 
314
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
 
315
                     GroupsColumn.DISPLAY_NAME, _("Downloads"),
 
316
                     GroupsColumn.ICON_HINT, "", -1);
 
317
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
 
318
                     GroupsColumn.DISPLAY_NAME, _("Favorite Folders"),
 
319
                     GroupsColumn.ICON_HINT, "", -1);
 
320
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
 
321
                     GroupsColumn.DISPLAY_NAME, _("Files"),
318
322
                     GroupsColumn.ICON_HINT, "", -1);
319
323
      groups.append (GroupsColumn.RENDERER, "UnityEmptySearchRenderer",
320
 
                     GroupsColumn.DISPLAY_NAME, "No search results",
 
324
                     GroupsColumn.DISPLAY_NAME, "No search results", /* No i18n. Should never be rendered */
321
325
                     GroupsColumn.ICON_HINT, "", -1);
322
326
      groups.append (GroupsColumn.RENDERER, "UnityEmptySectionRenderer",
323
 
                     GroupsColumn.DISPLAY_NAME, "Empty section",
324
 
                     GroupsColumn.ICON_HINT, "", -1);
325
 
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
326
 
                     GroupsColumn.DISPLAY_NAME, "Today",
327
 
                     GroupsColumn.ICON_HINT, "", -1);
328
 
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
329
 
                     GroupsColumn.DISPLAY_NAME, "Yesterday",
330
 
                     GroupsColumn.ICON_HINT, "", -1);
331
 
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
332
 
                     GroupsColumn.DISPLAY_NAME, "This week",
333
 
                     GroupsColumn.ICON_HINT, "", -1);
334
 
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
335
 
                     GroupsColumn.DISPLAY_NAME, "Last Week",
336
 
                     GroupsColumn.ICON_HINT, "", -1);
337
 
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
338
 
                     GroupsColumn.DISPLAY_NAME, "This Month",
339
 
                     GroupsColumn.ICON_HINT, "", -1);
340
 
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
341
 
                     GroupsColumn.DISPLAY_NAME, "Past Six Months",
342
 
                     GroupsColumn.ICON_HINT, "", -1);
343
 
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
344
 
                     GroupsColumn.DISPLAY_NAME, "This Year",
345
 
                     GroupsColumn.ICON_HINT, "", -1);
346
 
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
347
 
                     GroupsColumn.DISPLAY_NAME, "Last Year",
348
 
                     GroupsColumn.ICON_HINT, "", -1);
349
 
      groups.append (GroupsColumn.RENDERER, "Specific Year", // FIXME: Use actual year, eg "2009"
350
 
                     GroupsColumn.DISPLAY_NAME, "Today",
351
 
                     GroupsColumn.ICON_HINT, "", -1);
352
 
      groups.append (GroupsColumn.RENDERER, "UnityDefaultRenderer",
353
 
                     GroupsColumn.DISPLAY_NAME, "Today",
354
 
                     GroupsColumn.ICON_HINT, "", -1);
 
327
                     GroupsColumn.DISPLAY_NAME, "Empty section", /* No i18n. Should never be rendered */
 
328
                     GroupsColumn.ICON_HINT, "", -1);
 
329
      groups.append (GroupsColumn.RENDERER, "UnityFileInfoRenderer",
 
330
                     GroupsColumn.DISPLAY_NAME, _("Today"),
 
331
                     GroupsColumn.ICON_HINT, "", -1);
 
332
      groups.append (GroupsColumn.RENDERER, "UnityFileInfoRenderer",
 
333
                     GroupsColumn.DISPLAY_NAME, _("Yesterday"),
 
334
                     GroupsColumn.ICON_HINT, "", -1);
 
335
      groups.append (GroupsColumn.RENDERER, "UnityFileInfoRenderer",
 
336
                     GroupsColumn.DISPLAY_NAME, _("This week"),
 
337
                     GroupsColumn.ICON_HINT, "", -1);
 
338
      groups.append (GroupsColumn.RENDERER, "UnityFileInfoRenderer",
 
339
                     GroupsColumn.DISPLAY_NAME, _("Last Week"),
 
340
                     GroupsColumn.ICON_HINT, "", -1);
 
341
      groups.append (GroupsColumn.RENDERER, "UnityFileInfoRenderer",
 
342
                     GroupsColumn.DISPLAY_NAME, _("This Month"),
 
343
                     GroupsColumn.ICON_HINT, "", -1);
 
344
      groups.append (GroupsColumn.RENDERER, "UnityFileInfoRenderer",
 
345
                     GroupsColumn.DISPLAY_NAME, _("Past Six Months"),
 
346
                     GroupsColumn.ICON_HINT, "", -1);
 
347
      groups.append (GroupsColumn.RENDERER, "UnityFileInfoRenderer",
 
348
                     GroupsColumn.DISPLAY_NAME, _("This Year"),
 
349
                     GroupsColumn.ICON_HINT, "", -1);
 
350
      groups.append (GroupsColumn.RENDERER, "UnityFileInfoRenderer",
 
351
                     GroupsColumn.DISPLAY_NAME, _("Last Year"),
 
352
                     GroupsColumn.ICON_HINT, "", -1);
 
353
      // FIXME: For prehistoric items use actual year, eg "2009"
 
354
 
355
355
 
356
356
      months = new Gee.ArrayList<unowned Dee.ModelIter?>();
357
357
      months.add(null);
358
358
      for (uint i = 1; i <= DateMonth.DECEMBER; i++)
359
359
      {
360
360
        unowned Dee.ModelIter iter = groups.append (
361
 
                                  GroupsColumn.RENDERER, "UnityDefaultRenderer",
 
361
                                  GroupsColumn.RENDERER, "UnityFileInfoRenderer",
362
362
                                  GroupsColumn.DISPLAY_NAME, Utils.get_month_name ((DateMonth)i),
363
363
                                  GroupsColumn.ICON_HINT, "", -1);
364
364
        months.add(iter);
480
480
 
481
481
    private bool search_is_invalid (Search? search)
482
482
    {
483
 
      return search == null ||
484
 
             search.get_search_string () == null ||
485
 
             search.get_search_string () == "";
 
483
      /* This boolean expression is unfolded as we seem to get
 
484
       * some null dereference if we join them in a big || expression */
 
485
      if (search == null)
 
486
        return true;
 
487
      else if (search.get_search_string () == null)
 
488
        return true;
 
489
      
 
490
      return search.get_search_string () == "";
486
491
    }
487
492
 
488
493
    public void on_results_model_ready (Dee.SharedModel model)
731
736
      
732
737
      foreach (var uri in favorites)
733
738
      {
734
 
        File f = File.new_for_uri (uri);
 
739
        if (uri == "")
 
740
          continue;
 
741
      
735
742
        var icon = Utils.get_icon_for_uri (uri, mimetype);
 
743
        string[] parts = uri.split (" ", 2);
 
744
        string display_name;
 
745
        
 
746
        if (parts.length == 1)
 
747
          {
 
748
            display_name = Uri.unescape_string (uri);
 
749
            display_name = Filename.display_basename (display_name);
 
750
          }
 
751
        else if (parts.length == 2)
 
752
          display_name = parts[1];
 
753
        else
 
754
          {
 
755
            warning ("Internal error computing display name for favorite '%s'",
 
756
                     uri);
 
757
            display_name = uri;
 
758
          }
 
759
        
736
760
        
737
761
        results_model.append (ResultsColumn.URI, uri,
738
762
                              ResultsColumn.ICON_HINT, icon,
739
763
                              ResultsColumn.GROUP_ID, Group.FAVORITE_FOLDERS,
740
764
                              ResultsColumn.MIMETYPE, mimetype,
741
 
                              ResultsColumn.DISPLAY_NAME, f.get_basename (), // FIXME: Should be display name
 
765
                              ResultsColumn.DISPLAY_NAME, display_name,
742
766
                              ResultsColumn.COMMENT, uri,
743
767
                              -1);
744
768
      }
810
834
                                         ResultsColumn.GROUP_ID, group_id,
811
835
                                         ResultsColumn.MIMETYPE, su.get_mimetype(),
812
836
                                         ResultsColumn.DISPLAY_NAME, su.get_text(),
813
 
                                         ResultsColumn.COMMENT, su.get_uri(),
 
837
                                         ResultsColumn.COMMENT, su.get_uri (),
814
838
                                         -1);
815
839
                }
816
840
            }
830
854
     * Override of the default activation handler. The files place daemon
831
855
     * can handle activation of folders which puts it into "folder browsing mode"
832
856
     */
833
 
    public async bool activate (string uri)
 
857
    public async uint32 activate (string uri)
834
858
    {
835
859
      // FIXME (big fixme): revert to normal when done browsing
836
860
      
839
863
      if (f.query_file_type (0, null) != FileType.DIRECTORY)
840
864
        {
841
865
          debug ("Declined activation of URI '%s': Not a directory", uri);
842
 
          return false;
 
866
          return ActivationStatus.NOT_ACTIVATED;
843
867
        }
844
868
      
845
869
      debug ("Browsing folder: %s", uri);
871
895
       
872
896
      browse_folder.begin (f);
873
897
 
874
 
      return true;
 
898
      return ActivationStatus.ACTIVATED_SHOW_DASH;
875
899
      
876
900
    }
877
901
    
975
999
                            ResultsColumn.ICON_HINT, "",
976
1000
                            ResultsColumn.GROUP_ID, Group.EMPTY_SEARCH,
977
1001
                            ResultsColumn.MIMETYPE, "",
978
 
                            ResultsColumn.DISPLAY_NAME, "You search did not match any files",
 
1002
                            ResultsColumn.DISPLAY_NAME, _("You search did not match any files"),
979
1003
                            ResultsColumn.COMMENT, "",
980
1004
                            -1);      
981
1005
      
985
1009
                            ResultsColumn.ICON_HINT, "",
986
1010
                            ResultsColumn.GROUP_ID, Group.EMPTY_SEARCH,
987
1011
                            ResultsColumn.MIMETYPE, "",
988
 
                            ResultsColumn.DISPLAY_NAME, "Search the web",
 
1012
                            ResultsColumn.DISPLAY_NAME, _("Search the web"),
989
1013
                            ResultsColumn.COMMENT, "",
990
1014
                            -1);
991
1015
    }
1001
1025
      switch (section)
1002
1026
      {
1003
1027
        case Section.ALL_FILES:
1004
 
          section_name = "files";
 
1028
          section_name = _("files");
1005
1029
          break;
1006
1030
        case Section.DOCUMENTS:
1007
 
          section_name = "documents";
 
1031
          section_name = _("documents");
1008
1032
          break;
1009
1033
        case Section.FOLDERS:
1010
 
          section_name = "folders";
 
1034
          section_name = _("folders");
1011
1035
          break;
1012
1036
        case Section.IMAGES:
1013
 
          section_name = "images";
 
1037
          section_name = _("images");
1014
1038
          break;
1015
1039
        case Section.AUDIO:
1016
 
          section_name = "audio files";
 
1040
          section_name = _("audio files");
1017
1041
          break;
1018
1042
        case Section.VIDEOS:
1019
 
          section_name = "videos";
 
1043
          section_name = _("videos");
1020
1044
          break;
1021
1045
        case Section.PRESENTATIONS:
1022
 
          section_name = "presentations";
 
1046
          section_name = _("presentations");
1023
1047
          break;
1024
1048
        case Section.OTHER:
1025
 
            section_name = "other files";
 
1049
            section_name = _("other files");
1026
1050
          break;
1027
1051
        default:
1028
 
          section_name = "files";
 
1052
          warning ("Unknown section number: %u", section);
 
1053
          section_name = _("files");
1029
1054
          break;
1030
1055
      }
1031
1056
      
1033
1058
                            ResultsColumn.ICON_HINT, "",
1034
1059
                            ResultsColumn.GROUP_ID, Group.EMPTY_SECTION,
1035
1060
                            ResultsColumn.MIMETYPE, "",
1036
 
                            ResultsColumn.DISPLAY_NAME, @"There are no $section_name in your Home folder",
 
1061
                            ResultsColumn.DISPLAY_NAME, _(@"There are no $section_name in your Home folder"), /* TRANSLATORS: section_name is plural */
1037
1062
                            ResultsColumn.COMMENT, "",
1038
1063
                            -1);
1039
1064
    }
1090
1115
                  string icon = Utils.get_icon_for_uri (uri, mimetype);
1091
1116
                  
1092
1117
                  uint group_id;
 
1118
                  string comment = "";
 
1119
                  
 
1120
                  /* We call this as we want the comment string */
 
1121
                  group_id= Utils.get_time_group (ev, groups, out comment);
 
1122
 
1093
1123
                  if (group_override >= 0)
1094
 
                    group_id = (uint) group_override;
1095
 
                  else
1096
 
                    group_id= Utils.get_time_group (ev, groups);
 
1124
                    {
 
1125
                      group_id = (uint) group_override;
 
1126
                    }
1097
1127
                  
1098
1128
                  //debug ("Got %s, %s, %u, %s", su.get_uri(), su.get_mimetype(), group_id, icon);
1099
 
 
1100
1129
                  results.append (ResultsColumn.URI, uri,
1101
1130
                                  ResultsColumn.ICON_HINT, icon,
1102
1131
                                  ResultsColumn.GROUP_ID, group_id,
1103
1132
                                  ResultsColumn.MIMETYPE, mimetype,
1104
1133
                                  ResultsColumn.DISPLAY_NAME, display_name,
1105
 
                                  ResultsColumn.COMMENT, uri,
 
1134
                                  ResultsColumn.COMMENT, comment,
1106
1135
                                  -1);
1107
1136
                }
1108
1137
            }