Пример #1
0
static GtkWidget *
glade_eprop_accel_view (GladeEditorProperty * eprop)
{
  GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
  GtkWidget *view_widget;
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;

  eprop_accel->model = (GtkTreeModel *) 
    gtk_tree_store_new (ACCEL_NUM_COLUMNS, G_TYPE_STRING,   /* The GSignal name formatted for display */
			G_TYPE_STRING,      /* The GSignal name */
			G_TYPE_STRING,      /* The text to show in the accelerator cell */
			G_TYPE_INT, /* PangoWeight attribute for bold headers */
			G_TYPE_INT, /* PangoStyle attribute for italic grey unset items */
			G_TYPE_STRING,      /* Foreground colour for italic grey unset items */
			G_TYPE_BOOLEAN,     /* Visible attribute to hide items for header entries */
			G_TYPE_BOOLEAN,     /* Whether the key has been entered for this row */
			G_TYPE_UINT,        /* Hardware keycode */
			G_TYPE_INT);        /* GdkModifierType */
  
  view_widget = gtk_tree_view_new_with_model (eprop_accel->model);
  gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (view_widget), FALSE);
  gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view_widget), FALSE);

  /********************* signal name column *********************/
  renderer = gtk_cell_renderer_text_new ();
  g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);

  column = gtk_tree_view_column_new_with_attributes
      (_("Signal"), renderer,
       "text", ACCEL_COLUMN_SIGNAL, "weight", ACCEL_COLUMN_WEIGHT, NULL);


  gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
  gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);

  /********************* accel editor column *********************/
  renderer = gtk_cell_renderer_accel_new ();
  g_object_set (G_OBJECT (renderer), "editable", TRUE, NULL);

  g_signal_connect (renderer, "accel-edited", G_CALLBACK (accel_edited), eprop);
  g_signal_connect (renderer, "accel-cleared",
                    G_CALLBACK (accel_cleared), eprop);

  column = gtk_tree_view_column_new_with_attributes
      (_("Accelerator Key"), renderer,
       "text", ACCEL_COLUMN_TEXT,
       "foreground", ACCEL_COLUMN_FOREGROUND,
       "style", ACCEL_COLUMN_STYLE, "visible", ACCEL_COLUMN_VISIBLE, NULL);

  gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
  gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);

  return view_widget;
}
Пример #2
0
static GtkWidget *
key_test (void)
{
	GtkWidget *window, *sw, *tv;
	GtkListStore *store;
	GtkTreeViewColumn *column;
	GtkCellRenderer *rend;
	gint i;

	/* create window */
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);


	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_container_add (GTK_CONTAINER (window), sw);

	store = gtk_list_store_new (3, G_TYPE_INT, G_TYPE_UINT, G_TYPE_UINT);
	tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
	gtk_container_add (GTK_CONTAINER (sw), tv);
	column = gtk_tree_view_column_new ();
	rend = gtk_cell_renderer_accel_new ();
	g_object_set (G_OBJECT (rend), 
		      "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_GTK, 
                      "editable", TRUE, 
		      NULL);
	g_signal_connect (G_OBJECT (rend),
			  "accel-edited",
			  G_CALLBACK (accel_edited_callback),
			  store);

	gtk_tree_view_column_pack_start (column, rend,
					 TRUE);
	gtk_tree_view_column_set_attributes (column, rend,
					     "accel-mods", 0,
					     "accel-key", 1,
					     "keycode", 2,
					     NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tv), column);

	for (i = 0; i < 10; i++) {
		GtkTreeIter iter;

		gtk_list_store_append (store, &iter);
	}

	/* done */

	return window;
}
Пример #3
0
GtkWidget* create_hotkey_editor(void)
{
	GtkWidget *hotkey_tree_view = NULL;
	GtkCellRenderer *renderer = NULL;
	GtkListStore  *model = NULL;
	GtkTreeViewColumn *column = NULL;
	GtkTreeIter iter = {0};

	/* create a tree view */
	hotkey_tree_view = gtk_tree_view_new();
	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(hotkey_tree_view), FALSE);
	g_signal_connect (hotkey_tree_view, "button-press-event", G_CALLBACK (start_editing_cb), NULL);
	g_signal_connect (hotkey_tree_view, "row-activated", G_CALLBACK (start_editing_keybd_cb), NULL);
	g_object_set(hotkey_tree_view, "visible", TRUE, NULL);

	/* create the Egg Cell Renderer and connect to signals */
	renderer = (GtkCellRenderer*) gtk_cell_renderer_accel_new ();
	g_object_set(renderer, "editable", TRUE, NULL);
	g_signal_connect (renderer, "accel-edited", G_CALLBACK (accel_edited_callback), hotkey_tree_view);
	g_signal_connect (renderer, "accel-cleared", G_CALLBACK (accel_cleared_callback), hotkey_tree_view);

	/* create a column and set the created renderer - append the same to the tree view */
	column = gtk_tree_view_column_new_with_attributes ("Shortcut", renderer, NULL);
	/* since it's a custom renderer, setting the data to the cell needs to be custom as well */
	gtk_tree_view_column_set_cell_data_func (column, renderer, accel_set_func, NULL, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW(hotkey_tree_view), column);

	/* create the list store for the tree */
	model = gtk_list_store_new (1, G_TYPE_POINTER);
	gtk_tree_view_set_model (GTK_TREE_VIEW (hotkey_tree_view), GTK_TREE_MODEL(model));

	gtk_list_store_append (model, &iter);
	gtk_list_store_set (model, &iter, HOTKEY_COLUMN, &app_hotkey, -1);

	/* The tree view has acquired its own reference to the
	*  model, so we can drop ours. That way the model will
	*  be freed automatically when the tree view is destroyed */
	g_object_unref (model);

	g_object_set(hotkey_tree_view, "visible", TRUE, NULL);

	return hotkey_tree_view;
}
Пример #4
0
JNIEXPORT jlong JNICALL
Java_org_gnome_gtk_GtkCellRendererAccel_gtk_1cell_1renderer_1accel_1new
(
	JNIEnv* env,
	jclass cls
)
{
	GtkCellRenderer* result;
	jlong _result;

	// call function
	result = gtk_cell_renderer_accel_new();

	// translate return value to JNI type
	_result = (jlong) result;

	// cleanup return value
	if (result != NULL) {
		bindings_java_memory_cleanup((GObject*)result, TRUE);
	}

	// and finally
	return _result;
}
Пример #5
0
GtkWidget *
gimp_action_view_new (GimpUIManager *manager,
                      const gchar   *select_action,
                      gboolean       show_shortcuts)
{
  GtkTreeView       *view;
  GtkTreeViewColumn *column;
  GtkCellRenderer   *cell;
  GtkTreeStore      *store;
  GtkTreeModel      *filter;
  GtkAccelGroup     *accel_group;
  GList             *list;
  GtkTreePath       *select_path = NULL;

  g_return_val_if_fail (GIMP_IS_UI_MANAGER (manager), NULL);

  store = gtk_tree_store_new (GIMP_ACTION_VIEW_N_COLUMNS,
                              G_TYPE_BOOLEAN,         /* COLUMN_VISIBLE        */
                              GTK_TYPE_ACTION,        /* COLUMN_ACTION         */
                              G_TYPE_STRING,          /* COLUMN_STOCK_ID       */
                              G_TYPE_STRING,          /* COLUMN_LABEL          */
                              G_TYPE_STRING,          /* COLUMN_LABEL_CASEFOLD */
                              G_TYPE_STRING,          /* COLUMN_NAME           */
                              G_TYPE_UINT,            /* COLUMN_ACCEL_KEY      */
                              GDK_TYPE_MODIFIER_TYPE, /* COLUMN_ACCEL_MASK     */
                              G_TYPE_CLOSURE);        /* COLUMN_ACCEL_CLOSURE  */

  accel_group = gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (manager));

  for (list = gtk_ui_manager_get_action_groups (GTK_UI_MANAGER (manager));
       list;
       list = g_list_next (list))
    {
      GimpActionGroup *group = list->data;
      GList           *actions;
      GList           *list2;
      GtkTreeIter      group_iter;

      gtk_tree_store_append (store, &group_iter, NULL);

      gtk_tree_store_set (store, &group_iter,
                          GIMP_ACTION_VIEW_COLUMN_STOCK_ID, group->stock_id,
                          GIMP_ACTION_VIEW_COLUMN_LABEL,    group->label,
                          -1);

      actions = gtk_action_group_list_actions (GTK_ACTION_GROUP (group));

      actions = g_list_sort (actions, (GCompareFunc) gimp_action_name_compare);

      for (list2 = actions; list2; list2 = g_list_next (list2))
        {
          GtkAction       *action        = list2->data;
          const gchar     *name          = gtk_action_get_name (action);
          const gchar     *stock_id      = gtk_action_get_stock_id (action);
          gchar           *label;
          gchar           *label_casefold;
          guint            accel_key     = 0;
          GdkModifierType  accel_mask    = 0;
          GClosure        *accel_closure = NULL;
          GtkTreeIter      action_iter;

          if (strstr (name, "-menu")  ||
              strstr (name, "-popup") ||
              name[0] == '<')
            continue;

          label = gimp_strip_uline (gtk_action_get_label (action));

          if (! (label && strlen (label)))
            {
              g_free (label);
              label = g_strdup (name);
            }

          label_casefold = g_utf8_casefold (label, -1);

          if (show_shortcuts)
            {
              accel_closure = gtk_action_get_accel_closure (action);

              if (accel_closure)
                {
                  GtkAccelKey *key;

                  key = gtk_accel_group_find (accel_group,
                                              gimp_action_view_accel_find_func,
                                              accel_closure);

                  if (key            &&
                      key->accel_key &&
                      key->accel_flags & GTK_ACCEL_VISIBLE)
                    {
                      accel_key  = key->accel_key;
                      accel_mask = key->accel_mods;
                    }
                }
            }

          gtk_tree_store_append (store, &action_iter, &group_iter);

          gtk_tree_store_set (store, &action_iter,
                              GIMP_ACTION_VIEW_COLUMN_VISIBLE,        TRUE,
                              GIMP_ACTION_VIEW_COLUMN_ACTION,         action,
                              GIMP_ACTION_VIEW_COLUMN_STOCK_ID,       stock_id,
                              GIMP_ACTION_VIEW_COLUMN_LABEL,          label,
                              GIMP_ACTION_VIEW_COLUMN_LABEL_CASEFOLD, label_casefold,
                              GIMP_ACTION_VIEW_COLUMN_NAME,           name,
                              GIMP_ACTION_VIEW_COLUMN_ACCEL_KEY,      accel_key,
                              GIMP_ACTION_VIEW_COLUMN_ACCEL_MASK,     accel_mask,
                              GIMP_ACTION_VIEW_COLUMN_ACCEL_CLOSURE,  accel_closure,
                              -1);

          g_free (label);
          g_free (label_casefold);

          if (select_action && ! strcmp (select_action, name))
            {
              select_path = gtk_tree_model_get_path (GTK_TREE_MODEL (store),
                                                     &action_iter);
            }
        }

      g_list_free (actions);
    }

  filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);

  g_object_unref (store);

  view = g_object_new (GIMP_TYPE_ACTION_VIEW,
                       "model",      filter,
                       "rules-hint", TRUE,
                       NULL);

  g_object_unref (filter);

  gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER (filter),
                                            GIMP_ACTION_VIEW_COLUMN_VISIBLE);

  GIMP_ACTION_VIEW (view)->manager        = g_object_ref (manager);
  GIMP_ACTION_VIEW (view)->show_shortcuts = show_shortcuts;

  gtk_tree_view_set_search_column (GTK_TREE_VIEW (view),
                                   GIMP_ACTION_VIEW_COLUMN_LABEL);

  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column, _("Action"));

  cell = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (column, cell, FALSE);
  gtk_tree_view_column_set_attributes (column, cell,
                                       "stock-id",
                                       GIMP_ACTION_VIEW_COLUMN_STOCK_ID,
                                       NULL);

  cell = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column, cell, TRUE);
  gtk_tree_view_column_set_attributes (column, cell,
                                       "text",
                                       GIMP_ACTION_VIEW_COLUMN_LABEL,
                                       NULL);

  gtk_tree_view_append_column (view, column);

  if (show_shortcuts)
    {
      g_signal_connect (view, "button-press-event",
                        G_CALLBACK (gimp_action_view_button_press),
                        NULL);

      g_signal_connect (accel_group, "accel-changed",
                        G_CALLBACK (gimp_action_view_accel_changed),
                        view);

      column = gtk_tree_view_column_new ();
      gtk_tree_view_column_set_title (column, _("Shortcut"));

      cell = gtk_cell_renderer_accel_new ();
      g_object_set (cell,
                    "mode",     GTK_CELL_RENDERER_MODE_EDITABLE,
                    "editable", TRUE,
                    NULL);
      gtk_tree_view_column_pack_start (column, cell, TRUE);
      gtk_tree_view_column_set_attributes (column, cell,
                                           "accel-key",
                                           GIMP_ACTION_VIEW_COLUMN_ACCEL_KEY,
                                           "accel-mods",
                                           GIMP_ACTION_VIEW_COLUMN_ACCEL_MASK,
                                           NULL);

      g_signal_connect (cell, "accel-edited",
                        G_CALLBACK (gimp_action_view_accel_edited),
                        view);
      g_signal_connect (cell, "accel-cleared",
                        G_CALLBACK (gimp_action_view_accel_cleared),
                        view);

      gtk_tree_view_append_column (view, column);
    }

  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column, _("Name"));

  cell = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column, cell, TRUE);
  gtk_tree_view_column_set_attributes (column, cell,
                                       "text",
                                       GIMP_ACTION_VIEW_COLUMN_NAME,
                                       NULL);

  gtk_tree_view_append_column (view, column);

  if (select_path)
    {
      gimp_action_view_select_path (GIMP_ACTION_VIEW (view), select_path);
      gtk_tree_path_free (select_path);
    }

  return GTK_WIDGET (view);
}
Пример #6
0
static GtkWidget*
shortcuts_get_preferences_dialog (MidoriExtension* extension)
{
    MidoriApp* app;
    GtkWidget* browser;
    const gchar* dialog_title;
    GtkWidget* dialog;
    gint width, height;
    GtkWidget* xfce_heading;
    GtkWidget* hbox;
    GtkListStore* liststore;
    GtkTreeModel* model;
    GtkWidget* treeview;
    GtkTreeViewColumn* column;
    GtkCellRenderer* renderer;
    GtkWidget* scrolled;
    GtkActionGroup* action_group;
    GList* actions;
    guint i;
    GtkAction* action;
    #if HAVE_OSX
    GtkWidget* icon;
    #endif

    app = midori_extension_get_app (extension);
    browser = katze_object_get_object (app, "browser");

    dialog_title = _("Customize Keyboard shortcuts");
    dialog = gtk_dialog_new_with_buttons (dialog_title, GTK_WINDOW (browser),
        GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
        #if !HAVE_OSX
        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
        #endif
        NULL);
    g_signal_connect (dialog, "destroy",
                      G_CALLBACK (gtk_widget_destroyed), &dialog);
    gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PROPERTIES);
    sokoke_widget_get_text_size (dialog, "M", &width, &height);
    gtk_window_set_default_size (GTK_WINDOW (dialog), width * 52, height * 24);
    g_signal_connect (dialog, "response",
                      G_CALLBACK (shortcuts_preferences_response_cb), NULL);
    if ((xfce_heading = sokoke_xfce_header_new (
        gtk_window_get_icon_name (GTK_WINDOW (dialog)), dialog_title)))
        gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
                            xfce_heading, FALSE, FALSE, 0);
    hbox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
                                 TRUE, TRUE, 12);
    liststore = gtk_list_store_new (7,
        G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_BOOLEAN,
        G_TYPE_STRING, GTK_TYPE_ACTION);
    model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (liststore));
    treeview = gtk_tree_view_new_with_model (model);
    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
    column = gtk_tree_view_column_new ();
    renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_column_pack_start (column, renderer, FALSE);
    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "text", 0);
    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
    column = gtk_tree_view_column_new ();
    renderer = gtk_cell_renderer_accel_new ();
    gtk_tree_view_column_pack_start (column, renderer, TRUE);
    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "accel-key", 1);
    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "accel-mods", 2);
    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "accel-mode", 3);
    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "sensitive", 4);
    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "editable", 4);
    g_signal_connect (renderer, "accel-edited",
        G_CALLBACK (shortcuts_accel_edited_cb), model);
    g_signal_connect (renderer, "accel-cleared",
        G_CALLBACK (shortcuts_accel_cleared_cb), model);
    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
    scrolled = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
                                    GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_container_add (GTK_CONTAINER (scrolled), treeview);
    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
                                         GTK_SHADOW_IN);
    gtk_box_pack_start (GTK_BOX (hbox), scrolled, TRUE, TRUE, 5);

    action_group = midori_browser_get_action_group (MIDORI_BROWSER (browser));
    actions = gtk_action_group_list_actions (action_group);
    i = 0;
    /* FIXME: Catch added and removed actions */
    while ((action = g_list_nth_data (actions, i++)))
    {
        gchar* label = shortcuts_label_for_action (action);
        GtkAccelKey key;
        gboolean has_hotkey = shortcuts_hotkey_for_action (action, &key);
        gtk_list_store_insert_with_values (GTK_LIST_STORE (liststore),
            NULL, G_MAXINT, 0, label, 1, key.accel_key, 2, key.accel_mods,
                            3, GTK_CELL_RENDERER_ACCEL_MODE_OTHER,
                            4, has_hotkey, 6, action, -1);
        g_free (label);
    }
    g_list_free (actions);

    g_object_unref (liststore);
    gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
                                          0, GTK_SORT_ASCENDING);
    g_object_unref (model);

    gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);

    g_object_unref (browser);

    return dialog;
}
Пример #7
0
static GtkWidget *
key_dialog_treeview_new (GtkWidget *box)
{
	GtkWidget *scroll;
	GtkListStore *store, *combostore;
	GtkTreeViewColumn *col;
	GtkWidget *view;
	GtkCellRenderer *render;
	int i;

	scroll = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);

	store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
								G_TYPE_STRING, G_TYPE_STRING);
	g_return_val_if_fail (store != NULL, NULL);

	view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
	gtk_tree_view_set_fixed_height_mode (GTK_TREE_VIEW (view), TRUE);
	gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), FALSE);
	gtk_tree_view_set_reorderable (GTK_TREE_VIEW (view), TRUE);

	g_signal_connect (G_OBJECT (view), "key-press-event",
					G_CALLBACK (key_dialog_keypress), NULL);
	g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW(view))),
					"changed", G_CALLBACK (key_dialog_selection_changed), NULL);

	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (view), TRUE);

	render = gtk_cell_renderer_accel_new ();
	g_object_set (render, "editable", TRUE,
#ifndef WIN32
					"accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_OTHER,
#endif
					NULL);
	g_signal_connect (G_OBJECT (render), "accel-edited",
					G_CALLBACK (key_dialog_set_key), NULL);
	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), KEY_COLUMN,
												"Key", render,
												"text", KEY_COLUMN,
												NULL);

	render = gtk_cell_renderer_text_new ();
	gtk_tree_view_insert_column_with_attributes (
							GTK_TREE_VIEW (view), ACCEL_COLUMN,
							"Accel", render,
							"text", ACCEL_COLUMN,
							NULL);

	combostore = gtk_list_store_new (1, G_TYPE_STRING);
	for (i = 0; i <= KEY_MAX_ACTIONS; i++)
	{
		GtkTreeIter iter;

		if (key_actions[i].name[0])
		{
			gtk_list_store_append (combostore, &iter);
			gtk_list_store_set (combostore, &iter, 0, key_actions[i].name, -1);
		}
	}

	render = gtk_cell_renderer_combo_new ();
	g_object_set (G_OBJECT (render), "model", combostore,
									"has-entry", FALSE,
									"editable", TRUE, 
									"text-column", 0,
									NULL);
	g_signal_connect (G_OBJECT (render), "edited",
					G_CALLBACK (key_dialog_entry_edited), GINT_TO_POINTER (ACTION_COLUMN));
	g_signal_connect (G_OBJECT (render), "changed",
					G_CALLBACK (key_dialog_combo_changed), combostore);
	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), ACTION_COLUMN,
													"Action", render,
													"text", ACTION_COLUMN, 
													NULL);

	render = gtk_cell_renderer_text_new ();
	g_object_set (render, "editable", TRUE, NULL);
	g_signal_connect (G_OBJECT (render), "edited",
				G_CALLBACK (key_dialog_entry_edited), GINT_TO_POINTER (D1_COLUMN));
	gtk_tree_view_insert_column_with_attributes (
							GTK_TREE_VIEW (view), D1_COLUMN,
							"Data1", render,
							"text", D1_COLUMN,
							NULL);

	render = gtk_cell_renderer_text_new ();
	g_object_set (render, "editable", TRUE, NULL);
	g_signal_connect (G_OBJECT (render), "edited",
				G_CALLBACK (key_dialog_entry_edited), GINT_TO_POINTER (D2_COLUMN));
	gtk_tree_view_insert_column_with_attributes (
							GTK_TREE_VIEW (view), D2_COLUMN,
							"Data2", render,
							"text", D2_COLUMN,
							NULL);

	col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), KEY_COLUMN);
	gtk_tree_view_column_set_fixed_width (col, 200);
	gtk_tree_view_column_set_resizable (col, TRUE);
	col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), ACCEL_COLUMN);
	gtk_tree_view_column_set_visible (col, FALSE);
	col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), ACTION_COLUMN);
	gtk_tree_view_column_set_fixed_width (col, 160);
	col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), D1_COLUMN);
	gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
	gtk_tree_view_column_set_min_width (col, 80);
	gtk_tree_view_column_set_resizable (col, TRUE);
	col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), D2_COLUMN);
	gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
	gtk_tree_view_column_set_min_width (col, 80);
	gtk_tree_view_column_set_resizable (col, TRUE);

	gtk_container_add (GTK_CONTAINER (scroll), view);
	gtk_container_add (GTK_CONTAINER (box), scroll);

	return view;
}
Пример #8
0
static GObject *
games_controls_list_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam *construct_params)
{
  GObject *object;
  GamesControlsList *list;
  GtkScrolledWindow *scrolled_window;
  GtkTreeViewColumn *column;
  GtkCellRenderer *label_renderer, *key_renderer;
  GtkListStore *store;

  object = G_OBJECT_CLASS (games_controls_list_parent_class)->constructor
             (type, n_construct_properties, construct_params);

  list = GAMES_CONTROLS_LIST (object);
  scrolled_window = GTK_SCROLLED_WINDOW (object);

  store = gtk_list_store_new (N_COLUMNS,
                              G_TYPE_STRING,
                              G_TYPE_STRING,
                              G_TYPE_UINT,
                              G_TYPE_UINT,
                              G_TYPE_UINT,
                              G_TYPE_UINT);
  list->priv->store = store;
  list->priv->model = GTK_TREE_MODEL (store);

  list->priv->view = gtk_tree_view_new_with_model (list->priv->model);
  g_object_unref (store);

  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (list->priv->view), FALSE);
  gtk_tree_view_set_enable_search (GTK_TREE_VIEW (list->priv->view), FALSE);

  /* label column */
  label_renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("Control",
						     label_renderer,
						     "text", LABEL_COLUMN,
						     NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (list->priv->view), column);

  /* key column */
  key_renderer = gtk_cell_renderer_accel_new ();
  g_object_set (key_renderer,
                "editable", TRUE,
                "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_OTHER,
                NULL);
  g_signal_connect (key_renderer, "accel-edited",
                    G_CALLBACK (accel_edited_cb), list);
  g_signal_connect (key_renderer, "accel-cleared",
                    G_CALLBACK (accel_cleared_cb), list);

  column = gtk_tree_view_column_new_with_attributes ("Key",
						     key_renderer,
                                                     "accel-key", KEYCODE_COLUMN,
                                                     "accel-mods", KEYMODS_COLUMN,
						     NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (list->priv->view), column);

  gtk_container_add (GTK_CONTAINER (scrolled_window), list->priv->view);

  return object;
}
Пример #9
0
/*#
    @class GtkCellRendererAccel
    @brief Renders a keyboard accelerator in a cell

    GtkCellRendererAccel displays a keyboard accelerator (i.e. a key combination
    like <Control>-a). If the cell renderer is editable, the accelerator can be
    changed by simply typing the new combination.
 */
FALCON_FUNC CellRendererAccel::init( VMARG )
{
    NO_ARGS
    MYSELF;
    self->setObject( (GObject*) gtk_cell_renderer_accel_new() );
}
Пример #10
0
void
terminal_edit_keys_dialog_show (GtkWindow *transient_parent)
{
	TerminalApp *app;
	GtkWidget *dialog, *tree_view, *disable_mnemonics_button, *disable_menu_accel_button;
	GtkTreeViewColumn *column;
	GtkCellRenderer *cell_renderer;
	GtkTreeStore *tree;
	guint i;

	if (edit_keys_dialog != NULL)
		goto done;

	if (!terminal_util_load_builder_file ("keybinding-editor.ui",
	                                      "keybindings-dialog", &dialog,
	                                      "disable-mnemonics-checkbutton", &disable_mnemonics_button,
	                                      "disable-menu-accel-checkbutton", &disable_menu_accel_button,
	                                      "accelerators-treeview", &tree_view,
	                                      NULL))
		return;

	app = terminal_app_get ();
	terminal_util_bind_object_property_to_widget (G_OBJECT (app), TERMINAL_APP_ENABLE_MNEMONICS,
	        disable_mnemonics_button, 0);
	terminal_util_bind_object_property_to_widget (G_OBJECT (app), TERMINAL_APP_ENABLE_MENU_BAR_ACCEL,
	        disable_menu_accel_button, 0);

	/* Column 1 */
	cell_renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes (_("_Action"),
	         cell_renderer,
	         "text", ACTION_COLUMN,
	         NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
	gtk_tree_view_column_set_sort_column_id (column, ACTION_COLUMN);

	/* Column 2 */
	cell_renderer = gtk_cell_renderer_accel_new ();
	g_object_set (cell_renderer,
	              "editable", TRUE,
	              "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_GTK,
	              NULL);
	g_signal_connect (cell_renderer, "accel-edited",
	                  G_CALLBACK (accel_edited_callback), tree_view);
	g_signal_connect (cell_renderer, "accel-cleared",
	                  G_CALLBACK (accel_cleared_callback), tree_view);

	column = gtk_tree_view_column_new ();
	gtk_tree_view_column_set_title (column, _("Shortcut _Key"));
	gtk_tree_view_column_pack_start (column, cell_renderer, TRUE);
	gtk_tree_view_column_set_cell_data_func (column, cell_renderer, accel_set_func, NULL, NULL);
	gtk_tree_view_column_set_sort_column_id (column, KEYVAL_COLUMN);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);

	/* Add the data */

	tree = edit_keys_store = gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER);

#ifdef MATE_ENABLE_DEBUG
	_TERMINAL_DEBUG_IF (TERMINAL_DEBUG_ACCELS)
	g_signal_connect (tree, "row-changed", G_CALLBACK (row_changed), NULL);
#endif

	for (i = 0; i < G_N_ELEMENTS (all_entries); ++i)
	{
		GtkTreeIter parent_iter;
		guint j;

		gtk_tree_store_append (tree, &parent_iter, NULL);
		gtk_tree_store_set (tree, &parent_iter,
		                    ACTION_COLUMN, _(all_entries[i].user_visible_name),
		                    -1);

		for (j = 0; j < all_entries[i].n_elements; ++j)
		{
			KeyEntry *key_entry = &(all_entries[i].key_entry[j]);
			GtkTreeIter iter;

			gtk_tree_store_insert_with_values (tree, &iter, &parent_iter, -1,
			                                   ACTION_COLUMN, _(key_entry->user_visible_name),
			                                   KEYVAL_COLUMN, key_entry,
			                                   -1);
		}
	}

	gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (tree),
	                                 KEYVAL_COLUMN, accel_compare_func,
	                                 NULL, NULL);
	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (tree), ACTION_COLUMN,
	                                      GTK_SORT_ASCENDING);

	gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (tree));
	g_object_unref (tree);

	gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));

	g_signal_connect (notification_group, "accel-changed",
	                  G_CALLBACK (treeview_accel_changed_cb), tree);

	edit_keys_dialog = dialog;
	g_signal_connect (dialog, "destroy",
	                  G_CALLBACK (edit_keys_dialog_destroy_cb), tree);
	g_signal_connect (dialog, "response",
	                  G_CALLBACK (edit_keys_dialog_response_cb),
	                  NULL);
	gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 350);

done:
	gtk_window_set_transient_for (GTK_WINDOW (edit_keys_dialog), transient_parent);
	gtk_window_present (GTK_WINDOW (edit_keys_dialog));
}