~feng-kylin/ubuntu-kylin-wizard/trunk

« back to all changes in this revision

Viewing changes to src/style.cpp

  • Committer: handsome_feng
  • Date: 2016-07-15 09:14:12 UTC
  • Revision ID: 445865575@qq.com-20160715091412-blz57nd8z4lmijx5
Use pango instead of gtkLabel to draw the text

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
 
55
55
const double DEFAULT_DPI = 96.0f;
56
56
 
 
57
gboolean get_app_installed(const gchar *app_name)
 
58
{
 
59
  gchar *path = g_find_program_in_path(app_name);
 
60
  if (path)
 
61
    return true;
 
62
  else
 
63
    return false;
 
64
}
 
65
 
 
66
 
57
67
void Style::UpdateDPI()
58
68
{
59
69
  GSettings *ubuntu_ui_settings = g_settings_new(UBUNTU_UI_SETTINGS.c_str());
111
121
    left_arrow_pos_.x = 0.05 * (pri_monitor_width_ - ARROW_WIDTH);
112
122
    left_arrow_pos_.y = 0.5 * (pri_monitor_height_ - ARROW_HEIGHT);
113
123
 
114
 
    right_arrow_pos_.x = 0.95 * (pri_monitor_width_ - ARROW_WIDTH);
115
 
    right_arrow_pos_.y = 0.5 * (pri_monitor_height_ - ARROW_HEIGHT);
116
 
 
117
124
    base_pos_.x = 0.125 * pri_monitor_width_;
118
125
    base_pos_.y = 0.25 * pri_monitor_height_;
119
126
 
121
128
    title_pos_.y = 0.25 * pri_monitor_height_;
122
129
 
123
130
    subtitle_pos_.x = title_pos_.x;
124
 
    subtitle_pos_.y = 0.35 * pri_monitor_height_;
 
131
    subtitle_pos_.y = 0.33 * pri_monitor_height_;
125
132
 
126
133
    details_pos_.x = title_pos_.x;
127
134
    details_pos_.y = 0.4 * pri_monitor_height_;
129
136
    close_pos_.x = 0.5 * pri_monitor_width_;
130
137
    close_pos_.y = 0.9 * (pri_monitor_height_ - launcher_size_);
131
138
 
132
 
    page_ind_pos_.x = 0.75 * pri_monitor_width_;
133
 
    page_ind_pos_.y = close_pos_.y + (CLOSE_BUTTON_HEIGHT - PAGE_IND_HEIGTH) / 2;
134
 
 
135
139
    spot_pos_.x = (base_pos_.x + 422 + title_pos_.x) / 2;
136
140
    spot_pos_.y = 0.25 * pri_monitor_height_;
137
141
 
143
147
    left_arrow_pos_.x = 0.05 * (pri_monitor_width_ - ARROW_WIDTH) + launcher_size_;
144
148
    left_arrow_pos_.y = 0.5 * (pri_monitor_height_ - ARROW_HEIGHT);
145
149
 
146
 
    right_arrow_pos_.x = 0.95 * (pri_monitor_width_ - ARROW_WIDTH);
147
 
    right_arrow_pos_.y = 0.5 * (pri_monitor_height_ - ARROW_HEIGHT);
148
 
 
149
150
    base_pos_.x = 0.55 * pri_monitor_width_;
150
151
    base_pos_.y = 0.25 * pri_monitor_height_;
151
152
 
153
154
    spot_pos_.y = 0.25 * pri_monitor_height_;
154
155
 
155
156
    title_pos_.x = 0.125 * pri_monitor_width_;
156
 
    title_pos_.y = spot_pos_.y - 70;
 
157
    title_pos_.y = spot_pos_.y;
157
158
 
158
159
    subtitle_pos_.x = title_pos_.x;
159
 
    subtitle_pos_.y = spot_pos_.y + 10;
 
160
    subtitle_pos_.y = 0.33 * pri_monitor_height_;
160
161
 
161
162
    details_pos_.x = title_pos_.x;
162
 
    details_pos_.y = subtitle_pos_.y + 10;
 
163
    details_pos_.y = 0.4 * pri_monitor_height_;
163
164
 
164
165
    close_pos_.x = 0.125 * pri_monitor_width_;
165
166
    close_pos_.y = 0.9 * (pri_monitor_height_ - launcher_size_);
166
167
 
167
 
    page_ind_pos_.x = 0.75 * pri_monitor_width_;
168
 
    page_ind_pos_.y = close_pos_.y + (CLOSE_BUTTON_HEIGHT - PAGE_IND_HEIGTH) / 2;
169
 
 
170
168
    inflexion_pos_.x = (launcher_size_ + title_pos_.x) / 2;
171
169
    inflexion_pos_.y = (panel_height_ + base_pos_.y) / 2;  // This is only use for the last page(indicator).
172
170
  }
173
171
 
 
172
  right_arrow_pos_.x = 0.95 * (pri_monitor_width_ - ARROW_WIDTH);
 
173
  right_arrow_pos_.y = 0.5 * (pri_monitor_height_ - ARROW_HEIGHT);
 
174
 
 
175
  page_ind_pos_.x = 0.75 * pri_monitor_width_;
 
176
  page_ind_pos_.y = close_pos_.y + (CLOSE_BUTTON_HEIGHT - PAGE_IND_HEIGTH) / 2;
 
177
 
174
178
  icon_order_[0] = LAUNCHER;
175
179
  icon_order_[1] = 0;
176
180
  icon_order_[2] = get_icon_order("Nautilus");
177
 
  icon_order_[3] = get_icon_order("youker-assistant");
 
181
  if (get_app_installed("youker-assistant"))
 
182
    icon_order_[3] = get_icon_order("youker-assistant");
 
183
  else
 
184
    icon_order_[3] = get_icon_order("Software");
178
185
  icon_order_[4] = get_icon_order("unity-control-center");
179
186
  icon_order_[5] = UNDER_PANEL;
180
187
 
252
259
    std::string value = strings[i];
253
260
 
254
261
    if (value.find("devices") != std::string::npos || value.find("running") != std::string::npos ||
255
 
        value.find("expo-icon") != std::string::npos || value.find("ubiquity") != std::string::npos)
 
262
        value.find("ubiquity") != std::string::npos)
256
263
      adjust--;
257
264
 
258
265
    if (!value.empty() && value.find(icon_name) != std::string::npos)
349
356
  else
350
357
  {
351
358
    focus.x = launcher_size_;
352
 
    focus.y = panel_height_ + index * (icon_size_.CP(cv_) + SPACE_BETWEEN_ICONS.CP(cv_)) + icon_size_.CP(cv_);
 
359
    focus.y = panel_height_ + index * (icon_size_.CP(cv_) + SPACE_BETWEEN_ICONS.CP(cv_)) + SPACE_BETWEEN_ICONS.CP(cv_) + 0.5 * icon_size_.CP(cv_);
353
360
  }
354
361
 
355
362
  return focus;