コード例 #1
0
ファイル: workspace-switcher.c プロジェクト: oz123/mate-panel
static void workspace_renamed(MatewnckWorkspace* space, PagerData* pager)
{
	int i;
	GtkTreeIter iter;

	i = matewnck_workspace_get_number(space);

	if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(pager->workspaces_store), &iter, NULL, i))
		gtk_list_store_set(pager->workspaces_store, &iter, 0, matewnck_workspace_get_name(space), -1);
}
コード例 #2
0
ファイル: selector.c プロジェクト: bftanase/libmatewnck
static void
matewnck_selector_workspace_name_changed (MatewnckWorkspace *workspace,
                                      GtkLabel      *label)
{
  GtkStyle *style;
  GdkColor *color;
  char     *name;
  char     *markup;

  style = gtk_widget_get_style (GTK_WIDGET (label));
  color = &style->fg[GTK_STATE_INSENSITIVE];

  name = g_markup_escape_text (matewnck_workspace_get_name (workspace), -1);
  markup = g_strdup_printf ("<span size=\"x-small\" style=\"italic\" foreground=\"#%.2x%.2x%.2x\">%s</span>",
                            color->red, color->green, color->blue, name);
  g_free (name);

  gtk_label_set_markup (label, markup);
  g_free (markup);
}
コード例 #3
0
ファイル: workspace-switcher.c プロジェクト: oz123/mate-panel
static void update_workspaces_model(PagerData* pager)
{
	int nr_ws, i;
	MatewnckWorkspace* workspace;
	GtkTreeIter iter;

	nr_ws = matewnck_screen_get_workspace_count(pager->screen);

	if (pager->properties_dialog)
	{
		if (nr_ws != gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(pager->num_workspaces_spin)))
			gtk_spin_button_set_value(GTK_SPIN_BUTTON(pager->num_workspaces_spin), nr_ws);

		gtk_list_store_clear(pager->workspaces_store);

		for (i = 0; i < nr_ws; i++)
		{
			workspace = matewnck_screen_get_workspace(pager->screen, i);
			gtk_list_store_append(pager->workspaces_store, &iter);
			gtk_list_store_set(pager->workspaces_store, &iter, 0, matewnck_workspace_get_name(workspace), -1);
		}
	}
}
コード例 #4
0
static char *
get_workspace_name_with_accel (MatewnckWindow *window,
			       int index)
{
  const char *name;
  int number;

  name = matewnck_workspace_get_name (matewnck_screen_get_workspace (matewnck_window_get_screen (window),
				  index));

  g_assert (name != NULL);

  /*
   * If the name is of the form "Workspace x" where x is an unsigned
   * integer, insert a '_' before the number if it is less than 10 and
   * return it
   */
  number = 0;
  if (sscanf (name, _("Workspace %d"), &number) == 1) {
      /* Keep this in sync with what is in refill_submenu_viewport() */
      char *new_name;

      /*
       * Above name is a pointer into the Workspace struct. Here we make
       * a copy copy so we can have our wicked way with it.
       */
      if (number == 10)
        new_name = g_strdup_printf (_("Workspace 1_0"));
      else
        new_name = g_strdup_printf (_("Workspace %s%d"),
                                    number < 10 ? "_" : "",
                                    number);
      return new_name;
  }
  else {
      /*
       * Otherwise this is just a normal name. Escape any _ characters so that
       * the user's workspace names do not get mangled.  If the number is less
       * than 10 we provide an accelerator.
       */
      char *new_name;
      const char *source;
      char *dest;

      /*
       * Assume the worst case, that every character is a _.  We also
       * provide memory for " (_#)"
       */
      new_name = g_malloc0 (strlen (name) * 2 + 6 + 1);

      /*
       * Now iterate down the strings, adding '_' to escape as we go
       */
      dest = new_name;
      source = name;
      while (*source != '\0') {
          if (*source == '_')
            *dest++ = '_';
          *dest++ = *source++;
      }

      /* People don't start at workstation 0, but workstation 1 */
      if (index < 9) {
          g_snprintf (dest, 6, " (_%d)", index + 1);
      }
      else if (index == 9) {
          g_snprintf (dest, 6, " (_0)");
      }

      return new_name;
  }
}