private void rename_label(UserLabel label) { renamed_label = label; Gtk.Entry rename_label = new Gtk.Entry(); rename_label.Text = label.metalabel.label; rename_label.Name = "rename_label"; rename_label.AddEvents((int)Gdk.EventMask.KeyReleaseMask); rename_label.KeyReleaseEvent += on_rename_key_release; int pos = 0; foreach (Widget w in representation) { if (w.Name == label.metalabel.label) { w.Destroy(); break; } else ++pos; } representation.Add(rename_label); representation.ReorderChild(rename_label, pos); representation.ShowAll(); rename_label.GrabFocus(); }
private void item_click(ButtonPressEventArgs args, UserLabel label, RightClickLabelButton b) { if (args.Event.Button == 1) { category.update_restriction_and_update_screen(label.metalabel); b.Active = !b.Active; } else if (args.Event.Button == 3) { Menu popupMenu = new Menu(); MenuItem rename_item = new MenuItem(Mono.Unix.Catalog.GetString("Rename label")); rename_item.Activated += delegate { rename_label(label); }; popupMenu.Add(rename_item); MenuItem delete_item = new MenuItem(Mono.Unix.Catalog.GetString("Delete label")); delete_item.Activated += delegate { remove_label(label.metalabel); }; popupMenu.Add(delete_item); popupMenu.Add(new Gtk.SeparatorMenuItem()); MenuItem create_label = new MenuItem(Mono.Unix.Catalog.GetString("Create a new label")); create_label.Activated += delegate { add_new_label(); }; popupMenu.Add(create_label); popupMenu.ShowAll(); popupMenu.Popup(null, null, null, args.Event.Button, args.Event.Time); } }
private RightClickLabelButton create_button(UserLabel label) { RightClickLabelButton b = new RightClickLabelButton(); b.Name = label.metalabel.label; Gtk.Alignment box_alignment = new Gtk.Alignment(0, 0, 0, 0); Gtk.HBox box = new Gtk.HBox(); Gtk.Label l = new Gtk.Label(" " + label.metalabel.label); Gtk.Image img = label.dot(); box.Add(img); GtkCommon.set_foreground_color(l, new Gdk.Color(label.metalabel.color.r, label.metalabel.color.g, label.metalabel.color.b)); box.Add(l); box_alignment.LeftPadding = 3; box_alignment.Add(box); b.Add(box_alignment); b.BorderWidth = 0; b.Relief = Gtk.ReliefStyle.None; b.ButtonPressEvent += delegate (object sender, ButtonPressEventArgs args) { item_click(args, label, b); }; return b; }
// labels public void make_label(UserLabel label) { // update own labels labels.Add(label); display_item.set_labels(); if (on_labels_callback != null) on_labels_callback(); // update tracker Singleton<SingletonWrapper<Broker>>.Instance.wrapped.add_label_to_file(file, label.metalabel); }
public bool contains_label(UserLabel label) { return labels.Exists(delegate (UserLabel tmp_label) { return tmp_label.metalabel.db_id == label.metalabel.db_id; }); }
public void remove_label(UserLabel label) { List<UserLabel> new_labels = new List<UserLabel>(); foreach (UserLabel tmp_label in labels) if (tmp_label.metalabel.db_id != label.metalabel.db_id) new_labels.Add(tmp_label); labels = new_labels; display_item.set_labels(); if (on_labels_callback != null) on_labels_callback(); Singleton<SingletonWrapper<Broker>>.Instance.wrapped.remove_label_from_file(file, label.metalabel); }