[geany/geany-plugins] 9ff8cf: scope - use ui_lookfind_widget(), sync [ ] Read only for the current document

Dimitar Zhekov git-noreply at xxxxx
Thu Jun 12 18:52:50 UTC 2014


Branch:      refs/heads/master
Author:      Dimitar Zhekov <dimitar.zhekov at gmail.com>
Committer:   Dimitar Zhekov <dimitar.zhekov at gmail.com>
Date:        Thu, 12 Jun 2014 18:52:50 UTC
Commit:      9ff8cf09058c0cd8e76425028cd0f6d78a7afdfd
             https://github.com/geany/geany-plugins/commit/9ff8cf09058c0cd8e76425028cd0f6d78a7afdfd

Log Message:
-----------
scope - use ui_lookfind_widget(), sync [ ] Read only for the current document


Modified Paths:
--------------
    scope/ChangeLog
    scope/docs/scope.html
    scope/src/menu.c
    scope/src/scope.c
    scope/src/scope.h
    scope/src/utils.c
    scope/src/utils.h

Modified: scope/ChangeLog
14 lines changed, 14 insertions(+), 0 deletions(-)
===================================================================
@@ -1,3 +1,17 @@
+2014-06-12  Dimitar Zhekov  <dimitar.zhekov at gmail.com>
+
+ * docs/scope.html:
+   Small changes in the "Temporary breakpoint on load" description.
+ * src/menu.c, src/scope.c, src/scope.h:
+   Replaced scope find_widget() with Geany ui_lookup_widget().
+ * src/scope.c:
+   Insert the Debug menu after Build if possible, instead of using
+   a fixed position.
+ * src/scope.c, src/utils.c, src/utils.h:
+   Sync Geany "Document -> [ ] Read only" state of the current
+   document if possible when locking/unlocking it on Run/Terminate.
+
+
 2014-04-27  Dimitar Zhekov  <dimitar.zhekov at gmail.com>
 
  * src/conterm.c:


Modified: scope/docs/scope.html
7 lines changed, 3 insertions(+), 4 deletions(-)
===================================================================
@@ -204,11 +204,10 @@
 from Scope preferences to take advantage of this.</p>
 
 <p><em>Temporary breakpoint on load at</em> - set a temporary breakpoint when the program is
-loaded. If you leave the text field empty, Scope will try to detect the 1st line of code and
+loaded. If you leave the text field empty, Scope will try to find the 1st line of code and
 place a breakpoint on it. Any breakpoint options and location are allowed in the text, for
-example <em>main</em> for C/C++ programs. Since setting a breakpoint requires a program, the
-temporary breakpoint on load will be disabled if both <em>Executable</em> and <em>Load
-script</em> are empty. </p>
+example <em>main</em> for C/C++ programs. Since setting a breakpoint requires a program, this
+option will be disabled if both <em>Executable</em> and <em>Load script</em> are empty.</p>
 
 <p><em>Delete all breakpoints, watches and inspects</em> - usually when setting up a new
 program. Scope will ask for confirmation.</p>


Modified: scope/src/menu.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -517,7 +517,7 @@ void menu_init(void)
 {
 	GtkMenuShell *shell = GTK_MENU_SHELL(geany->main_widgets->editor_menu);
 	GList *children = gtk_container_get_children(GTK_CONTAINER(shell));
-	GtkWidget *search2 = find_widget(shell, "search2");
+	GtkWidget *search2 = ui_lookup_widget(GTK_WIDGET(shell), "search2");
 
 	popup_item = get_widget("popup_item");
 	menu_connect("popup_menu", &popup_menu_info, NULL);


Modified: scope/src/scope.c
11 lines changed, 9 insertions(+), 2 deletions(-)
===================================================================
@@ -533,7 +533,7 @@ void plugin_init(G_GNUC_UNUSED GeanyData *gdata)
 	GeanyKeyGroup *scope_key_group;
 	char *gladefile = g_build_filename(PLUGINDATADIR, "scope.glade", NULL);
 	GError *gerror = NULL;
-	GtkWidget *menubar1 = find_widget(geany->main_widgets->window, "menubar1");
+	GtkWidget *menubar1 = ui_lookup_widget(geany->main_widgets->window, "menubar1");
 	guint item;
 	const MenuKey *menu_key = debug_menu_keys;
 	ToolItem *tool_item = toolbar_items;
@@ -564,7 +564,13 @@ void plugin_init(G_GNUC_UNUSED GeanyData *gdata)
 #endif
 	debug_item = get_widget("debug_item");
 	if (menubar1)
-		gtk_menu_shell_insert(GTK_MENU_SHELL(menubar1), debug_item, DEBUG_MENU_ITEM_POS);
+	{
+		GList *children = gtk_container_get_children(GTK_CONTAINER(menubar1));
+		GtkWidget *menu_build1 = ui_lookup_widget(menubar1, "menu_build1");
+
+		gtk_menu_shell_insert(GTK_MENU_SHELL(menubar1), debug_item,
+			menu_build1 ? g_list_index(children, menu_build1) + 1 : DEBUG_MENU_ITEM_POS);
+	}
 	else
 		gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), debug_item);
 
@@ -595,6 +601,7 @@ void plugin_init(G_GNUC_UNUSED GeanyData *gdata)
 	inspect_init();
 	register_init();
 	parse_init();
+	utils_init();
 	debug_init();
 	views_init();
 	thread_init();


Modified: scope/src/scope.h
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -26,7 +26,6 @@ void update_state(DebugState state);
 GObject *get_object(const char *name);
 GtkWidget *get_widget(const char *name);
 #define get_column(name) GTK_TREE_VIEW_COLUMN(get_object(name))
-#define find_widget(parent, name) GTK_WIDGET(g_object_get_data(G_OBJECT(parent), (name)))
 void configure_toolbar(void);
 void open_debug_panel(void);
 void configure_panel(void);


Modified: scope/src/utils.c
23 lines changed, 20 insertions(+), 3 deletions(-)
===================================================================
@@ -344,11 +344,22 @@ static void line_mark_unmark(GeanyDocument *doc, gboolean lock)
 	}
 }
 
+static GtkCheckMenuItem *set_file_readonly1;
+
 static void doc_lock_unlock(GeanyDocument *doc, gboolean lock)
 {
-	scintilla_send_message(doc->editor->sci, SCI_SETREADONLY, lock, 0);
-	doc->readonly = lock;
-	document_set_text_changed(doc, doc->changed);  /* to redraw tab and update sidebar */
+	if (set_file_readonly1 && doc == document_get_current())
+	{
+		/* to ensure correct state of Document -> [ ] Read Only */
+		if (gtk_check_menu_item_get_active(set_file_readonly1) != lock)
+			gtk_check_menu_item_set_active(set_file_readonly1, lock);
+	}
+	else
+	{
+		scintilla_send_message(doc->editor->sci, SCI_SETREADONLY, lock, 0);
+		doc->readonly = lock;
+		document_set_text_changed(doc, doc->changed);  /* to redraw tab & update sidebar */
+	}
 }
 
 void utils_lock(GeanyDocument *doc)
@@ -708,6 +719,12 @@ void utils_tree_set_cursor(GtkTreeSelection *selection, GtkTreeIter *iter, gdoub
 	gtk_tree_path_free(path);
 }
 
+void utils_init(void)
+{
+	set_file_readonly1 = GTK_CHECK_MENU_ITEM(ui_lookup_widget(geany->main_widgets->window,
+		"set_file_readonly1"));
+}
+
 void utils_finalize(void)
 {
 	guint i;


Modified: scope/src/utils.h
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -104,6 +104,7 @@ gchar *utils_text_buffer_get_text(GtkTextBuffer *text, gint maxlen);
 void utils_enter_to_clicked(GtkWidget *widget, GtkWidget *button);
 void utils_tree_set_cursor(GtkTreeSelection *selection, GtkTreeIter *iter, gdouble alignment);
 
+void utils_init(void);
 void utils_finalize(void);
 
 #define UTILS_H 1



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list