[PATCH 2/5] text: Rename text_model_manager to factory

Jan Arne Petersen jpetersen at openismus.com
Fri Aug 10 07:47:20 PDT 2012


From: Jan Arne Petersen <jpetersen at openismus.com>

The text_model_manager interface is just used to create text_model
instances. It is more a factory than a manager so rename it to
text_model_factory.
---
 clients/editor.c   | 12 +++++++-----
 protocol/text.xml  |  2 +-
 src/text-backend.c | 22 +++++++++++-----------
 3 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/clients/editor.c b/clients/editor.c
index 392edda..8f0e9d8 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -40,7 +40,7 @@ struct text_entry {
 };
 
 struct editor {
-	struct text_model_manager *text_model_manager;
+	struct text_model_factory *text_model_factory;
 	struct display *display;
 	struct window *window;
 	struct widget *widget;
@@ -130,7 +130,7 @@ text_entry_create(struct editor *editor, const char *text)
 	entry->widget = editor->widget;
 	entry->text = strdup(text);
 	entry->active = 0;
-	entry->model = text_model_manager_create_text_model(editor->text_model_manager, surface);
+	entry->model = text_model_factory_create_text_model(editor->text_model_factory, surface);
 	text_model_add_listener(entry->model, &text_model_listener, entry);
 
 	return entry;
@@ -311,9 +311,11 @@ global_handler(struct wl_display *display, uint32_t id,
 {
 	struct editor *editor = data;
 
-	if (!strcmp(interface, "text_model_manager")) {
-		editor->text_model_manager = wl_display_bind(display, id,
-							     &text_model_manager_interface);
+	if (!strcmp(interface, "text_model_factory")) {
+		editor->text_model_factory = wl_display_bind(display, id,
+							     &text_model_factory_interface);
+	} else if (!strcmp(interface, "wl_seat")) {
+		fprintf(stderr, "wl_seat added\n");
 	}
 }
 
diff --git a/protocol/text.xml b/protocol/text.xml
index a14277a..54866e1 100644
--- a/protocol/text.xml
+++ b/protocol/text.xml
@@ -36,7 +36,7 @@
     <event name="locale"/>      
   </interface>
 
-  <interface name="text_model_manager" version="1">
+  <interface name="text_model_factory" version="1">
     <request name="create_text_model">
       <arg name="id" type="new_id" interface="text_model"/>
       <arg name="surface" type="object" interface="wl_surface"/>
diff --git a/src/text-backend.c b/src/text-backend.c
index 353a983..bed3f77 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -38,7 +38,7 @@ struct text_model {
 struct input_method {
 	struct wl_resource *input_method_binding;
 	struct wl_global *input_method_global;
-	struct wl_global *text_model_manager_global;
+	struct wl_global *text_model_factory_global;
 	struct wl_listener destroy_listener;
 
 	struct weston_compositor *ec;
@@ -145,7 +145,7 @@ struct text_model_interface text_model_implementation = {
 	text_model_set_content_type
 };
 
-static void text_model_manager_create_text_model(struct wl_client *client,
+static void text_model_factory_create_text_model(struct wl_client *client,
 						 struct wl_resource *resource,
 						 uint32_t id,
 						 struct wl_resource *surface)
@@ -170,12 +170,12 @@ static void text_model_manager_create_text_model(struct wl_client *client,
 	wl_list_insert(&input_method->models, &text_model->link);
 };
 
-static const struct text_model_manager_interface text_model_manager_implementation = {
-	text_model_manager_create_text_model
+static const struct text_model_factory_interface text_model_factory_implementation = {
+	text_model_factory_create_text_model
 };
 
 static void
-bind_text_model_manager(struct wl_client *client,
+bind_text_model_factory(struct wl_client *client,
 			void *data,
 			uint32_t version,
 			uint32_t id)
@@ -184,8 +184,8 @@ bind_text_model_manager(struct wl_client *client,
 
 	/* No checking for duplicate binding necessary.
 	 * No events have to be sent, so we don't need the return value. */
-	wl_client_add_object(client, &text_model_manager_interface,
-			     &text_model_manager_implementation,
+	wl_client_add_object(client, &text_model_factory_interface,
+			     &text_model_factory_implementation,
 			     id, input_method);
 }
 
@@ -248,7 +248,7 @@ input_method_notifier_destroy(struct wl_listener *listener, void *data)
 	wl_display_remove_global(input_method->ec->wl_display,
 				 input_method->input_method_global);
 	wl_display_remove_global(input_method->ec->wl_display,
-				 input_method->text_model_manager_global);
+				 input_method->text_model_factory_global);
 	free(input_method);
 }
 
@@ -269,10 +269,10 @@ input_method_create(struct weston_compositor *ec)
 				      &input_method_interface,
 				      input_method, bind_input_method);
 
-	input_method->text_model_manager_global =
+	input_method->text_model_factory_global =
 		wl_display_add_global(ec->wl_display,
-				      &text_model_manager_interface,
-				      input_method, bind_text_model_manager);
+				      &text_model_factory_interface,
+				      input_method, bind_text_model_factory);
 
 	input_method->destroy_listener.notify = input_method_notifier_destroy;
 	wl_signal_add(&ec->destroy_signal, &input_method->destroy_listener);
-- 
1.7.11.2



More information about the wayland-devel mailing list