~unity-team/unity/trunk

« back to all changes in this revision

Viewing changes to unity-private/launcher/application-controller.vala

  • Committer: Gord Allott
  • Date: 2010-09-24 14:00:21 UTC
  • mfrom: (548.2.2 unity)
  • Revision ID: gord.allott@canonical.com-20100924140021-vmaoavujw3wqvwzh
fixes favorite loading for didrocks, fixes lp:645835

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    private Dbusmenu.Client menu_client;
38
38
    private Dbusmenu.Menuitem cached_menu;
39
39
    private int menu_items_realized_counter;
 
40
    private string _fav_id = "";
 
41
    public string fav_id {
 
42
      get
 
43
        {
 
44
          if (_fav_id == "" || _fav_id == null &&
 
45
              desktop_file != "" && desktop_file != null)
 
46
            {
 
47
              var filepath = desktop_file.split ("/");
 
48
              _fav_id = "app-" + filepath[filepath.length - 1];
 
49
            }
 
50
          return _fav_id;
 
51
        }
 
52
      set { _fav_id = value; }
 
53
    }
40
54
 
41
55
    public bool is_favorite = false;
42
56
 
90
104
 
91
105
      var favorites = Unity.Favorites.get_default ();
92
106
 
93
 
      string uid = favorites.find_uid_for_desktop_file (desktop_file);
94
 
      if (uid == "" || uid == null)
95
 
        {
96
 
          var filepath = desktop_file.split ("/");
97
 
          uid = "app-" + filepath[filepath.length - 1];
98
 
        }
99
 
 
100
107
      if (is_sticky)
101
108
        {
102
 
          favorites.set_string (uid, "type", "application");
103
 
          favorites.set_string (uid, "desktop_file", desktop_file);
104
 
          favorites.add_favorite (uid);
 
109
          favorites.set_string (fav_id, "type", "application");
 
110
          favorites.set_string (fav_id, "desktop_file", desktop_file);
 
111
          favorites.add_favorite (fav_id);
105
112
        }
106
113
      else
107
114
        {
108
 
          favorites.remove_favorite (uid);
 
115
          favorites.remove_favorite (fav_id);
109
116
        }
110
117
    }
111
118
 
115
122
        return false;
116
123
 
117
124
      var favorites = Unity.Favorites.get_default ();
118
 
      string uid = favorites.find_uid_for_desktop_file (desktop_file);
119
 
      if (uid == null || uid == "")
120
 
        return false;
121
 
      else
122
 
        return true;
 
125
      return favorites.is_favorite (fav_id);
123
126
    }
124
127
 
125
128
    public void close_windows ()
136
139
      if (desktop_file == "" || desktop_file == null)
137
140
        return;
138
141
 
139
 
      string uid = "app-" + Path.get_basename (desktop_file);
140
142
      var favorites = Unity.Favorites.get_default ();
141
 
      favorites.set_float (uid, "priority", priority);
 
143
      favorites.set_float (fav_id, "priority", priority);
142
144
    }
143
145
 
144
146
    public float get_priority () throws AppTypeError
146
148
      if (desktop_file == "" || desktop_file == null)
147
149
        throw new AppTypeError.NO_DESKTOP_FILE("There is no desktop file for this app, can't get priority");
148
150
 
149
 
      string uid = "app-" + Path.get_basename (desktop_file);
150
151
      var favorites = Unity.Favorites.get_default ();
151
 
      return favorites.get_float (uid, "priority");
 
152
      return favorites.get_float (fav_id, "priority");
152
153
    }
153
154
 
154
155
    private void on_favorite_added (string uid)
155
156
    {
156
157
      //check to see if we are the favorite
157
 
      var favorites = Unity.Favorites.get_default ();
158
 
      var desktop_filename = favorites.get_string (uid, "desktop_file");
159
 
      if (desktop_filename == desktop_file)
 
158
      if (uid == fav_id)
160
159
        {
161
160
          is_favorite = true;
162
161
          child.pin_type = PinType.PINNED;
165
164
 
166
165
    private void on_favorite_removed (string uid)
167
166
    {
168
 
      var favorites = Unity.Favorites.get_default ();
169
 
      var desktop_filename = favorites.get_string (uid, "desktop_file");
170
 
      if (desktop_filename == desktop_file)
 
167
      if (uid == fav_id)
171
168
        {
172
169
          is_favorite = false;
173
170
          child.pin_type = PinType.UNPINNED;
174
171
          closed ();
175
 
          if (".local" in desktop_filename)
176
 
           FileUtils.remove (desktop_filename);
 
172
          if (".local" in desktop_file)
 
173
           FileUtils.remove (desktop_file);
177
174
        }
178
175
    }
179
176